// // Copyright © 2024 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. // import { type Class, type Data, type Doc, type Ref } from '@hcengineering/core' import { type Builder } from '@hcengineering/model' import core from '@hcengineering/model-core' import { type AnyComponent } from '@hcengineering/ui' import { type Action, type AttributeCategory } from '@hcengineering/view' import view from '.' export function createAction> ( builder: Builder, data: Data>, id?: Ref> ): void { const { label, ...adata } = data builder.createDoc>(view.class.Action, core.space.Model, { label, ...adata }, id) } export function classPresenter ( builder: Builder, _class: Ref>, presenter: AnyComponent, editor?: AnyComponent, popup?: AnyComponent, activity?: AnyComponent ): void { builder.mixin(_class, core.class.Class, view.mixin.AttributePresenter, { presenter }) if (editor !== undefined) { builder.mixin(_class, core.class.Class, view.mixin.AttributeEditor, { inlineEditor: editor, popup }) } if (activity !== undefined) { builder.mixin(_class, core.class.Class, view.mixin.ActivityAttributePresenter, { presenter: activity }) } } export function createAttributePresenter ( builder: Builder, component: AnyComponent, _class: Ref>, key: keyof T, category: AttributeCategory ): void { const attr = builder.hierarchy.getAttribute(_class, key as string) builder.createDoc(view.class.AttrPresenter, core.space.Model, { component, attribute: attr._id, objectClass: _class, category }) }