@mediusinc/mng-commons 5.2.0-rc.0 → 5.2.0-rc.2
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/components/notification/notification-wrapper.component.d.ts +3 -1
- package/core/error/error-helpers.d.ts +5 -0
- package/core/error/error.model.d.ts +6 -0
- package/core/helpers/route.d.ts +1 -1
- package/core/models/menu.model.d.ts +2 -1
- package/core/router/route-builder.d.ts +0 -1
- package/core/security/permission.service.d.ts +13 -5
- package/core/security/permissions.model.d.ts +27 -2
- package/esm2022/core/components/notification/notification-wrapper.component.mjs +6 -5
- package/esm2022/core/error/error-helpers.mjs +8 -1
- package/esm2022/core/error/error.model.mjs +2 -1
- package/esm2022/core/models/menu.model.mjs +1 -1
- package/esm2022/core/router/route-builder.mjs +1 -24
- package/esm2022/core/rxjs/map-data-list-result-operator.mjs +4 -1
- package/esm2022/core/security/permission.guard.mjs +2 -2
- package/esm2022/core/security/permission.service.mjs +65 -15
- package/esm2022/core/security/permissions.model.mjs +1 -1
- package/esm2022/form/components/date-range/date-range.component.mjs +9 -3
- package/esm2022/form/components/number-range/number-range.component.mjs +106 -0
- package/esm2022/form/index.mjs +2 -1
- package/esm2022/model/descriptors/enum.descriptor.mjs +1 -1
- package/esm2022/model/helpers/i18n.mjs +2 -2
- package/esm2022/table/api/descriptors/column.descriptor.mjs +8 -19
- package/esm2022/table/api/descriptors/table.descriptor.mjs +13 -9
- package/esm2022/table/api/helpers/table-descriptor-helpers.mjs +3 -2
- package/esm2022/table/components/column-filter-full/column-filter-full.component.mjs +72 -10
- package/esm2022/table/helpers/notification.mjs +2 -2
- package/esm2022/tableview/action/components/action/action.component.mjs +6 -7
- package/esm2022/tableview/action/helpers/i18n.mjs +4 -4
- package/esm2022/tableview/action/services/action-executor.service.mjs +6 -3
- package/esm2022/tableview/api/action/descriptors/action-descriptor.factory.mjs +2 -2
- package/esm2022/tableview/api/editor/descriptors/editor.descriptor.mjs +5 -4
- package/esm2022/tableview/api/editor/descriptors/field-base.descriptor.mjs +2 -3
- package/esm2022/tableview/api/editor/descriptors/field-lookup.descriptor.mjs +2 -3
- package/esm2022/tableview/api/editor/descriptors/field.descriptor.mjs +14 -7
- package/esm2022/tableview/api/tableview/helpers/tableview-default-actions.mjs +1 -1
- package/esm2022/tableview/editor/components/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.mjs +12 -4
- package/fesm2022/mediusinc-mng-commons-core.mjs +82 -42
- package/fesm2022/mediusinc-mng-commons-core.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-form.mjs +109 -3
- package/fesm2022/mediusinc-mng-commons-form.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-model.mjs +1 -1
- package/fesm2022/mediusinc-mng-commons-model.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table-api.mjs +21 -27
- package/fesm2022/mediusinc-mng-commons-table-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table.mjs +72 -10
- package/fesm2022/mediusinc-mng-commons-table.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs +20 -13
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview.mjs +23 -14
- package/fesm2022/mediusinc-mng-commons-tableview.mjs.map +1 -1
- package/form/components/date-range/date-range.component.d.ts +4 -2
- package/form/components/number-range/number-range.component.d.ts +30 -0
- package/form/index.d.ts +1 -0
- package/i18n/en.json +1 -1
- package/i18n/sl.json +1 -1
- package/model/descriptors/enum.descriptor.d.ts +1 -1
- package/package.json +7 -7
- package/table/api/descriptors/column.descriptor.d.ts +4 -10
- package/table/api/descriptors/table.descriptor.d.ts +2 -1
- package/table/components/column-filter-full/column-filter-full.component.d.ts +3 -2
- package/tableview/action/components/action/action.component.d.ts +0 -1
- package/tableview/action/services/action-executor.service.d.ts +1 -0
- package/tableview/api/editor/descriptors/field.descriptor.d.ts +12 -7
- package/tableview/api/tableview/helpers/tableview-default-actions.d.ts +5 -5
- package/tableview/editor/components/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.d.ts +1 -0
- package/version-info.json +6 -6
|
@@ -215,7 +215,7 @@ function getI18nForModel(translate, model, keyPath, customKey, item, fallbackKey
|
|
|
215
215
|
}
|
|
216
216
|
function getI18nModelParams(translate, model, item, params = {}) {
|
|
217
217
|
const i18nParams = getI18nTypeParams(translate, model?.i18nBaseKey, item, params);
|
|
218
|
-
return populateI18nModelParams(model?.idProperty, model?.titleProperty, i18nParams);
|
|
218
|
+
return populateI18nModelParams(model?.idProperty, model?.titleProperty, item, i18nParams);
|
|
219
219
|
}
|
|
220
220
|
function getI18nModelParamsAsync(translate, model, item, params = {}) {
|
|
221
221
|
return getI18nTypeParamsAsync(translate, model?.i18nBaseKey, item, params).pipe(map(i18nParams => populateI18nModelParams(model?.idProperty, model?.titleProperty, item, i18nParams)));
|
|
@@ -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(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 | ((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._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 | ((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, 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,CAAC;AACjH,CAAC;AAOe,SAAA,qBAAqB,CACjC,KAAyC,EACzC,WAA0B,EAAA;IAE1B,OAAO,IAAI,gBAAgB,CAAiD,KAAK,CAAC,IAAwB,EAAE,WAA2B,CAAC,CAAC;AAC7I;;MCvBa,cAAc,CAAA;IAMvB,WAA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E,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<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 | ((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._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 | ((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';\n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;AACb,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAC1B;AACD,IAAA,OAAO,IAAI,CAAC;AAChB;;AC3DA;;ACAA;;AAEG;;;;"}
|
|
@@ -190,7 +190,7 @@ function getTableClassAttributeDef(type) {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
class ColumnDescriptor {
|
|
193
|
-
constructor(
|
|
193
|
+
constructor(property) {
|
|
194
194
|
this._columnType = ColumnTypeEnum.String;
|
|
195
195
|
this._columnDisplayType = ColumnDisplayTypeEnum.String;
|
|
196
196
|
this._isMultiline = false;
|
|
@@ -210,7 +210,6 @@ class ColumnDescriptor {
|
|
|
210
210
|
this._hasCopyToClipboard = false;
|
|
211
211
|
// localization
|
|
212
212
|
this._isLocalized = false;
|
|
213
|
-
this._table = table;
|
|
214
213
|
this._property = property;
|
|
215
214
|
}
|
|
216
215
|
get columnType() {
|
|
@@ -225,9 +224,6 @@ class ColumnDescriptor {
|
|
|
225
224
|
get displayFormat() {
|
|
226
225
|
return this._displayFormat;
|
|
227
226
|
}
|
|
228
|
-
get table() {
|
|
229
|
-
return this._table;
|
|
230
|
-
}
|
|
231
227
|
get property() {
|
|
232
228
|
return this._property;
|
|
233
229
|
}
|
|
@@ -407,13 +403,6 @@ class ColumnDescriptor {
|
|
|
407
403
|
this._title = title;
|
|
408
404
|
return this;
|
|
409
405
|
}
|
|
410
|
-
withFilterUnsafe(forceSimple = false) {
|
|
411
|
-
return this._table.addFilterFromColumnDescriptorUnsafe(this, forceSimple);
|
|
412
|
-
}
|
|
413
|
-
withSortUnsafe(isDefault = false, ascending) {
|
|
414
|
-
this._table.withSortUnsafe(this.property, isDefault, ascending);
|
|
415
|
-
return this;
|
|
416
|
-
}
|
|
417
406
|
withCopyToClipboard(hasCopyToClipboard = true, clipboardValueGetter) {
|
|
418
407
|
this._hasCopyToClipboard = hasCopyToClipboard;
|
|
419
408
|
if (clipboardValueGetter) {
|
|
@@ -456,7 +445,7 @@ class ColumnDescriptor {
|
|
|
456
445
|
return this;
|
|
457
446
|
}
|
|
458
447
|
copy() {
|
|
459
|
-
const descriptor = new ColumnDescriptor(this.
|
|
448
|
+
const descriptor = new ColumnDescriptor(this._property);
|
|
460
449
|
this.copyFieldsTo(descriptor);
|
|
461
450
|
return descriptor;
|
|
462
451
|
}
|
|
@@ -494,8 +483,8 @@ class ColumnDescriptor {
|
|
|
494
483
|
}
|
|
495
484
|
class ColumnDynamicDescriptor extends ColumnDescriptor {
|
|
496
485
|
// private _filterStatus;
|
|
497
|
-
constructor(
|
|
498
|
-
super(
|
|
486
|
+
constructor(property) {
|
|
487
|
+
super(property);
|
|
499
488
|
this._title = undefined;
|
|
500
489
|
this._visibility = true;
|
|
501
490
|
}
|
|
@@ -533,14 +522,14 @@ class ColumnDynamicDescriptor extends ColumnDescriptor {
|
|
|
533
522
|
* creates deep copy of column dynamic descriptor
|
|
534
523
|
*/
|
|
535
524
|
copy() {
|
|
536
|
-
const descriptor = new ColumnDynamicDescriptor(this.
|
|
525
|
+
const descriptor = new ColumnDynamicDescriptor(this._property);
|
|
537
526
|
this.copyFieldsTo(descriptor);
|
|
538
527
|
descriptor._title = this._title;
|
|
539
528
|
descriptor._visibility = this._visibility;
|
|
540
529
|
return descriptor;
|
|
541
530
|
}
|
|
542
|
-
toColumnDescriptor(
|
|
543
|
-
const descriptor = new ColumnDescriptor(
|
|
531
|
+
toColumnDescriptor() {
|
|
532
|
+
const descriptor = new ColumnDescriptor(this._property);
|
|
544
533
|
this.copyFieldsTo(descriptor);
|
|
545
534
|
return descriptor;
|
|
546
535
|
}
|
|
@@ -772,18 +761,18 @@ class TableDescriptorInst {
|
|
|
772
761
|
return this;
|
|
773
762
|
}
|
|
774
763
|
addColumn(property) {
|
|
775
|
-
const column = new ColumnDescriptor(
|
|
764
|
+
const column = new ColumnDescriptor(property);
|
|
776
765
|
this._columns.push(column);
|
|
777
766
|
return column;
|
|
778
767
|
}
|
|
779
768
|
addColumnEnum(property, enumDesc) {
|
|
780
|
-
const column = new ColumnDescriptor(
|
|
769
|
+
const column = new ColumnDescriptor(property);
|
|
781
770
|
column.asEnumUnsafe(enumDesc);
|
|
782
771
|
this._columns.push(column);
|
|
783
772
|
return column;
|
|
784
773
|
}
|
|
785
774
|
addColumnUnsafe(property) {
|
|
786
|
-
const column = new ColumnDescriptor(
|
|
775
|
+
const column = new ColumnDescriptor(property);
|
|
787
776
|
this._columns.push(column);
|
|
788
777
|
return column;
|
|
789
778
|
}
|
|
@@ -791,6 +780,10 @@ class TableDescriptorInst {
|
|
|
791
780
|
properties.forEach(p => this.addColumn(p));
|
|
792
781
|
return this;
|
|
793
782
|
}
|
|
783
|
+
withColumnDescriptors(...descriptors) {
|
|
784
|
+
descriptors.forEach(d => this.withColumn(d));
|
|
785
|
+
return this;
|
|
786
|
+
}
|
|
794
787
|
withPaginationMode(paginationMode) {
|
|
795
788
|
this._paginationMode = paginationMode;
|
|
796
789
|
return this;
|
|
@@ -947,7 +940,7 @@ class TableDescriptorInst {
|
|
|
947
940
|
}
|
|
948
941
|
return this.addFilterFromColumnDescriptorUnsafe(column, forceSimple);
|
|
949
942
|
}
|
|
950
|
-
addFilterFromColumnDescriptorUnsafe(column, forceSimple) {
|
|
943
|
+
addFilterFromColumnDescriptorUnsafe(column, forceSimple = false) {
|
|
951
944
|
let filterDescriptor = new FilterDescriptor(column.property);
|
|
952
945
|
let filterType;
|
|
953
946
|
switch (column.columnType) {
|
|
@@ -1200,7 +1193,7 @@ class TableDynamicDescriptorInst extends TableDescriptorInst {
|
|
|
1200
1193
|
if (!metaColumn.visibility) {
|
|
1201
1194
|
continue;
|
|
1202
1195
|
}
|
|
1203
|
-
column = metaColumn.toColumnDescriptor(
|
|
1196
|
+
column = metaColumn.toColumnDescriptor();
|
|
1204
1197
|
tableDescriptor.withColumn(column);
|
|
1205
1198
|
}
|
|
1206
1199
|
else {
|
|
@@ -1213,13 +1206,13 @@ class TableDynamicDescriptorInst extends TableDescriptorInst {
|
|
|
1213
1206
|
const elementOfSortColumns = this._sortColumns.includes(column.property);
|
|
1214
1207
|
if ((this._sortColumnMode === TableDynamicColumnsModeEnum.EXCLUDE && !elementOfSortColumns) ||
|
|
1215
1208
|
(this._sortColumnMode === TableDynamicColumnsModeEnum.INCLUDE_ONLY && elementOfSortColumns)) {
|
|
1216
|
-
|
|
1209
|
+
tableDescriptor.withSortUnsafe(column.property);
|
|
1217
1210
|
}
|
|
1218
1211
|
const elementOfFilterColumns = this._filterColumns.includes(column.property);
|
|
1219
1212
|
if (this._filterColumns.length > 0 &&
|
|
1220
1213
|
((this._filterColumnMode === TableDynamicColumnsModeEnum.EXCLUDE && !elementOfFilterColumns) ||
|
|
1221
1214
|
(this._filterColumnMode === TableDynamicColumnsModeEnum.INCLUDE_ONLY && elementOfFilterColumns))) {
|
|
1222
|
-
|
|
1215
|
+
tableDescriptor.addFilterFromColumnDescriptorUnsafe(column, false);
|
|
1223
1216
|
}
|
|
1224
1217
|
}
|
|
1225
1218
|
return tableDescriptor;
|
|
@@ -1229,7 +1222,7 @@ class TableDynamicDescriptorInst extends TableDescriptorInst {
|
|
|
1229
1222
|
* @param property column's property
|
|
1230
1223
|
*/
|
|
1231
1224
|
addColumn(property) {
|
|
1232
|
-
const column = new ColumnDynamicDescriptor(
|
|
1225
|
+
const column = new ColumnDynamicDescriptor(property);
|
|
1233
1226
|
this._columns.push(column);
|
|
1234
1227
|
return column;
|
|
1235
1228
|
}
|
|
@@ -1281,7 +1274,8 @@ function upsertTableColumnFromAttributeDef(desc, attribute, column, ...args) {
|
|
|
1281
1274
|
}
|
|
1282
1275
|
}
|
|
1283
1276
|
else {
|
|
1284
|
-
|
|
1277
|
+
desc.addFilterFromColumnDescriptorUnsafe(column, false);
|
|
1278
|
+
desc.withSortUnsafe(column.property);
|
|
1285
1279
|
}
|
|
1286
1280
|
return column;
|
|
1287
1281
|
}
|