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