@mediusinc/mng-commons 5.0.0-rc.2 → 5.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/data-providers/base-data-provider.factory.d.ts +13 -0
- package/core/data-providers/base.data-provider.d.ts +2 -14
- package/core/descriptors/editor.descriptor.d.ts +1 -1
- package/core/descriptors/tableview.descriptor.d.ts +5 -5
- package/core/directives/component.directive.d.ts +2 -2
- package/core/index.d.ts +1 -0
- package/core/security/permission.service.d.ts +1 -0
- package/core/services/commons-router.service.d.ts +3 -3
- package/core/services/commons.service.d.ts +31 -42
- package/core/services/tokens/module-config.token.d.ts +2 -2
- package/esm2022/core/components/notification/notification-wrapper.component.mjs +3 -3
- package/esm2022/core/components/pages/error/error.page.component.mjs +3 -3
- package/esm2022/core/components/pages/not-found/not-found.page.component.mjs +3 -3
- package/esm2022/core/data-providers/base-data-provider.factory.mjs +28 -0
- package/esm2022/core/data-providers/base.data-provider.mjs +1 -31
- package/esm2022/core/descriptors/editor.descriptor.mjs +1 -1
- package/esm2022/core/descriptors/tableview.descriptor.mjs +1 -1
- package/esm2022/core/directives/component.directive.mjs +10 -7
- package/esm2022/core/index.mjs +2 -1
- package/esm2022/core/security/permission.service.mjs +4 -2
- package/esm2022/core/services/commons-init.service.mjs +2 -2
- package/esm2022/core/services/commons-router.service.mjs +16 -15
- package/esm2022/core/services/commons.service.mjs +109 -166
- package/esm2022/core/services/tokens/module-config.token.mjs +1 -1
- package/esm2022/filter/descriptors/filter-lookup.descriptor.mjs +4 -4
- package/esm2022/form/api/data-providers/lookup-data-provider.factory.mjs +31 -0
- package/esm2022/form/api/data-providers/lookup.data-provider.mjs +1 -31
- package/esm2022/form/api/index.mjs +2 -1
- package/esm2022/form/components/autocomplete/autocomplete.component.mjs +92 -83
- package/esm2022/form/components/dropdown/dropdown.component.mjs +145 -87
- package/esm2022/model/data-providers/base-from-type-data-provider.factory.mjs +8 -0
- package/esm2022/model/descriptors/enum.descriptor.mjs +3 -6
- package/esm2022/model/descriptors/model.descriptor.mjs +22 -9
- package/esm2022/model/descriptors/type.descriptor.mjs +3 -9
- package/esm2022/model/index.mjs +3 -1
- package/esm2022/table/api/data-providers/table-data-provider.factory.mjs +33 -0
- package/esm2022/table/api/data-providers/table.data-provider.mjs +1 -31
- package/esm2022/table/api/descriptors/sort.descriptor.mjs +2 -2
- package/esm2022/table/api/descriptors/table-descriptor.factory.mjs +89 -0
- package/esm2022/table/api/descriptors/table.descriptor.mjs +4 -139
- package/esm2022/table/api/helpers/table-descriptor-helpers.mjs +97 -0
- package/esm2022/table/api/index.mjs +4 -1
- package/esm2022/table/components/column-filter-full/column-filter-full.component.mjs +6 -7
- package/esm2022/table/components/column-value/column-value.component.mjs +2 -2
- package/esm2022/table/components/table/table.component.mjs +5 -5
- package/esm2022/table/pipes/locale-default-row-class.pipe.mjs +2 -2
- package/esm2022/table/services/data-list.service.mjs +1 -1
- package/esm2022/tableview/action/components/action/action.component.mjs +140 -188
- package/esm2022/tableview/action/components/editor/action-editor.component.mjs +56 -66
- package/esm2022/tableview/action/components/editor/injector-context/action-editor-injector-context.component.mjs +119 -141
- package/esm2022/tableview/action/components/localization/data-language-dropdown.component.mjs +21 -39
- package/esm2022/tableview/action/components/route/action-route.component.mjs +17 -23
- package/esm2022/tableview/action/components/table/action-table.component.mjs +1 -1
- package/esm2022/tableview/action/services/action-executor.service.mjs +9 -9
- package/esm2022/tableview/action/services/navigation.service.mjs +3 -2
- package/esm2022/tableview/action/services/view-container.service.mjs +5 -21
- package/esm2022/tableview/api/action/descriptors/action-descriptor.factory.mjs +119 -0
- package/esm2022/tableview/api/action/descriptors/action-editor-descriptor.factory.mjs +77 -0
- package/esm2022/tableview/api/action/descriptors/action-editor.descriptor.mjs +20 -80
- package/esm2022/tableview/api/action/descriptors/action-link-descriptor.factory.mjs +45 -0
- package/esm2022/tableview/api/action/descriptors/action-link.descriptor.mjs +1 -32
- package/esm2022/tableview/api/action/descriptors/action.descriptor.mjs +3 -69
- package/esm2022/tableview/api/action/models/action-component.model.mjs +1 -1
- package/esm2022/tableview/api/action/models/execution/view-container.model.mjs +1 -1
- package/esm2022/tableview/api/editor/data-providers/editor-data-provider.factory.mjs +33 -0
- package/esm2022/tableview/api/editor/data-providers/editor.data-provider.mjs +1 -31
- package/esm2022/tableview/api/editor/descriptors/editor-descriptor.factory.mjs +81 -0
- package/esm2022/tableview/api/editor/descriptors/editor.descriptor.mjs +7 -133
- package/esm2022/tableview/api/editor/descriptors/field-action.descriptor.mjs +1 -1
- package/esm2022/tableview/api/editor/descriptors/field-base.descriptor.mjs +13 -5
- package/esm2022/tableview/api/editor/descriptors/field-group.descriptor.mjs +1 -1
- package/esm2022/tableview/api/editor/descriptors/field-lookup.descriptor.mjs +4 -4
- package/esm2022/tableview/api/editor/descriptors/field-many.descriptor.mjs +3 -3
- package/esm2022/tableview/api/editor/descriptors/field-validation.descriptor.mjs +1 -1
- package/esm2022/tableview/api/editor/descriptors/field.descriptor.mjs +1 -1
- package/esm2022/tableview/api/editor/helpers/editor-descriptor-helpers.mjs +95 -0
- package/esm2022/tableview/api/editor/helpers/field-validators.mjs +7 -7
- package/esm2022/tableview/api/editor/models/editor-fields.model.mjs +1 -1
- package/esm2022/tableview/api/editor/models/field-action-context.model.mjs +1 -1
- package/esm2022/tableview/api/editor/models/field-validation.model.mjs +2 -0
- package/esm2022/tableview/api/editor/models/field.model.mjs +1 -1
- package/esm2022/tableview/api/editor/models/form-editor.event.mjs +1 -1
- package/esm2022/tableview/api/editor/models/form-editor.interface.mjs +1 -1
- package/esm2022/tableview/api/editor/models/formly-field.model.mjs +1 -1
- package/esm2022/tableview/api/index.mjs +11 -1
- package/esm2022/tableview/api/tableview/data-providers/tableview-data-provider.factory.mjs +47 -0
- package/esm2022/tableview/api/tableview/data-providers/tableview.data-provider.mjs +5 -46
- package/esm2022/tableview/api/tableview/descriptors/tableview-descriptor.factory.mjs +111 -0
- package/esm2022/tableview/api/tableview/descriptors/tableview.descriptor.mjs +15 -168
- package/esm2022/tableview/api/tableview/helpers/files-export.mjs +2 -2
- package/esm2022/tableview/api/tableview/helpers/tableview-create.mjs +5 -5
- package/esm2022/tableview/api/tableview/helpers/tableview-default-actions.mjs +53 -18
- package/esm2022/tableview/api/tableview/helpers/tableview-descriptor-helpers.mjs +110 -0
- package/esm2022/tableview/api/tableview/helpers/tableview-input-builder.mjs +2 -2
- package/esm2022/tableview/editor/components/editor/form-editor.component.mjs +16 -11
- package/esm2022/tableview/editor/components/formly/fields/formly-field-action/formly-field-action.component.mjs +6 -2
- package/esm2022/tableview/editor/components/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.mjs +10 -11
- package/esm2022/tableview/editor/components/formly/fields/formly-field-custom/formly-field-custom.component.mjs +1 -1
- package/esm2022/tableview/editor/components/formly/fields/formly-field-datepicker/formly-field-datepicker.component.mjs +4 -4
- package/esm2022/tableview/editor/components/formly/fields/formly-field-dropdown/formly-field-dropdown.component.mjs +9 -11
- package/esm2022/tableview/editor/components/formly/fields/formly-field-input/formly-field-input.component.mjs +4 -4
- package/esm2022/tableview/editor/components/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.mjs +16 -18
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +20 -22
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +18 -20
- package/esm2022/tableview/editor/helpers/editor-formly.mjs +27 -6
- package/esm2022/tableview/editor/services/form-editor.service.mjs +96 -0
- package/esm2022/tableview/index.mjs +2 -1
- package/esm2022/tableview/tableview/components/tableview/tableview.component.mjs +3 -3
- package/fesm2022/mediusinc-mng-commons-core.mjs +155 -210
- package/fesm2022/mediusinc-mng-commons-core.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-filter.mjs +3 -3
- package/fesm2022/mediusinc-mng-commons-filter.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-form-api.mjs +18 -18
- package/fesm2022/mediusinc-mng-commons-form-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-form.mjs +236 -169
- package/fesm2022/mediusinc-mng-commons-form.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-model.mjs +43 -33
- package/fesm2022/mediusinc-mng-commons-model.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table-api.mjs +192 -146
- package/fesm2022/mediusinc-mng-commons-table-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table.mjs +11 -12
- package/fesm2022/mediusinc-mng-commons-table.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs +822 -590
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview.mjs +564 -571
- package/fesm2022/mediusinc-mng-commons-tableview.mjs.map +1 -1
- package/form/api/data-providers/lookup-data-provider.factory.d.ts +18 -0
- package/form/api/data-providers/lookup.data-provider.d.ts +2 -14
- package/form/api/index.d.ts +1 -0
- package/form/components/autocomplete/autocomplete.component.d.ts +31 -23
- package/form/components/dropdown/dropdown.component.d.ts +38 -25
- package/model/data-providers/base-from-type-data-provider.factory.d.ts +8 -0
- package/model/descriptors/enum.descriptor.d.ts +1 -2
- package/model/descriptors/model.descriptor.d.ts +11 -4
- package/model/descriptors/type.descriptor.d.ts +2 -4
- package/model/index.d.ts +1 -0
- package/package.json +7 -7
- package/table/api/data-providers/table-data-provider.factory.d.ts +18 -0
- package/table/api/data-providers/table.data-provider.d.ts +2 -14
- package/table/api/descriptors/table-descriptor.factory.d.ts +44 -0
- package/table/api/descriptors/table.descriptor.d.ts +4 -65
- package/table/api/helpers/table-descriptor-helpers.d.ts +44 -0
- package/table/api/index.d.ts +3 -0
- package/table/components/column-filter-full/column-filter-full.component.d.ts +5 -4
- package/table/components/table/table.component.d.ts +11 -11
- package/table/services/data-list.service.d.ts +9 -10
- package/tableview/action/components/action/action.component.d.ts +37 -44
- package/tableview/action/components/editor/action-editor.component.d.ts +20 -18
- package/tableview/action/components/editor/injector-context/action-editor-injector-context.component.d.ts +23 -23
- package/tableview/action/components/localization/data-language-dropdown.component.d.ts +11 -14
- package/tableview/action/components/route/action-route.component.d.ts +6 -11
- package/tableview/action/components/table/action-table.component.d.ts +3 -3
- package/tableview/action/services/view-container.service.d.ts +3 -9
- package/tableview/api/action/descriptors/action-descriptor.factory.d.ts +36 -0
- package/tableview/api/action/descriptors/action-editor-descriptor.factory.d.ts +31 -0
- package/tableview/api/action/descriptors/action-editor.descriptor.d.ts +17 -37
- package/tableview/api/action/descriptors/action-link-descriptor.factory.d.ts +15 -0
- package/tableview/api/action/descriptors/action-link.descriptor.d.ts +1 -9
- package/tableview/api/action/descriptors/action.descriptor.d.ts +4 -27
- package/tableview/api/action/models/action-component.model.d.ts +8 -8
- package/tableview/api/action/models/execution/view-container.model.d.ts +4 -3
- package/tableview/api/editor/data-providers/editor-data-provider.factory.d.ts +18 -0
- package/tableview/api/editor/data-providers/editor.data-provider.d.ts +2 -14
- package/tableview/api/editor/descriptors/editor-descriptor.factory.d.ts +44 -0
- package/tableview/api/editor/descriptors/editor.descriptor.d.ts +34 -90
- package/tableview/api/editor/descriptors/field-action.descriptor.d.ts +3 -3
- package/tableview/api/editor/descriptors/field-base.descriptor.d.ts +15 -13
- package/tableview/api/editor/descriptors/field-group.descriptor.d.ts +7 -6
- package/tableview/api/editor/descriptors/field-lookup.descriptor.d.ts +2 -2
- package/tableview/api/editor/descriptors/field-many.descriptor.d.ts +8 -8
- package/tableview/api/editor/descriptors/field-validation.descriptor.d.ts +6 -6
- package/tableview/api/editor/descriptors/field.descriptor.d.ts +1 -1
- package/tableview/api/editor/helpers/editor-descriptor-helpers.d.ts +43 -0
- package/tableview/api/editor/helpers/field-validators.d.ts +1 -1
- package/tableview/api/editor/models/editor-fields.model.d.ts +24 -22
- package/tableview/api/editor/models/field-action-context.model.d.ts +10 -8
- package/tableview/api/editor/models/field-validation.model.d.ts +26 -0
- package/tableview/api/editor/models/field.model.d.ts +0 -19
- package/tableview/api/editor/models/form-editor.event.d.ts +24 -16
- package/tableview/api/editor/models/form-editor.interface.d.ts +2 -1
- package/tableview/api/editor/models/formly-custom-field.model.d.ts +1 -1
- package/tableview/api/editor/models/formly-field.model.d.ts +4 -4
- package/tableview/api/index.d.ts +10 -0
- package/tableview/api/tableview/data-providers/tableview-data-provider.factory.d.ts +25 -0
- package/tableview/api/tableview/data-providers/tableview.data-provider.d.ts +3 -20
- package/tableview/api/tableview/descriptors/tableview-descriptor.factory.d.ts +49 -0
- package/tableview/api/tableview/descriptors/tableview.descriptor.d.ts +40 -100
- package/tableview/api/tableview/helpers/tableview-create.d.ts +2 -2
- package/tableview/api/tableview/helpers/tableview-default-actions.d.ts +4 -2
- package/tableview/api/tableview/helpers/tableview-descriptor-helpers.d.ts +42 -0
- package/tableview/api/tableview/helpers/tableview-input-builder.d.ts +1 -1
- package/tableview/editor/components/editor/form-editor.component.d.ts +6 -4
- package/tableview/editor/components/formly/fields/formly-field-action/formly-field-action.component.d.ts +5 -3
- package/tableview/editor/components/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.d.ts +1 -0
- package/tableview/editor/components/formly/fields/formly-field-dropdown/formly-field-dropdown.component.d.ts +1 -1
- package/tableview/editor/components/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.d.ts +1 -1
- package/tableview/editor/components/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.d.ts +3 -4
- package/tableview/editor/components/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.d.ts +3 -4
- package/tableview/editor/helpers/editor-formly.d.ts +1 -1
- package/tableview/editor/services/form-editor.service.d.ts +39 -0
- package/tableview/index.d.ts +1 -0
- package/tableview/tableview/components/route/tableview-route.component.d.ts +1 -1
- package/tableview/tableview/components/tableview/tableview.component.d.ts +1 -1
- package/version-info.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediusinc-mng-commons-model.mjs","sources":["../../model/src/descriptors/enum.descriptor.ts","../../model/src/helpers/model.ts","../../model/src/descriptors/model.descriptor.ts","../../model/src/descriptors/type.descriptor.ts","../../model/src/helpers/i18n.ts","../../model/src/index.ts","../../model/src/mediusinc-mng-commons-model.ts"],"sourcesContent":["import {EnumType, findReflectEnumName} from '@mediusinc/mng-commons/core';\n\nexport class EnumDescriptor<Enum> {\n private readonly _value: Enum;\n private readonly _type: EnumType;\n private readonly _nameAsValue;\n private readonly _i18nBaseKey: string | null;\n\n protected constructor(value: Enum, type: EnumType, i18nBaseKey?: string | null, nameAsValue = false) {\n this._value = value;\n this._type = type;\n this._nameAsValue = nameAsValue;\n\n if (typeof i18nBaseKey === 'undefined') {\n i18nBaseKey = findReflectEnumName(type);\n }\n this._i18nBaseKey = i18nBaseKey;\n }\n\n public get type() {\n return this._type;\n }\n\n public get i18nBaseKey() {\n return this._i18nBaseKey;\n }\n\n public get nameAsValue() {\n return this._nameAsValue;\n }\n\n public static create<Enum>(value: Enum, type: EnumType, i18nBaseKey: string | undefined | null = null, nameAsValue = false) {\n return new EnumDescriptor<Enum>(value, type, i18nBaseKey, nameAsValue);\n }\n}\n\nexport function enumModel<Enum>(value: Enum, type: EnumType, i18nBaseKey: string | undefined | null = null, nameAsValue = false) {\n return EnumDescriptor.create<Enum>(value, type, i18nBaseKey, nameAsValue);\n}\n\nexport function enumModelGeneric(type: EnumType, i18nBaseKey: string | undefined | null = null, nameAsValue = false) {\n return EnumDescriptor.create<any>(undefined, type, i18nBaseKey, nameAsValue);\n}\n","import {ClassAttributeDef, ClassType, ILookupDescriptor, TypeRegistry} from '@mediusinc/mng-commons/core';\n\nexport function findClassIdAttribute<T>(classType?: ClassType<T>): string | null {\n if (!classType) return null;\n\n const attrDef = getClassAttributeDef(classType);\n if (!attrDef) {\n return null;\n }\n\n let idAttribute = findAttributeByTypeAndName(attrDef, ['string', 'number'], 'id', 'uuid', 'code', 'sifra');\n if (!idAttribute) {\n // if no id or code, take the first attribute\n idAttribute = attrDef[0];\n }\n\n return idAttribute?.name ?? null;\n}\n\nexport function findClassTitleAttribute<T>(classType?: ClassType<T>): string | null {\n if (!classType) return null;\n\n const attrDef = getClassAttributeDef(classType);\n if (!attrDef) {\n return null;\n }\n\n let titleAttribute = findAttributeByTypeAndName(attrDef, ['string'], 'name', 'ime', 'title', 'naziv');\n if (!titleAttribute) {\n // if no name or title, take the first attribute\n titleAttribute = attrDef[0];\n }\n\n return titleAttribute?.name ?? null;\n}\n\nexport function getClassAttributeDef<T>(classType?: ClassType<T>) {\n if (!classType) return null;\n const attrDefByFn = (classType as any).getAttributeTypeMap?.() as Array<ClassAttributeDef> | undefined;\n if (attrDefByFn) return attrDefByFn;\n const attrDefByProp = (classType as any).attributeTypeMap as Array<ClassAttributeDef> | undefined;\n if (attrDefByProp) return attrDefByProp;\n const attrByObjSer = TypeRegistry.get().findAttributesDefinitionByClassType(classType);\n if (attrByObjSer) return attrByObjSer;\n return null;\n}\n\nfunction findAttributeByTypeAndName(attributes: ClassAttributeDef[], types: string[], ...names: string[]): ClassAttributeDef | null {\n for (const name of names) {\n const attribute = attributes.find(a => types.some(t => t === a.type) && a.name === name);\n if (attribute) {\n return attribute;\n }\n }\n return null;\n}\n\nexport function trySetLookupItemsProperties<T>(lookup: ILookupDescriptor<T>, idAsTrack = true) {\n if (lookup.dataProvider.classType) {\n if (!lookup.optionsValueProperty && !lookup.optionsTrackProperty) {\n const idProperty = findClassIdAttribute(lookup.dataProvider.classType) ?? undefined;\n if (idProperty && !lookup.optionsValueProperty && !lookup.optionsTrackProperty) {\n if (idAsTrack) {\n lookup.withOptionsTrackPropertyUnsafe(idProperty);\n }\n }\n }\n if (!lookup.optionsLabelProperty) {\n const labelProperty = findClassTitleAttribute(lookup.dataProvider.classType);\n if (labelProperty) {\n lookup.withOptionsLabelPropertyUnsafe(labelProperty);\n }\n }\n }\n}\n","import {ClassOptType, ClassType, CommonsInternalError, IModelDescriptor, findReflectTypeName} from '@mediusinc/mng-commons/core';\n\nimport {findClassIdAttribute, findClassTitleAttribute} from '../helpers/model';\nimport {TypeDescriptor} from './type.descriptor';\n\nexport class ModelDescriptor<Model, ModelClass = ClassOptType<Model>> implements IModelDescriptor<Model, ModelClass> {\n private readonly _type: ModelClass;\n private readonly _typeName?: string;\n private _i18nBaseKey: string;\n private _idProperty?: string;\n private _titleProperty?: string;\n\n protected constructor(type: ModelClass, idProperty?: string, titleProperty?: string, i18nBaseKey?: string | ClassType<any>) {\n this._type = type;\n this._typeName = findReflectTypeName(type as ClassType<Model>) ?? undefined;\n this._idProperty = idProperty;\n this._titleProperty = titleProperty;\n if (!this._idProperty && type) {\n this._idProperty = findClassIdAttribute(type as unknown as ClassType<Model>) ?? undefined;\n }\n if (!this._titleProperty && type) {\n this._titleProperty = findClassTitleAttribute(type as unknown as ClassType<Model>) ?? undefined;\n }\n this._i18nBaseKey = (typeof i18nBaseKey === 'string' || typeof i18nBaseKey === 'undefined' ? i18nBaseKey : findReflectTypeName(i18nBaseKey)) ?? this._typeName ?? '';\n }\n\n public static create<Model>(idProperty?: keyof Model, titleProperty?: keyof Model, i18nBaseKey?: string | ClassType<unknown>): ModelDescriptor<Model, undefined> {\n return new ModelDescriptor(undefined, idProperty as string, titleProperty as string, i18nBaseKey);\n }\n\n public static fromClass<Model>(\n type: ClassType<Model>,\n idProperty?: keyof Model,\n titleProperty?: keyof Model,\n i18nBaseKey?: string | ClassType<unknown>\n ): ModelDescriptor<Model, ClassType<Model>> {\n return new ModelDescriptor(type, idProperty as string, titleProperty as string, i18nBaseKey);\n }\n\n public get type() {\n return this._type;\n }\n\n public get typeName() {\n return this._typeName;\n }\n\n public get i18nBaseKey() {\n return this._i18nBaseKey;\n }\n\n public get idProperty() {\n return this._idProperty;\n }\n\n public get titleProperty() {\n return this._titleProperty;\n }\n\n public withIdProperty(property: keyof Model): this {\n this._idProperty = property as string;\n return this;\n }\n\n public withIdPropertyUnsafe(property: string): this {\n this._idProperty = property;\n return this;\n }\n\n public withTitleProperty(property: keyof Model): this {\n this._titleProperty = property as string;\n return this;\n }\n\n public withTitlePropertyUnsafe(property: string): this {\n this._titleProperty = property;\n return this;\n }\n\n public withI18nBase(base: ClassType<any> | string): this {\n if (typeof base !== 'string') {\n const typeName = findReflectTypeName(base);\n if (!typeName) {\n throw new CommonsInternalError(`Could not find define i18nBaseKey for ${base} on model ${this.typeName}`);\n }\n base = typeName;\n }\n this._i18nBaseKey = base;\n return this;\n }\n\n public copy(): ModelDescriptor<Model, ModelClass> {\n return new ModelDescriptor<Model, ModelClass>(this._type, this._idProperty, this._titleProperty, this._i18nBaseKey);\n }\n}\n\nexport type ModelDescriptorCreateOpts<Model> = {\n id?: keyof Model;\n title?: keyof Model;\n i18nBase?: string | ClassType<any>;\n};\n\nexport function modelFromClass<Model>(type: ClassType<Model>, opts?: ModelDescriptorCreateOpts<Model>): ModelDescriptor<Model, ClassType<Model>> {\n return ModelDescriptor.fromClass(type, opts?.id, opts?.title, opts?.i18nBase);\n}\n\nexport function modelFromType<Model>(type: TypeDescriptor<Model>, opts?: ModelDescriptorCreateOpts<Model>): ModelDescriptor<Model, undefined> {\n return ModelDescriptor.create<Model>(opts?.id, opts?.title, opts?.i18nBase);\n}\n\nexport function model<Model>(opts?: ModelDescriptorCreateOpts<Model>): ModelDescriptor<Model, undefined> {\n return ModelDescriptor.create<Model>(opts?.id, opts?.title, opts?.i18nBase);\n}\n","import {ClassType} from '@mediusinc/mng-commons/core';\n\nexport class TypeDescriptor<Type> {\n private readonly _classType?: ClassType<Type>;\n\n protected constructor(classType?: ClassType<Type>) {\n this._classType = classType;\n }\n\n public static create<Type>() {\n return new TypeDescriptor<Type>();\n }\n\n public static fromClass<Type>(type: ClassType<Type>) {\n return new TypeDescriptor<Type>(type);\n }\n\n public get classType() {\n return this._classType;\n }\n}\n\nexport function type<Type>(): TypeDescriptor<Type> {\n return TypeDescriptor.create<Type>();\n}\n\nexport function typeClass<TypeClass>(type: ClassType<TypeClass>): TypeDescriptor<TypeClass> {\n return TypeDescriptor.fromClass(type);\n}\n","import {TranslateService} from '@ngx-translate/core';\nimport {Observable} from 'rxjs';\nimport {map} from 'rxjs/operators';\n\nimport {KeyOfType, getI18n, getI18nTypeKeyBasePath, getI18nTypeName, getI18nTypeNameAsync, getI18nTypeParams, getI18nTypeParamsAsync} from '@mediusinc/mng-commons/core';\n\nimport {ModelDescriptor} from '../descriptors/model.descriptor';\n\nexport function getI18nForModel(\n translate: TranslateService,\n model: ModelDescriptor<any>,\n keyPath: string,\n customKey?: string,\n item?: any,\n fallbackKey?: string,\n params?: any\n): string | null {\n const keys = getKeysByPriority(model, keyPath, customKey, fallbackKey);\n const i18nParams = getI18nModelParams(translate, model, item, params);\n return getI18n(translate, i18nParams, ...keys);\n}\n\nexport function getI18nModelName(translate: TranslateService, model: ModelDescriptor<any>, singular?: boolean): string | null {\n return getI18nTypeName(translate, model.i18nBaseKey, singular);\n}\n\nexport function getI18nModelNameAsync(translate: TranslateService, model: ModelDescriptor<any>, singular?: boolean): Observable<string | null> {\n return getI18nTypeNameAsync(translate, model.i18nBaseKey, singular);\n}\n\nexport function getI18nModelParams(translate: TranslateService, model?: ModelDescriptor<any>, item?: any, params: any = {}): any {\n const i18nParams = getI18nTypeParams(translate, model?.i18nBaseKey, item, params);\n return populateI18nModelParams(model?.idProperty, model?.titleProperty, item, i18nParams);\n}\n\nexport function getI18nModelParamsAsync(translate: TranslateService, model?: ModelDescriptor<any>, item?: any, params: any = {}): Observable<any> {\n return getI18nTypeParamsAsync(translate, model?.i18nBaseKey, item, params).pipe(\n map(i18nParams => populateI18nModelParams(model?.idProperty, model?.titleProperty, item, i18nParams))\n );\n}\n\nexport function populateI18nModelParams(idProperty?: KeyOfType, titleProperty?: KeyOfType, item?: any, params: any = {}): any {\n const paramsRes = {...params, itemId: '', itemTitle: ''};\n if (item) {\n if (idProperty && item[idProperty]) {\n paramsRes.itemId = item[idProperty];\n }\n if (titleProperty && item[titleProperty]) {\n paramsRes.itemTitle = item[titleProperty];\n }\n }\n return paramsRes;\n}\n\nfunction getKeysByPriority(model: ModelDescriptor<any>, keyPath: string, customKey?: string, fallbackKey?: string) {\n const keys = [];\n if (customKey) {\n keys.push(customKey);\n }\n const modelActionKey = getI18nTypeKeyBasePath(model.i18nBaseKey, ...keyPath);\n keys.push(modelActionKey);\n if (fallbackKey) {\n keys.push(fallbackKey);\n }\n return keys;\n}\n","// descriptors\nexport * from './descriptors/enum.descriptor';\nexport * from './descriptors/model.descriptor';\nexport * from './descriptors/type.descriptor';\n\n// helpers\nexport * from './helpers/i18n';\nexport * from './helpers/model';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;MAEa,cAAc,CAAA;IAMvB,WAAsB,CAAA,KAAW,EAAE,IAAc,EAAE,WAA2B,EAAE,WAAW,GAAG,KAAK,EAAA;AAC/F,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;AACpB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;AAClB,QAAA,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;AAEhC,QAAA,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE;AACpC,YAAA,WAAW,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;SAC3C;AACD,QAAA,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;KACnC;AAED,IAAA,IAAW,IAAI,GAAA;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;KACrB;AAED,IAAA,IAAW,WAAW,GAAA;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;KAC5B;AAED,IAAA,IAAW,WAAW,GAAA;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;KAC5B;AAEM,IAAA,OAAO,MAAM,CAAO,KAAW,EAAE,IAAc,EAAE,WAAA,GAAyC,IAAI,EAAE,WAAW,GAAG,KAAK,EAAA;QACtH,OAAO,IAAI,cAAc,CAAO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AAI,IAAI,CAAC,aAAa,CAAC,EAAE;AACtC,YAAA,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;SAC7C;KACJ;AACD,IAAA,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,iBAAiB,CAAC,KAA2B,EAAE,OAAe,EAAE,SAAkB,EAAE,WAAoB,EAAA;IAC7G,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,IAAI,SAAS,EAAE;AACX,QAAA,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACxB;IACD,MAAM,cAAc,GAAG,sBAAsB,CAAC,KAAK,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,CAAC;AAC7E,IAAA,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC1B,IAAI,WAAW,EAAE;AACb,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAC1B;AACD,IAAA,OAAO,IAAI,CAAC;AAChB;;ACjEA;;ACAA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"mediusinc-mng-commons-model.mjs","sources":["../../model/src/data-providers/base-from-type-data-provider.factory.ts","../../model/src/descriptors/enum.descriptor.ts","../../model/src/helpers/model.ts","../../model/src/descriptors/type.descriptor.ts","../../model/src/descriptors/model.descriptor.ts","../../model/src/helpers/i18n.ts","../../model/src/index.ts","../../model/src/mediusinc-mng-commons-model.ts"],"sourcesContent":["import {ClassType, DataProviderInst, ServiceClassType} from '@mediusinc/mng-commons/core';\n\nimport {ModelDescriptor} from '../descriptors/model.descriptor';\nimport {TypeDescriptor} from '../descriptors/type.descriptor';\n\nexport function dataProvider<Model>(): DataProviderInst<Model, undefined, undefined, undefined>;\nexport function dataProvider<Model>(type: TypeDescriptor<Model>): DataProviderInst<Model, undefined, undefined, undefined>;\nexport function dataProvider<Model, Service = any>(\n type: TypeDescriptor<Model>,\n serviceType: ServiceClassType<Service>\n): DataProviderInst<Model, Service, undefined, ServiceClassType<Service>>;\nexport function dataProvider<Model, Service = any, ServiceClass = ServiceClassType<Service>>(type?: TypeDescriptor<Model>, serviceType?: ServiceClass) {\n return new DataProviderInst<Model, Service, undefined, ServiceClass>(undefined, serviceType as ServiceClass);\n}\n\nexport function dataProviderFromModel<Model, ModelClass = ClassType<Model>>(model: ModelDescriptor<Model, ModelClass>): DataProviderInst<Model, undefined, ModelClass, undefined>;\nexport function dataProviderFromModel<Model, Service = any, ModelClass = ClassType<Model>>(\n model: ModelDescriptor<Model, ModelClass>,\n ServiceClass: ServiceClassType<Service>\n): DataProviderInst<Model, Service, ModelClass, ServiceClassType<Service>>;\nexport function dataProviderFromModel<Model, Service = any, ModelClass = ClassType<Model>, ServiceClass = ServiceClassType<Service>>(\n model: ModelDescriptor<Model, ModelClass>,\n serviceType?: ServiceClass\n) {\n return new DataProviderInst<Model, Service, ClassType<Model>, ServiceClass>(model.type as ClassType<Model>, serviceType as ServiceClass);\n}\n","import {EnumType, findReflectEnumName} from '@mediusinc/mng-commons/core';\n\nexport class EnumDescriptor<Enum> {\n private readonly _value: Enum;\n private readonly _type: EnumType;\n private readonly _nameAsValue;\n private readonly _i18nBaseKey: string | null;\n\n public constructor(value: Enum, type: EnumType, i18nBaseKey?: string | null, nameAsValue = false) {\n this._value = value;\n this._type = type;\n this._nameAsValue = nameAsValue;\n\n if (typeof i18nBaseKey === 'undefined') {\n i18nBaseKey = findReflectEnumName(type);\n }\n this._i18nBaseKey = i18nBaseKey;\n }\n\n public get type() {\n return this._type;\n }\n\n public get i18nBaseKey() {\n return this._i18nBaseKey;\n }\n\n public get nameAsValue() {\n return this._nameAsValue;\n }\n}\n\nexport function enumModel<Enum>(value: Enum, type: EnumType, i18nBaseKey: string | undefined | null = null, nameAsValue = false) {\n return new EnumDescriptor<Enum>(value, type, i18nBaseKey, nameAsValue);\n}\n\nexport function enumModelGeneric(type: EnumType, i18nBaseKey: string | undefined | null = null, nameAsValue = false) {\n return new EnumDescriptor<any>(undefined, type, i18nBaseKey, nameAsValue);\n}\n","import {ClassAttributeDef, ClassType, ILookupDescriptor, TypeRegistry} from '@mediusinc/mng-commons/core';\n\nexport function findClassIdAttribute<T>(classType?: ClassType<T>): string | null {\n if (!classType) return null;\n\n const attrDef = getClassAttributeDef(classType);\n if (!attrDef) {\n return null;\n }\n\n let idAttribute = findAttributeByTypeAndName(attrDef, ['string', 'number'], 'id', 'uuid', 'code', 'sifra');\n if (!idAttribute) {\n // if no id or code, take the first attribute\n idAttribute = attrDef[0];\n }\n\n return idAttribute?.name ?? null;\n}\n\nexport function findClassTitleAttribute<T>(classType?: ClassType<T>): string | null {\n if (!classType) return null;\n\n const attrDef = getClassAttributeDef(classType);\n if (!attrDef) {\n return null;\n }\n\n let titleAttribute = findAttributeByTypeAndName(attrDef, ['string'], 'name', 'ime', 'title', 'naziv');\n if (!titleAttribute) {\n // if no name or title, take the first attribute\n titleAttribute = attrDef[0];\n }\n\n return titleAttribute?.name ?? null;\n}\n\nexport function getClassAttributeDef<T>(classType?: ClassType<T>) {\n if (!classType) return null;\n const attrDefByFn = (classType as any).getAttributeTypeMap?.() as Array<ClassAttributeDef> | undefined;\n if (attrDefByFn) return attrDefByFn;\n const attrDefByProp = (classType as any).attributeTypeMap as Array<ClassAttributeDef> | undefined;\n if (attrDefByProp) return attrDefByProp;\n const attrByObjSer = TypeRegistry.get().findAttributesDefinitionByClassType(classType);\n if (attrByObjSer) return attrByObjSer;\n return null;\n}\n\nfunction findAttributeByTypeAndName(attributes: ClassAttributeDef[], types: string[], ...names: string[]): ClassAttributeDef | null {\n for (const name of names) {\n const attribute = attributes.find(a => types.some(t => t === a.type) && a.name === name);\n if (attribute) {\n return attribute;\n }\n }\n return null;\n}\n\nexport function trySetLookupItemsProperties<T>(lookup: ILookupDescriptor<T>, idAsTrack = true) {\n if (lookup.dataProvider.classType) {\n if (!lookup.optionsValueProperty && !lookup.optionsTrackProperty) {\n const idProperty = findClassIdAttribute(lookup.dataProvider.classType) ?? undefined;\n if (idProperty && !lookup.optionsValueProperty && !lookup.optionsTrackProperty) {\n if (idAsTrack) {\n lookup.withOptionsTrackPropertyUnsafe(idProperty);\n }\n }\n }\n if (!lookup.optionsLabelProperty) {\n const labelProperty = findClassTitleAttribute(lookup.dataProvider.classType);\n if (labelProperty) {\n lookup.withOptionsLabelPropertyUnsafe(labelProperty);\n }\n }\n }\n}\n","import {ClassType} from '@mediusinc/mng-commons/core';\n\nexport class TypeDescriptor<Type> {\n private readonly _classType?: ClassType<Type>;\n\n public constructor(classType?: ClassType<Type>) {\n this._classType = classType;\n }\n\n public get classType() {\n return this._classType;\n }\n}\n\nexport function type<Type>(): TypeDescriptor<Type> {\n return new TypeDescriptor<Type>();\n}\n\nexport function typeClass<Type>(type: ClassType<Type>): TypeDescriptor<Type> {\n return new TypeDescriptor<Type>(type);\n}\n","import {ClassOptType, ClassType, CommonsInternalError, IModelDescriptor, findReflectTypeName} from '@mediusinc/mng-commons/core';\n\nimport {findClassIdAttribute, findClassTitleAttribute} from '../helpers/model';\nimport {TypeDescriptor} from './type.descriptor';\n\nexport class ModelDescriptor<Model, ModelClass = ClassOptType<Model>> implements IModelDescriptor<Model, ModelClass> {\n private readonly _type: ModelClass;\n private readonly _typeName?: string;\n private _i18nBaseKey: string;\n private _idProperty?: string;\n private _titleProperty?: string;\n\n public constructor(type: ModelClass, idProperty?: string, titleProperty?: string, i18nBaseKey?: string | ClassType<any>) {\n this._type = type;\n this._typeName = findReflectTypeName(type as ClassType<Model>) ?? undefined;\n this._idProperty = idProperty;\n this._titleProperty = titleProperty;\n if (!this._idProperty && type) {\n this._idProperty = findClassIdAttribute(type as unknown as ClassType<Model>) ?? undefined;\n }\n if (!this._titleProperty && type) {\n this._titleProperty = findClassTitleAttribute(type as unknown as ClassType<Model>) ?? undefined;\n }\n this._i18nBaseKey = (typeof i18nBaseKey === 'string' || typeof i18nBaseKey === 'undefined' ? i18nBaseKey : findReflectTypeName(i18nBaseKey)) ?? this._typeName ?? '';\n }\n\n /**\n * @deprecated Use standalone {model()} instead.\n */\n public static create<Model>(idProperty?: keyof Model, titleProperty?: keyof Model, i18nBaseKey?: string | ClassType<unknown>): ModelDescriptor<Model, undefined> {\n return new ModelDescriptor(undefined, idProperty as string, titleProperty as string, i18nBaseKey);\n }\n\n /**\n * @deprecated Use standalone {model()} instead.\n */\n public static fromClass<Model>(\n type: ClassType<Model>,\n idProperty?: keyof Model,\n titleProperty?: keyof Model,\n i18nBaseKey?: string | ClassType<unknown>\n ): ModelDescriptor<Model, ClassType<Model>> {\n return new ModelDescriptor(type, idProperty as string, titleProperty as string, i18nBaseKey);\n }\n\n public get type() {\n return this._type;\n }\n\n public get typeName() {\n return this._typeName;\n }\n\n public get i18nBaseKey() {\n return this._i18nBaseKey;\n }\n\n public get idProperty() {\n return this._idProperty;\n }\n\n public get titleProperty() {\n return this._titleProperty;\n }\n\n public withIdProperty(property: keyof Model): this {\n this._idProperty = property as string;\n return this;\n }\n\n public withIdPropertyUnsafe(property: string): this {\n this._idProperty = property;\n return this;\n }\n\n public withTitleProperty(property: keyof Model): this {\n this._titleProperty = property as string;\n return this;\n }\n\n public withTitlePropertyUnsafe(property: string): this {\n this._titleProperty = property;\n return this;\n }\n\n public withI18nBase(base: ClassType<any> | string): this {\n if (typeof base !== 'string') {\n const typeName = findReflectTypeName(base);\n if (!typeName) {\n throw new CommonsInternalError(`Could not find define i18nBaseKey for ${base} on model ${this.typeName}`);\n }\n base = typeName;\n }\n this._i18nBaseKey = base;\n return this;\n }\n\n public copy(): ModelDescriptor<Model, ModelClass> {\n return new ModelDescriptor<Model, ModelClass>(this._type, this._idProperty, this._titleProperty, this._i18nBaseKey);\n }\n}\n\nexport type ModelDescriptorCreateOpts<Model> = {\n id?: keyof Model;\n title?: keyof Model;\n i18nBase?: string | ClassType<any>;\n};\n\nexport function model<Model>(): ModelDescriptor<Model, undefined>;\nexport function model<Model>(opts: ModelDescriptorCreateOpts<Model>): ModelDescriptor<Model, undefined>;\nexport function model<Model>(type: TypeDescriptor<Model>, opts?: ModelDescriptorCreateOpts<Model>): ModelDescriptor<Model, undefined>;\nexport function model<Model>(clazz: ClassType<Model>, opts?: ModelDescriptorCreateOpts<Model>): ModelDescriptor<Model, ClassType<Model>>;\nexport function model<Model>(typeOrClassOrOpts?: ClassType<Model> | TypeDescriptor<Model> | ModelDescriptorCreateOpts<Model>, opts?: ModelDescriptorCreateOpts<Model>) {\n if (typeOrClassOrOpts == null) {\n return new ModelDescriptor<Model, undefined>(undefined);\n } else if (typeOrClassOrOpts instanceof TypeDescriptor) {\n return new ModelDescriptor<Model, undefined>(undefined, opts?.id as string, opts?.title as string, opts?.i18nBase);\n } else if (typeof typeOrClassOrOpts === 'function') {\n return new ModelDescriptor<Model, ClassType<Model>>(typeOrClassOrOpts as ClassType<Model>, opts?.id as string, opts?.title as string, opts?.i18nBase);\n } else {\n const typeOrClassAsOpts = typeOrClassOrOpts as ModelDescriptorCreateOpts<Model>;\n return new ModelDescriptor<Model, undefined>(undefined, typeOrClassAsOpts?.id as string, typeOrClassAsOpts?.title as string, typeOrClassAsOpts?.i18nBase);\n }\n}\n","import {TranslateService} from '@ngx-translate/core';\nimport {Observable} from 'rxjs';\nimport {map} from 'rxjs/operators';\n\nimport {KeyOfType, getI18n, getI18nTypeKeyBasePath, getI18nTypeName, getI18nTypeNameAsync, getI18nTypeParams, getI18nTypeParamsAsync} from '@mediusinc/mng-commons/core';\n\nimport {ModelDescriptor} from '../descriptors/model.descriptor';\n\nexport function getI18nForModel(\n translate: TranslateService,\n model: ModelDescriptor<any>,\n keyPath: string,\n customKey?: string,\n item?: any,\n fallbackKey?: string,\n params?: any\n): string | null {\n const keys = getKeysByPriority(model, keyPath, customKey, fallbackKey);\n const i18nParams = getI18nModelParams(translate, model, item, params);\n return getI18n(translate, i18nParams, ...keys);\n}\n\nexport function getI18nModelName(translate: TranslateService, model: ModelDescriptor<any>, singular?: boolean): string | null {\n return getI18nTypeName(translate, model.i18nBaseKey, singular);\n}\n\nexport function getI18nModelNameAsync(translate: TranslateService, model: ModelDescriptor<any>, singular?: boolean): Observable<string | null> {\n return getI18nTypeNameAsync(translate, model.i18nBaseKey, singular);\n}\n\nexport function getI18nModelParams(translate: TranslateService, model?: ModelDescriptor<any>, item?: any, params: any = {}): any {\n const i18nParams = getI18nTypeParams(translate, model?.i18nBaseKey, item, params);\n return populateI18nModelParams(model?.idProperty, model?.titleProperty, item, i18nParams);\n}\n\nexport function getI18nModelParamsAsync(translate: TranslateService, model?: ModelDescriptor<any>, item?: any, params: any = {}): Observable<any> {\n return getI18nTypeParamsAsync(translate, model?.i18nBaseKey, item, params).pipe(\n map(i18nParams => populateI18nModelParams(model?.idProperty, model?.titleProperty, item, i18nParams))\n );\n}\n\nexport function populateI18nModelParams(idProperty?: KeyOfType, titleProperty?: KeyOfType, item?: any, params: any = {}): any {\n const paramsRes = {...params, itemId: '', itemTitle: ''};\n if (item) {\n if (idProperty && item[idProperty]) {\n paramsRes.itemId = item[idProperty];\n }\n if (titleProperty && item[titleProperty]) {\n paramsRes.itemTitle = item[titleProperty];\n }\n }\n return paramsRes;\n}\n\nfunction getKeysByPriority(model: ModelDescriptor<any>, keyPath: string, customKey?: string, fallbackKey?: string) {\n const keys = [];\n if (customKey) {\n keys.push(customKey);\n }\n const modelActionKey = getI18nTypeKeyBasePath(model.i18nBaseKey, ...keyPath);\n keys.push(modelActionKey);\n if (fallbackKey) {\n keys.push(fallbackKey);\n }\n return keys;\n}\n","// data providers\nexport * from './data-providers/base-from-type-data-provider.factory';\n\n// descriptors\nexport * from './descriptors/enum.descriptor';\nexport * from './descriptors/model.descriptor';\nexport * from './descriptors/type.descriptor';\n\n// helpers\nexport * from './helpers/i18n';\nexport * from './helpers/model';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAWgB,SAAA,YAAY,CAAiE,IAA4B,EAAE,WAA0B,EAAA;AACjJ,IAAA,OAAO,IAAI,gBAAgB,CAA0C,SAAS,EAAE,WAA2B,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AA,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAC1B;AACD,IAAA,OAAO,IAAI,CAAC;AAChB;;ACjEA;;ACAA;;AAEG;;;;"}
|
|
@@ -2,7 +2,7 @@ import { Subject } from 'rxjs';
|
|
|
2
2
|
import { map } from 'rxjs/operators';
|
|
3
3
|
import { DataProviderInst, toObservable, TypeRegistry, CommonsInternalError, fromAngularDateFormatToPrime, angularDateFormatHasTime, angularDateFormatHasSeconds, flattenObjectKeys } from '@mediusinc/mng-commons/core';
|
|
4
4
|
import { FilterDescriptor, FilterLookupDescriptor, FilterLookupEnumDescriptor, FilterTypeEnum } from '@mediusinc/mng-commons/filter';
|
|
5
|
-
import { enumModelGeneric, findClassTitleAttribute, ModelDescriptor } from '@mediusinc/mng-commons/model';
|
|
5
|
+
import { enumModelGeneric, findClassTitleAttribute, model, TypeDescriptor, ModelDescriptor } from '@mediusinc/mng-commons/model';
|
|
6
6
|
|
|
7
7
|
class TableDataProviderInst extends DataProviderInst {
|
|
8
8
|
constructor(type, serviceType) {
|
|
@@ -33,36 +33,38 @@ class TableDataProviderInst extends DataProviderInst {
|
|
|
33
33
|
this._getAllReloadSubject.next(queryParam);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
|
|
36
37
|
class TableDataProvider extends TableDataProviderInst {
|
|
37
38
|
constructor() {
|
|
38
39
|
super(undefined, undefined);
|
|
39
40
|
}
|
|
40
41
|
static create() {
|
|
41
|
-
return
|
|
42
|
+
return tableDataProvider();
|
|
42
43
|
}
|
|
43
44
|
static fromClass(type) {
|
|
44
|
-
return
|
|
45
|
+
return tableDataProviderFromClass(type);
|
|
45
46
|
}
|
|
46
47
|
static fromClassWithService(type, serviceType) {
|
|
47
|
-
return
|
|
48
|
+
return tableDataProviderFromClass(type, serviceType);
|
|
48
49
|
}
|
|
49
50
|
static fromService(serviceType) {
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
static fromAnyParam(type, serviceType) {
|
|
53
|
-
if (typeof type !== 'undefined') {
|
|
54
|
-
return typeof serviceType !== 'undefined'
|
|
55
|
-
? TableDataProvider.fromClassWithService(type, serviceType)
|
|
56
|
-
: TableDataProvider.fromClass(type);
|
|
57
|
-
}
|
|
58
|
-
else if (typeof serviceType !== 'undefined') {
|
|
59
|
-
return TableDataProvider.fromService(serviceType);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
return TableDataProvider.create();
|
|
63
|
-
}
|
|
51
|
+
return tableDataProviderWithService(serviceType);
|
|
64
52
|
}
|
|
65
53
|
}
|
|
54
|
+
function tableDataProvider(type, serviceType) {
|
|
55
|
+
return new TableDataProviderInst(undefined, serviceType);
|
|
56
|
+
}
|
|
57
|
+
function tableDataProviderWithService(serviceType) {
|
|
58
|
+
return new TableDataProviderInst(undefined, serviceType);
|
|
59
|
+
}
|
|
60
|
+
function tableDataProviderFromClass(type, serviceType) {
|
|
61
|
+
return new TableDataProviderInst(type, serviceType);
|
|
62
|
+
}
|
|
63
|
+
function tableDataProviderFromModel(model, serviceType) {
|
|
64
|
+
return typeof serviceType !== 'undefined'
|
|
65
|
+
? new TableDataProviderInst(model.type, serviceType)
|
|
66
|
+
: new TableDataProviderInst(model.type, undefined);
|
|
67
|
+
}
|
|
66
68
|
|
|
67
69
|
var ColumnTypeEnum;
|
|
68
70
|
(function (ColumnTypeEnum) {
|
|
@@ -576,7 +578,7 @@ class SortDescriptor {
|
|
|
576
578
|
}
|
|
577
579
|
withDefaultSort(enabled = true, ascending, order) {
|
|
578
580
|
this._defaultIsEnabled = enabled;
|
|
579
|
-
this._defaultIsAscending = true;
|
|
581
|
+
this._defaultIsAscending = ascending ?? true;
|
|
580
582
|
this._defaultOrder = order;
|
|
581
583
|
return this;
|
|
582
584
|
}
|
|
@@ -1099,129 +1101,6 @@ class TableDescriptorInst {
|
|
|
1099
1101
|
descriptor._columns = this.columns.map(c => c.copy());
|
|
1100
1102
|
return descriptor;
|
|
1101
1103
|
}
|
|
1102
|
-
/**
|
|
1103
|
-
* defines modified type of column
|
|
1104
|
-
* DO NOT USE with enum (use withCustomEnumType)
|
|
1105
|
-
* @param property column name
|
|
1106
|
-
* @param columnType modified type
|
|
1107
|
-
* @param args additional attributes
|
|
1108
|
-
* @param columnDisplayType
|
|
1109
|
-
*/
|
|
1110
|
-
withColumnModifiedType(property, columnType, columnDisplayType, ...args) {
|
|
1111
|
-
return this.withColumnModifiedTypeUnsafe(property, columnType, columnDisplayType, ...args);
|
|
1112
|
-
}
|
|
1113
|
-
withColumnModifiedTypeUnsafe(property, columnType, columnDisplayType, ...args) {
|
|
1114
|
-
if (!this.model.type) {
|
|
1115
|
-
throw new CommonsInternalError(`withColumnModifiedType cannot be executed for property ${property}: Model type is not defined.`);
|
|
1116
|
-
}
|
|
1117
|
-
const attributeDef = getTableClassAttributeDef(this.model.type).find(attr => attr.name === property);
|
|
1118
|
-
if (attributeDef != null) {
|
|
1119
|
-
attributeDef.columnType = columnType ?? attributeDef.columnType;
|
|
1120
|
-
attributeDef.columnDisplayType = columnDisplayType ?? attributeDef.columnDisplayType;
|
|
1121
|
-
TableDescriptorInst.upsertColumnFromAttributeDef(this, attributeDef, this.columns.find(col => col.property === attributeDef.name), ...args);
|
|
1122
|
-
}
|
|
1123
|
-
return this;
|
|
1124
|
-
}
|
|
1125
|
-
/**
|
|
1126
|
-
* defines custom enum type for column
|
|
1127
|
-
* @param property column name
|
|
1128
|
-
* @param enumDesc Enum descriptor.
|
|
1129
|
-
*/
|
|
1130
|
-
withColumnModifiedEnum(property, enumDesc) {
|
|
1131
|
-
return this.withColumnModifiedEnumUnsafe(property, enumDesc);
|
|
1132
|
-
}
|
|
1133
|
-
withColumnModifiedEnumUnsafe(property, enumDesc) {
|
|
1134
|
-
if (!this.model.type) {
|
|
1135
|
-
throw new CommonsInternalError(`withColumnModifiedEnum cannot be executed for property ${property}: Model type is not defined.`);
|
|
1136
|
-
}
|
|
1137
|
-
const attributeDef = getTableClassAttributeDef(this.model.type).find(attr => attr.name === property);
|
|
1138
|
-
if (attributeDef != null) {
|
|
1139
|
-
attributeDef.columnType = ColumnTypeEnum.Enum;
|
|
1140
|
-
TableDescriptorInst.upsertColumnFromAttributeDef(this, attributeDef, this.columns.find(col => col.property === property), enumDesc ?? enumModelGeneric(TypeRegistry.get().findEnum(attributeDef.type)));
|
|
1141
|
-
}
|
|
1142
|
-
return this;
|
|
1143
|
-
}
|
|
1144
|
-
/**
|
|
1145
|
-
* modifies column with class and lookup provider
|
|
1146
|
-
* @param property column name
|
|
1147
|
-
* @param lookupProvider lookupProvider for class
|
|
1148
|
-
* @param optionsLabelProperty
|
|
1149
|
-
* @param filterProperty
|
|
1150
|
-
*/
|
|
1151
|
-
withModifiedLookup(property, lookupProvider, optionsLabelProperty, filterProperty) {
|
|
1152
|
-
return this.withColumnModifiedLookupUnsafe(property, lookupProvider, optionsLabelProperty, filterProperty);
|
|
1153
|
-
}
|
|
1154
|
-
withColumnModifiedLookupUnsafe(property, lookupProvider, optionsLabelProperty, filterProperty) {
|
|
1155
|
-
const column = this.columns.find(col => col.property === property);
|
|
1156
|
-
if (column) {
|
|
1157
|
-
const filter = this.addFilterLookupUnsafe(column.property, lookupProvider, filterProperty);
|
|
1158
|
-
if (optionsLabelProperty) {
|
|
1159
|
-
filter.withOptionsLabelPropertyUnsafe(optionsLabelProperty);
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
return this;
|
|
1163
|
-
}
|
|
1164
|
-
/**
|
|
1165
|
-
* generates column based on attributes
|
|
1166
|
-
* @param desc Table descriptor
|
|
1167
|
-
* @param attribute attribute map
|
|
1168
|
-
* @param column if provided, replaced by new, otherwise new is created
|
|
1169
|
-
* @param args additional parameters
|
|
1170
|
-
*/
|
|
1171
|
-
static upsertColumnFromAttributeDef(desc, attribute, column, ...args) {
|
|
1172
|
-
if (column == null) {
|
|
1173
|
-
column = desc.addColumnUnsafe(attribute.name);
|
|
1174
|
-
}
|
|
1175
|
-
if (attribute.columnType === ColumnTypeEnum.Enum && args.length === 0 && attribute.enumType) {
|
|
1176
|
-
args = [enumModelGeneric(attribute.enumType)];
|
|
1177
|
-
}
|
|
1178
|
-
column = column.asType(attribute.columnType, attribute.columnDisplayType, ...args);
|
|
1179
|
-
if (attribute.classType) {
|
|
1180
|
-
const titleProperty = findClassTitleAttribute(attribute.classType) ?? undefined;
|
|
1181
|
-
if (titleProperty) {
|
|
1182
|
-
column.withGetter(value => value?.[titleProperty]);
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
else {
|
|
1186
|
-
column.withSortUnsafe().withFilterUnsafe();
|
|
1187
|
-
}
|
|
1188
|
-
return column;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
class TableDescriptor extends TableDescriptorInst {
|
|
1192
|
-
constructor() {
|
|
1193
|
-
super(ModelDescriptor.create());
|
|
1194
|
-
}
|
|
1195
|
-
static create(idProperty, titleProperty, i18nBaseKey) {
|
|
1196
|
-
return new TableDescriptorInst(ModelDescriptor.create(idProperty, titleProperty, i18nBaseKey));
|
|
1197
|
-
}
|
|
1198
|
-
static fromClass(type, idProperty, titleProperty, i18nBaseKey, isAutoGenerated = false) {
|
|
1199
|
-
return new TableDescriptorInst(ModelDescriptor.fromClass(type, idProperty, titleProperty, i18nBaseKey), isAutoGenerated);
|
|
1200
|
-
}
|
|
1201
|
-
static fromModel(model) {
|
|
1202
|
-
return new TableDescriptorInst(model);
|
|
1203
|
-
}
|
|
1204
|
-
/**
|
|
1205
|
-
* generates descriptor based on type attribute definition
|
|
1206
|
-
* @param type class type
|
|
1207
|
-
* @param idProperty
|
|
1208
|
-
* @param titleProperty
|
|
1209
|
-
*/
|
|
1210
|
-
static fromClassWithAutoAttrsDef(type, idProperty, titleProperty) {
|
|
1211
|
-
return TableDescriptor.fromClassWithCustomAttrsDef(type, getTableClassAttributeDef(type), idProperty, titleProperty);
|
|
1212
|
-
}
|
|
1213
|
-
/**
|
|
1214
|
-
* generates descriptor base on given attribute definition
|
|
1215
|
-
* @param type class type
|
|
1216
|
-
* @param attributes attributes from which descriptor is generated
|
|
1217
|
-
* @param idProperty
|
|
1218
|
-
* @param titleProperty
|
|
1219
|
-
*/
|
|
1220
|
-
static fromClassWithCustomAttrsDef(type, attributes, idProperty, titleProperty) {
|
|
1221
|
-
const descriptor = TableDescriptor.fromClass(type, idProperty, titleProperty, undefined, true);
|
|
1222
|
-
attributes.filter(attr => !attr.type.includes('Set') && !attr.type.includes('Array')).forEach(attr => TableDescriptorInst.upsertColumnFromAttributeDef(descriptor, attr));
|
|
1223
|
-
return descriptor;
|
|
1224
|
-
}
|
|
1225
1104
|
}
|
|
1226
1105
|
class TableDynamicDescriptorInst extends TableDescriptorInst {
|
|
1227
1106
|
constructor(model) {
|
|
@@ -1274,7 +1153,7 @@ class TableDynamicDescriptorInst extends TableDescriptorInst {
|
|
|
1274
1153
|
* @param displayType custom column value display type
|
|
1275
1154
|
* @param args addition arguments for column
|
|
1276
1155
|
*/
|
|
1277
|
-
|
|
1156
|
+
withColumnPresetType(property, type, displayType, ...args) {
|
|
1278
1157
|
const column = this._columns.find(col => property === col.property) ?? this.addColumn(property).withTitle(property);
|
|
1279
1158
|
if (column) {
|
|
1280
1159
|
column.asType(type, displayType, ...args);
|
|
@@ -1369,17 +1248,184 @@ class TableDynamicDescriptorInst extends TableDescriptorInst {
|
|
|
1369
1248
|
return descriptor;
|
|
1370
1249
|
}
|
|
1371
1250
|
}
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* generates column based on attributes
|
|
1254
|
+
* @param desc Table descriptor
|
|
1255
|
+
* @param attribute attribute map
|
|
1256
|
+
* @param column if provided, replaced by new, otherwise new is created
|
|
1257
|
+
* @param args additional parameters
|
|
1258
|
+
*/
|
|
1259
|
+
function upsertTableColumnFromAttributeDef(desc, attribute, column, ...args) {
|
|
1260
|
+
if (column == null) {
|
|
1261
|
+
column = desc.addColumnUnsafe(attribute.name);
|
|
1262
|
+
}
|
|
1263
|
+
if (attribute.columnType === ColumnTypeEnum.Enum && args.length === 0 && attribute.enumType) {
|
|
1264
|
+
args = [enumModelGeneric(attribute.enumType)];
|
|
1265
|
+
}
|
|
1266
|
+
column = column.asType(attribute.columnType, attribute.columnDisplayType, ...args);
|
|
1267
|
+
if (attribute.classType) {
|
|
1268
|
+
const titleProperty = findClassTitleAttribute(attribute.classType) ?? undefined;
|
|
1269
|
+
if (titleProperty) {
|
|
1270
|
+
column.withGetter(value => value?.[titleProperty]);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
else {
|
|
1274
|
+
column.withSortUnsafe().withFilterUnsafe();
|
|
1275
|
+
}
|
|
1276
|
+
return column;
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* defines modified type of column
|
|
1280
|
+
* DO NOT USE with enum (use withCustomEnumType)
|
|
1281
|
+
* @param descriptor table descriptor
|
|
1282
|
+
* @param property column name
|
|
1283
|
+
* @param columnType modified type
|
|
1284
|
+
* @param args additional attributes
|
|
1285
|
+
* @param columnDisplayType
|
|
1286
|
+
*/
|
|
1287
|
+
function modifyTableClassAttributeColumnType(descriptor, property, columnType, columnDisplayType, ...args) {
|
|
1288
|
+
return modifyTableClassAttributeColumnTypeUnsafe(descriptor, property, columnType, columnDisplayType, ...args);
|
|
1289
|
+
}
|
|
1290
|
+
function modifyTableClassAttributeColumnTypeUnsafe(descriptor, property, columnType, columnDisplayType, ...args) {
|
|
1291
|
+
if (!descriptor.model.type) {
|
|
1292
|
+
throw new CommonsInternalError(`withColumnModifiedType cannot be executed for property ${property}: Model type is not defined.`);
|
|
1293
|
+
}
|
|
1294
|
+
const attributeDef = getTableClassAttributeDef(descriptor.model.type).find(attr => attr.name === property);
|
|
1295
|
+
if (attributeDef != null) {
|
|
1296
|
+
attributeDef.columnType = columnType ?? attributeDef.columnType;
|
|
1297
|
+
attributeDef.columnDisplayType = columnDisplayType ?? attributeDef.columnDisplayType;
|
|
1298
|
+
return upsertTableColumnFromAttributeDef(descriptor, attributeDef, descriptor.columns.find(col => col.property === attributeDef.name), ...args);
|
|
1299
|
+
}
|
|
1300
|
+
return null;
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* defines custom enum type for column
|
|
1304
|
+
* @param descriptor table descriptor
|
|
1305
|
+
* @param property column name
|
|
1306
|
+
* @param enumDesc Enum descriptor.
|
|
1307
|
+
*/
|
|
1308
|
+
function modifyTableClassAttributeColumnEnum(descriptor, property, enumDesc) {
|
|
1309
|
+
return tableDescriptorModifyEnumColumnUnsafe(descriptor, property, enumDesc);
|
|
1310
|
+
}
|
|
1311
|
+
function tableDescriptorModifyEnumColumnUnsafe(descriptor, property, enumDesc) {
|
|
1312
|
+
if (!descriptor.model.type) {
|
|
1313
|
+
throw new CommonsInternalError(`withColumnModifiedEnum cannot be executed for property ${property}: Model type is not defined.`);
|
|
1314
|
+
}
|
|
1315
|
+
const attributeDef = getTableClassAttributeDef(descriptor.model.type).find(attr => attr.name === property);
|
|
1316
|
+
if (attributeDef != null) {
|
|
1317
|
+
attributeDef.columnType = ColumnTypeEnum.Enum;
|
|
1318
|
+
upsertTableColumnFromAttributeDef(descriptor, attributeDef, descriptor.columns.find(col => col.property === property), enumDesc ?? enumModelGeneric(TypeRegistry.get().findEnum(attributeDef.type)));
|
|
1319
|
+
}
|
|
1320
|
+
return null;
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* modifies column with class and lookup provider
|
|
1324
|
+
* @param descriptor table descriptor
|
|
1325
|
+
* @param property column name
|
|
1326
|
+
* @param lookupProvider lookupProvider for class
|
|
1327
|
+
* @param optionsLabelProperty
|
|
1328
|
+
* @param filterProperty
|
|
1329
|
+
*/
|
|
1330
|
+
function modifyTableColumnFilterLookup(descriptor, property, lookupProvider, optionsLabelProperty, filterProperty) {
|
|
1331
|
+
return modifyTableColumnFilterLookupUnsafe(descriptor, property, lookupProvider, optionsLabelProperty, filterProperty);
|
|
1332
|
+
}
|
|
1333
|
+
function modifyTableColumnFilterLookupUnsafe(descriptor, property, lookupProvider, optionsLabelProperty, filterProperty) {
|
|
1334
|
+
const column = descriptor.columns.find(col => col.property === property);
|
|
1335
|
+
if (column) {
|
|
1336
|
+
const filter = descriptor.addFilterLookupUnsafe(column.property, lookupProvider, filterProperty);
|
|
1337
|
+
if (optionsLabelProperty) {
|
|
1338
|
+
filter.withOptionsLabelPropertyUnsafe(optionsLabelProperty);
|
|
1339
|
+
}
|
|
1340
|
+
return filter;
|
|
1341
|
+
}
|
|
1342
|
+
return null;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
class TableDescriptor extends TableDescriptorInst {
|
|
1346
|
+
constructor() {
|
|
1347
|
+
super(model());
|
|
1348
|
+
}
|
|
1349
|
+
static create(idProperty, titleProperty, i18nBaseKey) {
|
|
1350
|
+
return tableDescriptor({ id: idProperty, title: titleProperty, i18nBase: i18nBaseKey });
|
|
1351
|
+
}
|
|
1352
|
+
static fromClass(type, idProperty, titleProperty, i18nBaseKey) {
|
|
1353
|
+
return tableDescriptorFromClass(type, { id: idProperty, title: titleProperty, i18nBase: i18nBaseKey });
|
|
1354
|
+
}
|
|
1355
|
+
static fromModel(model) {
|
|
1356
|
+
return new TableDescriptorInst(model);
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* generates descriptor based on type attribute definition
|
|
1360
|
+
* @param type class type
|
|
1361
|
+
* @param idProperty
|
|
1362
|
+
* @param titleProperty
|
|
1363
|
+
*/
|
|
1364
|
+
static fromClassWithAutoAttrsDef(type, idProperty, titleProperty) {
|
|
1365
|
+
return tableDescriptorFromClassAttrsDef(type, undefined, { id: idProperty, title: titleProperty });
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* generates descriptor base on given attribute definition
|
|
1369
|
+
* @param type class type
|
|
1370
|
+
* @param attributes attributes from which descriptor is generated
|
|
1371
|
+
* @param idProperty
|
|
1372
|
+
* @param titleProperty
|
|
1373
|
+
*/
|
|
1374
|
+
static fromClassWithCustomAttrsDef(type, attributes, idProperty, titleProperty) {
|
|
1375
|
+
return tableDescriptorFromClassAttrsDef(type, attributes, { id: idProperty, title: titleProperty });
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
function tableDescriptor(typeOrModelOrClassOrOpts, opts) {
|
|
1379
|
+
if (typeOrModelOrClassOrOpts == null) {
|
|
1380
|
+
return new TableDescriptorInst(model());
|
|
1381
|
+
}
|
|
1382
|
+
else if (typeOrModelOrClassOrOpts instanceof TypeDescriptor) {
|
|
1383
|
+
return new TableDescriptorInst(model(opts ?? {}));
|
|
1384
|
+
}
|
|
1385
|
+
else if (typeOrModelOrClassOrOpts instanceof ModelDescriptor) {
|
|
1386
|
+
return new TableDescriptorInst(typeOrModelOrClassOrOpts);
|
|
1387
|
+
}
|
|
1388
|
+
else {
|
|
1389
|
+
// this could have autoGenerated if model descriptor is class
|
|
1390
|
+
return new TableDescriptorInst(model(typeOrModelOrClassOrOpts));
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
function tableDescriptorFromClass(type, opts) {
|
|
1394
|
+
return new TableDescriptorInst(model(type, opts));
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* generates descriptor based on type attribute definition
|
|
1398
|
+
* @param type class type
|
|
1399
|
+
* @param attributes
|
|
1400
|
+
* @param opts
|
|
1401
|
+
*/
|
|
1402
|
+
function tableDescriptorFromClassAttrsDef(type, attributes, opts) {
|
|
1403
|
+
const descriptor = new TableDescriptorInst(model(type, opts), true);
|
|
1404
|
+
(attributes ?? getTableClassAttributeDef(type))
|
|
1405
|
+
.filter(attr => !attr.type.includes('Set') && !attr.type.includes('Array'))
|
|
1406
|
+
.forEach(attr => upsertTableColumnFromAttributeDef(descriptor, attr));
|
|
1407
|
+
return descriptor;
|
|
1408
|
+
}
|
|
1372
1409
|
class TableDynamicDescriptor extends TableDynamicDescriptorInst {
|
|
1373
1410
|
constructor() {
|
|
1374
1411
|
super(ModelDescriptor.create());
|
|
1375
1412
|
}
|
|
1376
1413
|
static create(idProperty, titleProperty, i18nBaseKey) {
|
|
1377
|
-
return
|
|
1414
|
+
return tableDynamicDescriptor({
|
|
1415
|
+
id: idProperty,
|
|
1416
|
+
title: titleProperty,
|
|
1417
|
+
i18nBase: i18nBaseKey
|
|
1418
|
+
});
|
|
1378
1419
|
}
|
|
1379
1420
|
static fromModel(model) {
|
|
1380
|
-
return
|
|
1421
|
+
return tableDynamicDescriptor(model);
|
|
1381
1422
|
}
|
|
1382
1423
|
}
|
|
1424
|
+
function tableDynamicDescriptor(modelOrOpts) {
|
|
1425
|
+
return modelOrOpts instanceof ModelDescriptor
|
|
1426
|
+
? new TableDynamicDescriptorInst(modelOrOpts)
|
|
1427
|
+
: new TableDynamicDescriptorInst(new ModelDescriptor(undefined, modelOrOpts?.id, modelOrOpts?.title, modelOrOpts?.i18nBase));
|
|
1428
|
+
}
|
|
1383
1429
|
|
|
1384
1430
|
// data providers
|
|
1385
1431
|
|
|
@@ -1387,5 +1433,5 @@ class TableDynamicDescriptor extends TableDynamicDescriptorInst {
|
|
|
1387
1433
|
* Generated bundle index. Do not edit.
|
|
1388
1434
|
*/
|
|
1389
1435
|
|
|
1390
|
-
export { ColumnDescriptor, ColumnDisplayTypeEnum, ColumnDynamicDescriptor, ColumnTypeEnum, SortDescriptor, TableDataProvider, TableDataProviderInst, TableDescriptor, TableDescriptorInst, TableDynamicColumnsModeEnum, TableDynamicDescriptor, TableDynamicDescriptorInst, TablePaginationModeEnum, TableSizeEnum, columnToDateNumberOrBoolean, expandClassAttributeDefWithTableDef, getColumnDisplayTypeFromColumnType, getColumnTypeFromClassAttributeDefType, getTableClassAttributeDef };
|
|
1436
|
+
export { ColumnDescriptor, ColumnDisplayTypeEnum, ColumnDynamicDescriptor, ColumnTypeEnum, SortDescriptor, TableDataProvider, TableDataProviderInst, TableDescriptor, TableDescriptorInst, TableDynamicColumnsModeEnum, TableDynamicDescriptor, TableDynamicDescriptorInst, TablePaginationModeEnum, TableSizeEnum, columnToDateNumberOrBoolean, expandClassAttributeDefWithTableDef, getColumnDisplayTypeFromColumnType, getColumnTypeFromClassAttributeDefType, getTableClassAttributeDef, modifyTableClassAttributeColumnEnum, modifyTableClassAttributeColumnType, modifyTableClassAttributeColumnTypeUnsafe, modifyTableColumnFilterLookup, modifyTableColumnFilterLookupUnsafe, tableDataProvider, tableDataProviderFromClass, tableDataProviderFromModel, tableDataProviderWithService, tableDescriptor, tableDescriptorFromClass, tableDescriptorFromClassAttrsDef, tableDescriptorModifyEnumColumnUnsafe, tableDynamicDescriptor, upsertTableColumnFromAttributeDef };
|
|
1391
1437
|
//# sourceMappingURL=mediusinc-mng-commons-table-api.mjs.map
|