2021-08-06 10:18:50 +00: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.
|
|
|
|
//
|
|
|
|
|
2022-01-19 09:04:30 +00:00
|
|
|
import type { Class, Client, Doc, DocumentQuery, FindOptions, Mixin, Obj, Ref, Space, TxOperations, UXObject } from '@anticrm/core'
|
2021-12-20 09:37:15 +00:00
|
|
|
import type { Asset, IntlString, Plugin, Resource, Status } from '@anticrm/platform'
|
2021-08-06 10:18:50 +00:00
|
|
|
import { plugin } from '@anticrm/platform'
|
2021-11-18 12:48:05 +00:00
|
|
|
import type { AnyComponent, AnySvelteComponent } from '@anticrm/ui'
|
2021-08-06 10:18:50 +00:00
|
|
|
|
2021-08-07 05:39:49 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 10:18:50 +00:00
|
|
|
export interface AttributeEditor extends Class<Doc> {
|
|
|
|
editor: AnyComponent
|
|
|
|
}
|
|
|
|
|
2021-08-07 05:39:49 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 10:18:50 +00:00
|
|
|
export interface AttributePresenter extends Class<Doc> {
|
|
|
|
presenter: AnyComponent
|
|
|
|
}
|
|
|
|
|
2021-09-08 16:42:40 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ObjectEditor extends Class<Doc> {
|
|
|
|
editor: AnyComponent
|
|
|
|
}
|
|
|
|
|
2022-01-18 10:21:32 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ObjectEditorHeader extends Class<Doc> {
|
|
|
|
editor: AnyComponent
|
|
|
|
}
|
|
|
|
|
2021-12-20 09:37:15 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ObjectValidator extends Class<Doc> {
|
|
|
|
validator: Resource<<T extends Doc>(doc: T, client: Client) => Promise<Status>>
|
|
|
|
}
|
|
|
|
|
2021-08-07 05:39:49 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 10:18:50 +00:00
|
|
|
export interface ViewletDescriptor extends Doc, UXObject {
|
|
|
|
component: AnyComponent
|
|
|
|
}
|
|
|
|
|
2021-08-07 05:39:49 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 10:18:50 +00:00
|
|
|
export interface Viewlet extends Doc {
|
|
|
|
attachTo: Ref<Class<Space>>
|
|
|
|
descriptor: Ref<ViewletDescriptor>
|
|
|
|
options?: FindOptions<Doc>
|
|
|
|
config: any
|
|
|
|
}
|
|
|
|
|
2021-09-25 16:48:22 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Action extends Doc, UXObject {
|
|
|
|
action: Resource<(doc: Doc) => Promise<void>>
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2022-01-18 10:21:32 +00:00
|
|
|
export interface ActionTarget<T extends Doc = Doc> extends Doc {
|
2021-12-20 10:18:29 +00:00
|
|
|
target: Ref<Class<T>>
|
2021-09-25 16:48:22 +00:00
|
|
|
action: Ref<Action>
|
2021-12-20 10:18:29 +00:00
|
|
|
|
|
|
|
query?: DocumentQuery<T>
|
2021-09-25 16:48:22 +00:00
|
|
|
}
|
|
|
|
|
2021-08-07 05:39:49 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 10:18:50 +00:00
|
|
|
export const viewId = 'view' as Plugin
|
|
|
|
|
2021-12-08 09:09:51 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-12-20 10:18:29 +00:00
|
|
|
export interface BuildModelKey {
|
|
|
|
key: string
|
|
|
|
presenter?: AnyComponent
|
|
|
|
label?: IntlString
|
2021-12-20 09:06:31 +00:00
|
|
|
sortingKey?: string
|
2021-12-08 09:09:51 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 12:48:05 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface AttributeModel {
|
|
|
|
key: string
|
|
|
|
label: IntlString
|
2021-12-03 10:16:16 +00:00
|
|
|
_class: Ref<Class<Doc>>
|
2021-11-18 12:48:05 +00:00
|
|
|
presenter: AnySvelteComponent
|
2021-12-08 09:09:51 +00:00
|
|
|
// Extra properties for component
|
|
|
|
props?: Record<string, any>
|
2021-12-20 09:06:31 +00:00
|
|
|
sortingKey: string
|
2022-01-11 09:09:52 +00:00
|
|
|
// Extra icon if applicable
|
|
|
|
icon?: Asset
|
2021-11-18 12:48:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface BuildModelOptions {
|
|
|
|
client: Client
|
|
|
|
_class: Ref<Class<Obj>>
|
2021-12-20 10:18:29 +00:00
|
|
|
keys: (BuildModelKey | string)[]
|
2021-11-18 12:48:05 +00:00
|
|
|
options?: FindOptions<Doc>
|
|
|
|
ignoreMissing?: boolean
|
|
|
|
}
|
|
|
|
|
2022-01-11 09:05:53 +00:00
|
|
|
/**
|
|
|
|
* Define document create popup widget
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
export interface ObjectFactory extends Class<Obj> {
|
|
|
|
component: AnyComponent
|
|
|
|
}
|
|
|
|
|
2022-01-19 09:04:30 +00:00
|
|
|
/**
|
|
|
|
* Allow to contribute and find all derived objects for document.
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ObjectDDParticipant extends Class<Obj> {
|
|
|
|
// Collect more items to be deleted if parent document is deleted.
|
|
|
|
collectDocs: Resource<(doc: Doc, client: TxOperations) => Promise<Doc[]>>
|
|
|
|
}
|
|
|
|
|
2021-12-14 09:24:14 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
const view = plugin(viewId, {
|
2021-08-06 10:18:50 +00:00
|
|
|
mixin: {
|
|
|
|
AttributeEditor: '' as Ref<Mixin<AttributeEditor>>,
|
2021-09-07 08:36:50 +00:00
|
|
|
AttributePresenter: '' as Ref<Mixin<AttributePresenter>>,
|
2021-12-20 09:37:15 +00:00
|
|
|
ObjectEditor: '' as Ref<Mixin<ObjectEditor>>,
|
2022-01-18 10:21:32 +00:00
|
|
|
ObjectEditorHeader: '' as Ref<Mixin<ObjectEditorHeader>>,
|
2022-01-11 09:05:53 +00:00
|
|
|
ObjectValidator: '' as Ref<Mixin<ObjectValidator>>,
|
2022-01-19 09:04:30 +00:00
|
|
|
ObjectFactory: '' as Ref<Mixin<ObjectFactory>>,
|
|
|
|
ObjectDDParticipant: '' as Ref<ObjectDDParticipant>
|
2021-08-06 10:18:50 +00:00
|
|
|
},
|
|
|
|
class: {
|
|
|
|
ViewletDescriptor: '' as Ref<Class<ViewletDescriptor>>,
|
2021-09-25 16:48:22 +00:00
|
|
|
Viewlet: '' as Ref<Class<Viewlet>>,
|
|
|
|
Action: '' as Ref<Class<Action>>,
|
2021-12-15 09:04:43 +00:00
|
|
|
ActionTarget: '' as Ref<Class<ActionTarget>>
|
2021-08-06 10:18:50 +00:00
|
|
|
},
|
|
|
|
viewlet: {
|
2021-12-15 09:04:43 +00:00
|
|
|
Table: '' as Ref<ViewletDescriptor>
|
2021-10-23 10:09:39 +00:00
|
|
|
},
|
2022-01-19 09:04:30 +00:00
|
|
|
component: {
|
2022-02-04 09:03:24 +00:00
|
|
|
ObjectPresenter: '' as AnyComponent,
|
|
|
|
EditDoc: '' as AnyComponent
|
2022-01-19 09:04:30 +00:00
|
|
|
},
|
2021-08-06 10:18:50 +00:00
|
|
|
icon: {
|
2021-09-06 08:30:31 +00:00
|
|
|
Table: '' as Asset,
|
2021-12-13 09:05:46 +00:00
|
|
|
Delete: '' as Asset,
|
2021-12-15 09:04:43 +00:00
|
|
|
MoreH: '' as Asset,
|
2021-12-21 09:08:22 +00:00
|
|
|
Move: '' as Asset,
|
2021-12-22 09:03:28 +00:00
|
|
|
Archive: '' as Asset,
|
|
|
|
Statuses: '' as Asset
|
2021-08-06 10:18:50 +00:00
|
|
|
}
|
|
|
|
})
|
2021-12-14 09:24:14 +00:00
|
|
|
export default view
|