2021-08-06 13:18:50 +03:00
|
|
|
//
|
|
|
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
|
|
|
// Copyright © 2021 Hardcore Engineering Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
2021-11-18 15:48:05 +03:00
|
|
|
import type { Plugin, Asset, Resource, IntlString } from '@anticrm/platform'
|
2021-08-06 13:18:50 +03:00
|
|
|
import { plugin } from '@anticrm/platform'
|
2021-11-18 15:48:05 +03:00
|
|
|
import type { Ref, Mixin, UXObject, Space, FindOptions, Class, Doc, Arr, State, Client, Obj } from '@anticrm/core'
|
2021-08-06 13:18:50 +03:00
|
|
|
|
2021-11-18 15:48:05 +03:00
|
|
|
import type { AnyComponent, AnySvelteComponent } from '@anticrm/ui'
|
2021-08-06 13:18:50 +03:00
|
|
|
|
2021-08-07 08:39:49 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 13:18:50 +03:00
|
|
|
export interface AttributeEditor extends Class<Doc> {
|
|
|
|
editor: AnyComponent
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:39:49 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 13:18:50 +03:00
|
|
|
export interface AttributePresenter extends Class<Doc> {
|
|
|
|
presenter: AnyComponent
|
|
|
|
}
|
|
|
|
|
2021-09-07 11:36:50 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface KanbanCard extends Class<Doc> {
|
|
|
|
card: AnyComponent
|
|
|
|
}
|
|
|
|
|
2021-09-08 19:42:40 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ObjectEditor extends Class<Doc> {
|
|
|
|
editor: AnyComponent
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:39:49 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 13:18:50 +03:00
|
|
|
export interface ViewletDescriptor extends Doc, UXObject {
|
|
|
|
component: AnyComponent
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:39:49 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 13:18:50 +03:00
|
|
|
export interface Viewlet extends Doc {
|
|
|
|
attachTo: Ref<Class<Space>>
|
|
|
|
descriptor: Ref<ViewletDescriptor>
|
|
|
|
open: AnyComponent
|
|
|
|
options?: FindOptions<Doc>
|
|
|
|
config: any
|
|
|
|
}
|
|
|
|
|
2021-09-25 19:48:22 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Action extends Doc, UXObject {
|
|
|
|
action: Resource<(doc: Doc) => Promise<void>>
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ActionTarget extends Doc {
|
|
|
|
target: Ref<Class<Doc>>
|
|
|
|
action: Ref<Action>
|
|
|
|
}
|
|
|
|
|
2021-10-08 17:49:46 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Kanban extends Doc {
|
|
|
|
attachedTo: Ref<Space>
|
2021-10-09 18:02:32 +03:00
|
|
|
states: Arr<Ref<State>>
|
2021-10-08 17:49:46 +03:00
|
|
|
order: Arr<Ref<Doc>>
|
|
|
|
}
|
|
|
|
|
2021-10-23 13:09:39 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Sequence extends Doc {
|
|
|
|
attachedTo: Ref<Class<Doc>>
|
|
|
|
sequence: number
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:39:49 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 13:18:50 +03:00
|
|
|
export const viewId = 'view' as Plugin
|
|
|
|
|
2021-12-08 12:09:51 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type BuildModelKey = string | {
|
|
|
|
presenter: AnyComponent
|
|
|
|
label: string
|
|
|
|
}
|
|
|
|
|
2021-11-18 15:48:05 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface AttributeModel {
|
|
|
|
key: string
|
|
|
|
label: IntlString
|
2021-12-03 13:16:16 +03:00
|
|
|
_class: Ref<Class<Doc>>
|
2021-11-18 15:48:05 +03:00
|
|
|
presenter: AnySvelteComponent
|
2021-12-08 12:09:51 +03:00
|
|
|
// Extra properties for component
|
|
|
|
props?: Record<string, any>
|
2021-11-18 15:48:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface BuildModelOptions {
|
|
|
|
client: Client
|
|
|
|
_class: Ref<Class<Obj>>
|
2021-12-08 12:09:51 +03:00
|
|
|
keys: BuildModelKey[]
|
2021-11-18 15:48:05 +03:00
|
|
|
options?: FindOptions<Doc>
|
|
|
|
ignoreMissing?: boolean
|
|
|
|
}
|
|
|
|
|
2021-08-06 13:18:50 +03:00
|
|
|
export default plugin(viewId, {
|
|
|
|
mixin: {
|
|
|
|
AttributeEditor: '' as Ref<Mixin<AttributeEditor>>,
|
2021-09-07 11:36:50 +03:00
|
|
|
AttributePresenter: '' as Ref<Mixin<AttributePresenter>>,
|
2021-09-08 19:42:40 +03:00
|
|
|
KanbanCard: '' as Ref<Mixin<KanbanCard>>,
|
|
|
|
ObjectEditor: '' as Ref<Mixin<ObjectEditor>>
|
2021-08-06 13:18:50 +03:00
|
|
|
},
|
|
|
|
class: {
|
|
|
|
ViewletDescriptor: '' as Ref<Class<ViewletDescriptor>>,
|
2021-09-25 19:48:22 +03:00
|
|
|
Viewlet: '' as Ref<Class<Viewlet>>,
|
|
|
|
Action: '' as Ref<Class<Action>>,
|
2021-10-08 17:49:46 +03:00
|
|
|
ActionTarget: '' as Ref<Class<ActionTarget>>,
|
2021-10-23 13:09:39 +03:00
|
|
|
Kanban: '' as Ref<Class<Kanban>>,
|
|
|
|
Sequence: '' as Ref<Class<Sequence>>
|
2021-08-06 13:18:50 +03:00
|
|
|
},
|
|
|
|
viewlet: {
|
2021-09-06 11:30:31 +03:00
|
|
|
Table: '' as Ref<ViewletDescriptor>,
|
|
|
|
Kanban: '' as Ref<ViewletDescriptor>
|
2021-08-06 13:18:50 +03:00
|
|
|
},
|
2021-10-23 13:09:39 +03:00
|
|
|
space: {
|
|
|
|
Sequence: '' as Ref<Space>
|
|
|
|
},
|
2021-08-06 13:18:50 +03:00
|
|
|
icon: {
|
2021-09-06 11:30:31 +03:00
|
|
|
Table: '' as Asset,
|
2021-11-29 14:41:15 +03:00
|
|
|
Kanban: '' as Asset,
|
|
|
|
Delete: '' as Asset
|
2021-08-06 13:18:50 +03:00
|
|
|
}
|
|
|
|
})
|