diff --git a/models/tags/src/index.ts b/models/tags/src/index.ts index 555ace1050..2209c7f27e 100644 --- a/models/tags/src/index.ts +++ b/models/tags/src/index.ts @@ -97,6 +97,10 @@ export class TTagCategory extends TDoc implements TagCategory { export function createModel (builder: Builder): void { builder.createModel(TTagElement, TTagReference, TTagCategory) + builder.mixin(tags.class.TagElement, core.class.Class, view.mixin.ObjectFactory, { + create: tags.function.CreateTagElement + }) + builder.mixin(tags.class.TagReference, core.class.Class, view.mixin.CollectionEditor, { editor: tags.component.Tags, inlineEditor: tags.component.TagsAttributeEditor diff --git a/plugins/tags-resources/src/index.ts b/plugins/tags-resources/src/index.ts index 15c57f4e6b..025385a825 100644 --- a/plugins/tags-resources/src/index.ts +++ b/plugins/tags-resources/src/index.ts @@ -30,6 +30,7 @@ import TagsFilter from './components/TagsFilter.svelte' import TagsAttributeEditor from './components/TagsAttributeEditor.svelte' import TagsEditorPopup from './components/TagsEditorPopup.svelte' import LabelsPresenter from './components/LabelsPresenter.svelte' +import CreateTagElement from './components/CreateTagElement.svelte' import { ObjQueryType } from '@hcengineering/core' import { getRefs } from './utils' import { Filter } from '@hcengineering/view' @@ -44,6 +45,10 @@ export async function tagsNinResult (filter: Filter, onUpdate: () => void): Prom return { $nin: result } } +export async function createTagElement (props: Record<string, any> = {}): Promise<void> { + showPopup(CreateTagElement, props, 'top') +} + export default async (): Promise<Resources> => ({ component: { Tags, @@ -69,6 +74,7 @@ export default async (): Promise<Resources> => ({ }, function: { FilterTagsInResult: tagsInResult, - FilterTagsNinResult: tagsNinResult + FilterTagsNinResult: tagsNinResult, + CreateTagElement: createTagElement } }) diff --git a/plugins/tags-resources/src/plugin.ts b/plugins/tags-resources/src/plugin.ts index 572dd0b8b0..1408854f14 100644 --- a/plugins/tags-resources/src/plugin.ts +++ b/plugins/tags-resources/src/plugin.ts @@ -55,6 +55,7 @@ export default mergeIds(tagsId, tags, { }, function: { FilterTagsInResult: '' as Resource<(filter: Filter, onUpdate: () => void) => Promise<ObjQueryType<any>>>, - FilterTagsNinResult: '' as Resource<(filter: Filter, onUpdate: () => void) => Promise<ObjQueryType<any>>> + FilterTagsNinResult: '' as Resource<(filter: Filter, onUpdate: () => void) => Promise<ObjQueryType<any>>>, + CreateTagElement: '' as Resource<(props?: Record<string, any>) => Promise<void>> } }) diff --git a/plugins/view-resources/src/components/list/SortableList.svelte b/plugins/view-resources/src/components/list/SortableList.svelte index 6a8fe2556d..744027d780 100644 --- a/plugins/view-resources/src/components/list/SortableList.svelte +++ b/plugins/view-resources/src/components/list/SortableList.svelte @@ -122,7 +122,7 @@ async function create () { if (objectFactory?.create) { const createFn = await getResource(objectFactory.create) - await createFn() + await createFn(query) return } diff --git a/plugins/view/src/index.ts b/plugins/view/src/index.ts index 3823690e6e..ee86c6d2c4 100644 --- a/plugins/view/src/index.ts +++ b/plugins/view/src/index.ts @@ -377,7 +377,7 @@ export interface BuildModelOptions { */ export interface ObjectFactory extends Class<Obj> { component?: AnyComponent - create?: Resource<() => Promise<void>> + create?: Resource<(props?: Record<string, any>) => Promise<void>> } /**