mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
Add object factory for the "TagElement" component (#2435)
This commit is contained in:
parent
3c93efde07
commit
fdeba8ea65
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
})
|
||||
|
@ -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>>
|
||||
}
|
||||
})
|
||||
|
@ -122,7 +122,7 @@
|
||||
async function create () {
|
||||
if (objectFactory?.create) {
|
||||
const createFn = await getResource(objectFactory.create)
|
||||
await createFn()
|
||||
await createFn(query)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -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>>
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user