@mediusinc/mng-commons 5.0.0-rc.0 → 5.0.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/data-list/data-list-params-helpers.d.ts +82 -0
- package/core/descriptors/action.descriptor.d.ts +3 -3
- package/core/descriptors/column.descriptor.d.ts +1 -1
- package/core/descriptors/editor.descriptor.d.ts +6 -6
- package/core/descriptors/enum.descriptor.d.ts +6 -0
- package/core/descriptors/filter.descriptor.d.ts +1 -1
- package/core/descriptors/model.descriptor.d.ts +1 -1
- package/core/descriptors/table.descriptor.d.ts +6 -6
- package/core/descriptors/tableview.descriptor.d.ts +10 -10
- package/core/enum/enum-helpers.d.ts +49 -0
- package/core/error/error-helpers.d.ts +114 -0
- package/core/helpers/date.d.ts +14 -0
- package/core/helpers/object.d.ts +27 -0
- package/core/helpers/route.d.ts +35 -0
- package/core/helpers/string.d.ts +7 -0
- package/core/helpers/templates.d.ts +3 -0
- package/core/i18n/i18n-common.d.ts +6 -0
- package/core/i18n/i18n-error.d.ts +4 -0
- package/core/i18n/i18n-type.d.ts +20 -0
- package/core/index.d.ts +15 -9
- package/{model → core}/pipes/enum.pipe.d.ts +2 -2
- package/core/pipes/enumerate.pipe.d.ts +3 -3
- package/{model → core}/pipes/i18n-property.pipe.d.ts +2 -2
- package/core/pipes/template.pipe.d.ts +0 -2
- package/core/router/route-builder.d.ts +151 -30
- package/core/router/routes-builder.d.ts +29 -15
- package/core/security/permission-helpers.d.ts +3 -0
- package/core/security/permissions.model.d.ts +2 -2
- package/esm2022/core/components/notification/notification-wrapper.component.mjs +4 -4
- 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-list/data-list-params-helpers.mjs +415 -0
- package/esm2022/core/data-list/filter-match.model.mjs +1 -1
- package/esm2022/core/data-providers/base.data-provider.mjs +1 -1
- package/esm2022/core/descriptors/action.descriptor.mjs +1 -1
- package/esm2022/core/descriptors/column.descriptor.mjs +1 -1
- package/esm2022/core/descriptors/editor.descriptor.mjs +1 -1
- package/esm2022/core/descriptors/enum.descriptor.mjs +2 -0
- package/esm2022/core/descriptors/filter.descriptor.mjs +1 -1
- package/esm2022/core/descriptors/model.descriptor.mjs +1 -1
- package/esm2022/core/descriptors/table.descriptor.mjs +1 -1
- package/esm2022/core/descriptors/tableview.descriptor.mjs +1 -1
- package/esm2022/core/directives/component.directive.mjs +4 -4
- package/esm2022/core/directives/dialog-keydown-handler.directive.mjs +4 -4
- package/esm2022/core/directives/template.directive.mjs +3 -3
- package/esm2022/core/enum/enum-helpers.mjs +81 -0
- package/esm2022/core/error/error-handler.mjs +3 -3
- package/esm2022/core/error/error-helpers.mjs +247 -0
- package/esm2022/core/helpers/coercion.mjs +1 -1
- package/esm2022/core/helpers/date.mjs +119 -0
- package/esm2022/core/helpers/object.mjs +145 -0
- package/esm2022/core/helpers/route.mjs +58 -0
- package/esm2022/core/helpers/string.mjs +57 -0
- package/esm2022/core/helpers/templates.mjs +4 -0
- package/esm2022/core/i18n/i18n-common.mjs +24 -0
- package/esm2022/core/i18n/i18n-error.mjs +27 -0
- package/esm2022/core/i18n/i18n-type.mjs +79 -0
- package/esm2022/core/index.mjs +17 -11
- package/esm2022/core/log/log-publisher-console.service.mjs +3 -3
- package/esm2022/core/log/logger.service.mjs +3 -3
- package/esm2022/core/pipes/boolean.pipe.mjs +4 -4
- package/esm2022/core/pipes/class-map.pipe.mjs +4 -4
- package/esm2022/core/pipes/enum.pipe.mjs +27 -0
- package/esm2022/core/pipes/enumerate-async.pipe.mjs +8 -8
- package/esm2022/core/pipes/enumerate.pipe.mjs +10 -10
- package/esm2022/core/pipes/getter.pipe.mjs +4 -4
- package/esm2022/core/pipes/i18n-property.pipe.mjs +19 -0
- package/esm2022/core/pipes/json-path.pipe.mjs +6 -6
- package/esm2022/core/pipes/parametrize.pipe.mjs +6 -6
- package/esm2022/core/pipes/template.pipe.mjs +7 -8
- package/esm2022/core/provide.mjs +1 -21
- package/esm2022/core/reflect/type-enum-metadata.mjs +1 -1
- package/esm2022/core/registry/type-registry.mjs +1 -1
- package/esm2022/core/router/route-builder.mjs +218 -107
- package/esm2022/core/router/routes-builder.mjs +42 -43
- package/esm2022/core/security/permission-helpers.mjs +14 -0
- package/esm2022/core/security/permission.guard.mjs +1 -1
- package/esm2022/core/security/permission.service.mjs +6 -6
- package/esm2022/core/security/permissions.model.mjs +1 -1
- package/esm2022/core/services/commons-configuration.service.mjs +6 -6
- 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.service.mjs +4 -4
- package/esm2022/core/services/local-storage-config.service.mjs +4 -4
- package/esm2022/filter/descriptors/filter-lookup.descriptor.mjs +9 -10
- package/esm2022/filter/descriptors/filter.descriptor.mjs +1 -1
- package/esm2022/form/api/data-providers/lookup.data-provider.mjs +1 -1
- package/esm2022/form/api/descriptors/button-style.builder.mjs +1 -1
- package/esm2022/form/components/autocomplete/autocomplete.component.mjs +39 -45
- package/esm2022/form/components/date-range/date-range.component.mjs +4 -4
- package/esm2022/form/components/dropdown/dropdown.component.mjs +7 -7
- package/esm2022/form/directives/input-trim.directive.mjs +4 -4
- package/esm2022/model/descriptors/enum.descriptor.mjs +1 -1
- package/esm2022/model/descriptors/model.descriptor.mjs +4 -4
- package/esm2022/model/helpers/i18n.mjs +45 -0
- package/esm2022/model/helpers/model.mjs +71 -0
- package/esm2022/model/index.mjs +4 -7
- package/esm2022/table/api/data-providers/table.data-provider.mjs +1 -1
- package/esm2022/table/api/descriptors/column.descriptor.mjs +1 -1
- package/esm2022/table/api/descriptors/table.descriptor.mjs +36 -8
- package/esm2022/table/api/helpers/class-attribute-converter.mjs +1 -1
- package/esm2022/table/components/column-filter-full/column-filter-full.component.mjs +9 -9
- package/esm2022/table/components/column-value/column-value.component.mjs +12 -14
- package/esm2022/table/components/table/table.component.mjs +20 -37
- package/esm2022/table/helpers/notification.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/data-list.service.mjs +3 -3
- package/esm2022/tableview/action/components/action/action.component.mjs +9 -9
- 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 +22 -21
- package/esm2022/tableview/action/components/localization/data-language-dropdown.component.mjs +3 -3
- package/esm2022/tableview/action/components/route/action-route.component.mjs +6 -5
- package/esm2022/tableview/action/components/table/action-table.component.mjs +12 -24
- package/esm2022/tableview/action/helpers/i18n.mjs +82 -0
- package/esm2022/tableview/action/helpers/notification.mjs +8 -8
- package/esm2022/tableview/action/helpers/styles.mjs +1 -1
- package/esm2022/tableview/action/models/execution/action-context.model.mjs +1 -1
- package/esm2022/tableview/action/models/execution/action-instance.model.mjs +1 -1
- package/esm2022/tableview/action/services/action-error-mapper.service.mjs +1 -1
- package/esm2022/tableview/action/services/action-executor.service.mjs +10 -9
- package/esm2022/tableview/action/services/component-action-executor.service.mjs +3 -3
- package/esm2022/tableview/action/services/data-provider-executor.service.mjs +3 -3
- package/esm2022/tableview/action/services/navigation.service.mjs +4 -4
- package/esm2022/tableview/action/services/providers/provide-view-container.mjs +1 -1
- package/esm2022/tableview/action/services/root-action-executor.service.mjs +3 -3
- package/esm2022/tableview/action/services/view-container.service.mjs +3 -3
- package/esm2022/tableview/api/action/descriptors/action-confirmation.descriptor.mjs +1 -1
- package/esm2022/tableview/api/action/descriptors/action-editor.descriptor.mjs +9 -1
- package/esm2022/tableview/api/action/descriptors/action.descriptor.mjs +1 -1
- package/esm2022/tableview/api/action/helpers/data-provider-executors.mjs +1 -1
- package/esm2022/tableview/api/action/models/execution/action-instance.model.mjs +1 -1
- package/esm2022/tableview/api/editor/data-providers/editor.data-provider.mjs +1 -1
- package/esm2022/tableview/api/editor/descriptors/editor.descriptor.mjs +21 -32
- package/esm2022/tableview/api/editor/descriptors/field-action.descriptor.mjs +1 -1
- package/esm2022/tableview/api/editor/descriptors/field-base.descriptor.mjs +3 -3
- package/esm2022/tableview/api/editor/descriptors/field-group.descriptor.mjs +3 -3
- package/esm2022/tableview/api/editor/descriptors/field-lookup.descriptor.mjs +8 -8
- package/esm2022/tableview/api/editor/descriptors/field-many.descriptor.mjs +1 -1
- package/esm2022/tableview/api/editor/descriptors/field-validation.descriptor.mjs +1 -1
- package/esm2022/tableview/api/editor/descriptors/field.descriptor.mjs +39 -10
- package/esm2022/tableview/api/editor/helpers/class-attribute-converter.mjs +1 -1
- package/esm2022/tableview/api/editor/helpers/field-validators.mjs +15 -25
- package/esm2022/tableview/api/editor/models/editor-fields.model.mjs +1 -1
- 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-custom-field.model.mjs +3 -3
- package/esm2022/tableview/api/editor/models/formly-field.model.mjs +1 -1
- package/esm2022/tableview/api/tableview/data-providers/tableview.data-provider.mjs +1 -1
- package/esm2022/tableview/api/tableview/descriptors/tableview.descriptor.mjs +15 -22
- package/esm2022/tableview/api/tableview/helpers/class-attribute-converter.mjs +1 -1
- package/esm2022/tableview/api/tableview/helpers/files-export.mjs +1 -1
- package/esm2022/tableview/api/tableview/helpers/tableview-default-actions.mjs +4 -4
- package/esm2022/tableview/api/tableview/helpers/tableview-input-builder.mjs +1 -1
- package/esm2022/tableview/editor/components/editor/form-editor.component.mjs +158 -138
- 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 +5 -7
- package/esm2022/tableview/editor/components/formly/fields/formly-field-custom/formly-field-custom.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-datepicker/formly-field-datepicker.component.mjs +103 -0
- package/esm2022/tableview/editor/components/formly/fields/formly-field-dropdown/formly-field-dropdown.component.mjs +5 -7
- package/esm2022/tableview/editor/components/formly/fields/formly-field-fieldset/formly-field-fieldset.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-input/formly-field-input.component.mjs +33 -50
- package/esm2022/tableview/editor/components/formly/fields/formly-field-label/formly-field-label.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.mjs +8 -10
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +6 -8
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +19 -18
- package/esm2022/tableview/editor/components/formly/fields/formly-field-tabs/formly-field-tabs.component.mjs +3 -3
- 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-formly.mjs +343 -0
- package/esm2022/tableview/editor/helpers/formly-config.mjs +5 -3
- package/esm2022/tableview/editor/models/formly-config.model.mjs +1 -1
- package/esm2022/tableview/editor/services/formly-config.provider.mjs +1 -1
- package/esm2022/tableview/index.mjs +3 -5
- package/esm2022/tableview/provide.mjs +2 -1
- package/esm2022/tableview/tableview/components/route/tableview-route.component.mjs +10 -10
- package/esm2022/tableview/tableview/components/tableview/tableview.component.mjs +30 -56
- package/esm2022/tableview/tableview/router/tableview-route-builder.mjs +17 -43
- package/fesm2022/mediusinc-mng-commons-core.mjs +1599 -1496
- package/fesm2022/mediusinc-mng-commons-core.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-filter.mjs +8 -9
- 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 +51 -56
- package/fesm2022/mediusinc-mng-commons-form.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-model.mjs +99 -148
- package/fesm2022/mediusinc-mng-commons-model.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table-api.mjs +35 -7
- package/fesm2022/mediusinc-mng-commons-table-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table.mjs +48 -65
- package/fesm2022/mediusinc-mng-commons-table.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs +105 -96
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview.mjs +865 -868
- package/fesm2022/mediusinc-mng-commons-tableview.mjs.map +1 -1
- package/filter/descriptors/filter.descriptor.d.ts +2 -2
- package/form/components/autocomplete/autocomplete.component.d.ts +8 -7
- package/model/descriptors/model.descriptor.d.ts +2 -2
- package/model/helpers/i18n.d.ts +10 -0
- package/model/helpers/model.d.ts +5 -0
- package/model/index.d.ts +2 -4
- package/package.json +7 -7
- package/table/api/descriptors/table.descriptor.d.ts +10 -0
- package/table/components/column-value/column-value.component.d.ts +3 -4
- package/table/components/table/table.component.d.ts +13 -13
- package/tableview/action/components/editor/injector-context/action-editor-injector-context.component.d.ts +1 -3
- package/tableview/action/components/route/action-route.component.d.ts +1 -1
- package/tableview/action/components/table/action-table.component.d.ts +6 -6
- package/tableview/action/helpers/i18n.d.ts +22 -0
- package/tableview/action/models/execution/action-instance-state.model.d.ts +21 -21
- package/tableview/action/models/execution/action-instance.model.d.ts +2 -1
- package/tableview/action/services/action-executor.service.d.ts +1 -1
- package/tableview/api/action/descriptors/action-editor.descriptor.d.ts +9 -1
- package/tableview/api/action/descriptors/action.descriptor.d.ts +3 -3
- package/tableview/api/action/models/action.type.d.ts +2 -2
- package/tableview/api/action/models/execution/action-instance-state.model.d.ts +21 -21
- package/tableview/api/action/models/execution/action-instance.model.d.ts +2 -1
- package/tableview/api/editor/descriptors/editor.descriptor.d.ts +16 -21
- package/tableview/api/editor/descriptors/field-action.descriptor.d.ts +2 -2
- package/tableview/api/editor/descriptors/field-base.descriptor.d.ts +29 -29
- package/tableview/api/editor/descriptors/field-group.descriptor.d.ts +9 -9
- package/tableview/api/editor/descriptors/field-lookup.descriptor.d.ts +4 -4
- package/tableview/api/editor/descriptors/field-many.descriptor.d.ts +4 -4
- package/tableview/api/editor/descriptors/field-validation.descriptor.d.ts +10 -13
- package/tableview/api/editor/descriptors/field.descriptor.d.ts +17 -2
- package/tableview/api/editor/helpers/field-validators.d.ts +6 -2
- package/tableview/api/editor/models/editor-fields.model.d.ts +9 -7
- package/tableview/api/editor/models/field.model.d.ts +16 -7
- package/tableview/api/editor/models/form-editor.event.d.ts +6 -4
- package/tableview/api/editor/models/form-editor.interface.d.ts +37 -8
- package/tableview/api/editor/models/formly-custom-field.model.d.ts +1 -1
- package/tableview/api/editor/models/formly-field.model.d.ts +9 -7
- package/tableview/api/tableview/descriptors/tableview.descriptor.d.ts +8 -9
- package/tableview/editor/components/editor/form-editor.component.d.ts +51 -35
- package/tableview/editor/components/formly/fields/formly-field-datepicker/formly-field-datepicker.component.d.ts +22 -0
- package/tableview/editor/components/formly/fields/formly-field-input/formly-field-input.component.d.ts +5 -7
- package/tableview/editor/components/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.d.ts +0 -1
- package/tableview/editor/helpers/editor-formly.d.ts +11 -0
- package/tableview/editor/models/formly-config.model.d.ts +1 -1
- package/tableview/index.d.ts +2 -2
- package/tableview/tableview/components/route/tableview-route.component.d.ts +2 -2
- package/tableview/tableview/components/tableview/tableview.component.d.ts +16 -15
- package/tableview/tableview/router/tableview-route-builder.d.ts +7 -13
- package/version-info.json +11 -0
- package/core/data-list/data-list-params.util.d.ts +0 -84
- package/core/enum/enum.util.d.ts +0 -51
- package/core/error/error.util.d.ts +0 -116
- package/core/security/permission.util.d.ts +0 -5
- package/core/utils/date.util.d.ts +0 -20
- package/core/utils/i18n.util.d.ts +0 -36
- package/core/utils/object.util.d.ts +0 -31
- package/core/utils/route.util.d.ts +0 -37
- package/core/utils/string.util.d.ts +0 -9
- package/esm2022/core/data-list/data-list-params.util.mjs +0 -417
- package/esm2022/core/enum/enum.util.mjs +0 -83
- package/esm2022/core/error/error.util.mjs +0 -249
- package/esm2022/core/security/permission.util.mjs +0 -16
- package/esm2022/core/utils/date.util.mjs +0 -136
- package/esm2022/core/utils/i18n.util.mjs +0 -137
- package/esm2022/core/utils/object.util.mjs +0 -147
- package/esm2022/core/utils/route.util.mjs +0 -60
- package/esm2022/core/utils/string.util.mjs +0 -59
- package/esm2022/model/pipes/enum.pipe.mjs +0 -26
- package/esm2022/model/pipes/i18n-property.pipe.mjs +0 -19
- package/esm2022/model/utils/i18n.util.mjs +0 -51
- package/esm2022/model/utils/model.util.mjs +0 -73
- package/esm2022/tableview/action/utils/i18n.util.mjs +0 -126
- package/esm2022/tableview/editor/utils/editor-formly.util.mjs +0 -337
- package/model/utils/i18n.util.d.ts +0 -15
- package/model/utils/model.util.d.ts +0 -8
- package/tableview/action/utils/i18n.util.d.ts +0 -48
- package/tableview/editor/utils/editor-formly.util.d.ts +0 -12
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { findReflectEnumName, TypeRegistry, findReflectTypeName, CommonsInternalError,
|
|
2
|
-
import * as i0 from '@angular/core';
|
|
3
|
-
import { Pipe } from '@angular/core';
|
|
1
|
+
import { findReflectEnumName, TypeRegistry, findReflectTypeName, CommonsInternalError, getI18n, getI18nTypeName, getI18nTypeNameAsync, getI18nTypeParams, getI18nTypeParamsAsync, getI18nTypeKeyBasePath } from '@mediusinc/mng-commons/core';
|
|
4
2
|
import { map } from 'rxjs/operators';
|
|
5
3
|
|
|
6
4
|
class EnumDescriptor {
|
|
@@ -33,73 +31,71 @@ function enumModelGeneric(type, i18nBaseKey = null, nameAsValue = false) {
|
|
|
33
31
|
return EnumDescriptor.create(undefined, type, i18nBaseKey, nameAsValue);
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!attrDef) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
let idAttribute = ModelUtil.findAttributeByTypeAndName(attrDef, ['string', 'number'], 'id', 'uuid', 'code', 'sifra');
|
|
45
|
-
if (!idAttribute) {
|
|
46
|
-
// if no id or code, take the first attribute
|
|
47
|
-
idAttribute = attrDef[0];
|
|
48
|
-
}
|
|
49
|
-
return idAttribute?.name ?? null;
|
|
50
|
-
}
|
|
51
|
-
static findTitleAttribute(classType) {
|
|
52
|
-
if (!classType)
|
|
53
|
-
return null;
|
|
54
|
-
const attrDef = ModelUtil.getAttributeDef(classType);
|
|
55
|
-
if (!attrDef) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
let titleAttribute = ModelUtil.findAttributeByTypeAndName(attrDef, ['string'], 'name', 'ime', 'title', 'naziv');
|
|
59
|
-
if (!titleAttribute) {
|
|
60
|
-
// if no name or title, take the first attribute
|
|
61
|
-
titleAttribute = attrDef[0];
|
|
62
|
-
}
|
|
63
|
-
return titleAttribute?.name ?? null;
|
|
64
|
-
}
|
|
65
|
-
static getAttributeDef(classType) {
|
|
66
|
-
if (!classType)
|
|
67
|
-
return null;
|
|
68
|
-
const attrDefByFn = classType.getAttributeTypeMap?.();
|
|
69
|
-
if (attrDefByFn)
|
|
70
|
-
return attrDefByFn;
|
|
71
|
-
const attrDefByProp = classType.attributeTypeMap;
|
|
72
|
-
if (attrDefByProp)
|
|
73
|
-
return attrDefByProp;
|
|
74
|
-
const attrByObjSer = TypeRegistry.get().findAttributesDefinitionByClassType(classType);
|
|
75
|
-
if (attrByObjSer)
|
|
76
|
-
return attrByObjSer;
|
|
34
|
+
function findClassIdAttribute(classType) {
|
|
35
|
+
if (!classType)
|
|
36
|
+
return null;
|
|
37
|
+
const attrDef = getClassAttributeDef(classType);
|
|
38
|
+
if (!attrDef) {
|
|
77
39
|
return null;
|
|
78
40
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
41
|
+
let idAttribute = findAttributeByTypeAndName(attrDef, ['string', 'number'], 'id', 'uuid', 'code', 'sifra');
|
|
42
|
+
if (!idAttribute) {
|
|
43
|
+
// if no id or code, take the first attribute
|
|
44
|
+
idAttribute = attrDef[0];
|
|
45
|
+
}
|
|
46
|
+
return idAttribute?.name ?? null;
|
|
47
|
+
}
|
|
48
|
+
function findClassTitleAttribute(classType) {
|
|
49
|
+
if (!classType)
|
|
50
|
+
return null;
|
|
51
|
+
const attrDef = getClassAttributeDef(classType);
|
|
52
|
+
if (!attrDef) {
|
|
86
53
|
return null;
|
|
87
54
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
55
|
+
let titleAttribute = findAttributeByTypeAndName(attrDef, ['string'], 'name', 'ime', 'title', 'naziv');
|
|
56
|
+
if (!titleAttribute) {
|
|
57
|
+
// if no name or title, take the first attribute
|
|
58
|
+
titleAttribute = attrDef[0];
|
|
59
|
+
}
|
|
60
|
+
return titleAttribute?.name ?? null;
|
|
61
|
+
}
|
|
62
|
+
function getClassAttributeDef(classType) {
|
|
63
|
+
if (!classType)
|
|
64
|
+
return null;
|
|
65
|
+
const attrDefByFn = classType.getAttributeTypeMap?.();
|
|
66
|
+
if (attrDefByFn)
|
|
67
|
+
return attrDefByFn;
|
|
68
|
+
const attrDefByProp = classType.attributeTypeMap;
|
|
69
|
+
if (attrDefByProp)
|
|
70
|
+
return attrDefByProp;
|
|
71
|
+
const attrByObjSer = TypeRegistry.get().findAttributesDefinitionByClassType(classType);
|
|
72
|
+
if (attrByObjSer)
|
|
73
|
+
return attrByObjSer;
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
function findAttributeByTypeAndName(attributes, types, ...names) {
|
|
77
|
+
for (const name of names) {
|
|
78
|
+
const attribute = attributes.find(a => types.some(t => t === a.type) && a.name === name);
|
|
79
|
+
if (attribute) {
|
|
80
|
+
return attribute;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
function trySetLookupItemsProperties(lookup, idAsTrack = true) {
|
|
86
|
+
if (lookup.dataProvider.classType) {
|
|
87
|
+
if (!lookup.optionsValueProperty && !lookup.optionsTrackProperty) {
|
|
88
|
+
const idProperty = findClassIdAttribute(lookup.dataProvider.classType) ?? undefined;
|
|
89
|
+
if (idProperty && !lookup.optionsValueProperty && !lookup.optionsTrackProperty) {
|
|
90
|
+
if (idAsTrack) {
|
|
91
|
+
lookup.withOptionsTrackPropertyUnsafe(idProperty);
|
|
96
92
|
}
|
|
97
93
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
}
|
|
95
|
+
if (!lookup.optionsLabelProperty) {
|
|
96
|
+
const labelProperty = findClassTitleAttribute(lookup.dataProvider.classType);
|
|
97
|
+
if (labelProperty) {
|
|
98
|
+
lookup.withOptionsLabelPropertyUnsafe(labelProperty);
|
|
103
99
|
}
|
|
104
100
|
}
|
|
105
101
|
}
|
|
@@ -112,10 +108,10 @@ class ModelDescriptor {
|
|
|
112
108
|
this._idProperty = idProperty;
|
|
113
109
|
this._titleProperty = titleProperty;
|
|
114
110
|
if (!this._idProperty && type) {
|
|
115
|
-
this._idProperty =
|
|
111
|
+
this._idProperty = findClassIdAttribute(type) ?? undefined;
|
|
116
112
|
}
|
|
117
113
|
if (!this._titleProperty && type) {
|
|
118
|
-
this._titleProperty =
|
|
114
|
+
this._titleProperty = findClassTitleAttribute(type) ?? undefined;
|
|
119
115
|
}
|
|
120
116
|
this._i18nBaseKey = (typeof i18nBaseKey === 'string' || typeof i18nBaseKey === 'undefined' ? i18nBaseKey : findReflectTypeName(i18nBaseKey)) ?? this._typeName ?? '';
|
|
121
117
|
}
|
|
@@ -202,93 +198,48 @@ function typeClass(type) {
|
|
|
202
198
|
return TypeDescriptor.fromClass(type);
|
|
203
199
|
}
|
|
204
200
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
201
|
+
function getI18nForModel(translate, model, keyPath, customKey, item, fallbackKey, params) {
|
|
202
|
+
const keys = getKeysByPriority(model, keyPath, customKey, fallbackKey);
|
|
203
|
+
const i18nParams = getI18nModelParams(translate, model, item, params);
|
|
204
|
+
return getI18n(translate, i18nParams, ...keys);
|
|
205
|
+
}
|
|
206
|
+
function getI18nModelName(translate, model, singular) {
|
|
207
|
+
return getI18nTypeName(translate, model.i18nBaseKey, singular);
|
|
208
|
+
}
|
|
209
|
+
function getI18nModelNameAsync(translate, model, singular) {
|
|
210
|
+
return getI18nTypeNameAsync(translate, model.i18nBaseKey, singular);
|
|
211
|
+
}
|
|
212
|
+
function getI18nModelParams(translate, model, item, params = {}) {
|
|
213
|
+
const i18nParams = getI18nTypeParams(translate, model?.i18nBaseKey, item, params);
|
|
214
|
+
return populateI18nModelParams(model?.idProperty, model?.titleProperty, item, i18nParams);
|
|
215
|
+
}
|
|
216
|
+
function getI18nModelParamsAsync(translate, model, item, params = {}) {
|
|
217
|
+
return getI18nTypeParamsAsync(translate, model?.i18nBaseKey, item, params).pipe(map(i18nParams => populateI18nModelParams(model?.idProperty, model?.titleProperty, item, i18nParams)));
|
|
218
|
+
}
|
|
219
|
+
function populateI18nModelParams(idProperty, titleProperty, item, params = {}) {
|
|
220
|
+
const paramsRes = { ...params, itemId: '', itemTitle: '' };
|
|
221
|
+
if (item) {
|
|
222
|
+
if (idProperty && item[idProperty]) {
|
|
223
|
+
paramsRes.itemId = item[idProperty];
|
|
209
224
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
i18nPath = enumDesc.i18nBaseKey === undefined ? findReflectEnumName(enumDesc.type) : null;
|
|
225
|
+
if (titleProperty && item[titleProperty]) {
|
|
226
|
+
paramsRes.itemTitle = item[titleProperty];
|
|
213
227
|
}
|
|
214
|
-
return i18nPath ? `${i18nPath}.${enumConstantName}` : enumConstantName;
|
|
215
228
|
}
|
|
216
|
-
|
|
217
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.2.1", ngImport: i0, type: EnumPipe, isStandalone: true, name: "mngEnum" }); }
|
|
229
|
+
return paramsRes;
|
|
218
230
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
name: 'mngEnum',
|
|
224
|
-
pure: true
|
|
225
|
-
}]
|
|
226
|
-
}] });
|
|
227
|
-
|
|
228
|
-
class I18nPropertyPipe {
|
|
229
|
-
transform(property, model) {
|
|
230
|
-
return I18nUtils$1.Type.getPropertyKey(model.i18nBaseKey, property);
|
|
231
|
+
function getKeysByPriority(model, keyPath, customKey, fallbackKey) {
|
|
232
|
+
const keys = [];
|
|
233
|
+
if (customKey) {
|
|
234
|
+
keys.push(customKey);
|
|
231
235
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
type: Pipe,
|
|
237
|
-
args: [{
|
|
238
|
-
standalone: true,
|
|
239
|
-
name: 'mngI18nProperty',
|
|
240
|
-
pure: true
|
|
241
|
-
}]
|
|
242
|
-
}] });
|
|
243
|
-
|
|
244
|
-
var I18nUtils;
|
|
245
|
-
(function (I18nUtils) {
|
|
246
|
-
class Model {
|
|
247
|
-
static get(translate, model, keyPath, customKey, item, fallbackKey, params) {
|
|
248
|
-
const keys = I18nUtils.Model.getKeysByPriority(model, keyPath, customKey, fallbackKey);
|
|
249
|
-
const i18nParams = I18nUtils.Model.getParams(translate, model, item, params);
|
|
250
|
-
return I18nUtils$1.Common.get(translate, i18nParams, ...keys);
|
|
251
|
-
}
|
|
252
|
-
static getName(translate, model, singular) {
|
|
253
|
-
return I18nUtils$1.Type.getName(translate, model.i18nBaseKey, singular);
|
|
254
|
-
}
|
|
255
|
-
static getNameAsync(translate, model, singular) {
|
|
256
|
-
return I18nUtils$1.Type.getNameAsync(translate, model.i18nBaseKey, singular);
|
|
257
|
-
}
|
|
258
|
-
static getParams(translate, model, item, params = {}) {
|
|
259
|
-
const i18nParams = I18nUtils$1.Type.getParams(translate, model?.i18nBaseKey, item, params);
|
|
260
|
-
return I18nUtils.Model.populateParams(model?.idProperty, model?.titleProperty, item, i18nParams);
|
|
261
|
-
}
|
|
262
|
-
static getParamsAsync(translate, model, item, params = {}) {
|
|
263
|
-
return I18nUtils$1.Type.getParamsAsync(translate, model?.i18nBaseKey, item, params).pipe(map(i18nParams => I18nUtils.Model.populateParams(model?.idProperty, model?.titleProperty, item, i18nParams)));
|
|
264
|
-
}
|
|
265
|
-
static populateParams(idProperty, titleProperty, item, params = {}) {
|
|
266
|
-
const paramsRes = { ...params, itemId: '', itemTitle: '' };
|
|
267
|
-
if (item) {
|
|
268
|
-
if (idProperty && item[idProperty]) {
|
|
269
|
-
paramsRes.itemId = item[idProperty];
|
|
270
|
-
}
|
|
271
|
-
if (titleProperty && item[titleProperty]) {
|
|
272
|
-
paramsRes.itemTitle = item[titleProperty];
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return paramsRes;
|
|
276
|
-
}
|
|
277
|
-
static getKeysByPriority(model, keyPath, customKey, fallbackKey) {
|
|
278
|
-
const keys = [];
|
|
279
|
-
if (customKey) {
|
|
280
|
-
keys.push(customKey);
|
|
281
|
-
}
|
|
282
|
-
const modelActionKey = I18nUtils$1.Type.getPath(model.i18nBaseKey, ...keyPath);
|
|
283
|
-
keys.push(modelActionKey);
|
|
284
|
-
if (fallbackKey) {
|
|
285
|
-
keys.push(fallbackKey);
|
|
286
|
-
}
|
|
287
|
-
return keys;
|
|
288
|
-
}
|
|
236
|
+
const modelActionKey = getI18nTypeKeyBasePath(model.i18nBaseKey, ...keyPath);
|
|
237
|
+
keys.push(modelActionKey);
|
|
238
|
+
if (fallbackKey) {
|
|
239
|
+
keys.push(fallbackKey);
|
|
289
240
|
}
|
|
290
|
-
|
|
291
|
-
}
|
|
241
|
+
return keys;
|
|
242
|
+
}
|
|
292
243
|
|
|
293
244
|
// descriptors
|
|
294
245
|
|
|
@@ -296,5 +247,5 @@ var I18nUtils;
|
|
|
296
247
|
* Generated bundle index. Do not edit.
|
|
297
248
|
*/
|
|
298
249
|
|
|
299
|
-
export { EnumDescriptor,
|
|
250
|
+
export { EnumDescriptor, ModelDescriptor, TypeDescriptor, enumModel, enumModelGeneric, findClassIdAttribute, findClassTitleAttribute, getClassAttributeDef, getI18nForModel, getI18nModelName, getI18nModelNameAsync, getI18nModelParams, getI18nModelParamsAsync, model, modelFromClass, modelFromType, populateI18nModelParams, trySetLookupItemsProperties, type, typeClass };
|
|
300
251
|
//# sourceMappingURL=mediusinc-mng-commons-model.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediusinc-mng-commons-model.mjs","sources":["../../model/src/descriptors/enum.descriptor.ts","../../model/src/utils/model.util.ts","../../model/src/descriptors/model.descriptor.ts","../../model/src/descriptors/type.descriptor.ts","../../model/src/pipes/enum.pipe.ts","../../model/src/pipes/i18n-property.pipe.ts","../../model/src/utils/i18n.util.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 class ModelUtil {\n public static findIdAttribute<T>(classType?: ClassType<T>): string | null {\n if (!classType) return null;\n\n const attrDef = ModelUtil.getAttributeDef(classType);\n if (!attrDef) {\n return null;\n }\n\n let idAttribute = ModelUtil.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\n public static findTitleAttribute<T>(classType?: ClassType<T>): string | null {\n if (!classType) return null;\n\n const attrDef = ModelUtil.getAttributeDef(classType);\n if (!attrDef) {\n return null;\n }\n\n let titleAttribute = ModelUtil.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\n public static getAttributeDef<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\n private static 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\n public static trySetLookupItemsProperties<T>(lookup: ILookupDescriptor<T>, idAsTrack = true) {\n if (lookup.dataProvider.classType) {\n if (!lookup.optionsValueProperty && !lookup.optionsTrackProperty) {\n const idProperty = ModelUtil.findIdAttribute(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 = ModelUtil.findTitleAttribute(lookup.dataProvider.classType);\n if (labelProperty) {\n lookup.withOptionsLabelPropertyUnsafe(labelProperty);\n }\n }\n }\n }\n}\n","import {ClassOptType, ClassType, CommonsInternalError, IModelDescriptorInternal, findReflectTypeName} from '@mediusinc/mng-commons/core';\n\nimport {ModelUtil} from '../utils/model.util';\nimport {TypeDescriptor} from './type.descriptor';\n\nexport class ModelDescriptor<Model, ModelClass = ClassOptType<Model>> implements IModelDescriptorInternal<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 = ModelUtil.findIdAttribute(type as unknown as ClassType<Model>) ?? undefined;\n }\n if (!this._titleProperty && type) {\n this._titleProperty = ModelUtil.findTitleAttribute(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 {Pipe, PipeTransform} from '@angular/core';\n\nimport {EnumType, EnumUtil, findReflectEnumName} from '@mediusinc/mng-commons/core';\n\nimport {EnumDescriptor} from '../descriptors/enum.descriptor';\n\n@Pipe({\n standalone: true,\n name: 'mngEnum',\n pure: true\n})\nexport class EnumPipe implements PipeTransform {\n transform(value: unknown, enumDesc?: EnumDescriptor<any>, i18nPath?: string | null): any {\n if (!value || (typeof value !== 'number' && typeof value !== 'string')) {\n return value;\n }\n const enumConstantName = !enumDesc || enumDesc.nameAsValue ? value : EnumUtil.getConstantNameFromEnumObject(enumDesc.type, value) ?? value;\n if (typeof i18nPath === 'undefined' && enumDesc) {\n i18nPath = enumDesc.i18nBaseKey === undefined ? findReflectEnumName(enumDesc.type as EnumType) : null;\n }\n return i18nPath ? `${i18nPath}.${enumConstantName}` : enumConstantName;\n }\n}\n","import {Pipe, PipeTransform} from '@angular/core';\n\nimport {I18nUtils} from '@mediusinc/mng-commons/core';\n\nimport {ModelDescriptor} from '../descriptors/model.descriptor';\n\n@Pipe({\n standalone: true,\n name: 'mngI18nProperty',\n pure: true\n})\nexport class I18nPropertyPipe implements PipeTransform {\n transform(property: string, model: ModelDescriptor<any>): any {\n return I18nUtils.Type.getPropertyKey(model.i18nBaseKey, property);\n }\n}\n","import {TranslateService} from '@ngx-translate/core';\nimport {Observable} from 'rxjs';\nimport {map} from 'rxjs/operators';\n\nimport {I18nUtils as CoreI18nUtils, KeyOfType} from '@mediusinc/mng-commons/core';\n\nimport {ModelDescriptor} from '../descriptors/model.descriptor';\n\nexport namespace I18nUtils {\n export class Model {\n public static get(\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 = I18nUtils.Model.getKeysByPriority(model, keyPath, customKey, fallbackKey);\n const i18nParams = I18nUtils.Model.getParams(translate, model, item, params);\n return CoreI18nUtils.Common.get(translate, i18nParams, ...keys);\n }\n\n public static getName(translate: TranslateService, model: ModelDescriptor<any>, singular?: boolean): string | null {\n return CoreI18nUtils.Type.getName(translate, model.i18nBaseKey, singular);\n }\n\n public static getNameAsync(translate: TranslateService, model: ModelDescriptor<any>, singular?: boolean): Observable<string | null> {\n return CoreI18nUtils.Type.getNameAsync(translate, model.i18nBaseKey, singular);\n }\n\n public static getParams(translate: TranslateService, model?: ModelDescriptor<any>, item?: any, params: any = {}): any {\n const i18nParams = CoreI18nUtils.Type.getParams(translate, model?.i18nBaseKey, item, params);\n return I18nUtils.Model.populateParams(model?.idProperty, model?.titleProperty, item, i18nParams);\n }\n\n public static getParamsAsync(translate: TranslateService, model?: ModelDescriptor<any>, item?: any, params: any = {}): Observable<any> {\n return CoreI18nUtils.Type.getParamsAsync(translate, model?.i18nBaseKey, item, params).pipe(\n map(i18nParams => I18nUtils.Model.populateParams(model?.idProperty, model?.titleProperty, item, i18nParams))\n );\n }\n\n public static populateParams(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\n private static getKeysByPriority(model: ModelDescriptor<any>, keyPath: string, customKey?: string, fallbackKey?: string) {\n const keys = [];\n if (customKey) {\n keys.push(customKey);\n }\n const modelActionKey = CoreI18nUtils.Type.getPath(model.i18nBaseKey, ...keyPath);\n keys.push(modelActionKey);\n if (fallbackKey) {\n keys.push(fallbackKey);\n }\n return keys;\n }\n }\n}\n","// descriptors\nexport * from './descriptors/enum.descriptor';\nexport * from './descriptors/model.descriptor';\nexport * from './descriptors/type.descriptor';\n\n// pipes\nexport * from './pipes/enum.pipe';\nexport * from './pipes/i18n-property.pipe';\n\n// utils\nexport * from './utils/i18n.util';\nexport * from './utils/model.util';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["I18nUtils","CoreI18nUtils"],"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;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AAU,CAAC,EAAE;AAChC,oBAAA,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;AACvC,iBAAA;AACD,gBAAA,IAAI,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,EAAE;AACtC,oBAAA,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;AAC7C,iBAAA;AACJ,aAAA;AACD,YAAA,OAAO,SAAS,CAAC;SACpB;QAEO,OAAO,iBAAiB,CAAC,KAA2B,EAAE,OAAe,EAAE,SAAkB,EAAE,WAAoB,EAAA;YACnH,MAAM,IAAI,GAAG,EAAE,CAAC;AAChB,YAAA,IAAI,SAAS,EAAE;AACX,gBAAA,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACxB,aAAA;AACD,YAAA,MAAM,cAAc,GAAGA,WAAa,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,CAAC;AACjF,YAAA,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAC1B,YAAA,IAAI,WAAW,EAAE;AACb,gBAAA,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC1B,aAAA;AACD,YAAA,OAAO,IAAI,CAAC;SACf;AACJ,KAAA;AA3DY,IAAA,SAAA,CAAA,KAAK,QA2DjB,CAAA;AACL,CAAC,EA7DgB,SAAS,KAAT,SAAS,GA6DzB,EAAA,CAAA,CAAA;;ACrED;;ACAA;;AAEG;;;;"}
|
|
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,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;KAC1E;AACJ,CAAA;AAEe,SAAA,SAAS,CAAO,KAAW,EAAE,IAAc,EAAE,WAAA,GAAyC,IAAI,EAAE,WAAW,GAAG,KAAK,EAAA;AAC3H,IAAA,OAAO,cAAc,CAAC,MAAM,CAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;AAC9E,CAAC;AAEK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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,8 +1,8 @@
|
|
|
1
1
|
import { Subject } from 'rxjs';
|
|
2
2
|
import { map } from 'rxjs/operators';
|
|
3
|
-
import { DataProviderInst, toObservable, TypeRegistry, CommonsInternalError,
|
|
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,
|
|
5
|
+
import { enumModelGeneric, findClassTitleAttribute, ModelDescriptor } from '@mediusinc/mng-commons/model';
|
|
6
6
|
|
|
7
7
|
class TableDataProviderInst extends DataProviderInst {
|
|
8
8
|
constructor(type, serviceType) {
|
|
@@ -628,6 +628,9 @@ class TableDescriptorInst {
|
|
|
628
628
|
this._sorts = [];
|
|
629
629
|
// localization
|
|
630
630
|
this._isLocalized = false;
|
|
631
|
+
// row expand
|
|
632
|
+
this._rowExpandable = false;
|
|
633
|
+
this._rowExpandableColSpan = 100;
|
|
631
634
|
this._model = model;
|
|
632
635
|
this._trackProperty = this._model.idProperty;
|
|
633
636
|
this._autoGenerated = autoGenerated;
|
|
@@ -716,6 +719,18 @@ class TableDescriptorInst {
|
|
|
716
719
|
get localizationLocaleProperty() {
|
|
717
720
|
return this._localizationLocaleProperty;
|
|
718
721
|
}
|
|
722
|
+
get rowExpandable() {
|
|
723
|
+
return this._rowExpandable;
|
|
724
|
+
}
|
|
725
|
+
get rowExpandableColSpan() {
|
|
726
|
+
return this._rowExpandableColSpan;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* This table model property tells us if the specific row should be expandable or not based on row item value
|
|
730
|
+
*/
|
|
731
|
+
get rowExpandableProperty() {
|
|
732
|
+
return this._rowExpandableProperty;
|
|
733
|
+
}
|
|
719
734
|
/**
|
|
720
735
|
* Track property is used for the purpose of combined saving user preferences in localstorage if 2 tables have the same track properties they will share the same localstorage entry.
|
|
721
736
|
* Similarly, this property can also be used to differentiate two tables of the same model on the same url (so that they have separate entries in localstorage).
|
|
@@ -963,9 +978,9 @@ class TableDescriptorInst {
|
|
|
963
978
|
else if (filterType === FilterTypeEnum.Date) {
|
|
964
979
|
const displayFormat = column.displayFormat;
|
|
965
980
|
if (displayFormat) {
|
|
966
|
-
const filterDisplayFormat =
|
|
967
|
-
const hasTime =
|
|
968
|
-
const hasSeconds =
|
|
981
|
+
const filterDisplayFormat = fromAngularDateFormatToPrime(displayFormat);
|
|
982
|
+
const hasTime = angularDateFormatHasTime(displayFormat);
|
|
983
|
+
const hasSeconds = angularDateFormatHasSeconds(displayFormat);
|
|
969
984
|
filterDescriptor.withDateFormat(filterDisplayFormat, hasTime, hasSeconds);
|
|
970
985
|
}
|
|
971
986
|
}
|
|
@@ -1044,6 +1059,16 @@ class TableDescriptorInst {
|
|
|
1044
1059
|
this._localizationLocaleProperty = localizationLocaleProperty;
|
|
1045
1060
|
return this;
|
|
1046
1061
|
}
|
|
1062
|
+
withRowExpandable(property, colSpan) {
|
|
1063
|
+
this._rowExpandable = true;
|
|
1064
|
+
if (property) {
|
|
1065
|
+
this._rowExpandableProperty = property;
|
|
1066
|
+
}
|
|
1067
|
+
if (colSpan) {
|
|
1068
|
+
this._rowExpandableColSpan = colSpan;
|
|
1069
|
+
}
|
|
1070
|
+
return this;
|
|
1071
|
+
}
|
|
1047
1072
|
copyFieldsTo(obj) {
|
|
1048
1073
|
obj._title = this._title;
|
|
1049
1074
|
obj._hideHeader = this._hideHeader;
|
|
@@ -1064,6 +1089,9 @@ class TableDescriptorInst {
|
|
|
1064
1089
|
obj._localizationLocaleProperty = this._localizationLocaleProperty;
|
|
1065
1090
|
obj._paginationMode = this._paginationMode;
|
|
1066
1091
|
obj._rowsPerPageOptions = this._rowsPerPageOptions;
|
|
1092
|
+
obj._rowExpandable = this._rowExpandable;
|
|
1093
|
+
obj._rowExpandableColSpan = this._rowExpandableColSpan;
|
|
1094
|
+
obj._rowExpandableProperty = this._rowExpandableProperty;
|
|
1067
1095
|
}
|
|
1068
1096
|
copy() {
|
|
1069
1097
|
const descriptor = new TableDescriptorInst(this.model.copy());
|
|
@@ -1149,7 +1177,7 @@ class TableDescriptorInst {
|
|
|
1149
1177
|
}
|
|
1150
1178
|
column = column.asType(attribute.columnType, attribute.columnDisplayType, ...args);
|
|
1151
1179
|
if (attribute.classType) {
|
|
1152
|
-
const titleProperty =
|
|
1180
|
+
const titleProperty = findClassTitleAttribute(attribute.classType) ?? undefined;
|
|
1153
1181
|
if (titleProperty) {
|
|
1154
1182
|
column.withGetter(value => value?.[titleProperty]);
|
|
1155
1183
|
}
|
|
@@ -1273,7 +1301,7 @@ class TableDynamicDescriptorInst extends TableDescriptorInst {
|
|
|
1273
1301
|
return tableDescriptor;
|
|
1274
1302
|
}
|
|
1275
1303
|
const objectModel = data.data[0];
|
|
1276
|
-
const entries =
|
|
1304
|
+
const entries = flattenObjectKeys(objectModel)
|
|
1277
1305
|
.filter(([key]) => !this._excludedColumns.includes(key))
|
|
1278
1306
|
.filter(([, value]) => !Array.isArray(value)); //exclude arrays and sets
|
|
1279
1307
|
for (const [key, value] of entries) {
|