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-04-19 12:38:31 +03:00
|
|
|
import type {
|
|
|
|
AnyAttribute,
|
|
|
|
Class,
|
|
|
|
Client,
|
|
|
|
Doc,
|
|
|
|
DocumentQuery,
|
|
|
|
FindOptions,
|
2022-05-13 09:38:54 +03:00
|
|
|
Lookup,
|
2022-04-19 12:38:31 +03:00
|
|
|
Mixin,
|
|
|
|
Obj,
|
2022-05-19 09:38:12 +03:00
|
|
|
ObjQueryType,
|
2022-04-19 12:38:31 +03:00
|
|
|
Ref,
|
2023-01-14 13:54:54 +03:00
|
|
|
SortingOrder,
|
2022-04-19 12:38:31 +03:00
|
|
|
Space,
|
2022-05-19 09:38:12 +03:00
|
|
|
Type,
|
2022-04-19 12:38:31 +03:00
|
|
|
UXObject
|
2022-09-21 11:08:25 +03:00
|
|
|
} from '@hcengineering/core'
|
|
|
|
import { Asset, IntlString, Plugin, plugin, Resource, Status } from '@hcengineering/platform'
|
|
|
|
import type { Preference } from '@hcengineering/preference'
|
2023-01-19 18:38:18 +03:00
|
|
|
import type {
|
|
|
|
AnyComponent,
|
|
|
|
AnySvelteComponent,
|
|
|
|
PopupAlignment,
|
|
|
|
PopupPosAlignment,
|
|
|
|
Location as PlatformLocation
|
|
|
|
} from '@hcengineering/ui'
|
2021-08-06 13:18:50 +03:00
|
|
|
|
2022-05-19 09:38:12 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface KeyFilter {
|
2022-06-21 07:05:09 +03:00
|
|
|
_class: Ref<Class<Doc>>
|
2022-05-19 09:38:12 +03:00
|
|
|
key: string
|
2023-01-31 22:00:22 +03:00
|
|
|
attribute: AnyAttribute
|
2022-05-19 09:38:12 +03:00
|
|
|
component: AnyComponent
|
|
|
|
label: IntlString
|
2022-07-14 20:44:24 +03:00
|
|
|
icon: Asset | AnySvelteComponent | undefined
|
2022-05-19 09:38:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2022-06-03 19:12:18 +03:00
|
|
|
export interface FilterMode extends Doc {
|
2022-05-19 09:38:12 +03:00
|
|
|
label: IntlString
|
2022-07-14 20:44:24 +03:00
|
|
|
disableValueSelector?: boolean
|
2023-02-08 09:42:26 +03:00
|
|
|
result: FilterFunction
|
2022-05-19 09:38:12 +03:00
|
|
|
}
|
|
|
|
|
2023-02-08 09:42:26 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type FilterFunction = Resource<(filter: Filter, onUpdate: () => void) => Promise<ObjQueryType<any>>>
|
|
|
|
|
2022-05-19 09:38:12 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Filter {
|
|
|
|
key: KeyFilter
|
2022-06-21 07:05:09 +03:00
|
|
|
nested?: Filter
|
2022-06-03 19:12:18 +03:00
|
|
|
mode: Ref<FilterMode>
|
|
|
|
modes: Ref<FilterMode>[]
|
2022-05-19 09:38:12 +03:00
|
|
|
value: any[]
|
2022-11-29 18:22:33 +03:00
|
|
|
props?: Record<string, any>
|
2022-05-21 20:17:10 +03:00
|
|
|
index: number
|
|
|
|
onRemove?: () => void
|
2022-05-19 09:38:12 +03:00
|
|
|
}
|
|
|
|
|
2023-01-19 18:38:18 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface FilteredView extends Preference {
|
|
|
|
name: string
|
|
|
|
location: PlatformLocation
|
|
|
|
filters: string
|
2023-01-21 17:16:14 +03:00
|
|
|
viewOptions?: ViewOptions
|
|
|
|
viewletId?: Ref<Viewlet> | null
|
2023-01-19 18:38:18 +03:00
|
|
|
}
|
|
|
|
|
2022-05-19 09:38:12 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ClassFilters extends Class<Doc> {
|
|
|
|
filters: (KeyFilter | string)[]
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface AttributeFilter extends Class<Type<any>> {
|
|
|
|
component: AnyComponent
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:39:49 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 13:18:50 +03:00
|
|
|
export interface AttributeEditor extends Class<Doc> {
|
2022-06-15 20:25:58 +03:00
|
|
|
inlineEditor: AnyComponent
|
2022-05-28 10:33:11 +03:00
|
|
|
// If defined could be used for ShowEditor declarative actions.
|
|
|
|
popup?: AnyComponent
|
2021-08-06 13:18:50 +03:00
|
|
|
}
|
|
|
|
|
2022-05-06 20:48:43 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface CollectionEditor extends Class<Doc> {
|
|
|
|
editor: AnyComponent
|
2022-06-15 20:25:58 +03:00
|
|
|
inlineEditor?: AnyComponent
|
2022-05-06 20:48:43 +03:00
|
|
|
}
|
|
|
|
|
2022-08-30 08:54:03 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface InlineAttributEditor extends Class<Doc> {
|
|
|
|
editor: AnyComponent
|
|
|
|
}
|
|
|
|
|
2022-06-08 16:55:01 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ArrayEditor extends Class<Doc> {
|
2022-06-20 18:59:56 +03:00
|
|
|
editor?: AnyComponent
|
|
|
|
inlineEditor?: AnyComponent
|
2022-06-08 16:55:01 +03:00
|
|
|
}
|
|
|
|
|
2022-05-19 10:14:05 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface CollectionPresenter extends Class<Doc> {
|
|
|
|
presenter: 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
|
|
|
|
}
|
|
|
|
|
2023-01-14 13:54:54 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ObjectPresenter extends Class<Doc> {
|
|
|
|
presenter: AnyComponent
|
|
|
|
}
|
|
|
|
|
2022-12-20 06:26:51 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ListItemPresenter extends Class<Doc> {
|
|
|
|
presenter: AnyComponent
|
|
|
|
}
|
|
|
|
|
2021-09-08 19:42:40 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ObjectEditor extends Class<Doc> {
|
|
|
|
editor: AnyComponent
|
2022-11-30 08:53:49 +03:00
|
|
|
pinned?: boolean
|
2021-09-08 19:42:40 +03:00
|
|
|
}
|
|
|
|
|
2023-01-29 08:44:12 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ObjectEditorFooter extends Class<Doc> {
|
|
|
|
editor: AnyComponent
|
|
|
|
props?: Record<string, any>
|
|
|
|
}
|
|
|
|
|
2022-04-12 08:59:38 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface SpaceHeader extends Class<Doc> {
|
|
|
|
header: AnyComponent
|
|
|
|
}
|
|
|
|
|
2022-04-22 06:13:15 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface SpaceName extends Class<Doc> {
|
|
|
|
getName: Resource<(client: Client, space: Space) => Promise<string>>
|
|
|
|
}
|
|
|
|
|
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>>
|
|
|
|
}
|
|
|
|
|
2022-06-24 10:46:53 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ObjectTitle extends Class<Doc> {
|
|
|
|
titleProvider: Resource<<T extends Doc>(client: Client, ref: Ref<T>) => Promise<string>>
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-01-14 13:54:54 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ListHeaderExtra extends Class<Doc> {
|
|
|
|
presenters: AnyComponent[]
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type SortFunc = Resource<(values: any[]) => Promise<any[]>>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ClassSortFuncs extends Class<Doc> {
|
|
|
|
func: SortFunc
|
|
|
|
}
|
|
|
|
|
2023-02-08 09:42:26 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface AllValuesFunc extends Class<Doc> {
|
|
|
|
func: Resource<(space: Ref<Space> | undefined) => Promise<any[]>>
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:39:49 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2021-08-06 13:18:50 +03:00
|
|
|
export interface Viewlet extends Doc {
|
2023-01-14 13:54:54 +03:00
|
|
|
attachTo: Ref<Class<Doc>>
|
2021-08-06 13:18:50 +03:00
|
|
|
descriptor: Ref<ViewletDescriptor>
|
|
|
|
options?: FindOptions<Doc>
|
2022-05-13 09:38:54 +03:00
|
|
|
config: (BuildModelKey | string)[]
|
2022-05-13 20:31:57 +03:00
|
|
|
hiddenKeys?: string[]
|
2023-01-14 13:54:54 +03:00
|
|
|
viewOptions?: ViewOptionsModel
|
2023-01-18 08:14:59 +03:00
|
|
|
variant?: string
|
2021-08-06 13:18:50 +03:00
|
|
|
}
|
|
|
|
|
2022-04-28 13:05:28 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface LinkPresenter extends Doc {
|
|
|
|
pattern: string
|
|
|
|
component: AnyComponent
|
|
|
|
}
|
|
|
|
|
2022-04-19 12:38:31 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*
|
|
|
|
* "Alt + K" =\> Alt and K should be pressed together
|
|
|
|
* "J T" - J and then T shold be pressed.
|
|
|
|
*/
|
|
|
|
export type KeyBinding = string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2022-05-04 11:08:12 +03:00
|
|
|
export type ViewActionInput = 'focus' | 'selection' | 'any' | 'none'
|
|
|
|
|
2021-09-25 19:48:22 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2022-05-04 11:08:12 +03:00
|
|
|
export type ViewAction<T = Record<string, any>> = Resource<
|
|
|
|
(doc: Doc | Doc[] | undefined, evt: Event, params?: T) => Promise<void>
|
|
|
|
>
|
2022-04-19 12:38:31 +03:00
|
|
|
|
2022-05-04 11:08:12 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ActionCategory extends Doc, UXObject {
|
|
|
|
// Does category is visible for use in popup.
|
|
|
|
visible: boolean
|
2021-09-25 19:48:22 +03:00
|
|
|
}
|
|
|
|
|
2022-06-24 15:36:08 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type ActionGroup = 'create' | 'edit' | 'associate' | 'copy' | 'tools' | 'other'
|
|
|
|
|
2021-09-25 19:48:22 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2022-05-04 11:08:12 +03:00
|
|
|
export interface Action<T extends Doc = Doc, P = Record<string, any>> extends Doc, UXObject {
|
|
|
|
// Action implementation details
|
|
|
|
action: ViewAction<P>
|
|
|
|
// Action implementation parameters
|
|
|
|
actionProps?: P
|
|
|
|
|
2022-06-24 15:36:08 +03:00
|
|
|
// If specified, will show sub menu based on actionPopup/actionProps
|
|
|
|
actionPopup?: AnyComponent
|
|
|
|
|
2022-05-04 11:08:12 +03:00
|
|
|
// If specified, action could be used only with one item selected.
|
|
|
|
// single - one object is required
|
|
|
|
// any - one or multiple objects are required
|
|
|
|
// any - any input is suitable.
|
|
|
|
input: ViewActionInput
|
2022-05-25 09:08:26 +03:00
|
|
|
inline?: boolean
|
2022-05-04 11:08:12 +03:00
|
|
|
|
|
|
|
// Focus and/or all selection document should match target class.
|
|
|
|
target: Ref<Class<Doc>>
|
|
|
|
// Action is applicable only for objects matching criteria
|
2021-12-20 13:18:29 +03:00
|
|
|
query?: DocumentQuery<T>
|
2022-04-22 09:30:34 +03:00
|
|
|
|
2022-05-04 11:08:12 +03:00
|
|
|
// If defined, types should be matched to proposed list
|
|
|
|
inputProps?: Record<string, Ref<Class<Doc>>>
|
|
|
|
|
|
|
|
// Kayboard bindings
|
|
|
|
keyBinding?: KeyBinding[]
|
|
|
|
|
|
|
|
// short description for action.
|
|
|
|
description?: IntlString
|
|
|
|
|
|
|
|
// Action category, for UI.
|
|
|
|
category: Ref<ActionCategory>
|
|
|
|
|
|
|
|
// Context action is defined for
|
|
|
|
context: ViewContext
|
2022-06-03 07:24:38 +03:00
|
|
|
|
|
|
|
// A list of actions replaced by this one.
|
|
|
|
// For example it could be global action and action for focus class, second one fill override first one.
|
|
|
|
override?: Ref<Action>[]
|
2022-07-01 18:22:58 +03:00
|
|
|
|
|
|
|
// Avaible only for workspace owners
|
|
|
|
secured?: boolean
|
2022-04-19 12:38:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
2022-05-04 11:08:12 +03:00
|
|
|
* context - only for context menu actions.
|
2022-04-19 12:38:31 +03:00
|
|
|
* workbench - global actions per application or entire workbench.
|
|
|
|
* browser - actions for list/table/kanban browsing.
|
|
|
|
* editor - actions for selected editor context.
|
2022-05-04 11:08:12 +03:00
|
|
|
* panel - for panel based actions.
|
|
|
|
* popup - for popup based actions, like Close of Popup.
|
|
|
|
* input - for input based actions, some actions should be available for input controls.
|
2022-04-19 12:38:31 +03:00
|
|
|
*/
|
2022-05-04 11:08:12 +03:00
|
|
|
export type ViewContextType = 'context' | 'workbench' | 'browser' | 'editor' | 'panel' | 'popup' | 'input' | 'none'
|
2022-04-19 12:38:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ViewContext {
|
|
|
|
mode: ViewContextType | ViewContextType[]
|
|
|
|
// Active application
|
|
|
|
application?: Ref<Doc>
|
2022-06-24 15:36:08 +03:00
|
|
|
|
2022-04-19 12:38:31 +03:00
|
|
|
// Optional groupping
|
2022-06-24 15:36:08 +03:00
|
|
|
group?: ActionGroup
|
2021-09-25 19:48:22 +03:00
|
|
|
}
|
|
|
|
|
2022-02-25 18:32:23 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface IgnoreActions extends Class<Doc> {
|
|
|
|
actions: Ref<Action>[]
|
|
|
|
}
|
|
|
|
|
2022-04-19 12:38:31 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface PreviewPresenter extends Class<Doc> {
|
|
|
|
presenter: AnyComponent
|
|
|
|
}
|
|
|
|
|
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
|
2022-07-18 06:16:08 +03:00
|
|
|
presenter?: AnyComponent | AnySvelteComponent
|
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
|
2022-06-29 14:46:22 +03:00
|
|
|
sortingKey?: string | string[]
|
2022-03-15 12:01:49 +03:00
|
|
|
|
|
|
|
// On client sorting function
|
|
|
|
sortingFunction?: (a: Doc, b: Doc) => number
|
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>
|
2022-06-29 14:46:22 +03:00
|
|
|
sortingKey: string | string[]
|
2022-10-24 13:26:56 +03:00
|
|
|
optional?: boolean
|
|
|
|
excludeByKey?: 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
|
2022-06-07 07:10:34 +03:00
|
|
|
collectionAttr: boolean
|
2023-02-07 07:52:34 +03:00
|
|
|
isLookup: boolean
|
2022-08-16 13:19:33 +03:00
|
|
|
|
|
|
|
castRequest?: Ref<Mixin<Doc>>
|
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)[]
|
2022-05-13 09:38:54 +03:00
|
|
|
lookup?: Lookup<Doc>
|
2021-11-18 15:48:05 +03:00
|
|
|
ignoreMissing?: boolean
|
|
|
|
}
|
|
|
|
|
2022-01-11 12:05:53 +03:00
|
|
|
/**
|
|
|
|
* Define document create popup widget
|
|
|
|
*
|
|
|
|
* @public
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
export interface ObjectFactory extends Class<Obj> {
|
2022-11-30 19:03:05 +03:00
|
|
|
component?: AnyComponent
|
2022-12-14 07:46:51 +03:00
|
|
|
create?: Resource<(props?: Record<string, any>) => Promise<void>>
|
2022-01-11 12:05:53 +03:00
|
|
|
}
|
|
|
|
|
2022-05-13 09:38:54 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ViewletPreference extends Preference {
|
|
|
|
attachedTo: Ref<Viewlet>
|
|
|
|
config: (BuildModelKey | string)[]
|
|
|
|
}
|
|
|
|
|
2023-01-14 13:54:54 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type ViewOptions = {
|
2023-01-25 16:45:50 +03:00
|
|
|
groupBy: string[]
|
2023-01-14 13:54:54 +03:00
|
|
|
orderBy: OrderOption
|
|
|
|
} & Record<string, any>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ViewOption {
|
|
|
|
type: string
|
|
|
|
key: string
|
|
|
|
defaultValue: any
|
|
|
|
label: IntlString
|
|
|
|
hidden?: (viewOptions: ViewOptions) => boolean
|
2023-02-08 09:42:26 +03:00
|
|
|
actionTartget?: 'query' | 'category'
|
2023-01-14 13:54:54 +03:00
|
|
|
action?: Resource<(value: any, ...params: any) => any>
|
|
|
|
}
|
|
|
|
|
2023-02-08 09:42:26 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type ViewCategoryAction = Resource<
|
|
|
|
(_class: Ref<Class<Doc>>, space: Ref<Space> | undefined, key: string) => Promise<any[] | undefined>
|
|
|
|
>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface CategoryOption extends ViewOption {
|
|
|
|
actionTartget: 'category'
|
|
|
|
action: ViewCategoryAction
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type ViewQueryAction = Resource<(value: any, query: DocumentQuery<Doc>) => DocumentQuery<Doc>>
|
|
|
|
|
2023-01-14 13:54:54 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ViewQueryOption extends ViewOption {
|
|
|
|
actionTartget: 'query'
|
2023-02-08 09:42:26 +03:00
|
|
|
action: ViewQueryAction
|
2023-01-14 13:54:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ToggleViewOption extends ViewOption {
|
|
|
|
type: 'toggle'
|
|
|
|
defaultValue: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface DropdownViewOption extends ViewOption {
|
|
|
|
type: 'dropdown'
|
|
|
|
defaultValue: string
|
|
|
|
values: Array<{ label: IntlString, id: string, hidden?: (viewOptions: ViewOptions) => boolean }>
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type ViewOptionModel = ToggleViewOption | DropdownViewOption
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export type OrderOption = [string, SortingOrder]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ViewOptionsModel {
|
|
|
|
groupBy: string[]
|
|
|
|
orderBy: OrderOption[]
|
|
|
|
other: ViewOptionModel[]
|
2023-02-08 09:42:26 +03:00
|
|
|
groupDepth?: number
|
2023-01-14 13:54:54 +03:00
|
|
|
}
|
|
|
|
|
2021-12-14 12:24:14 +03:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
const view = plugin(viewId, {
|
2021-08-06 13:18:50 +03:00
|
|
|
mixin: {
|
2022-05-19 09:38:12 +03:00
|
|
|
ClassFilters: '' as Ref<Mixin<ClassFilters>>,
|
|
|
|
AttributeFilter: '' as Ref<Mixin<AttributeFilter>>,
|
2021-08-06 13:18:50 +03:00
|
|
|
AttributeEditor: '' as Ref<Mixin<AttributeEditor>>,
|
2022-05-19 10:14:05 +03:00
|
|
|
CollectionPresenter: '' as Ref<Mixin<CollectionPresenter>>,
|
2022-05-06 20:48:43 +03:00
|
|
|
CollectionEditor: '' as Ref<Mixin<CollectionEditor>>,
|
2022-08-30 08:54:03 +03:00
|
|
|
InlineAttributEditor: '' as Ref<Mixin<InlineAttributEditor>>,
|
2022-06-08 16:55:01 +03:00
|
|
|
ArrayEditor: '' as Ref<Mixin<ArrayEditor>>,
|
2021-09-07 11:36:50 +03:00
|
|
|
AttributePresenter: '' as Ref<Mixin<AttributePresenter>>,
|
2022-12-20 06:26:51 +03:00
|
|
|
ListItemPresenter: '' as Ref<Mixin<ListItemPresenter>>,
|
2021-12-20 12:37:15 +03:00
|
|
|
ObjectEditor: '' as Ref<Mixin<ObjectEditor>>,
|
2023-01-14 13:54:54 +03:00
|
|
|
ObjectPresenter: '' as Ref<Mixin<ObjectPresenter>>,
|
2022-01-18 13:21:32 +03:00
|
|
|
ObjectEditorHeader: '' as Ref<Mixin<ObjectEditorHeader>>,
|
2023-01-29 08:44:12 +03:00
|
|
|
ObjectEditorFooter: '' as Ref<Mixin<ObjectEditorFooter>>,
|
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>>,
|
2022-06-24 10:46:53 +03:00
|
|
|
ObjectTitle: '' as Ref<Mixin<ObjectTitle>>,
|
2022-04-12 08:59:38 +03:00
|
|
|
SpaceHeader: '' as Ref<Mixin<SpaceHeader>>,
|
2022-04-22 06:13:15 +03:00
|
|
|
SpaceName: '' as Ref<Mixin<SpaceName>>,
|
2022-02-25 18:32:23 +03:00
|
|
|
IgnoreActions: '' as Ref<Mixin<IgnoreActions>>,
|
2023-01-14 13:54:54 +03:00
|
|
|
PreviewPresenter: '' as Ref<Mixin<PreviewPresenter>>,
|
|
|
|
ListHeaderExtra: '' as Ref<Mixin<ListHeaderExtra>>,
|
2023-02-08 09:42:26 +03:00
|
|
|
SortFuncs: '' as Ref<Mixin<ClassSortFuncs>>,
|
|
|
|
AllValuesFunc: '' as Ref<Mixin<AllValuesFunc>>
|
2021-08-06 13:18:50 +03:00
|
|
|
},
|
|
|
|
class: {
|
2022-05-13 09:38:54 +03:00
|
|
|
ViewletPreference: '' as Ref<Class<ViewletPreference>>,
|
2021-08-06 13:18:50 +03:00
|
|
|
ViewletDescriptor: '' as Ref<Class<ViewletDescriptor>>,
|
2021-09-25 19:48:22 +03:00
|
|
|
Viewlet: '' as Ref<Class<Viewlet>>,
|
|
|
|
Action: '' as Ref<Class<Action>>,
|
2022-05-04 11:08:12 +03:00
|
|
|
ActionCategory: '' as Ref<Class<ActionCategory>>,
|
2022-06-03 19:12:18 +03:00
|
|
|
LinkPresenter: '' as Ref<Class<LinkPresenter>>,
|
2023-01-19 18:38:18 +03:00
|
|
|
FilterMode: '' as Ref<Class<FilterMode>>,
|
|
|
|
FilteredView: '' as Ref<Class<FilteredView>>
|
2021-08-06 13:18:50 +03:00
|
|
|
},
|
2022-06-23 11:54:58 +03:00
|
|
|
action: {
|
|
|
|
Delete: '' as Ref<Action>,
|
|
|
|
Move: '' as Ref<Action>,
|
|
|
|
MoveLeft: '' as Ref<Action>,
|
|
|
|
MoveRight: '' as Ref<Action>,
|
|
|
|
MoveUp: '' as Ref<Action>,
|
|
|
|
MoveDown: '' as Ref<Action>,
|
|
|
|
|
|
|
|
SelectItem: '' as Ref<Action>,
|
|
|
|
SelectItemAll: '' as Ref<Action>,
|
|
|
|
SelectItemNone: '' as Ref<Action>,
|
|
|
|
SelectUp: '' as Ref<Action>,
|
|
|
|
SelectDown: '' as Ref<Action>,
|
|
|
|
|
|
|
|
ShowPreview: '' as Ref<Action>,
|
|
|
|
ShowActions: '' as Ref<Action>,
|
|
|
|
|
|
|
|
// Edit document
|
|
|
|
Open: '' as Ref<Action>
|
|
|
|
},
|
2021-08-06 13:18:50 +03:00
|
|
|
viewlet: {
|
2023-01-14 13:54:54 +03:00
|
|
|
Table: '' as Ref<ViewletDescriptor>,
|
|
|
|
List: '' 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,
|
2022-04-16 06:02:12 +03:00
|
|
|
EditDoc: '' as AnyComponent,
|
2022-05-28 10:33:11 +03:00
|
|
|
SpacePresenter: '' as AnyComponent,
|
2022-06-24 15:36:08 +03:00
|
|
|
BooleanTruePresenter: '' as AnyComponent,
|
2023-01-18 08:14:59 +03:00
|
|
|
ValueSelector: '' as AnyComponent,
|
|
|
|
GrowPresenter: '' as AnyComponent
|
2022-01-19 12:04:30 +03:00
|
|
|
},
|
2022-05-13 09:38:54 +03:00
|
|
|
string: {
|
2022-06-23 11:54:58 +03:00
|
|
|
CustomizeView: '' as IntlString,
|
2022-06-29 09:54:47 +03:00
|
|
|
LabelNA: '' as IntlString,
|
2023-01-19 18:38:18 +03:00
|
|
|
View: '' as IntlString,
|
|
|
|
FilteredViews: '' as IntlString,
|
|
|
|
NewFilteredView: '' as IntlString,
|
2023-01-24 16:43:06 +03:00
|
|
|
FilteredViewName: '' as IntlString,
|
|
|
|
List: '' as IntlString,
|
|
|
|
Timeline: '' as IntlString
|
2022-05-13 09:38:54 +03:00
|
|
|
},
|
2021-08-06 13:18:50 +03:00
|
|
|
icon: {
|
2021-09-06 11:30:31 +03:00
|
|
|
Table: '' as Asset,
|
2023-01-16 08:51:17 +03:00
|
|
|
List: '' as Asset,
|
2022-05-02 07:23:57 +03:00
|
|
|
Card: '' as Asset,
|
2023-01-24 16:43:06 +03:00
|
|
|
Timeline: '' 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,
|
2022-04-24 08:18:03 +03:00
|
|
|
Statuses: '' as Asset,
|
2022-05-13 09:38:54 +03:00
|
|
|
Setting: '' as Asset,
|
2022-05-04 11:08:12 +03:00
|
|
|
Open: '' as Asset,
|
2022-05-24 17:46:19 +03:00
|
|
|
ArrowRight: '' as Asset,
|
2022-05-29 10:31:37 +03:00
|
|
|
Views: '' as Asset,
|
2022-06-14 06:03:41 +03:00
|
|
|
Pin: '' as Asset,
|
2022-06-20 17:11:14 +03:00
|
|
|
Model: '' as Asset,
|
|
|
|
ViewButton: '' as Asset
|
2022-05-04 11:08:12 +03:00
|
|
|
},
|
|
|
|
category: {
|
|
|
|
General: '' as Ref<ActionCategory>,
|
|
|
|
GeneralNavigation: '' as Ref<ActionCategory>,
|
|
|
|
Navigation: '' as Ref<ActionCategory>,
|
|
|
|
Editor: '' as Ref<ActionCategory>,
|
|
|
|
MarkdownFormatting: '' as Ref<ActionCategory>
|
|
|
|
},
|
2022-06-21 07:05:09 +03:00
|
|
|
filter: {
|
2022-06-03 19:12:18 +03:00
|
|
|
FilterObjectIn: '' as Ref<FilterMode>,
|
|
|
|
FilterObjectNin: '' as Ref<FilterMode>,
|
|
|
|
FilterValueIn: '' as Ref<FilterMode>,
|
|
|
|
FilterValueNin: '' as Ref<FilterMode>,
|
|
|
|
FilterBefore: '' as Ref<FilterMode>,
|
2022-06-21 07:05:09 +03:00
|
|
|
FilterAfter: '' as Ref<FilterMode>,
|
|
|
|
FilterNestedMatch: '' as Ref<FilterMode>,
|
|
|
|
FilterNestedDontMatch: '' as Ref<FilterMode>
|
2022-06-03 19:12:18 +03:00
|
|
|
},
|
2022-05-25 09:08:26 +03:00
|
|
|
popup: {
|
|
|
|
PositionElementAlignment: '' as Resource<(e?: Event) => PopupAlignment | undefined>
|
|
|
|
},
|
2022-05-04 11:08:12 +03:00
|
|
|
actionImpl: {
|
2022-10-14 08:45:04 +03:00
|
|
|
CopyTextToClipboard: '' as ViewAction<{
|
|
|
|
textProvider: Resource<(doc: Doc, props: Record<string, any>) => Promise<string>>
|
|
|
|
props?: Record<string, any>
|
|
|
|
}>,
|
2022-05-04 11:08:12 +03:00
|
|
|
UpdateDocument: '' as ViewAction<{
|
|
|
|
key: string
|
|
|
|
value: any
|
|
|
|
ask?: boolean
|
|
|
|
label?: IntlString
|
|
|
|
message?: IntlString
|
|
|
|
}>,
|
|
|
|
ShowPanel: '' as ViewAction<{
|
|
|
|
component?: AnyComponent
|
|
|
|
element?: PopupPosAlignment
|
|
|
|
rightSection?: AnyComponent
|
|
|
|
}>,
|
|
|
|
ShowPopup: '' as ViewAction<{
|
|
|
|
component: AnyComponent
|
2022-05-25 09:08:26 +03:00
|
|
|
element?: PopupPosAlignment | Resource<(e?: Event) => PopupAlignment | undefined>
|
2022-05-04 11:08:12 +03:00
|
|
|
_id?: string
|
|
|
|
_class?: string
|
|
|
|
_space?: string
|
|
|
|
value?: string
|
|
|
|
values?: string
|
|
|
|
props?: Record<string, any>
|
2022-06-24 15:36:08 +03:00
|
|
|
// Will copy values from selection document to props
|
|
|
|
fillProps?: Record<string, string>
|
2022-05-28 10:33:11 +03:00
|
|
|
}>,
|
|
|
|
ShowEditor: '' as ViewAction<{
|
|
|
|
element?: PopupPosAlignment | Resource<(e?: Event) => PopupAlignment | undefined>
|
|
|
|
attribute: string
|
|
|
|
props?: Record<string, any>
|
2022-06-24 15:36:08 +03:00
|
|
|
}>,
|
|
|
|
ValueSelector: '' as ViewAction<{
|
|
|
|
attribute: string
|
|
|
|
|
|
|
|
// Class object finder
|
|
|
|
_class?: Ref<Class<Doc>>
|
|
|
|
query?: DocumentQuery<Doc>
|
|
|
|
queryOptions?: FindOptions<Doc>
|
|
|
|
// Will copy values from selection document to query
|
|
|
|
// If set of docs passed, will do $in for values.
|
|
|
|
fillQuery?: Record<string, string>
|
|
|
|
|
|
|
|
// A list of fields with matched values to perform action.
|
|
|
|
docMatches?: string[]
|
|
|
|
searchField?: string
|
|
|
|
|
|
|
|
// Or list of values to select from
|
|
|
|
values?: { icon?: Asset, label: IntlString, id: number | string }[]
|
|
|
|
|
|
|
|
placeholder?: IntlString
|
2022-05-04 11:08:12 +03:00
|
|
|
}>
|
2021-08-06 13:18:50 +03:00
|
|
|
}
|
|
|
|
})
|
2021-12-14 12:24:14 +03:00
|
|
|
export default view
|