@mediusinc/mng-commons 5.4.0 → 5.5.0-rc.1
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/descriptors/table.descriptor.d.ts +4 -2
- package/core/directives/rerender.directive.d.ts +9 -0
- package/core/helpers/route.d.ts +25 -25
- package/core/index.d.ts +2 -0
- package/core/models/version.model.d.ts +16 -4
- package/core/reactivity/effect.d.ts +16 -0
- package/esm2022/core/components/notification/notification-wrapper.component.mjs +4 -4
- package/esm2022/core/components/pages/error/error.page.component.mjs +4 -4
- package/esm2022/core/components/pages/not-found/not-found.page.component.mjs +4 -4
- package/esm2022/core/data-list/data-list-params-helpers.mjs +18 -3
- package/esm2022/core/descriptors/table.descriptor.mjs +1 -1
- package/esm2022/core/directives/component.directive.mjs +4 -4
- package/esm2022/core/directives/rerender.directive.mjs +25 -0
- package/esm2022/core/directives/template.directive.mjs +4 -4
- package/esm2022/core/index.mjs +4 -1
- package/esm2022/core/models/version.model.mjs +1 -1
- package/esm2022/core/pipes/boolean.pipe.mjs +6 -6
- package/esm2022/core/pipes/class-map.pipe.mjs +4 -4
- package/esm2022/core/pipes/enum.pipe.mjs +4 -4
- package/esm2022/core/pipes/enumerate-async.pipe.mjs +4 -4
- package/esm2022/core/pipes/enumerate.pipe.mjs +4 -4
- package/esm2022/core/pipes/getter.pipe.mjs +5 -5
- package/esm2022/core/pipes/i18n-property.pipe.mjs +4 -4
- package/esm2022/core/pipes/json-path.pipe.mjs +4 -4
- package/esm2022/core/pipes/parametrize.pipe.mjs +4 -4
- package/esm2022/core/pipes/template.pipe.mjs +4 -4
- package/esm2022/core/reactivity/effect.mjs +22 -0
- package/esm2022/core/security/permission.service.mjs +4 -4
- package/esm2022/core/services/commons-init.service.mjs +4 -4
- package/esm2022/core/services/commons-router.service.mjs +4 -4
- package/esm2022/core/services/commons-storage.service.mjs +4 -4
- package/esm2022/core/services/commons.service.mjs +8 -8
- package/esm2022/filter/descriptors/filter-lookup.descriptor.mjs +32 -25
- package/esm2022/filter/descriptors/filter.descriptor.mjs +53 -1
- package/esm2022/form/components/autocomplete/autocomplete.component.mjs +4 -4
- package/esm2022/form/components/date-range/date-range.component.mjs +4 -4
- package/esm2022/form/components/dropdown/dropdown.component.mjs +4 -4
- package/esm2022/form/components/number-range/number-range.component.mjs +4 -4
- package/esm2022/form/directives/input-trim.directive.mjs +4 -4
- package/esm2022/table/api/descriptors/sort.descriptor.mjs +2 -2
- package/esm2022/table/api/descriptors/table.descriptor.mjs +31 -7
- package/esm2022/table/components/column-filter/column-filter.component.mjs +33 -40
- package/esm2022/table/components/column-value/column-value.component.mjs +6 -6
- package/esm2022/table/components/filter/filter-active-tag/filter-active-tag.component.mjs +7 -7
- package/esm2022/table/components/filter/filter-form/filter-form.component.mjs +28 -35
- package/esm2022/table/components/filter/filter-overlay-with-tag/filter-overlay-with-tag.component.mjs +44 -45
- package/esm2022/table/components/table/table.component.mjs +114 -430
- package/esm2022/table/helpers/filters.mjs +9 -25
- package/esm2022/table/helpers/table.mjs +24 -0
- package/esm2022/table/index.mjs +2 -2
- package/esm2022/table/models/column-preferences.model.mjs +1 -1
- package/esm2022/table/models/filter.model.mjs +1 -1
- package/esm2022/table/pipes/filter-value.pipe.mjs +4 -4
- package/esm2022/table/pipes/locale-default-row-class.pipe.mjs +4 -4
- package/esm2022/table/pipes/table-column-filter-class.pipe.mjs +4 -4
- package/esm2022/table/services/table-data.service.mjs +194 -0
- package/esm2022/table/services/table-metadata.service.mjs +136 -0
- package/esm2022/table/services/table-preferences.service.mjs +142 -0
- package/esm2022/tableview/action/components/action/action.component.mjs +6 -7
- package/esm2022/tableview/action/components/editor/action-editor.component.mjs +4 -4
- package/esm2022/tableview/action/components/editor/injector-context/action-editor-injector-context.component.mjs +69 -46
- package/esm2022/tableview/action/components/localization/data-language-dropdown.component.mjs +4 -4
- package/esm2022/tableview/action/components/route/action-route.component.mjs +5 -6
- package/esm2022/tableview/action/components/table/action-table.component.mjs +6 -6
- package/esm2022/tableview/action/helpers/action-execution.mjs +25 -0
- package/esm2022/tableview/action/models/execution/action-instance.model.mjs +2 -3
- package/esm2022/tableview/action/services/action-executor.service.mjs +12 -79
- package/esm2022/tableview/action/services/component-action-executor.service.mjs +4 -4
- package/esm2022/tableview/action/services/data-provider-executor.service.mjs +4 -4
- package/esm2022/tableview/action/services/navigation.service.mjs +4 -4
- package/esm2022/tableview/action/services/root-action-executor.service.mjs +4 -4
- package/esm2022/tableview/action/services/view-container.service.mjs +4 -4
- package/esm2022/tableview/api/action/descriptors/action-confirmation.descriptor.mjs +13 -1
- package/esm2022/tableview/api/action/descriptors/action-editor.descriptor.mjs +67 -10
- package/esm2022/tableview/api/action/descriptors/action-link-descriptor.factory.mjs +2 -2
- package/esm2022/tableview/api/action/descriptors/action-link.descriptor.mjs +17 -1
- package/esm2022/tableview/api/action/descriptors/action.descriptor.mjs +32 -7
- package/esm2022/tableview/api/action/models/execution/action-instance-state.model.mjs +2 -2
- package/esm2022/tableview/api/editor/descriptors/field-many.descriptor.mjs +2 -1
- package/esm2022/tableview/api/editor/models/formly-custom-field.model.mjs +4 -4
- package/esm2022/tableview/api/tableview/descriptors/tableview.descriptor.mjs +13 -5
- package/esm2022/tableview/api/tableview/helpers/tableview-default-actions.mjs +3 -2
- package/esm2022/tableview/api/tableview/helpers/tableview-descriptor-helpers.mjs +2 -2
- package/esm2022/tableview/editor/components/editor/auto-save-status/auto-save-status.component.mjs +4 -4
- package/esm2022/tableview/editor/components/editor/form-editor.component.mjs +31 -38
- package/esm2022/tableview/editor/components/formly/fields/formly-field-action/formly-field-action.component.mjs +4 -4
- package/esm2022/tableview/editor/components/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.mjs +7 -5
- package/esm2022/tableview/editor/components/formly/fields/formly-field-custom/formly-field-custom.component.mjs +4 -4
- package/esm2022/tableview/editor/components/formly/fields/formly-field-datepicker/formly-field-datepicker.component.mjs +7 -5
- package/esm2022/tableview/editor/components/formly/fields/formly-field-dropdown/formly-field-dropdown.component.mjs +7 -5
- package/esm2022/tableview/editor/components/formly/fields/formly-field-fieldset/formly-field-fieldset.component.mjs +4 -4
- package/esm2022/tableview/editor/components/formly/fields/formly-field-input/formly-field-input.component.mjs +5 -5
- package/esm2022/tableview/editor/components/formly/fields/formly-field-label/formly-field-label.component.mjs +4 -4
- package/esm2022/tableview/editor/components/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.mjs +5 -6
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +5 -6
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +6 -7
- package/esm2022/tableview/editor/components/formly/fields/formly-field-tabs/formly-field-tabs.component.mjs +4 -4
- package/esm2022/tableview/editor/components/formly/fields/formly-field-type.abstract.component.mjs +6 -5
- package/esm2022/tableview/editor/components/formly/pipes/formly-field-label.pipe.mjs +4 -4
- package/esm2022/tableview/editor/components/formly/wrappers/formly-field-no-label-wrapper/formly-field-no-label-wrapper.component.mjs +4 -4
- package/esm2022/tableview/editor/components/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.mjs +4 -4
- package/esm2022/tableview/editor/helpers/editor-autosave.mjs +2 -2
- package/esm2022/tableview/editor/services/form-editor.service.mjs +4 -4
- package/esm2022/tableview/index.mjs +1 -2
- package/esm2022/tableview/tableview/components/route/tableview-route.component.mjs +4 -4
- package/esm2022/tableview/tableview/components/tableview/tableview.component.mjs +4 -4
- package/fesm2022/mediusinc-mng-commons-core.mjs +130 -71
- package/fesm2022/mediusinc-mng-commons-core.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-filter.mjs +83 -24
- package/fesm2022/mediusinc-mng-commons-filter.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-form-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-form.mjs +15 -15
- package/fesm2022/mediusinc-mng-commons-form.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-model.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table-api.mjs +31 -7
- package/fesm2022/mediusinc-mng-commons-table-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table.mjs +704 -606
- package/fesm2022/mediusinc-mng-commons-table.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs +146 -26
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview.mjs +260 -317
- package/fesm2022/mediusinc-mng-commons-tableview.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons.mjs.map +1 -1
- package/filter/descriptors/filter-lookup.descriptor.d.ts +17 -20
- package/filter/descriptors/filter.descriptor.d.ts +32 -2
- package/form/components/date-range/date-range.component.d.ts +3 -3
- package/form/components/number-range/number-range.component.d.ts +2 -2
- package/package.json +4 -4
- package/table/api/descriptors/column.descriptor.d.ts +1 -1
- package/table/api/descriptors/sort.descriptor.d.ts +2 -2
- package/table/api/descriptors/table.descriptor.d.ts +20 -6
- package/table/components/column-filter/column-filter.component.d.ts +8 -14
- package/table/components/filter/filter-active-tag/filter-active-tag.component.d.ts +5 -5
- package/table/components/filter/filter-form/filter-form.component.d.ts +10 -19
- package/table/components/filter/filter-overlay-with-tag/filter-overlay-with-tag.component.d.ts +11 -13
- package/table/components/table/table.component.d.ts +20 -64
- package/table/helpers/filters.d.ts +4 -7
- package/table/helpers/table.d.ts +6 -0
- package/table/index.d.ts +1 -1
- package/table/models/column-preferences.model.d.ts +2 -2
- package/table/models/filter.model.d.ts +14 -2
- package/table/services/table-data.service.d.ts +36 -0
- package/table/services/table-metadata.service.d.ts +31 -0
- package/table/services/table-preferences.service.d.ts +25 -0
- package/tableview/action/components/editor/injector-context/action-editor-injector-context.component.d.ts +4 -7
- package/tableview/action/components/localization/data-language-dropdown.component.d.ts +1 -1
- package/tableview/action/helpers/action-execution.d.ts +7 -0
- package/tableview/action/models/execution/action-instance.model.d.ts +1 -2
- package/tableview/action/services/action-executor.service.d.ts +1 -2
- package/tableview/api/action/descriptors/action-confirmation.descriptor.d.ts +1 -0
- package/tableview/api/action/descriptors/action-editor.descriptor.d.ts +12 -4
- package/tableview/api/action/descriptors/action-link.descriptor.d.ts +1 -0
- package/tableview/api/action/descriptors/action.descriptor.d.ts +5 -3
- package/tableview/api/action/models/execution/action-instance-state.model.d.ts +1 -1
- package/tableview/api/editor/descriptors/field-base.descriptor.d.ts +4 -10
- package/tableview/api/editor/descriptors/field-group.descriptor.d.ts +1 -1
- package/tableview/api/tableview/descriptors/tableview.descriptor.d.ts +6 -4
- package/tableview/editor/components/editor/form-editor.component.d.ts +3 -2
- package/tableview/editor/components/formly/fields/formly-field-fieldset/formly-field-fieldset.component.d.ts +1 -1
- package/tableview/editor/components/formly/fields/formly-field-type.abstract.component.d.ts +2 -1
- package/tableview/index.d.ts +0 -1
- package/version-info.json +6 -6
- package/esm2022/table/services/data-list.service.mjs +0 -29
- package/esm2022/tableview/action/models/execution/action-instance-state.model.mjs +0 -32
- package/table/services/data-list.service.d.ts +0 -19
- package/tableview/action/models/execution/action-instance-state.model.d.ts +0 -30
|
@@ -1 +1 @@
|
|
|
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<Enum = any>(type: EnumType, i18nBaseKey: string | undefined | null = null, nameAsValue = false) {\n return new EnumDescriptor<Enum>(undefined as Enum, 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<Model>(lookup: ILookupDescriptor<Model, any, any, any>, 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 _i18nBaseKey: string;\n private _idProperty?: string;\n private _titleProperty?: string | ((item: Model) => string);\n\n public constructor(type: ModelClass, idProperty?: string, titleProperty?: string | ((item: Model) => string), i18nBaseKey?: string | ClassType<any>) {\n this._type = type;\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 =\n (typeof i18nBaseKey === 'string' || typeof i18nBaseKey === 'undefined' ? i18nBaseKey : findReflectTypeName(i18nBaseKey)) ??\n findReflectTypeName(type as ClassType<Model>) ??\n '';\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 /**\n * @deprecated Use `i18nBaseKey` instead.\n */\n public get typeName() {\n return this.i18nBaseKey;\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.i18nBaseKey}`);\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 | ((item: Model) => string);\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, 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 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) => string), 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 (typeof titleProperty === 'function') {\n paramsRes.itemTitle = titleProperty(item);\n } else 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,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,uBAAuB,CAAC,UAAsB,EAAE,aAAmD,EAAE,IAAU,EAAE,MAAA,GAAc,EAAE,EAAA;AAC7I,IAAA,MAAM,SAAS,GAAG,EAAC,GAAG,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAC,CAAC;IACzD,IAAI,IAAI,EAAE;AACN,QAAA,IAAI,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE;AAChC,YAAA,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;SACvC;AACD,QAAA,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;AACrC,YAAA,SAAS,CAAC,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;SAC7C;AAAM,aAAA,IAAI,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,EAAE;AAC7C,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;;AC3DA;;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<Enum = any>(type: EnumType, i18nBaseKey: string | undefined | null = null, nameAsValue = false) {\n return new EnumDescriptor<Enum>(undefined as Enum, 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<Model>(lookup: ILookupDescriptor<Model, any, any, any>, 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 _i18nBaseKey: string;\n private _idProperty?: string;\n private _titleProperty?: string | ((item: Model) => string);\n\n public constructor(type: ModelClass, idProperty?: string, titleProperty?: string | ((item: Model) => string), i18nBaseKey?: string | ClassType<any>) {\n this._type = type;\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 =\n (typeof i18nBaseKey === 'string' || typeof i18nBaseKey === 'undefined' ? i18nBaseKey : findReflectTypeName(i18nBaseKey)) ??\n findReflectTypeName(type as ClassType<Model>) ??\n '';\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 /**\n * @deprecated Use `i18nBaseKey` instead.\n */\n public get typeName() {\n return this.i18nBaseKey;\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.i18nBaseKey}`);\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 | ((item: Model) => string);\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, 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 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) => string), 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 (typeof titleProperty === 'function') {\n paramsRes.itemTitle = titleProperty(item);\n } else 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,CAAC;AAChH;AAOgB,SAAA,qBAAqB,CACjC,KAAyC,EACzC,WAA0B,EAAA;IAE1B,OAAO,IAAI,gBAAgB,CAAiD,KAAK,CAAC,IAAwB,EAAE,WAA2B,CAAC;AAC5I;;MCvBa,cAAc,CAAA;IAMvB,WAAmB,CAAA,KAAW,EAAE,IAAc,EAAE,WAA2B,EAAE,WAAW,GAAG,KAAK,EAAA;AAC5F,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;AACnB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI;AACjB,QAAA,IAAI,CAAC,YAAY,GAAG,WAAW;AAE/B,QAAA,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE;AACpC,YAAA,WAAW,GAAG,mBAAmB,CAAC,IAAI,CAAC;;AAE3C,QAAA,IAAI,CAAC,YAAY,GAAG,WAAW;;AAGnC,IAAA,IAAW,IAAI,GAAA;QACX,OAAO,IAAI,CAAC,KAAK;;AAGrB,IAAA,IAAW,WAAW,GAAA;QAClB,OAAO,IAAI,CAAC,YAAY;;AAG5B,IAAA,IAAW,WAAW,GAAA;QAClB,OAAO,IAAI,CAAC,YAAY;;AAE/B;AAEe,SAAA,SAAS,CAAO,KAAW,EAAE,IAAc,EAAE,WAAA,GAAyC,IAAI,EAAE,WAAW,GAAG,KAAK,EAAA;IAC3H,OAAO,IAAI,cAAc,CAAO,KA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AA,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;AACrC,YAAA,SAAS,CAAC,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC;;AACtC,aAAA,IAAI,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,EAAE;AAC7C,YAAA,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC;;;AAGjD,IAAA,OAAO,SAAS;AACpB;AAEA,SAAS,iBAAiB,CAAC,KAA2B,EAAE,OAAe,EAAE,SAAkB,EAAE,WAAoB,EAAA;IAC7G,MAAM,IAAI,GAAG,EAAE;IACf,IAAI,SAAS,EAAE;AACX,QAAA,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;;IAExB,MAAM,cAAc,GAAG,sBAAsB,CAAC,KAAK,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC;AAC5E,IAAA,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;IACzB,IAAI,WAAW,EAAE;AACb,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;;AAE1B,IAAA,OAAO,IAAI;AACf;;AC3DA;;ACAA;;AAEG;;;;"}
|
|
@@ -675,7 +675,7 @@ class ColumnDynamicDescriptor extends ColumnDescriptor {
|
|
|
675
675
|
class SortDescriptor {
|
|
676
676
|
constructor(property) {
|
|
677
677
|
this._defaultIsEnabled = false;
|
|
678
|
-
this._defaultIsAscending =
|
|
678
|
+
this._defaultIsAscending = true;
|
|
679
679
|
this._defaultOrder = undefined;
|
|
680
680
|
this._property = property;
|
|
681
681
|
this._showOnColumn = property;
|
|
@@ -891,6 +891,12 @@ class TableDescriptorInst {
|
|
|
891
891
|
get rowExpandableProperty() {
|
|
892
892
|
return this._rowExpandableProperty;
|
|
893
893
|
}
|
|
894
|
+
/**
|
|
895
|
+
* This table model property tells us when the table row should be expanded by default, without clicking on the toggle button.
|
|
896
|
+
*/
|
|
897
|
+
get isRowExpanded() {
|
|
898
|
+
return this._isRowExpanded;
|
|
899
|
+
}
|
|
894
900
|
/**
|
|
895
901
|
* This property is used to define the type of the custom component that will be used to render the expanded row.
|
|
896
902
|
*/
|
|
@@ -1175,11 +1181,10 @@ class TableDescriptorInst {
|
|
|
1175
1181
|
*
|
|
1176
1182
|
* @param property - The property to set default sort for.
|
|
1177
1183
|
* @param ascending - If the sorting should be ascending (default: true).
|
|
1178
|
-
* @param order - The order for this default sort (default: 0).
|
|
1179
1184
|
* @param enabled - Enables/disabled the default sort.
|
|
1180
1185
|
*/
|
|
1181
|
-
withDefaultSort(property, ascending,
|
|
1182
|
-
return this.withDefaultSortUnsafe(property, ascending,
|
|
1186
|
+
withDefaultSort(property, ascending, enabled) {
|
|
1187
|
+
return this.withDefaultSortUnsafe(property, ascending, enabled);
|
|
1183
1188
|
}
|
|
1184
1189
|
/**
|
|
1185
1190
|
* Sets the default sorting for the property.
|
|
@@ -1188,18 +1193,34 @@ class TableDescriptorInst {
|
|
|
1188
1193
|
*
|
|
1189
1194
|
* @param property - The property to set default sort for.
|
|
1190
1195
|
* @param ascending - If the sorting should be ascending (default: true).
|
|
1191
|
-
* @param order - The order for this default sort (default: 0).
|
|
1192
1196
|
* @param enabled - Enables/disabled the default sort.
|
|
1193
1197
|
*/
|
|
1194
|
-
withDefaultSortUnsafe(property, ascending,
|
|
1198
|
+
withDefaultSortUnsafe(property, ascending, enabled) {
|
|
1195
1199
|
let sort = this._sorts.find(s => s.property === property);
|
|
1196
1200
|
if (!sort) {
|
|
1197
1201
|
sort = new SortDescriptor(property);
|
|
1198
1202
|
this._sorts.push(sort);
|
|
1199
1203
|
}
|
|
1204
|
+
const order = this._sorts.filter(s => s.defaultIsEnabled).reduce((acc, s) => (s.defaultOrder == null || s.defaultOrder < acc ? acc : s.defaultOrder + 1), 0);
|
|
1200
1205
|
sort.withDefaultSort(enabled ?? true, ascending, order);
|
|
1201
1206
|
return this;
|
|
1202
1207
|
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Sets the default sorting for provided properties.
|
|
1210
|
+
*
|
|
1211
|
+
* @param properties - The properties to set default sort for.
|
|
1212
|
+
*/
|
|
1213
|
+
withDefaultSorts(...properties) {
|
|
1214
|
+
properties.forEach(p => this.withDefaultSortUnsafe(p));
|
|
1215
|
+
return this;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Unsets all default sorts.
|
|
1219
|
+
*/
|
|
1220
|
+
withoutDefaultSorts() {
|
|
1221
|
+
this._sorts.forEach(s => s.withDefaultSort(false, undefined, undefined));
|
|
1222
|
+
return this;
|
|
1223
|
+
}
|
|
1203
1224
|
/**
|
|
1204
1225
|
* Add sorts for more properties.
|
|
1205
1226
|
*
|
|
@@ -1637,8 +1658,9 @@ class TableDescriptorInst {
|
|
|
1637
1658
|
* @param property Property to check if row can be expanded.
|
|
1638
1659
|
* @param colSpan set custom row span for expanded row.
|
|
1639
1660
|
* @param componentType Component to be displayed on row expand.
|
|
1661
|
+
* @param isRowExpanded Property or function that tells the table to expand the row by default.
|
|
1640
1662
|
*/
|
|
1641
|
-
withRowExpandable(property, colSpan, componentType) {
|
|
1663
|
+
withRowExpandable(property, colSpan, componentType, isRowExpanded) {
|
|
1642
1664
|
this._rowExpandable = true;
|
|
1643
1665
|
if (property) {
|
|
1644
1666
|
this._rowExpandableProperty = property;
|
|
@@ -1649,6 +1671,7 @@ class TableDescriptorInst {
|
|
|
1649
1671
|
if (componentType) {
|
|
1650
1672
|
this._rowExpandableComponentType = componentType;
|
|
1651
1673
|
}
|
|
1674
|
+
this._isRowExpanded = isRowExpanded;
|
|
1652
1675
|
return this;
|
|
1653
1676
|
}
|
|
1654
1677
|
/**
|
|
@@ -1684,6 +1707,7 @@ class TableDescriptorInst {
|
|
|
1684
1707
|
obj._rowExpandable = this._rowExpandable;
|
|
1685
1708
|
obj._rowExpandableColSpan = this._rowExpandableColSpan;
|
|
1686
1709
|
obj._rowExpandableProperty = this._rowExpandableProperty;
|
|
1710
|
+
obj._isRowExpanded = this.isRowExpanded;
|
|
1687
1711
|
obj._rowExpandableComponentType = this._rowExpandableComponentType;
|
|
1688
1712
|
obj._rowReorderable = this._rowReorderable;
|
|
1689
1713
|
obj._genericFilter = this._genericFilter?.copy();
|