@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
|
@@ -56,10 +56,10 @@ class DialogKeydownHandlerDirective {
|
|
|
56
56
|
}
|
|
57
57
|
this.dialogsWithKeydownListener.forEach(c => c.bindDocumentKeydownListener());
|
|
58
58
|
}
|
|
59
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
60
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.
|
|
59
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: DialogKeydownHandlerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
60
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.4", type: DialogKeydownHandlerDirective, isStandalone: true, selector: "[mngDialogKeydownHandler]", ngImport: i0 }); }
|
|
61
61
|
}
|
|
62
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
62
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: DialogKeydownHandlerDirective, decorators: [{
|
|
63
63
|
type: Directive,
|
|
64
64
|
args: [{
|
|
65
65
|
standalone: true,
|
|
@@ -97,10 +97,10 @@ class NotificationWrapperComponent {
|
|
|
97
97
|
this.dialogNotification.set(null);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
101
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.
|
|
100
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NotificationWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
101
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.4", type: NotificationWrapperComponent, isStandalone: true, selector: "mng-notification-wrapper", ngImport: i0, template: "<ng-content></ng-content>\n<p-confirmDialog appendTo=\"body\" [baseZIndex]=\"50\"></p-confirmDialog>\n\n<p-toast [baseZIndex]=\"50\">\n <ng-template let-message pTemplate=\"message\">\n <span [class]=\"'p-toast-message-icon pi ' + getNotificationIconClass(message)\"></span>\n <div class=\"p-toast-message-text\">\n <div class=\"p-toast-summary\">{{ message.summary }}</div>\n <div class=\"p-toast-detail\">{{ message.detail.slice(0, notificationCutoff) + (message.detail.length > notificationCutoff ? '...' : '') }}</div>\n @if (message.detail.length > notificationCutoff) {\n <div (click)=\"onShowNotificationInDialog(message)\" class=\"p-link font-semibold text-sm mt-2 flex align-items-center\">\n <i class=\"pi pi-chevron-down mr-1\"></i>{{ 'notification.details' | translate }}\n </div>\n }\n </div>\n </ng-template>\n</p-toast>\n\n<p-dialog\n [visible]=\"isDialogNotificationVisible()\"\n (visibleChange)=\"onDialogNotificationVisibilityChange($event)\"\n [styleClass]=\"'p-fluid mng-dialog mng-dialog-xs ' + 'mng-message-detail-dialog mng-message-detail-dialog-' + (dialogNotification()?.severity ?? '')\">\n <ng-template pTemplate=\"header\" mngDialogKeydownHandler>\n <span class=\"p-dialog-title font-bold mng-dialog-success\">\n <span [class]=\"'mr-2 pi ' + getNotificationIconClass(dialogNotification())\"></span>\n {{ dialogNotification()?.summary ?? '' }}\n </span>\n </ng-template>\n <div>\n {{ dialogNotification()?.detail ?? '' }}\n </div>\n</p-dialog>\n", dependencies: [{ kind: "ngmodule", type: ToastModule }, { kind: "component", type: i1.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "life", "style", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "breakpoints"], outputs: ["onClose"] }, { kind: "directive", type: i2.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "ngmodule", type: ConfirmDialogModule }, { kind: "component", type: i3.ConfirmDialog, selector: "p-confirmDialog", inputs: ["header", "icon", "message", "style", "styleClass", "maskStyleClass", "acceptIcon", "acceptLabel", "closeAriaLabel", "acceptAriaLabel", "acceptVisible", "rejectIcon", "rejectLabel", "rejectAriaLabel", "rejectVisible", "acceptButtonStyleClass", "rejectButtonStyleClass", "closeOnEscape", "dismissableMask", "blockScroll", "rtl", "closable", "appendTo", "key", "autoZIndex", "baseZIndex", "transitionOptions", "focusTrap", "defaultFocus", "breakpoints", "visible", "position"], outputs: ["onHide"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3$1.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: DialogModule }, { kind: "component", type: i5.Dialog, selector: "p-dialog", inputs: ["header", "draggable", "resizable", "positionLeft", "positionTop", "contentStyle", "contentStyleClass", "modal", "closeOnEscape", "dismissableMask", "rtl", "closable", "responsive", "appendTo", "breakpoints", "styleClass", "maskStyleClass", "maskStyle", "showHeader", "breakpoint", "blockScroll", "autoZIndex", "baseZIndex", "minX", "minY", "focusOnShow", "maximizable", "keepInViewport", "focusTrap", "transitionOptions", "closeIcon", "closeAriaLabel", "closeTabindex", "minimizeIcon", "maximizeIcon", "visible", "style", "position"], outputs: ["onShow", "onHide", "visibleChange", "onResizeInit", "onResizeEnd", "onDragEnd", "onMaximize"] }, { kind: "directive", type: DialogKeydownHandlerDirective, selector: "[mngDialogKeydownHandler]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
102
102
|
}
|
|
103
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
103
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NotificationWrapperComponent, decorators: [{
|
|
104
104
|
type: Component,
|
|
105
105
|
args: [{ selector: 'mng-notification-wrapper', standalone: true, imports: [ToastModule, ConfirmDialogModule, TranslateModule, DialogModule, DialogKeydownHandlerDirective], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-content></ng-content>\n<p-confirmDialog appendTo=\"body\" [baseZIndex]=\"50\"></p-confirmDialog>\n\n<p-toast [baseZIndex]=\"50\">\n <ng-template let-message pTemplate=\"message\">\n <span [class]=\"'p-toast-message-icon pi ' + getNotificationIconClass(message)\"></span>\n <div class=\"p-toast-message-text\">\n <div class=\"p-toast-summary\">{{ message.summary }}</div>\n <div class=\"p-toast-detail\">{{ message.detail.slice(0, notificationCutoff) + (message.detail.length > notificationCutoff ? '...' : '') }}</div>\n @if (message.detail.length > notificationCutoff) {\n <div (click)=\"onShowNotificationInDialog(message)\" class=\"p-link font-semibold text-sm mt-2 flex align-items-center\">\n <i class=\"pi pi-chevron-down mr-1\"></i>{{ 'notification.details' | translate }}\n </div>\n }\n </div>\n </ng-template>\n</p-toast>\n\n<p-dialog\n [visible]=\"isDialogNotificationVisible()\"\n (visibleChange)=\"onDialogNotificationVisibilityChange($event)\"\n [styleClass]=\"'p-fluid mng-dialog mng-dialog-xs ' + 'mng-message-detail-dialog mng-message-detail-dialog-' + (dialogNotification()?.severity ?? '')\">\n <ng-template pTemplate=\"header\" mngDialogKeydownHandler>\n <span class=\"p-dialog-title font-bold mng-dialog-success\">\n <span [class]=\"'mr-2 pi ' + getNotificationIconClass(dialogNotification())\"></span>\n {{ dialogNotification()?.summary ?? '' }}\n </span>\n </ng-template>\n <div>\n {{ dialogNotification()?.detail ?? '' }}\n </div>\n</p-dialog>\n" }]
|
|
106
106
|
}] });
|
|
@@ -137,140 +137,123 @@ class CommonsHttpError extends ACommonsErrorBase {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
LLLL: 'MM',
|
|
184
|
-
LLLLL: 'M',
|
|
185
|
-
// year
|
|
186
|
-
y: 'y',
|
|
187
|
-
yy: 'y',
|
|
188
|
-
yyy: 'yy',
|
|
189
|
-
yyyy: 'yy',
|
|
190
|
-
Y: 'y',
|
|
191
|
-
YY: 'y',
|
|
192
|
-
YYY: 'yy',
|
|
193
|
-
YYYY: 'yy'
|
|
194
|
-
}; }
|
|
195
|
-
static padNumber(num, size = 2) {
|
|
196
|
-
let str = String(num);
|
|
197
|
-
while (str.length < size) {
|
|
198
|
-
str = '0' + str;
|
|
199
|
-
}
|
|
200
|
-
return str;
|
|
140
|
+
const ngPrimerFormatSupported = [/d{1,2}/g, /E{1,5}/g, /c{1,5}/g, /M{1,5}/g, /L{1,5}/g, /y{1,4}/g, /Y{1,4}/g];
|
|
141
|
+
const ngPrimeFormatOther = [/G{1,5}/g, /w{1,2}/g, /W/g, /a{1,5}/g, /B{1,5}/g, /b{1,5}/g, /h{1,2}/g, /H{1,2}/g, /m{1,2}/g, /s{1,2}/g, /S{1,3}/g, /z{1,4}/g, /Z{1,5}/g, /O{1,4}/g];
|
|
142
|
+
const ngPrimerFormatMap = {
|
|
143
|
+
// days
|
|
144
|
+
d: 'd',
|
|
145
|
+
dd: 'dd',
|
|
146
|
+
E: 'D',
|
|
147
|
+
EE: 'D',
|
|
148
|
+
EEE: 'D',
|
|
149
|
+
EEEE: 'DD',
|
|
150
|
+
EEEEE: 'D',
|
|
151
|
+
EEEEEE: 'D',
|
|
152
|
+
c: 'd',
|
|
153
|
+
cc: 'dd',
|
|
154
|
+
ccc: 'D',
|
|
155
|
+
cccc: 'DD',
|
|
156
|
+
ccccc: 'D',
|
|
157
|
+
cccccc: 'D',
|
|
158
|
+
// months
|
|
159
|
+
M: 'm',
|
|
160
|
+
MM: 'mm',
|
|
161
|
+
MMM: 'M',
|
|
162
|
+
MMMM: 'MM',
|
|
163
|
+
MMMMM: 'M',
|
|
164
|
+
L: 'm',
|
|
165
|
+
LL: 'mm',
|
|
166
|
+
LLL: 'M',
|
|
167
|
+
LLLL: 'MM',
|
|
168
|
+
LLLLL: 'M',
|
|
169
|
+
// year
|
|
170
|
+
y: 'y',
|
|
171
|
+
yy: 'y',
|
|
172
|
+
yyy: 'yy',
|
|
173
|
+
yyyy: 'yy',
|
|
174
|
+
Y: 'y',
|
|
175
|
+
YY: 'y',
|
|
176
|
+
YYY: 'yy',
|
|
177
|
+
YYYY: 'yy'
|
|
178
|
+
};
|
|
179
|
+
function padNumber(num, size = 2) {
|
|
180
|
+
let str = String(num);
|
|
181
|
+
while (str.length < size) {
|
|
182
|
+
str = '0' + str;
|
|
201
183
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
str = str.substring(0, str.length - 1);
|
|
224
|
-
}
|
|
225
|
-
return str;
|
|
184
|
+
return str;
|
|
185
|
+
}
|
|
186
|
+
function dateToIsoString(value, type = 'date-time', dateTimeOpts = {}) {
|
|
187
|
+
if (typeof value === 'string') {
|
|
188
|
+
value = new Date(value);
|
|
189
|
+
}
|
|
190
|
+
if (typeof value === 'number') {
|
|
191
|
+
value = new Date(value);
|
|
192
|
+
}
|
|
193
|
+
if (!(value instanceof Date)) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
if (type === 'date') {
|
|
197
|
+
// date only, no time part (and timezone, millis, utc does not matter ...)
|
|
198
|
+
return value.getFullYear() + '-' + padNumber(value.getMonth() + 1) + '-' + padNumber(value.getDate());
|
|
199
|
+
}
|
|
200
|
+
if (dateTimeOpts.utc) {
|
|
201
|
+
let str = value.toISOString();
|
|
202
|
+
if (dateTimeOpts.noMillis) {
|
|
203
|
+
const dotIdx = str.lastIndexOf('.');
|
|
204
|
+
str = str.substring(0, dotIdx) + str.substring(dotIdx + 4, str.length);
|
|
226
205
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
'-' +
|
|
230
|
-
DateUtil.padNumber(value.getMonth() + 1) +
|
|
231
|
-
'-' +
|
|
232
|
-
DateUtil.padNumber(value.getDate()) +
|
|
233
|
-
'T' +
|
|
234
|
-
DateUtil.padNumber(value.getHours()) +
|
|
235
|
-
':' +
|
|
236
|
-
DateUtil.padNumber(value.getMinutes()) +
|
|
237
|
-
':' +
|
|
238
|
-
DateUtil.padNumber(value.getSeconds());
|
|
239
|
-
if (!dateTimeOpts.noMillis) {
|
|
240
|
-
base += '.' + DateUtil.padNumber(value.getMilliseconds());
|
|
241
|
-
}
|
|
242
|
-
if (!dateTimeOpts.noTimezone) {
|
|
243
|
-
const tzo = -value.getTimezoneOffset(), dif = tzo >= 0 ? '+' : '-';
|
|
244
|
-
base = base + (dif + DateUtil.padNumber(Math.floor(Math.abs(tzo) / 60)) + ':' + DateUtil.padNumber(Math.abs(tzo) % 60));
|
|
245
|
-
}
|
|
246
|
-
return base;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
static fromAngularToPrimeDateFormat(ngDateFormat) {
|
|
250
|
-
let primeDateFormat = ngDateFormat;
|
|
251
|
-
for (const regex of DateUtil.NG_PRIME_FORMAT_OTHER) {
|
|
252
|
-
primeDateFormat = primeDateFormat.replace(regex, ' ');
|
|
253
|
-
}
|
|
254
|
-
for (const regex of DateUtil.NG_PRIME_FORMAT_SUPPORTED) {
|
|
255
|
-
const matches = [...primeDateFormat.matchAll(regex)].reverse();
|
|
256
|
-
for (const match of matches) {
|
|
257
|
-
if (match.index) {
|
|
258
|
-
const matchStr = match[0];
|
|
259
|
-
const replacement = DateUtil.NG_PRIME_FORMAT_MAP[matchStr] ?? match[0];
|
|
260
|
-
primeDateFormat = primeDateFormat.substring(0, match.index) + replacement + primeDateFormat.substring(match.index + matchStr.length);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
206
|
+
if (dateTimeOpts.noTimezone) {
|
|
207
|
+
str = str.substring(0, str.length - 1);
|
|
263
208
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
209
|
+
return str;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
let base = value.getFullYear() +
|
|
213
|
+
'-' +
|
|
214
|
+
padNumber(value.getMonth() + 1) +
|
|
215
|
+
'-' +
|
|
216
|
+
padNumber(value.getDate()) +
|
|
217
|
+
'T' +
|
|
218
|
+
padNumber(value.getHours()) +
|
|
219
|
+
':' +
|
|
220
|
+
padNumber(value.getMinutes()) +
|
|
221
|
+
':' +
|
|
222
|
+
padNumber(value.getSeconds());
|
|
223
|
+
if (!dateTimeOpts.noMillis) {
|
|
224
|
+
base += '.' + padNumber(value.getMilliseconds());
|
|
225
|
+
}
|
|
226
|
+
if (!dateTimeOpts.noTimezone) {
|
|
227
|
+
const tzo = -value.getTimezoneOffset(), dif = tzo >= 0 ? '+' : '-';
|
|
228
|
+
base = base + (dif + padNumber(Math.floor(Math.abs(tzo) / 60)) + ':' + padNumber(Math.abs(tzo) % 60));
|
|
229
|
+
}
|
|
230
|
+
return base;
|
|
267
231
|
}
|
|
268
|
-
|
|
269
|
-
|
|
232
|
+
}
|
|
233
|
+
function fromAngularDateFormatToPrime(ngDateFormat) {
|
|
234
|
+
let primeDateFormat = ngDateFormat;
|
|
235
|
+
for (const regex of ngPrimeFormatOther) {
|
|
236
|
+
primeDateFormat = primeDateFormat.replace(regex, ' ');
|
|
270
237
|
}
|
|
271
|
-
|
|
272
|
-
|
|
238
|
+
for (const regex of ngPrimerFormatSupported) {
|
|
239
|
+
const matches = [...primeDateFormat.matchAll(regex)].reverse();
|
|
240
|
+
for (const match of matches) {
|
|
241
|
+
if (match.index) {
|
|
242
|
+
const matchStr = match[0];
|
|
243
|
+
const replacement = ngPrimerFormatMap[matchStr] ?? match[0];
|
|
244
|
+
primeDateFormat = primeDateFormat.substring(0, match.index) + replacement + primeDateFormat.substring(match.index + matchStr.length);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
273
247
|
}
|
|
248
|
+
primeDateFormat = primeDateFormat.replace(/\s+\W\s+/g, ' ');
|
|
249
|
+
primeDateFormat = primeDateFormat.replace(/\s\s+/g, ' ');
|
|
250
|
+
return primeDateFormat.trim();
|
|
251
|
+
}
|
|
252
|
+
function angularDateFormatHasTime(ngDateFormat) {
|
|
253
|
+
return /[hHmsS]/.test(ngDateFormat);
|
|
254
|
+
}
|
|
255
|
+
function angularDateFormatHasSeconds(ngDateFormat) {
|
|
256
|
+
return /[sS]/.test(ngDateFormat);
|
|
274
257
|
}
|
|
275
258
|
|
|
276
259
|
var LogLevelEnum;
|
|
@@ -358,7 +341,7 @@ class LoggerService {
|
|
|
358
341
|
}
|
|
359
342
|
_getTimestamps() {
|
|
360
343
|
const timestamp = new Date();
|
|
361
|
-
const timestampFormatted = this.datePipe.transform(timestamp, LoggerService._timestampFormat) ??
|
|
344
|
+
const timestampFormatted = this.datePipe.transform(timestamp, LoggerService._timestampFormat) ?? dateToIsoString(timestamp);
|
|
362
345
|
return [timestamp, timestampFormatted];
|
|
363
346
|
}
|
|
364
347
|
_log(log) {
|
|
@@ -786,10 +769,10 @@ class CommonsService {
|
|
|
786
769
|
titlePieces.push(this.translate.instant('app.name'));
|
|
787
770
|
return titlePieces.join(' - ');
|
|
788
771
|
}
|
|
789
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
790
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.
|
|
772
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: CommonsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
773
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: CommonsService }); }
|
|
791
774
|
}
|
|
792
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
775
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: CommonsService, decorators: [{
|
|
793
776
|
type: Injectable
|
|
794
777
|
}] });
|
|
795
778
|
|
|
@@ -797,10 +780,10 @@ class ErrorPageComponent {
|
|
|
797
780
|
constructor(commons) {
|
|
798
781
|
this.commons = commons;
|
|
799
782
|
}
|
|
800
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
801
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.
|
|
783
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: ErrorPageComponent, deps: [{ token: CommonsService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
784
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.4", type: ErrorPageComponent, isStandalone: true, selector: "mng-error-page", ngImport: i0, template: "<div [class]=\"'exception-body min-h-screen ' + (commons.colorSchemeIsLight ? 'layout-light' : 'layout-dark')\">\n <div class=\"exception-container min-h-screen flex align-items-center justify-content-center flex-column bg-auto md:bg-contain bg-no-repeat\">\n <div class=\"exception-panel text-center flex align-items-center justify-content-center flex-column\">\n <h1 class=\"text-red-400 mb-0\">{{ 'pages.notFound.title' | translate }}</h1>\n <h3 class=\"text-red-300\">{{ 'pages.notFound.subtitle' | translate }}</h3>\n <button type=\"button\" pButton [label]=\"'general.returnHome' | translate\" [routerLink]=\"['/']\"></button>\n </div>\n <div class=\"exception-footer align-items-center flex\">\n <img [src]=\"commons.colorSchemeIsLight ? commons.appLogoDark : commons.appLogoLight\" class=\"exception-logo\" alt=\"App logo\" />\n <img [src]=\"commons.colorSchemeIsLight ? commons.appLogoNameDark : commons.appLogoNameLight\" class=\"exception-appname ml-3\" alt=\"App name\" />\n </div>\n </div>\n</div>\n", styles: [".exception-body{background:var(--surface-ground)}.exception-body .exception-container{background:var(--exception-pages-image);background-repeat:no-repeat;background-size:contain;box-sizing:border-box}.exception-body .exception-container .exception-panel{box-sizing:border-box;flex-grow:1;margin-top:3rem;margin-bottom:3rem}.exception-body .exception-container .exception-panel h1{font-size:140px;font-weight:900;text-shadow:0 0 50px rgba(252,97,97,.2)}.exception-body .exception-container .exception-panel h3{font-size:80px;font-weight:900;margin-top:-90px;margin-bottom:50px}.exception-body .exception-container .exception-panel button{margin-top:50px}.exception-body .exception-container .exception-footer{margin-bottom:2rem}.exception-body .exception-container .exception-footer .exception-logo{width:34px}.exception-body .exception-container .exception-footer .exception-appname{width:72px}\n"], dependencies: [{ kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i2$1.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3$1.TranslatePipe, name: "translate" }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
802
785
|
}
|
|
803
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
786
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: ErrorPageComponent, decorators: [{
|
|
804
787
|
type: Component,
|
|
805
788
|
args: [{ standalone: true, selector: 'mng-error-page', imports: [ButtonModule, TranslateModule, RouterLink], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [class]=\"'exception-body min-h-screen ' + (commons.colorSchemeIsLight ? 'layout-light' : 'layout-dark')\">\n <div class=\"exception-container min-h-screen flex align-items-center justify-content-center flex-column bg-auto md:bg-contain bg-no-repeat\">\n <div class=\"exception-panel text-center flex align-items-center justify-content-center flex-column\">\n <h1 class=\"text-red-400 mb-0\">{{ 'pages.notFound.title' | translate }}</h1>\n <h3 class=\"text-red-300\">{{ 'pages.notFound.subtitle' | translate }}</h3>\n <button type=\"button\" pButton [label]=\"'general.returnHome' | translate\" [routerLink]=\"['/']\"></button>\n </div>\n <div class=\"exception-footer align-items-center flex\">\n <img [src]=\"commons.colorSchemeIsLight ? commons.appLogoDark : commons.appLogoLight\" class=\"exception-logo\" alt=\"App logo\" />\n <img [src]=\"commons.colorSchemeIsLight ? commons.appLogoNameDark : commons.appLogoNameLight\" class=\"exception-appname ml-3\" alt=\"App name\" />\n </div>\n </div>\n</div>\n", styles: [".exception-body{background:var(--surface-ground)}.exception-body .exception-container{background:var(--exception-pages-image);background-repeat:no-repeat;background-size:contain;box-sizing:border-box}.exception-body .exception-container .exception-panel{box-sizing:border-box;flex-grow:1;margin-top:3rem;margin-bottom:3rem}.exception-body .exception-container .exception-panel h1{font-size:140px;font-weight:900;text-shadow:0 0 50px rgba(252,97,97,.2)}.exception-body .exception-container .exception-panel h3{font-size:80px;font-weight:900;margin-top:-90px;margin-bottom:50px}.exception-body .exception-container .exception-panel button{margin-top:50px}.exception-body .exception-container .exception-footer{margin-bottom:2rem}.exception-body .exception-container .exception-footer .exception-logo{width:34px}.exception-body .exception-container .exception-footer .exception-appname{width:72px}\n"] }]
|
|
806
789
|
}], ctorParameters: () => [{ type: CommonsService }] });
|
|
@@ -809,10 +792,10 @@ class NotFoundPageComponent {
|
|
|
809
792
|
constructor(commons) {
|
|
810
793
|
this.commons = commons;
|
|
811
794
|
}
|
|
812
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
813
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.
|
|
795
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NotFoundPageComponent, deps: [{ token: CommonsService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
796
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.4", type: NotFoundPageComponent, isStandalone: true, selector: "mng-not-found-page", ngImport: i0, template: "<div [class]=\"'exception-body min-h-screen ' + (commons.colorSchemeIsLight ? 'layout-light' : 'layout-dark')\">\n <div class=\"exception-container min-h-screen flex align-items-center justify-content-center flex-column bg-auto md:bg-contain bg-no-repeat\">\n <div class=\"exception-panel text-center flex align-items-center justify-content-center flex-column\">\n <h1 class=\"text-red-400 mb-0\">{{ 'pages.notFound.title' | translate }}</h1>\n <h3 class=\"text-red-300\">{{ 'pages.notFound.subtitle' | translate }}</h3>\n <p>{{ 'pages.notFound.message' | translate }}</p>\n <button type=\"button\" pButton [label]=\"'general.returnHome' | translate\" [routerLink]=\"['/']\"></button>\n </div>\n <div class=\"exception-footer align-items-center flex\">\n <img [src]=\"commons.colorSchemeIsLight ? commons.appLogoDark : commons.appLogoLight\" class=\"exception-logo\" alt=\"App logo\" />\n <img [src]=\"commons.colorSchemeIsLight ? commons.appLogoNameDark : commons.appLogoNameLight\" class=\"exception-appname ml-3\" alt=\"App name\" />\n </div>\n </div>\n</div>\n", styles: [".exception-body{background:var(--surface-ground)}.exception-body .exception-container{background:var(--exception-pages-image);background-repeat:no-repeat;background-size:contain;box-sizing:border-box}.exception-body .exception-container .exception-panel{box-sizing:border-box;flex-grow:1;margin-top:3rem;margin-bottom:3rem}.exception-body .exception-container .exception-panel h1{font-size:140px;font-weight:900;text-shadow:0 0 50px rgba(252,97,97,.2)}.exception-body .exception-container .exception-panel h3{font-size:80px;font-weight:900;margin-top:-90px;margin-bottom:50px}.exception-body .exception-container .exception-panel p{font-size:24px;font-weight:400;max-width:320px}.exception-body .exception-container .exception-panel button{margin-top:50px}.exception-body .exception-container .exception-footer{margin-bottom:2rem}.exception-body .exception-container .exception-footer .exception-logo{width:34px}.exception-body .exception-container .exception-footer .exception-appname{width:72px}\n"], dependencies: [{ kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i2$1.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3$1.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
814
797
|
}
|
|
815
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
798
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NotFoundPageComponent, decorators: [{
|
|
816
799
|
type: Component,
|
|
817
800
|
args: [{ standalone: true, selector: 'mng-not-found-page', imports: [ButtonModule, RouterLink, TranslateModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [class]=\"'exception-body min-h-screen ' + (commons.colorSchemeIsLight ? 'layout-light' : 'layout-dark')\">\n <div class=\"exception-container min-h-screen flex align-items-center justify-content-center flex-column bg-auto md:bg-contain bg-no-repeat\">\n <div class=\"exception-panel text-center flex align-items-center justify-content-center flex-column\">\n <h1 class=\"text-red-400 mb-0\">{{ 'pages.notFound.title' | translate }}</h1>\n <h3 class=\"text-red-300\">{{ 'pages.notFound.subtitle' | translate }}</h3>\n <p>{{ 'pages.notFound.message' | translate }}</p>\n <button type=\"button\" pButton [label]=\"'general.returnHome' | translate\" [routerLink]=\"['/']\"></button>\n </div>\n <div class=\"exception-footer align-items-center flex\">\n <img [src]=\"commons.colorSchemeIsLight ? commons.appLogoDark : commons.appLogoLight\" class=\"exception-logo\" alt=\"App logo\" />\n <img [src]=\"commons.colorSchemeIsLight ? commons.appLogoNameDark : commons.appLogoNameLight\" class=\"exception-appname ml-3\" alt=\"App name\" />\n </div>\n </div>\n</div>\n", styles: [".exception-body{background:var(--surface-ground)}.exception-body .exception-container{background:var(--exception-pages-image);background-repeat:no-repeat;background-size:contain;box-sizing:border-box}.exception-body .exception-container .exception-panel{box-sizing:border-box;flex-grow:1;margin-top:3rem;margin-bottom:3rem}.exception-body .exception-container .exception-panel h1{font-size:140px;font-weight:900;text-shadow:0 0 50px rgba(252,97,97,.2)}.exception-body .exception-container .exception-panel h3{font-size:80px;font-weight:900;margin-top:-90px;margin-bottom:50px}.exception-body .exception-container .exception-panel p{font-size:24px;font-weight:400;max-width:320px}.exception-body .exception-container .exception-panel button{margin-top:50px}.exception-body .exception-container .exception-footer{margin-bottom:2rem}.exception-body .exception-container .exception-footer .exception-logo{width:34px}.exception-body .exception-container .exception-footer .exception-appname{width:72px}\n"] }]
|
|
818
801
|
}], ctorParameters: () => [{ type: CommonsService }] });
|
|
@@ -922,418 +905,416 @@ class FilterMatchMode {
|
|
|
922
905
|
}
|
|
923
906
|
}
|
|
924
907
|
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
params.offset = event.first;
|
|
936
|
-
}
|
|
937
|
-
if (event.rows != null) {
|
|
938
|
-
params.limit = event.rows;
|
|
939
|
-
}
|
|
940
|
-
if (typeof event.globalFilter === 'string') {
|
|
941
|
-
params.search = event.globalFilter;
|
|
942
|
-
}
|
|
943
|
-
else if (Array.isArray(event.globalFilter) && event.globalFilter.length > 0) {
|
|
944
|
-
params.search = event.globalFilter.join(',');
|
|
945
|
-
}
|
|
946
|
-
if (Array.isArray(event.multiSortMeta) && event.multiSortMeta.length > 0) {
|
|
947
|
-
params.sort = event.multiSortMeta.map(m => ({ property: m.field, ascending: m.order >= 0 }));
|
|
948
|
-
}
|
|
949
|
-
if (event.filters) {
|
|
950
|
-
params.filters = Object.keys(event.filters).reduce((acc, key) => {
|
|
951
|
-
const filter = {};
|
|
952
|
-
const eventFilter = event.filters?.[key];
|
|
953
|
-
if (Array.isArray(eventFilter)) {
|
|
954
|
-
filter.value = eventFilter[0].value;
|
|
955
|
-
filter.matchMode = eventFilter[0].matchMode;
|
|
956
|
-
}
|
|
957
|
-
else if (eventFilter !== undefined) {
|
|
958
|
-
filter.value = eventFilter.value;
|
|
959
|
-
filter.matchMode = eventFilter.matchMode;
|
|
960
|
-
}
|
|
961
|
-
return { ...acc, [key]: filter };
|
|
962
|
-
}, {});
|
|
963
|
-
}
|
|
964
|
-
return params;
|
|
908
|
+
/**
|
|
909
|
+
* Converts a TableLazyLoadEvent to DataListParams.
|
|
910
|
+
*
|
|
911
|
+
* @param {TableLazyLoadEvent} event - The event containing the data to convert.
|
|
912
|
+
* @return {DataListParams} - The converted DataListParams object.
|
|
913
|
+
*/
|
|
914
|
+
function fromTableLoadToDataListParams(event) {
|
|
915
|
+
const params = {};
|
|
916
|
+
if (event.first != null) {
|
|
917
|
+
params.offset = event.first;
|
|
965
918
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
* Sorts are formatted in Medius data API sort query language: `asc:prop1,desc:prop2`, ...
|
|
969
|
-
* Filter keys are "flattened" in the new object, values are formatted in Medius data API filter query language: `cs:eq:asd`, `in:asd,qwe`, `ex`, ...
|
|
970
|
-
*
|
|
971
|
-
* @param {DataListParams} params - The parameters to convert.
|
|
972
|
-
* @param {DataListParams|null} defaults - The default parameters used if no matching property in params is available. Defaults to { limit: 25, offset: 0 } if not provided.
|
|
973
|
-
* @returns {Params} - The URL query parameters object.
|
|
974
|
-
*/
|
|
975
|
-
static toUrlQueryParams(params, defaults = {
|
|
976
|
-
limit: 25,
|
|
977
|
-
offset: 0
|
|
978
|
-
}) {
|
|
979
|
-
const urlParams = {};
|
|
980
|
-
if (params.limit && params.limit !== defaults?.limit) {
|
|
981
|
-
urlParams['limit'] = params.limit;
|
|
982
|
-
}
|
|
983
|
-
if (params.offset && params.offset !== defaults?.offset) {
|
|
984
|
-
urlParams['offset'] = params.offset;
|
|
985
|
-
}
|
|
986
|
-
if (params.search && params.search !== defaults?.search) {
|
|
987
|
-
urlParams['q'] = params.search;
|
|
988
|
-
}
|
|
989
|
-
if (params.sort && Array.isArray(params.sort) && params.sort.length > 0) {
|
|
990
|
-
if (defaults?.sort == null ||
|
|
991
|
-
!Array.isArray(defaults.sort) ||
|
|
992
|
-
defaults.sort.length === 0 ||
|
|
993
|
-
params.sort.length !== defaults.sort.length ||
|
|
994
|
-
defaults.sort.some((ds, idx) => ds.property !== params.sort[idx].property || (ds.ascending ?? true) !== (params.sort[idx].ascending ?? true))) {
|
|
995
|
-
urlParams['sort'] = DataListParamsUtil.sortToUrlQuery(params);
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
if (params.filters) {
|
|
999
|
-
Object.keys(params.filters).forEach(k => {
|
|
1000
|
-
const paramFilter = params.filters[k];
|
|
1001
|
-
const defaultFilter = defaults?.filters?.[k];
|
|
1002
|
-
if (defaultFilter &&
|
|
1003
|
-
((Array.isArray(defaultFilter.value) &&
|
|
1004
|
-
Array.isArray(paramFilter.value) &&
|
|
1005
|
-
defaultFilter.value.length === paramFilter.value.length &&
|
|
1006
|
-
defaultFilter.value.every((v, idx) => {
|
|
1007
|
-
const value = paramFilter.value[idx];
|
|
1008
|
-
if (value instanceof Date && v instanceof Date)
|
|
1009
|
-
return value.getTime() === v.getTime();
|
|
1010
|
-
else
|
|
1011
|
-
return value === v;
|
|
1012
|
-
})) || // handle arrays
|
|
1013
|
-
defaultFilter.value === paramFilter.value) &&
|
|
1014
|
-
defaultFilter.matchMode === paramFilter.matchMode &&
|
|
1015
|
-
(defaultFilter.caseSensitive ?? false) === (paramFilter.caseSensitive ?? false)) {
|
|
1016
|
-
return;
|
|
1017
|
-
}
|
|
1018
|
-
if (paramFilter.value == null && defaultFilter?.value == null) {
|
|
1019
|
-
return;
|
|
1020
|
-
}
|
|
1021
|
-
urlParams[k] = DataListParamsUtil.paramsFilterToUrlQuery(params, k, true);
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
if (defaults?.filters) {
|
|
1025
|
-
// add other defaults
|
|
1026
|
-
const paramFilterKeys = params.filters ? Object.keys(params.filters) : [];
|
|
1027
|
-
Object.keys(defaults.filters)
|
|
1028
|
-
.filter(k => paramFilterKeys.indexOf(k) < 0)
|
|
1029
|
-
.forEach(k => {
|
|
1030
|
-
urlParams[k] = DataListParamsUtil.paramsFilterToUrlQuery(defaults, k);
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
|
-
return urlParams;
|
|
919
|
+
if (event.rows != null) {
|
|
920
|
+
params.limit = event.rows;
|
|
1034
921
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
922
|
+
if (typeof event.globalFilter === 'string') {
|
|
923
|
+
params.search = event.globalFilter;
|
|
924
|
+
}
|
|
925
|
+
else if (Array.isArray(event.globalFilter) && event.globalFilter.length > 0) {
|
|
926
|
+
params.search = event.globalFilter.join(',');
|
|
927
|
+
}
|
|
928
|
+
if (Array.isArray(event.multiSortMeta) && event.multiSortMeta.length > 0) {
|
|
929
|
+
params.sort = event.multiSortMeta.map(m => ({ property: m.field, ascending: m.order >= 0 }));
|
|
930
|
+
}
|
|
931
|
+
if (event.filters) {
|
|
932
|
+
params.filters = Object.keys(event.filters).reduce((acc, key) => {
|
|
933
|
+
const filter = {};
|
|
934
|
+
const eventFilter = event.filters?.[key];
|
|
935
|
+
if (Array.isArray(eventFilter)) {
|
|
936
|
+
filter.value = eventFilter[0].value;
|
|
937
|
+
filter.matchMode = eventFilter[0].matchMode;
|
|
938
|
+
}
|
|
939
|
+
else if (eventFilter !== undefined) {
|
|
940
|
+
filter.value = eventFilter.value;
|
|
941
|
+
filter.matchMode = eventFilter.matchMode;
|
|
942
|
+
}
|
|
943
|
+
return { ...acc, [key]: filter };
|
|
944
|
+
}, {});
|
|
945
|
+
}
|
|
946
|
+
return params;
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Converts the given parameters to URL query parameters.
|
|
950
|
+
* Sorts are formatted in Medius data API sort query language: `asc:prop1,desc:prop2`, ...
|
|
951
|
+
* Filter keys are "flattened" in the new object, values are formatted in Medius data API filter query language: `cs:eq:asd`, `in:asd,qwe`, `ex`, ...
|
|
952
|
+
*
|
|
953
|
+
* @param {DataListParams} params - The parameters to convert.
|
|
954
|
+
* @param {DataListParams|null} defaults - The default parameters used if no matching property in params is available. Defaults to { limit: 25, offset: 0 } if not provided.
|
|
955
|
+
* @returns {Params} - The URL query parameters object.
|
|
956
|
+
*/
|
|
957
|
+
function dataListParamsToUrlQuery(params, defaults = {
|
|
958
|
+
limit: 25,
|
|
959
|
+
offset: 0
|
|
960
|
+
}) {
|
|
961
|
+
const urlParams = {};
|
|
962
|
+
if (params.limit && params.limit !== defaults?.limit) {
|
|
963
|
+
urlParams['limit'] = params.limit;
|
|
964
|
+
}
|
|
965
|
+
if (params.offset && params.offset !== defaults?.offset) {
|
|
966
|
+
urlParams['offset'] = params.offset;
|
|
967
|
+
}
|
|
968
|
+
if (params.search && params.search !== defaults?.search) {
|
|
969
|
+
urlParams['q'] = params.search;
|
|
970
|
+
}
|
|
971
|
+
if (params.sort && Array.isArray(params.sort) && params.sort.length > 0) {
|
|
972
|
+
if (defaults?.sort == null ||
|
|
973
|
+
!Array.isArray(defaults.sort) ||
|
|
974
|
+
defaults.sort.length === 0 ||
|
|
975
|
+
params.sort.length !== defaults.sort.length ||
|
|
976
|
+
defaults.sort.some((ds, idx) => ds.property !== params.sort[idx].property || (ds.ascending ?? true) !== (params.sort[idx].ascending ?? true))) {
|
|
977
|
+
urlParams['sort'] = dataListParamsSortToUrlQuery(params);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
if (params.filters) {
|
|
981
|
+
Object.keys(params.filters).forEach(k => {
|
|
982
|
+
const paramFilter = params.filters[k];
|
|
983
|
+
const defaultFilter = defaults?.filters?.[k];
|
|
984
|
+
if (defaultFilter &&
|
|
985
|
+
((Array.isArray(defaultFilter.value) &&
|
|
986
|
+
Array.isArray(paramFilter.value) &&
|
|
987
|
+
defaultFilter.value.length === paramFilter.value.length &&
|
|
988
|
+
defaultFilter.value.every((v, idx) => {
|
|
989
|
+
const value = paramFilter.value[idx];
|
|
990
|
+
if (value instanceof Date && v instanceof Date)
|
|
991
|
+
return value.getTime() === v.getTime();
|
|
992
|
+
else
|
|
993
|
+
return value === v;
|
|
994
|
+
})) || // handle arrays
|
|
995
|
+
defaultFilter.value === paramFilter.value) &&
|
|
996
|
+
defaultFilter.matchMode === paramFilter.matchMode &&
|
|
997
|
+
(defaultFilter.caseSensitive ?? false) === (paramFilter.caseSensitive ?? false)) {
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
if (paramFilter.value == null && defaultFilter?.value == null) {
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
urlParams[k] = dataListParamsFiltersToUrlQuery(params, k, true);
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
if (defaults?.filters) {
|
|
1007
|
+
// add other defaults
|
|
1008
|
+
const paramFilterKeys = params.filters ? Object.keys(params.filters) : [];
|
|
1009
|
+
Object.keys(defaults.filters)
|
|
1010
|
+
.filter(k => paramFilterKeys.indexOf(k) < 0)
|
|
1011
|
+
.forEach(k => {
|
|
1012
|
+
urlParams[k] = dataListParamsFiltersToUrlQuery(defaults, k);
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
return urlParams;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Merges the provided parameters with default values and returns the merged object.
|
|
1019
|
+
*
|
|
1020
|
+
* @param {DataListParams} params - The parameters to merge with defaults.
|
|
1021
|
+
* @param {DataListParams} defaults - The default values to merge with params (optional, default is { limit: 25, offset: 0 }).
|
|
1022
|
+
* @returns {DataListParams} - The merged parameters object.
|
|
1023
|
+
*/
|
|
1024
|
+
function mergeDataListParamsWithDefaults(params, defaults = {
|
|
1025
|
+
limit: 25,
|
|
1026
|
+
offset: 0
|
|
1027
|
+
}) {
|
|
1028
|
+
const merged = {
|
|
1029
|
+
limit: params.limit ?? defaults.limit,
|
|
1030
|
+
offset: params.offset ?? defaults.offset,
|
|
1031
|
+
search: params.search ?? defaults.search,
|
|
1032
|
+
sort: (params.sort ?? defaults.sort)?.map(s => ({ ...s }))
|
|
1033
|
+
};
|
|
1034
|
+
if (params.filters) {
|
|
1035
|
+
merged.filters = {};
|
|
1036
|
+
Object.entries(params.filters).forEach(([key, value]) => (merged.filters[key] = { ...value }));
|
|
1037
|
+
}
|
|
1038
|
+
if (defaults.filters) {
|
|
1039
|
+
if (!merged.filters)
|
|
1053
1040
|
merged.filters = {};
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
Object.entries(defaults.filters).forEach(([key, value]) => {
|
|
1060
|
-
if (merged.filters[key] === undefined) {
|
|
1061
|
-
merged.filters[key] = { ...value };
|
|
1062
|
-
}
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
return merged;
|
|
1041
|
+
Object.entries(defaults.filters).forEach(([key, value]) => {
|
|
1042
|
+
if (merged.filters[key] === undefined) {
|
|
1043
|
+
merged.filters[key] = { ...value };
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1066
1046
|
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1047
|
+
return merged;
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Converts an object of parameters to a URL query string for sorting.
|
|
1051
|
+
* Sorts are formatted in Medius data API sort query language: `asc:prop1,desc:prop2`, ...
|
|
1052
|
+
*
|
|
1053
|
+
* @param {DataListParams} params - An optional object containing sort parameters.
|
|
1054
|
+
* @returns A string representing the URL query or undefined if no sort parameters are provided.
|
|
1055
|
+
*/
|
|
1056
|
+
function dataListParamsSortToUrlQuery(params) {
|
|
1057
|
+
return params && Array.isArray(params.sort)
|
|
1058
|
+
? params.sort.map(s => `${s.ascending === true || s.ascending === undefined ? 'asc' : 'desc'}:${String(s.property)}`).join(',')
|
|
1059
|
+
: undefined;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Converts a specific filter parameter (by key) from DataListParams object to a URL query string.
|
|
1063
|
+
* Filter keys are "flattened" in the new object, values are formatted in Medius data API filter query language: `cs:eq:asd`, `in:asd,qwe`, `ex`, ...
|
|
1064
|
+
*
|
|
1065
|
+
* @param {DataListParams<any, Filters> | undefined} params - The DataListParams object containing the filters.
|
|
1066
|
+
* @param {Filters} key - The key of the filter to convert.
|
|
1067
|
+
* @param {boolean} [allowNull=false] - Indicates whether to allow null values in the query string.
|
|
1068
|
+
* @return {string | undefined} - The URL query string representing the specified filter, or undefined if the filter is not found.
|
|
1069
|
+
*/
|
|
1070
|
+
function dataListParamsFiltersToUrlQuery(params, key, allowNull = false) {
|
|
1071
|
+
const paramFilter = params?.filters?.[key];
|
|
1072
|
+
return dataListParamsFilterToUrlQuery(paramFilter, allowNull);
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Converts a filter to a URL query string.
|
|
1076
|
+
* Filter keys are "flattened" in the new object, values are formatted in Medius data API filter query language: `cs:eq:asd`, `in:asd,qwe`, `ex`, ...
|
|
1077
|
+
*
|
|
1078
|
+
* @param {DataListFilter} paramFilter - The filter object to be converted.
|
|
1079
|
+
* @param {boolean} [allowNull=false] - Indicates whether to allow null values in the filter.
|
|
1080
|
+
* @returns {string|undefined} - The filter converted to a URL query string, or undefined if no filter is provided or the filter has empty or invalid values.
|
|
1081
|
+
* @throws {CommonsInternalError} - If the filter has invalid values.
|
|
1082
|
+
*/
|
|
1083
|
+
function dataListParamsFilterToUrlQuery(paramFilter, allowNull = false) {
|
|
1084
|
+
const filterValueAsArray = Array.isArray(paramFilter?.value) ? paramFilter.value.filter(v => v !== undefined && (allowNull || v !== null)) : undefined;
|
|
1085
|
+
if (paramFilter === undefined ||
|
|
1086
|
+
(!allowNull && paramFilter.value == null) ||
|
|
1087
|
+
(typeof paramFilter.value === 'string' && paramFilter.value.length === 0) ||
|
|
1088
|
+
(Array.isArray(filterValueAsArray) && filterValueAsArray.length === 0)) {
|
|
1089
|
+
// no need to include filters for empty values
|
|
1090
|
+
return undefined;
|
|
1078
1091
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
*
|
|
1083
|
-
* @param {DataListParams<any, Filters> | undefined} params - The DataListParams object containing the filters.
|
|
1084
|
-
* @param {Filters} key - The key of the filter to convert.
|
|
1085
|
-
* @param {boolean} [allowNull=false] - Indicates whether to allow null values in the query string.
|
|
1086
|
-
* @return {string | undefined} - The URL query string representing the specified filter, or undefined if the filter is not found.
|
|
1087
|
-
*/
|
|
1088
|
-
static paramsFilterToUrlQuery(params, key, allowNull = false) {
|
|
1089
|
-
const paramFilter = params?.filters?.[key];
|
|
1090
|
-
return DataListParamsUtil.filterToUrlQuery(paramFilter, allowNull);
|
|
1092
|
+
const matchMode = paramFilter.matchMode ?? FilterMatchMode.Equals;
|
|
1093
|
+
if (matchMode === FilterMatchMode.Between && !(Array.isArray(filterValueAsArray) && filterValueAsArray.length === 2)) {
|
|
1094
|
+
throw new CommonsInternalError(`Filter match mode between requires exactly 2 values: ${paramFilter.value}`);
|
|
1091
1095
|
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1096
|
+
if ((matchMode === FilterMatchMode.In || matchMode === FilterMatchMode.NotIn) && (!Array.isArray(filterValueAsArray) || filterValueAsArray.length === 0)) {
|
|
1097
|
+
throw new CommonsInternalError(`Filter match mode ${matchMode} requires non-empty array: ${paramFilter.value}`);
|
|
1098
|
+
}
|
|
1099
|
+
if ([FilterMatchMode.In, FilterMatchMode.NotIn, FilterMatchMode.Between].indexOf(matchMode) === -1 && Array.isArray(filterValueAsArray)) {
|
|
1100
|
+
throw new CommonsInternalError(`Filter match mode ${matchMode} must not be array: ${paramFilter.value}`);
|
|
1101
|
+
}
|
|
1102
|
+
const noVal = paramFilter.matchMode === FilterMatchMode.Exists || paramFilter.matchMode === FilterMatchMode.DoesNotExist;
|
|
1103
|
+
const urlValuePart = noVal ? '' : `:${dataListParamsFilterValueToUrlString(filterValueAsArray ?? paramFilter.value, allowNull)}`;
|
|
1104
|
+
return `${paramFilter.caseSensitive ? 'cs:' : paramFilter.caseSensitive === false ? 'ci:' : ''}${FilterMatchMode.getAbbreviation(matchMode) ?? matchMode}${urlValuePart}`;
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Converts URL query parameters to a DataListParams object.
|
|
1108
|
+
* Sorts are formatted from Medius data API sort query language: `asc:prop1,desc:prop2`, ...
|
|
1109
|
+
* Filter keys are all keys in Params object that are not matched elsewhere, values are formatted from Medius data API filter query language: `cs:eq:asd`, `in:asd,qwe`, `ex`, ...
|
|
1110
|
+
*
|
|
1111
|
+
* @param {Params} urlParams - The URL query parameters.
|
|
1112
|
+
* @return {DataListParams} - The converted DataListParams object.
|
|
1113
|
+
*/
|
|
1114
|
+
function fromUrlQueryToDataListParams(urlParams) {
|
|
1115
|
+
const params = {};
|
|
1116
|
+
Object.entries(urlParams).forEach(([urlParamKey, urlParamValue]) => {
|
|
1117
|
+
if (urlParamKey === 'limit') {
|
|
1118
|
+
params.limit = +urlParamValue;
|
|
1119
|
+
if (isNaN(params.limit) || params.limit < 0) {
|
|
1120
|
+
delete params.limit;
|
|
1121
|
+
}
|
|
1113
1122
|
}
|
|
1114
|
-
if (
|
|
1115
|
-
|
|
1123
|
+
else if (urlParamKey === 'offset') {
|
|
1124
|
+
params.offset = +urlParamValue;
|
|
1125
|
+
if (isNaN(params.offset) || params.offset < 0) {
|
|
1126
|
+
delete params.offset;
|
|
1127
|
+
}
|
|
1116
1128
|
}
|
|
1117
|
-
if (
|
|
1118
|
-
|
|
1129
|
+
else if (urlParamKey === 'q') {
|
|
1130
|
+
params.search = urlParamValue;
|
|
1119
1131
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
* Sorts are formatted from Medius data API sort query language: `asc:prop1,desc:prop2`, ...
|
|
1127
|
-
* Filter keys are all keys in Params object that are not matched elsewhere, values are formatted from Medius data API filter query language: `cs:eq:asd`, `in:asd,qwe`, `ex`, ...
|
|
1128
|
-
*
|
|
1129
|
-
* @param {Params} urlParams - The URL query parameters.
|
|
1130
|
-
* @return {DataListParams} - The converted DataListParams object.
|
|
1131
|
-
*/
|
|
1132
|
-
static fromUrlQueryParams(urlParams) {
|
|
1133
|
-
const params = {};
|
|
1134
|
-
Object.entries(urlParams).forEach(([urlParamKey, urlParamValue]) => {
|
|
1135
|
-
if (urlParamKey === 'limit') {
|
|
1136
|
-
params.limit = +urlParamValue;
|
|
1137
|
-
if (isNaN(params.limit) || params.limit < 0) {
|
|
1138
|
-
delete params.limit;
|
|
1139
|
-
}
|
|
1132
|
+
else if (urlParamKey === 'sort') {
|
|
1133
|
+
if (typeof urlParamValue === 'string') {
|
|
1134
|
+
params.sort = urlParamValue.split(',').map(s => {
|
|
1135
|
+
const [direction, property] = s.split(':');
|
|
1136
|
+
return { property: (property ?? direction), ascending: direction !== 'desc' };
|
|
1137
|
+
});
|
|
1140
1138
|
}
|
|
1141
|
-
else
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1139
|
+
else {
|
|
1140
|
+
throw new CommonsInternalError(`String is expected as value for '${urlParamKey}' when converting from urlParams`);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
else if (typeof urlParamValue === 'string') {
|
|
1144
|
+
if (urlParamValue.length === 0) {
|
|
1145
|
+
// empty string should be ignored
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
const filterParts = urlParamValue.split(':');
|
|
1149
|
+
let partIdx = 0;
|
|
1150
|
+
// case sensitive
|
|
1151
|
+
let caseSensitive = undefined;
|
|
1152
|
+
if (filterParts[partIdx] === 'cs' || filterParts[partIdx] === 'ci') {
|
|
1153
|
+
caseSensitive = filterParts[partIdx++] === 'cs';
|
|
1154
|
+
}
|
|
1155
|
+
// match mode
|
|
1156
|
+
const matchMode = filterParts[partIdx] ? FilterMatchMode.fromAbbreviation(filterParts[partIdx]) ?? filterParts[partIdx] : FilterMatchMode.Equals;
|
|
1157
|
+
partIdx++;
|
|
1158
|
+
const noVal = matchMode === FilterMatchMode.Exists || matchMode === FilterMatchMode.DoesNotExist;
|
|
1159
|
+
// value
|
|
1160
|
+
let value = undefined;
|
|
1161
|
+
if (!noVal) {
|
|
1162
|
+
if (filterParts.length < 2) {
|
|
1163
|
+
return;
|
|
1145
1164
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
params.search = urlParamValue;
|
|
1149
|
-
}
|
|
1150
|
-
else if (urlParamKey === 'sort') {
|
|
1151
|
-
if (typeof urlParamValue === 'string') {
|
|
1152
|
-
params.sort = urlParamValue.split(',').map(s => {
|
|
1153
|
-
const [direction, property] = s.split(':');
|
|
1154
|
-
return { property: (property ?? direction), ascending: direction !== 'desc' };
|
|
1155
|
-
});
|
|
1165
|
+
if (partIdx === filterParts.length - 1) {
|
|
1166
|
+
value = filterParts[partIdx];
|
|
1156
1167
|
}
|
|
1157
|
-
else {
|
|
1158
|
-
|
|
1168
|
+
else if (partIdx < filterParts.length) {
|
|
1169
|
+
// array that should not be array, so join back together
|
|
1170
|
+
value = filterParts.slice(partIdx, filterParts.length).join(':');
|
|
1159
1171
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
if (urlParamValue.length === 0) {
|
|
1163
|
-
// empty string should be ignored
|
|
1172
|
+
if (value === undefined && matchMode !== FilterMatchMode.Exists && matchMode !== FilterMatchMode.DoesNotExist) {
|
|
1173
|
+
// if value undefined and match mode expects value, then skip
|
|
1164
1174
|
return;
|
|
1165
1175
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
// case sensitive
|
|
1169
|
-
let caseSensitive = undefined;
|
|
1170
|
-
if (filterParts[partIdx] === 'cs' || filterParts[partIdx] === 'ci') {
|
|
1171
|
-
caseSensitive = filterParts[partIdx++] === 'cs';
|
|
1176
|
+
if (value === 'null') {
|
|
1177
|
+
value = null;
|
|
1172
1178
|
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
const tokens = [];
|
|
1202
|
-
let currentToken = '';
|
|
1203
|
-
let explicitQuotes = false; //token is quoted, e.g. in:1,2,"22""",",123"""
|
|
1204
|
-
let quotesOpened = false; //token has started processing
|
|
1205
|
-
let quotesExplicitlyClosed = false; //token processing has finished, after single " in quoted mode, or before , in not quoted
|
|
1206
|
-
for (let i = 0; i < value.length; i++) {
|
|
1207
|
-
const c = value[i];
|
|
1208
|
-
// reset the tokenizer when seeing the token separator
|
|
1209
|
-
// only if either:
|
|
1210
|
-
// the quotes have not been opened yet (when there are no characters between separators),
|
|
1211
|
-
// the token has been explicitly closed (when we actually have explicit opening i.e., quotes as the first character)
|
|
1212
|
-
// or we have implicit quotes (i.e., quotes are not the first character)
|
|
1213
|
-
if (c === ',' && (!quotesOpened || quotesExplicitlyClosed || !explicitQuotes)) {
|
|
1214
|
-
tokens.push(currentToken);
|
|
1215
|
-
currentToken = '';
|
|
1216
|
-
quotesOpened = false;
|
|
1217
|
-
quotesExplicitlyClosed = false;
|
|
1218
|
-
explicitQuotes = false;
|
|
1179
|
+
if ((matchMode === FilterMatchMode.In || matchMode === FilterMatchMode.NotIn || matchMode === FilterMatchMode.Between) && typeof value === 'string') {
|
|
1180
|
+
let arrayVal = [];
|
|
1181
|
+
// these match modes expect array
|
|
1182
|
+
if (value.indexOf('"') >= 0) {
|
|
1183
|
+
const tokens = [];
|
|
1184
|
+
let currentToken = '';
|
|
1185
|
+
let explicitQuotes = false; //token is quoted, e.g. in:1,2,"22""",",123"""
|
|
1186
|
+
let quotesOpened = false; //token has started processing
|
|
1187
|
+
let quotesExplicitlyClosed = false; //token processing has finished, after single " in quoted mode, or before , in not quoted
|
|
1188
|
+
for (let i = 0; i < value.length; i++) {
|
|
1189
|
+
const c = value[i];
|
|
1190
|
+
// reset the tokenizer when seeing the token separator
|
|
1191
|
+
// only if either:
|
|
1192
|
+
// the quotes have not been opened yet (when there are no characters between separators),
|
|
1193
|
+
// the token has been explicitly closed (when we actually have explicit opening i.e., quotes as the first character)
|
|
1194
|
+
// or we have implicit quotes (i.e., quotes are not the first character)
|
|
1195
|
+
if (c === ',' && (!quotesOpened || quotesExplicitlyClosed || !explicitQuotes)) {
|
|
1196
|
+
tokens.push(currentToken);
|
|
1197
|
+
currentToken = '';
|
|
1198
|
+
quotesOpened = false;
|
|
1199
|
+
quotesExplicitlyClosed = false;
|
|
1200
|
+
explicitQuotes = false;
|
|
1201
|
+
}
|
|
1202
|
+
else if (c == '"') {
|
|
1203
|
+
// escaped double-quotes
|
|
1204
|
+
if (explicitQuotes && i + 1 < value.length && value[i + 1] === '"') {
|
|
1205
|
+
currentToken += c; // Append one double-quote to the current token
|
|
1206
|
+
i++; // Skip the next double-quote
|
|
1219
1207
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
currentToken += c; // Append one double-quote to the current token
|
|
1224
|
-
i++; // Skip the next double-quote
|
|
1225
|
-
}
|
|
1226
|
-
// we encounter quotes again after they were the first character => we close the token
|
|
1227
|
-
else if (explicitQuotes) {
|
|
1228
|
-
quotesExplicitlyClosed = true;
|
|
1229
|
-
}
|
|
1230
|
-
// implicit quotes
|
|
1231
|
-
else if (quotesOpened) {
|
|
1232
|
-
currentToken += c;
|
|
1233
|
-
}
|
|
1234
|
-
// quotes are the first character => explicitly open the token
|
|
1235
|
-
else {
|
|
1236
|
-
currentToken = '';
|
|
1237
|
-
quotesOpened = true;
|
|
1238
|
-
explicitQuotes = true;
|
|
1239
|
-
}
|
|
1208
|
+
// we encounter quotes again after they were the first character => we close the token
|
|
1209
|
+
else if (explicitQuotes) {
|
|
1210
|
+
quotesExplicitlyClosed = true;
|
|
1240
1211
|
}
|
|
1212
|
+
// implicit quotes
|
|
1213
|
+
else if (quotesOpened) {
|
|
1214
|
+
currentToken += c;
|
|
1215
|
+
}
|
|
1216
|
+
// quotes are the first character => explicitly open the token
|
|
1241
1217
|
else {
|
|
1242
|
-
|
|
1243
|
-
return;
|
|
1244
|
-
}
|
|
1218
|
+
currentToken = '';
|
|
1245
1219
|
quotesOpened = true;
|
|
1246
|
-
|
|
1220
|
+
explicitQuotes = true;
|
|
1247
1221
|
}
|
|
1248
1222
|
}
|
|
1249
|
-
|
|
1250
|
-
|
|
1223
|
+
else {
|
|
1224
|
+
if (quotesExplicitlyClosed) {
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
quotesOpened = true;
|
|
1228
|
+
currentToken += c;
|
|
1251
1229
|
}
|
|
1252
|
-
// Append the last token after the loop ends
|
|
1253
|
-
tokens.push(currentToken.toString());
|
|
1254
|
-
arrayVal = tokens;
|
|
1255
|
-
}
|
|
1256
|
-
else {
|
|
1257
|
-
arrayVal = value.split(',');
|
|
1258
1230
|
}
|
|
1259
|
-
if (
|
|
1231
|
+
if (quotesOpened && !quotesExplicitlyClosed && explicitQuotes) {
|
|
1260
1232
|
return;
|
|
1261
1233
|
}
|
|
1262
|
-
|
|
1234
|
+
// Append the last token after the loop ends
|
|
1235
|
+
tokens.push(currentToken.toString());
|
|
1236
|
+
arrayVal = tokens;
|
|
1263
1237
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1238
|
+
else {
|
|
1239
|
+
arrayVal = value.split(',');
|
|
1240
|
+
}
|
|
1241
|
+
if (matchMode === FilterMatchMode.Between && arrayVal.length !== 2) {
|
|
1266
1242
|
return;
|
|
1267
1243
|
}
|
|
1244
|
+
value = arrayVal;
|
|
1268
1245
|
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
if (!params.filters) {
|
|
1273
|
-
params.filters = {};
|
|
1246
|
+
if ((typeof value === 'string' && value.length === 0) || (Array.isArray(value) && value.length === 0)) {
|
|
1247
|
+
// filter with empty value is to be ignored
|
|
1248
|
+
return;
|
|
1274
1249
|
}
|
|
1275
|
-
params.filters[urlParamKey] = { value: value, matchMode: matchMode, caseSensitive: caseSensitive };
|
|
1276
1250
|
}
|
|
1277
|
-
});
|
|
1278
|
-
return params;
|
|
1279
|
-
}
|
|
1280
|
-
/**
|
|
1281
|
-
* Makes a copy of the given DataListParams object.
|
|
1282
|
-
*
|
|
1283
|
-
* @param {DataListParams<Sorts, Filters>} params - The DataListParams object to be copied.
|
|
1284
|
-
* @returns {DataListParams<Sorts, Filters>} - Returns a new copy of the DataListParams object.
|
|
1285
|
-
*/
|
|
1286
|
-
static copy(params) {
|
|
1287
|
-
const copy = {
|
|
1288
|
-
offset: params.offset,
|
|
1289
|
-
limit: params.limit,
|
|
1290
|
-
search: params.search
|
|
1291
|
-
};
|
|
1292
|
-
if (params.sort) {
|
|
1293
|
-
copy.sort = params.sort?.map(s => ({ ...s }));
|
|
1294
|
-
}
|
|
1295
|
-
if (params.filters) {
|
|
1296
|
-
copy.filters = Object.entries(params.filters).reduce((acc, [key, value]) => {
|
|
1297
|
-
const filterValue = value;
|
|
1298
|
-
return {
|
|
1299
|
-
...acc,
|
|
1300
|
-
[key]: {
|
|
1301
|
-
...filterValue,
|
|
1302
|
-
value: Array.isArray(filterValue.value) ? [...filterValue.value] : filterValue.value
|
|
1303
|
-
}
|
|
1304
|
-
};
|
|
1305
|
-
}, {});
|
|
1306
|
-
}
|
|
1307
|
-
return copy;
|
|
1308
|
-
}
|
|
1309
|
-
/**
|
|
1310
|
-
* Converts a value to a URL query param string representation.
|
|
1311
|
-
*
|
|
1312
|
-
* @param {unknown} value - The value to be converted.
|
|
1313
|
-
* @param {boolean} [allowNull=false] - Indicates whether null values are allowed.
|
|
1314
|
-
* @returns {string} The URL parameter representation of the value.
|
|
1315
|
-
* @throws {CommonsInternalError} If an undefined value is passed without allowNull set to true.
|
|
1316
|
-
* @throws {CommonsInternalError} If the value is an object (excluding Date).
|
|
1317
|
-
*/
|
|
1318
|
-
static filterValueToUrlParam(value, allowNull = false) {
|
|
1319
|
-
if (value === null && allowNull)
|
|
1320
|
-
return 'null';
|
|
1321
|
-
if (value == null)
|
|
1322
|
-
throw new CommonsInternalError('Undefined value cannot be converted to url param.'); // this should not happen, should be filtered out earlier
|
|
1323
|
-
if (Array.isArray(value))
|
|
1324
|
-
return value
|
|
1325
|
-
.map(v => DataListParamsUtil.filterValueToUrlParam(v, allowNull))
|
|
1326
|
-
.map(v => (v.indexOf(',') >= 0 || v.indexOf('"') >= 0 ? `"${v.replaceAll('"', '""')}"` : v))
|
|
1327
|
-
.join(',');
|
|
1328
|
-
if (typeof value === 'object') {
|
|
1329
|
-
if (value instanceof Date)
|
|
1330
|
-
return DateUtil.toIsoString(value, 'dateTime', { utc: true });
|
|
1331
1251
|
else {
|
|
1332
|
-
|
|
1252
|
+
caseSensitive = undefined;
|
|
1333
1253
|
}
|
|
1254
|
+
if (!params.filters) {
|
|
1255
|
+
params.filters = {};
|
|
1256
|
+
}
|
|
1257
|
+
params.filters[urlParamKey] = { value: value, matchMode: matchMode, caseSensitive: caseSensitive };
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
return params;
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Makes a copy of the given DataListParams object.
|
|
1264
|
+
*
|
|
1265
|
+
* @param {DataListParams<Sorts, Filters>} params - The DataListParams object to be copied.
|
|
1266
|
+
* @returns {DataListParams<Sorts, Filters>} - Returns a new copy of the DataListParams object.
|
|
1267
|
+
*/
|
|
1268
|
+
function copyDataListParams(params) {
|
|
1269
|
+
const copy = {
|
|
1270
|
+
offset: params.offset,
|
|
1271
|
+
limit: params.limit,
|
|
1272
|
+
search: params.search
|
|
1273
|
+
};
|
|
1274
|
+
if (params.sort) {
|
|
1275
|
+
copy.sort = params.sort?.map(s => ({ ...s }));
|
|
1276
|
+
}
|
|
1277
|
+
if (params.filters) {
|
|
1278
|
+
copy.filters = Object.entries(params.filters).reduce((acc, [key, value]) => {
|
|
1279
|
+
const filterValue = value;
|
|
1280
|
+
return {
|
|
1281
|
+
...acc,
|
|
1282
|
+
[key]: {
|
|
1283
|
+
...filterValue,
|
|
1284
|
+
value: Array.isArray(filterValue.value) ? [...filterValue.value] : filterValue.value
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
}, {});
|
|
1288
|
+
}
|
|
1289
|
+
return copy;
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Converts a value to a URL query param string representation.
|
|
1293
|
+
*
|
|
1294
|
+
* @param {unknown} value - The value to be converted.
|
|
1295
|
+
* @param {boolean} [allowNull=false] - Indicates whether null values are allowed.
|
|
1296
|
+
* @returns {string} The URL parameter representation of the value.
|
|
1297
|
+
* @throws {CommonsInternalError} If an undefined value is passed without allowNull set to true.
|
|
1298
|
+
* @throws {CommonsInternalError} If the value is an object (excluding Date).
|
|
1299
|
+
*/
|
|
1300
|
+
function dataListParamsFilterValueToUrlString(value, allowNull = false) {
|
|
1301
|
+
if (value === null && allowNull)
|
|
1302
|
+
return 'null';
|
|
1303
|
+
if (value == null)
|
|
1304
|
+
throw new CommonsInternalError('Undefined value cannot be converted to url param.'); // this should not happen, should be filtered out earlier
|
|
1305
|
+
if (Array.isArray(value))
|
|
1306
|
+
return value
|
|
1307
|
+
.map(v => dataListParamsFilterValueToUrlString(v, allowNull))
|
|
1308
|
+
.map(v => (v.indexOf(',') >= 0 || v.indexOf('"') >= 0 ? `"${v.replaceAll('"', '""')}"` : v))
|
|
1309
|
+
.join(',');
|
|
1310
|
+
if (typeof value === 'object') {
|
|
1311
|
+
if (value instanceof Date)
|
|
1312
|
+
return dateToIsoString(value, 'dateTime', { utc: true });
|
|
1313
|
+
else {
|
|
1314
|
+
throw new CommonsInternalError('Filter value cannot be object');
|
|
1334
1315
|
}
|
|
1335
|
-
return String(value);
|
|
1336
1316
|
}
|
|
1317
|
+
return String(value);
|
|
1337
1318
|
}
|
|
1338
1319
|
|
|
1339
1320
|
/**
|
|
@@ -1427,10 +1408,10 @@ class ComponentDirective {
|
|
|
1427
1408
|
}
|
|
1428
1409
|
this.componentInstanceEventEmitter.next(this.componentRef.instance);
|
|
1429
1410
|
}
|
|
1430
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
1431
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.
|
|
1411
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: ComponentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1412
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.4", type: ComponentDirective, isStandalone: true, selector: "[mngComponent]", inputs: { component: ["mngComponent", "component"], componentIt: ["injectionToken", "componentIt"], inputs: "inputs", attachToHost: "attachToHost", nodeInjector: "nodeInjector" }, outputs: { componentInstanceEventEmitter: "instanceCreated" }, ngImport: i0 }); }
|
|
1432
1413
|
}
|
|
1433
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
1414
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: ComponentDirective, decorators: [{
|
|
1434
1415
|
type: Directive,
|
|
1435
1416
|
args: [{
|
|
1436
1417
|
standalone: true,
|
|
@@ -1464,10 +1445,10 @@ class TemplateDirective {
|
|
|
1464
1445
|
getViewContainerRef() {
|
|
1465
1446
|
return this.viewContainerRef;
|
|
1466
1447
|
}
|
|
1467
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
1468
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.
|
|
1448
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: TemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1449
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.4", type: TemplateDirective, isStandalone: true, selector: "[mngTemplate]", inputs: { type: "type", name: ["mngTemplate", "name"] }, ngImport: i0 }); }
|
|
1469
1450
|
}
|
|
1470
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
1451
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: TemplateDirective, decorators: [{
|
|
1471
1452
|
type: Directive,
|
|
1472
1453
|
args: [{
|
|
1473
1454
|
standalone: true,
|
|
@@ -1480,536 +1461,528 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
|
|
|
1480
1461
|
args: [{ required: true, alias: 'mngTemplate' }]
|
|
1481
1462
|
}] } });
|
|
1482
1463
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1464
|
+
/**
|
|
1465
|
+
* Returns array of names for constants in enum.
|
|
1466
|
+
* @param enumType Enum object.
|
|
1467
|
+
*/
|
|
1468
|
+
function getEnumConstantNames(enumType) {
|
|
1469
|
+
return getEnumConstantNamesFromObject(enumType);
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Returns array of names for constants in enum.
|
|
1473
|
+
* @param enumObj Enum object.
|
|
1474
|
+
*/
|
|
1475
|
+
function getEnumConstantNamesFromObject(enumObj) {
|
|
1476
|
+
// in number enum, the numbers are also represented in objects and should be filtered out
|
|
1477
|
+
return Object.keys(enumObj).filter(v => isNaN(+v));
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Returns array of string values for constants in enum.
|
|
1481
|
+
* @param enumType Enum object.
|
|
1482
|
+
*/
|
|
1483
|
+
function getEnumConstantValuesAsString(enumType) {
|
|
1484
|
+
return Object.keys(enumType).map(v => enumType[v]);
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Returns array of number values for constants in enum.
|
|
1488
|
+
* @param enumType Enum object.
|
|
1489
|
+
*/
|
|
1490
|
+
function getEnumConstantValuesAsNumber(enumType) {
|
|
1491
|
+
return Object.keys(enumType)
|
|
1492
|
+
.filter(v => !isNaN(+v))
|
|
1493
|
+
.map(v => +v);
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Returns array of type EnumValue for all constants in enum.
|
|
1497
|
+
* @param enumType Enum object.
|
|
1498
|
+
* @param nameAsValue If use name of constant as value (optional, default: false).
|
|
1499
|
+
* @param titlePath Base path for title to use as translation (optional).
|
|
1500
|
+
*/
|
|
1501
|
+
function fromEnumConstantsAsValueArray(enumType, nameAsValue = false, titlePath) {
|
|
1502
|
+
return getEnumConstantNames(enumType).map(n => ({ name: n, title: `${titlePath ? `${titlePath}.` : ''}${n}`, value: nameAsValue ? n : enumType[n] }));
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Returns array of type EnumValue for provided values in enum.
|
|
1506
|
+
* @param enumType Enum object.
|
|
1507
|
+
* @param values Enum values (constants).
|
|
1508
|
+
* @param nameAsValue If use name of constant as value (optional, default: false).
|
|
1509
|
+
* @param titlePath Base path for title to use as translation (optional).
|
|
1510
|
+
*/
|
|
1511
|
+
function fromEnumValuesAsValueArray(enumType, values, nameAsValue = false, titlePath) {
|
|
1512
|
+
return values.map(v => {
|
|
1513
|
+
const k = getEnumConstantName(enumType, v);
|
|
1514
|
+
return { name: k, title: `${titlePath ? `${titlePath}.` : ''}${k}`, value: nameAsValue ? k : v };
|
|
1515
|
+
});
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Gets constant name for value.
|
|
1519
|
+
* @param enumType Enum object.
|
|
1520
|
+
* @param value Value of enum constant.
|
|
1521
|
+
*/
|
|
1522
|
+
function getEnumConstantName(enumType, value) {
|
|
1523
|
+
if (typeof value === 'string') {
|
|
1524
|
+
return getEnumConstantNames(enumType).find(c => enumType[c] === value) ?? null;
|
|
1490
1525
|
}
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
* @param enumObj Enum object.
|
|
1494
|
-
*/
|
|
1495
|
-
static getConstantNamesFromEnumObject(enumObj) {
|
|
1496
|
-
// in number enum, the numbers are also represented in objects and should be filtered out
|
|
1497
|
-
return Object.keys(enumObj).filter(v => isNaN(+v));
|
|
1526
|
+
else {
|
|
1527
|
+
return typeof enumType[value] !== 'undefined' ? enumType[value] : null;
|
|
1498
1528
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Gets constant name for value.
|
|
1532
|
+
* @param enumObj Enum object.
|
|
1533
|
+
* @param value Value of enum constant.
|
|
1534
|
+
*/
|
|
1535
|
+
function getEnumConstantNameFromObject(enumObj, value) {
|
|
1536
|
+
const enumObjAny = enumObj;
|
|
1537
|
+
if (typeof value === 'string') {
|
|
1538
|
+
return getEnumConstantNamesFromObject(enumObj).find(c => enumObjAny[c] === value) ?? null;
|
|
1505
1539
|
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
* @param enumType Enum object.
|
|
1509
|
-
*/
|
|
1510
|
-
static getConstantValuesAsNumber(enumType) {
|
|
1511
|
-
return Object.keys(enumType)
|
|
1512
|
-
.filter(v => !isNaN(+v))
|
|
1513
|
-
.map(v => +v);
|
|
1540
|
+
else {
|
|
1541
|
+
return typeof enumObjAny[value] !== 'undefined' ? enumObjAny[value] : null;
|
|
1514
1542
|
}
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
*/
|
|
1521
|
-
static fromConstantsAsEnumValueArray(enumType, nameAsValue = false, titlePath) {
|
|
1522
|
-
return EnumUtil.getConstantNames(enumType).map(n => ({ name: n, title: `${titlePath ? `${titlePath}.` : ''}${n}`, value: nameAsValue ? n : enumType[n] }));
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
function objectDeepCopy(obj, options) {
|
|
1546
|
+
if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
|
|
1547
|
+
return obj;
|
|
1523
1548
|
}
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
* @param enumType Enum object.
|
|
1527
|
-
* @param values Enum values (constants).
|
|
1528
|
-
* @param nameAsValue If use name of constant as value (optional, default: false).
|
|
1529
|
-
* @param titlePath Base path for title to use as translation (optional).
|
|
1530
|
-
*/
|
|
1531
|
-
static fromValuesAsEnumValueArray(enumType, values, nameAsValue = false, titlePath) {
|
|
1532
|
-
return values.map(v => {
|
|
1533
|
-
const k = EnumUtil.getConstantName(enumType, v);
|
|
1534
|
-
return { name: k, title: `${titlePath ? `${titlePath}.` : ''}${k}`, value: nameAsValue ? k : v };
|
|
1535
|
-
});
|
|
1549
|
+
if (obj instanceof Date) {
|
|
1550
|
+
return new Date(+obj);
|
|
1536
1551
|
}
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
* @param value Value of enum constant.
|
|
1541
|
-
*/
|
|
1542
|
-
static getConstantName(enumType, value) {
|
|
1543
|
-
if (typeof value === 'string') {
|
|
1544
|
-
return EnumUtil.getConstantNames(enumType).find(c => enumType[c] === value) ?? null;
|
|
1545
|
-
}
|
|
1546
|
-
else {
|
|
1547
|
-
return typeof enumType[value] !== 'undefined' ? enumType[value] : null;
|
|
1548
|
-
}
|
|
1552
|
+
let copy;
|
|
1553
|
+
if (options?.mapGettersToProperties) {
|
|
1554
|
+
copy = {};
|
|
1549
1555
|
}
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1556
|
+
else {
|
|
1557
|
+
copy = options?.objectPrototype ? Object.create(options.objectPrototype['prototype']) : Object.create(Object.getPrototypeOf(obj));
|
|
1558
|
+
Object.assign(copy, obj);
|
|
1559
|
+
}
|
|
1560
|
+
for (const key of getObjectProperties(obj)) {
|
|
1561
|
+
const prop = obj[key];
|
|
1562
|
+
copy[key] = handleProp(prop, { mapGettersToProperties: options?.mapGettersToProperties });
|
|
1563
|
+
}
|
|
1564
|
+
if (options?.mapGettersToProperties) {
|
|
1565
|
+
for (const getterKey of getObjectGetters(obj)) {
|
|
1566
|
+
const prop = obj[getterKey];
|
|
1567
|
+
copy[getterKey] = handleProp(prop, { mapGettersToProperties: options?.mapGettersToProperties });
|
|
1562
1568
|
}
|
|
1563
1569
|
}
|
|
1570
|
+
return copy;
|
|
1564
1571
|
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
|
|
1569
|
-
return obj;
|
|
1570
|
-
}
|
|
1571
|
-
if (obj instanceof Date) {
|
|
1572
|
-
return new Date(+obj);
|
|
1573
|
-
}
|
|
1574
|
-
let copy;
|
|
1575
|
-
if (options?.mapGettersToProperties) {
|
|
1576
|
-
copy = {};
|
|
1577
|
-
}
|
|
1578
|
-
else {
|
|
1579
|
-
copy = options?.objectPrototype ? Object.create(options.objectPrototype['prototype']) : Object.create(Object.getPrototypeOf(obj));
|
|
1580
|
-
Object.assign(copy, obj);
|
|
1581
|
-
}
|
|
1582
|
-
for (const key of ObjectUtil.getProperties(obj)) {
|
|
1583
|
-
const prop = obj[key];
|
|
1584
|
-
copy[key] = ObjectUtil.handleProp(prop, { mapGettersToProperties: options?.mapGettersToProperties });
|
|
1585
|
-
}
|
|
1586
|
-
if (options?.mapGettersToProperties) {
|
|
1587
|
-
for (const getterKey of ObjectUtil.getGetters(obj)) {
|
|
1588
|
-
const prop = obj[getterKey];
|
|
1589
|
-
copy[getterKey] = ObjectUtil.handleProp(prop, { mapGettersToProperties: options?.mapGettersToProperties });
|
|
1590
|
-
}
|
|
1591
|
-
}
|
|
1592
|
-
return copy;
|
|
1572
|
+
function objectDeepMerge(target, source) {
|
|
1573
|
+
if (!isObject(source)) {
|
|
1574
|
+
return target;
|
|
1593
1575
|
}
|
|
1594
|
-
|
|
1595
|
-
if (
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
for (const key of ObjectUtil.getProperties(source)) {
|
|
1599
|
-
if (ObjectUtil.isObject(source[key])) {
|
|
1600
|
-
if (ObjectUtil.isObject(target[key])) {
|
|
1601
|
-
target[key] = ObjectUtil.deepMerge(target[key], source[key]);
|
|
1602
|
-
}
|
|
1603
|
-
else {
|
|
1604
|
-
target[key] = ObjectUtil.deepCopy(source[key]);
|
|
1605
|
-
}
|
|
1576
|
+
for (const key of getObjectProperties(source)) {
|
|
1577
|
+
if (isObject(source[key])) {
|
|
1578
|
+
if (isObject(target[key])) {
|
|
1579
|
+
target[key] = objectDeepMerge(target[key], source[key]);
|
|
1606
1580
|
}
|
|
1607
|
-
else
|
|
1608
|
-
|
|
1609
|
-
target[key] = source[key].map(i => (ObjectUtil.isObject(i) ? ObjectUtil.deepMerge({}, i) : i));
|
|
1610
|
-
}
|
|
1581
|
+
else {
|
|
1582
|
+
target[key] = objectDeepCopy(source[key]);
|
|
1611
1583
|
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1584
|
+
}
|
|
1585
|
+
else if (Array.isArray(source[key])) {
|
|
1586
|
+
if (!Array.isArray(target[key])) {
|
|
1587
|
+
target[key] = source[key].map(i => (isObject(i) ? objectDeepMerge({}, i) : i));
|
|
1614
1588
|
}
|
|
1615
1589
|
}
|
|
1616
|
-
|
|
1590
|
+
else if (typeof target[key] === 'undefined') {
|
|
1591
|
+
target[key] = source[key];
|
|
1592
|
+
}
|
|
1617
1593
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1594
|
+
return target;
|
|
1595
|
+
}
|
|
1596
|
+
function isObject(obj) {
|
|
1597
|
+
return typeof obj === 'object' && obj !== null && !Array.isArray(obj);
|
|
1598
|
+
}
|
|
1599
|
+
function handleProp(prop, options) {
|
|
1600
|
+
if (Array.isArray(prop)) {
|
|
1601
|
+
return prop.map(i => objectDeepCopy(i, options));
|
|
1620
1602
|
}
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
return prop.map(i => ObjectUtil.deepCopy(i, options));
|
|
1624
|
-
}
|
|
1625
|
-
else if (typeof prop === 'object' && prop !== null) {
|
|
1626
|
-
return ObjectUtil.deepCopy(prop, options);
|
|
1627
|
-
}
|
|
1628
|
-
else {
|
|
1629
|
-
return prop;
|
|
1630
|
-
}
|
|
1603
|
+
else if (typeof prop === 'object' && prop !== null) {
|
|
1604
|
+
return objectDeepCopy(prop, options);
|
|
1631
1605
|
}
|
|
1632
|
-
|
|
1633
|
-
return
|
|
1606
|
+
else {
|
|
1607
|
+
return prop;
|
|
1634
1608
|
}
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1609
|
+
}
|
|
1610
|
+
function getObjectProperties(obj) {
|
|
1611
|
+
return Object.keys(obj);
|
|
1612
|
+
}
|
|
1613
|
+
function getObjectGetters(obj) {
|
|
1614
|
+
const getterSet = new Set();
|
|
1615
|
+
let currObj = obj;
|
|
1616
|
+
while (currObj) {
|
|
1617
|
+
const getters = Object.entries(Object.getOwnPropertyDescriptors(currObj))
|
|
1618
|
+
.filter(([, descriptor]) => typeof descriptor.get === 'function')
|
|
1619
|
+
.filter(([key]) => key !== '__proto__')
|
|
1620
|
+
.map(([key]) => key);
|
|
1621
|
+
for (const getter of getters) {
|
|
1622
|
+
getterSet.add(getter);
|
|
1623
|
+
}
|
|
1624
|
+
currObj = Object.getPrototypeOf(currObj);
|
|
1625
|
+
}
|
|
1626
|
+
return Array.from(getterSet);
|
|
1627
|
+
}
|
|
1628
|
+
function getObjectPropertyByPath(value, path) {
|
|
1629
|
+
if (path === '$') {
|
|
1630
|
+
// only return the root
|
|
1631
|
+
return value;
|
|
1649
1632
|
}
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
const
|
|
1675
|
-
if (
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
if (Array.isArray(array)) {
|
|
1681
|
-
if (arrayIdx >= 0 && arrayIdx < array.length) {
|
|
1682
|
-
// valid index, continue on the path
|
|
1683
|
-
currValue = array[arrayIdx];
|
|
1684
|
-
continue;
|
|
1685
|
-
}
|
|
1633
|
+
// Check for leading root object notation
|
|
1634
|
+
if (path.startsWith('$')) {
|
|
1635
|
+
path = path.substring(1);
|
|
1636
|
+
}
|
|
1637
|
+
// Check for leading .
|
|
1638
|
+
if (path.startsWith('.')) {
|
|
1639
|
+
path = path.substring(1);
|
|
1640
|
+
}
|
|
1641
|
+
if (path.indexOf('.') >= 0) {
|
|
1642
|
+
const pathSplit = path.split('.');
|
|
1643
|
+
let currValue = value;
|
|
1644
|
+
for (const p of pathSplit) {
|
|
1645
|
+
if (typeof currValue === 'undefined' || currValue === null) {
|
|
1646
|
+
return currValue;
|
|
1647
|
+
}
|
|
1648
|
+
if (!p.length) {
|
|
1649
|
+
// empty path, return current value
|
|
1650
|
+
return currValue;
|
|
1651
|
+
}
|
|
1652
|
+
const leftBracketIdx = p.indexOf('[');
|
|
1653
|
+
if (leftBracketIdx >= 0 && p.endsWith(']')) {
|
|
1654
|
+
// should be reference to array
|
|
1655
|
+
const arrayPath = p.substring(0, leftBracketIdx);
|
|
1656
|
+
const arrayIdx = +p.substring(leftBracketIdx + 1, p.length - 1);
|
|
1657
|
+
const array = currValue[arrayPath];
|
|
1658
|
+
if (Array.isArray(array)) {
|
|
1659
|
+
if (arrayIdx >= 0 && arrayIdx < array.length) {
|
|
1660
|
+
// valid index, continue on the path
|
|
1661
|
+
currValue = array[arrayIdx];
|
|
1662
|
+
continue;
|
|
1686
1663
|
}
|
|
1687
|
-
return undefined;
|
|
1688
|
-
}
|
|
1689
|
-
else if (typeof currValue === 'object') {
|
|
1690
|
-
currValue = currValue[p];
|
|
1691
1664
|
}
|
|
1665
|
+
return undefined;
|
|
1666
|
+
}
|
|
1667
|
+
else if (typeof currValue === 'object') {
|
|
1668
|
+
currValue = currValue[p];
|
|
1692
1669
|
}
|
|
1693
|
-
return currValue;
|
|
1694
|
-
}
|
|
1695
|
-
else {
|
|
1696
|
-
return value[path];
|
|
1697
1670
|
}
|
|
1671
|
+
return currValue;
|
|
1698
1672
|
}
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
let results = [];
|
|
1702
|
-
for (const key in object) {
|
|
1703
|
-
const value = object[key];
|
|
1704
|
-
const thisKey = parent ? `${parent}.${key}` : `${key}`;
|
|
1705
|
-
results = results.concat(ObjectUtil.isObject(value) ? flatten(value, thisKey) : [[`${thisKey}`, value]]);
|
|
1706
|
-
}
|
|
1707
|
-
return results;
|
|
1708
|
-
};
|
|
1709
|
-
return flatten(objectModel);
|
|
1673
|
+
else {
|
|
1674
|
+
return value[path];
|
|
1710
1675
|
}
|
|
1711
1676
|
}
|
|
1677
|
+
function flattenObjectKeys(objectModel) {
|
|
1678
|
+
const flatten = (object, parent) => {
|
|
1679
|
+
let results = [];
|
|
1680
|
+
for (const key in object) {
|
|
1681
|
+
const value = object[key];
|
|
1682
|
+
const thisKey = parent ? `${parent}.${key}` : `${key}`;
|
|
1683
|
+
results = results.concat(isObject(value) ? flatten(value, thisKey) : [[`${thisKey}`, value]]);
|
|
1684
|
+
}
|
|
1685
|
+
return results;
|
|
1686
|
+
};
|
|
1687
|
+
return flatten(objectModel);
|
|
1688
|
+
}
|
|
1712
1689
|
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
return StringUtil.escapeHtml(value);
|
|
1720
|
-
}
|
|
1721
|
-
else if (typeof value === 'object') {
|
|
1722
|
-
const escapedValue = ObjectUtil.deepCopy(value, { mapGettersToProperties: true });
|
|
1723
|
-
for (const key in value) {
|
|
1724
|
-
if (typeof value[key] === 'string') {
|
|
1725
|
-
escapedValue[key] = StringUtil.escapeHtml(value[key]);
|
|
1726
|
-
}
|
|
1727
|
-
else if (typeof value[key] === 'object') {
|
|
1728
|
-
escapedValue[key] = StringUtil.escapeHtmlAny(value[key]);
|
|
1729
|
-
}
|
|
1730
|
-
else {
|
|
1731
|
-
escapedValue[key] = value[key];
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
return escapedValue;
|
|
1735
|
-
}
|
|
1736
|
-
return value;
|
|
1690
|
+
function escapeHtml(value) {
|
|
1691
|
+
return value.replace(/</g, '<').replace(/>/g, '>');
|
|
1692
|
+
}
|
|
1693
|
+
function escapeHtmlAny(value) {
|
|
1694
|
+
if (typeof value === 'string') {
|
|
1695
|
+
return escapeHtml(value);
|
|
1737
1696
|
}
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
if (value === null) {
|
|
1744
|
-
return 'null';
|
|
1745
|
-
}
|
|
1746
|
-
if (typeof value === 'undefined') {
|
|
1747
|
-
return 'undefined';
|
|
1748
|
-
}
|
|
1749
|
-
// eliminate functions, cause they could fall into objects
|
|
1750
|
-
if (typeof value === 'function') {
|
|
1751
|
-
return `Function ${value.name ?? 'anonymous'}()`;
|
|
1752
|
-
}
|
|
1753
|
-
if (typeof value === 'object') {
|
|
1754
|
-
// date is object, but would like it in ISO string representation
|
|
1755
|
-
if (value instanceof Date) {
|
|
1756
|
-
return DateUtil.toIsoString(value) ?? 'null';
|
|
1697
|
+
else if (typeof value === 'object') {
|
|
1698
|
+
const escapedValue = objectDeepCopy(value, { mapGettersToProperties: true });
|
|
1699
|
+
for (const key in value) {
|
|
1700
|
+
if (typeof value[key] === 'string') {
|
|
1701
|
+
escapedValue[key] = escapeHtml(value[key]);
|
|
1757
1702
|
}
|
|
1758
|
-
|
|
1759
|
-
|
|
1703
|
+
else if (typeof value[key] === 'object') {
|
|
1704
|
+
escapedValue[key] = escapeHtmlAny(value[key]);
|
|
1760
1705
|
}
|
|
1761
|
-
|
|
1762
|
-
|
|
1706
|
+
else {
|
|
1707
|
+
escapedValue[key] = value[key];
|
|
1763
1708
|
}
|
|
1764
1709
|
}
|
|
1765
|
-
|
|
1766
|
-
return value.toString();
|
|
1710
|
+
return escapedValue;
|
|
1767
1711
|
}
|
|
1712
|
+
return value;
|
|
1768
1713
|
}
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
*/
|
|
1777
|
-
static fromSubscribeError(error, name, details) {
|
|
1778
|
-
const opts = {
|
|
1779
|
-
name,
|
|
1780
|
-
details,
|
|
1781
|
-
location: window?.location?.href
|
|
1782
|
-
};
|
|
1783
|
-
if (error instanceof HttpErrorResponse) {
|
|
1784
|
-
return new CommonsHttpError(error.message ?? 'Http Error occurred', error, opts);
|
|
1785
|
-
}
|
|
1786
|
-
else {
|
|
1787
|
-
opts.cause = error;
|
|
1788
|
-
return new CommonsInternalError(error.message ?? 'Internal Error occurred', opts);
|
|
1789
|
-
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Stringifies a value - primitives with toString, dates with dateUtil, objects with JSON.stringify.
|
|
1716
|
+
* @param value Any value.
|
|
1717
|
+
*/
|
|
1718
|
+
function stringify(value) {
|
|
1719
|
+
if (value === null) {
|
|
1720
|
+
return 'null';
|
|
1790
1721
|
}
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
* @param error
|
|
1794
|
-
*/
|
|
1795
|
-
static isHttpErrorResponse(error) {
|
|
1796
|
-
return error instanceof HttpErrorResponse || error instanceof CommonsHttpError || error?.httpError instanceof HttpErrorResponse;
|
|
1722
|
+
if (typeof value === 'undefined') {
|
|
1723
|
+
return 'undefined';
|
|
1797
1724
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1725
|
+
// eliminate functions, cause they could fall into objects
|
|
1726
|
+
if (typeof value === 'function') {
|
|
1727
|
+
return `Function ${value.name ?? 'anonymous'}()`;
|
|
1728
|
+
}
|
|
1729
|
+
if (typeof value === 'object') {
|
|
1730
|
+
// date is object, but would like it in ISO string representation
|
|
1731
|
+
if (value instanceof Date) {
|
|
1732
|
+
return dateToIsoString(value) ?? 'null';
|
|
1805
1733
|
}
|
|
1806
|
-
|
|
1807
|
-
return
|
|
1734
|
+
try {
|
|
1735
|
+
return JSON.stringify(value);
|
|
1808
1736
|
}
|
|
1809
|
-
|
|
1810
|
-
return
|
|
1811
|
-
}
|
|
1812
|
-
else {
|
|
1813
|
-
return null;
|
|
1737
|
+
catch (e) {
|
|
1738
|
+
return value.toString();
|
|
1814
1739
|
}
|
|
1815
1740
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1741
|
+
// only primitives should be left to be printed like this (string, number, boolean)
|
|
1742
|
+
return value.toString();
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
/**
|
|
1746
|
+
* Converts RxJS subscription error to CommonsError.
|
|
1747
|
+
* @param error Error.
|
|
1748
|
+
* @param name Optional name to write in commons error.
|
|
1749
|
+
* @param details Optional details of error.
|
|
1750
|
+
*/
|
|
1751
|
+
function fromSubscribeError(error, name, details) {
|
|
1752
|
+
const opts = {
|
|
1753
|
+
name,
|
|
1754
|
+
details,
|
|
1755
|
+
location: window?.location?.href
|
|
1756
|
+
};
|
|
1757
|
+
if (error instanceof HttpErrorResponse) {
|
|
1758
|
+
return new CommonsHttpError(error.message ?? 'Http Error occurred', error, opts);
|
|
1822
1759
|
}
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
*/
|
|
1827
|
-
static getErrorLogLevel(error) {
|
|
1828
|
-
if (ErrorUtil.isHttpErrorResponse(error)) {
|
|
1829
|
-
const status = ErrorUtil.getHttpErrorResponseStatus(error);
|
|
1830
|
-
if (status && status >= 400 && status < 500) {
|
|
1831
|
-
return LogLevelEnum.Warning;
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
return LogLevelEnum.Error;
|
|
1760
|
+
else {
|
|
1761
|
+
opts.cause = error;
|
|
1762
|
+
return new CommonsInternalError(error.message ?? 'Internal Error occurred', opts);
|
|
1835
1763
|
}
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Checks if error is Http error (Angular or Commons).
|
|
1767
|
+
* @param error
|
|
1768
|
+
*/
|
|
1769
|
+
function isHttpErrorResponse(error) {
|
|
1770
|
+
return error instanceof HttpErrorResponse || error instanceof CommonsHttpError || error?.httpError instanceof HttpErrorResponse;
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* Gets HttpErrorResponse from error (Angular or Commons).
|
|
1774
|
+
* @param error Error.
|
|
1775
|
+
*/
|
|
1776
|
+
function getHttpErrorResponse(error) {
|
|
1777
|
+
if (error instanceof HttpErrorResponse) {
|
|
1778
|
+
return error;
|
|
1847
1779
|
}
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
* @param error Http response error.
|
|
1851
|
-
* @param opts Options for hiding parts of error:
|
|
1852
|
-
* - hideMessage Hides message of error (message include url, status and status text!).
|
|
1853
|
-
* - hideHeaders Hides headers.
|
|
1854
|
-
* - hideBody Hides JSON representation of body.
|
|
1855
|
-
*/
|
|
1856
|
-
static httpErrorResponseToString(error, opts) {
|
|
1857
|
-
let str = opts?.hideMessage ? '' : `${error.message}\n`; // message should already include url, status, etc.
|
|
1858
|
-
if (!opts?.hideHeaders) {
|
|
1859
|
-
str += `Http Response Headers: ${error.headers.keys().reduce((acc, key) => `${acc}[${key}: ${error.headers.get(key)}]`, '')}`;
|
|
1860
|
-
}
|
|
1861
|
-
if (!opts?.hideBody) {
|
|
1862
|
-
str += `\nHttp Response Body: ${StringUtil.stringify(error.error)}`;
|
|
1863
|
-
}
|
|
1864
|
-
return str;
|
|
1780
|
+
else if (error instanceof CommonsHttpError) {
|
|
1781
|
+
return error.httpError;
|
|
1865
1782
|
}
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
* @param error Error.
|
|
1869
|
-
* @param opts Options for hiding parts of error:
|
|
1870
|
-
* - hideMessage Hides message of error.
|
|
1871
|
-
* - hideName Hides error name.
|
|
1872
|
-
* - hideCause Hides cause of an error (if present, see @link(errorCauseToString) for other options).
|
|
1873
|
-
* - hideStack Hides stack of an error (if present).
|
|
1874
|
-
* - hideDetails Hides JSON detail's representation of error (if present).
|
|
1875
|
-
* - hideLocation Hides location (URL) where error was thrown.
|
|
1876
|
-
* - hideHttp Hides http error portion of error if http error response (see @link(httpErrorResponseToString) for other options).
|
|
1877
|
-
*/
|
|
1878
|
-
static errorToString(error, opts) {
|
|
1879
|
-
if (error instanceof ACommonsErrorBase) {
|
|
1880
|
-
return ErrorUtil.commonsErrorToString(error, opts);
|
|
1881
|
-
}
|
|
1882
|
-
else if (error instanceof HttpErrorResponse) {
|
|
1883
|
-
return ErrorUtil.httpErrorResponseToString(error, opts);
|
|
1884
|
-
}
|
|
1885
|
-
const strBlocks = [];
|
|
1886
|
-
if (!opts?.hideMessage) {
|
|
1887
|
-
strBlocks.push(error.message);
|
|
1888
|
-
}
|
|
1889
|
-
if (error.name) {
|
|
1890
|
-
strBlocks.push(`Error name: ${error.name}`);
|
|
1891
|
-
}
|
|
1892
|
-
if (!opts?.hideCause) {
|
|
1893
|
-
strBlocks.push(ErrorUtil.errorCauseToString(error, opts));
|
|
1894
|
-
}
|
|
1895
|
-
if (!opts?.hideStack && error.stack) {
|
|
1896
|
-
strBlocks.push(`Stack trace:\n${error.stack}`);
|
|
1897
|
-
}
|
|
1898
|
-
return strBlocks.filter(s => s.trim().length > 0).join('\n');
|
|
1783
|
+
else if (error?.httpError instanceof HttpErrorResponse) {
|
|
1784
|
+
return error.httpError;
|
|
1899
1785
|
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
if (!opts?.hideName) {
|
|
1921
|
-
strBlocks.push(`Error name: ${error.name ?? error.type} ${error.name ? `(${error.type})` : ''}`);
|
|
1786
|
+
else {
|
|
1787
|
+
return null;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
/**
|
|
1791
|
+
* Gets HttpErrorResponse status from error (Angular or Commons).
|
|
1792
|
+
* @param error Error.
|
|
1793
|
+
*/
|
|
1794
|
+
function getHttpErrorResponseStatus(error) {
|
|
1795
|
+
return getHttpErrorResponse(error)?.status ?? null;
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* Get error log level. All is error, except if error is http error with status >=400 and <500.
|
|
1799
|
+
* @param error Error.
|
|
1800
|
+
*/
|
|
1801
|
+
function getErrorLogLevel(error) {
|
|
1802
|
+
if (isHttpErrorResponse(error)) {
|
|
1803
|
+
const status = getHttpErrorResponseStatus(error);
|
|
1804
|
+
if (status && status >= 400 && status < 500) {
|
|
1805
|
+
return LogLevelEnum.Warning;
|
|
1922
1806
|
}
|
|
1923
|
-
|
|
1924
|
-
|
|
1807
|
+
}
|
|
1808
|
+
return LogLevelEnum.Error;
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* Get error name (prototype name or type from commons error if name is not provided).
|
|
1812
|
+
* @param error Error.
|
|
1813
|
+
*/
|
|
1814
|
+
function getErrorName(error) {
|
|
1815
|
+
if (error instanceof ACommonsErrorBase) {
|
|
1816
|
+
return error.name ?? error.type;
|
|
1817
|
+
}
|
|
1818
|
+
else {
|
|
1819
|
+
return error.name;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Writes http error to string with all headers and body.
|
|
1824
|
+
* @param error Http response error.
|
|
1825
|
+
* @param opts Options for hiding parts of error:
|
|
1826
|
+
* - hideMessage Hides message of error (message include url, status and status text!).
|
|
1827
|
+
* - hideHeaders Hides headers.
|
|
1828
|
+
* - hideBody Hides JSON representation of body.
|
|
1829
|
+
*/
|
|
1830
|
+
function httpErrorResponseToString(error, opts) {
|
|
1831
|
+
let str = opts?.hideMessage ? '' : `${error.message}\n`; // message should already include url, status, etc.
|
|
1832
|
+
if (!opts?.hideHeaders) {
|
|
1833
|
+
str += `Http Response Headers: ${error.headers.keys().reduce((acc, key) => `${acc}[${key}: ${error.headers.get(key)}]`, '')}`;
|
|
1834
|
+
}
|
|
1835
|
+
if (!opts?.hideBody) {
|
|
1836
|
+
str += `\nHttp Response Body: ${stringify(error.error)}`;
|
|
1837
|
+
}
|
|
1838
|
+
return str;
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* Error to string.
|
|
1842
|
+
* @param error Error.
|
|
1843
|
+
* @param opts Options for hiding parts of error:
|
|
1844
|
+
* - hideMessage Hides message of error.
|
|
1845
|
+
* - hideName Hides error name.
|
|
1846
|
+
* - hideCause Hides cause of an error (if present, see @link(errorCauseToString) for other options).
|
|
1847
|
+
* - hideStack Hides stack of an error (if present).
|
|
1848
|
+
* - hideDetails Hides JSON detail's representation of error (if present).
|
|
1849
|
+
* - hideLocation Hides location (URL) where error was thrown.
|
|
1850
|
+
* - hideHttp Hides http error portion of error if http error response (see @link(httpErrorResponseToString) for other options).
|
|
1851
|
+
*/
|
|
1852
|
+
function errorToString(error, opts) {
|
|
1853
|
+
if (error instanceof ACommonsErrorBase) {
|
|
1854
|
+
return commonsErrorToString(error, opts);
|
|
1855
|
+
}
|
|
1856
|
+
else if (error instanceof HttpErrorResponse) {
|
|
1857
|
+
return httpErrorResponseToString(error, opts);
|
|
1858
|
+
}
|
|
1859
|
+
const strBlocks = [];
|
|
1860
|
+
if (!opts?.hideMessage) {
|
|
1861
|
+
strBlocks.push(error.message);
|
|
1862
|
+
}
|
|
1863
|
+
if (error.name) {
|
|
1864
|
+
strBlocks.push(`Error name: ${error.name}`);
|
|
1865
|
+
}
|
|
1866
|
+
if (!opts?.hideCause) {
|
|
1867
|
+
strBlocks.push(errorCauseToString(error, opts));
|
|
1868
|
+
}
|
|
1869
|
+
if (!opts?.hideStack && error.stack) {
|
|
1870
|
+
strBlocks.push(`Stack trace:\n${error.stack}`);
|
|
1871
|
+
}
|
|
1872
|
+
return strBlocks.filter(s => s.trim().length > 0).join('\n');
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Commons error to string.
|
|
1876
|
+
* @param error Commons error.
|
|
1877
|
+
* @param opts Options for hiding parts of error:
|
|
1878
|
+
* - hideMessage Hides message of error.
|
|
1879
|
+
* - hideName Hides error name.
|
|
1880
|
+
* - hideCause Hides cause of an error (if present, see @link(errorCauseToString) for other options).
|
|
1881
|
+
* - hideStack Hides stack of an error (if present).
|
|
1882
|
+
* - hideDetails Hides JSON detail's representation of error (if present).
|
|
1883
|
+
* - hideLocation Hides location (URL) where error was thrown.
|
|
1884
|
+
* - hideHttp Hides http error portion of error if http error response (see @link(httpErrorResponseToString) for other options).
|
|
1885
|
+
* - hideItems Hides all item information (http body, action context data).
|
|
1886
|
+
* - hideActionData See @link(commonsActionErrorContextToString) for additional info.
|
|
1887
|
+
* - hideQueryParams See @link(commonsActionErrorContextToString) for additional info.
|
|
1888
|
+
*/
|
|
1889
|
+
function commonsErrorToString(error, opts) {
|
|
1890
|
+
const strBlocks = [];
|
|
1891
|
+
if (!opts?.hideMessage) {
|
|
1892
|
+
strBlocks.push(`${error.message}${error.messageCode ? ` (code: ${error.messageCode})` : ''}`);
|
|
1893
|
+
}
|
|
1894
|
+
if (!opts?.hideName) {
|
|
1895
|
+
strBlocks.push(`Error name: ${error.name ?? error.type} ${error.name ? `(${error.type})` : ''}`);
|
|
1896
|
+
}
|
|
1897
|
+
if (!opts?.hideLocation && error.location) {
|
|
1898
|
+
strBlocks.push(`Location: ${error.location}`);
|
|
1899
|
+
}
|
|
1900
|
+
let isHttp = false;
|
|
1901
|
+
if (!opts?.hideHttp && error instanceof CommonsHttpError) {
|
|
1902
|
+
strBlocks.push(httpErrorResponseToString(error.httpError, {
|
|
1903
|
+
hideBody: opts?.hideItems || opts?.hideBody,
|
|
1904
|
+
hideHeaders: opts?.hideHeaders,
|
|
1905
|
+
hideMessage: error.message.indexOf(error.httpError.message) >= 0
|
|
1906
|
+
}));
|
|
1907
|
+
isHttp = true;
|
|
1908
|
+
}
|
|
1909
|
+
if (error.type === 'CommonsActionError') {
|
|
1910
|
+
const actionError = error;
|
|
1911
|
+
if (actionError.actionContext) {
|
|
1912
|
+
strBlocks.push(commonsActionErrorContextToString(actionError, opts));
|
|
1925
1913
|
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
strBlocks.push(ErrorUtil.httpErrorResponseToString(error.httpError, {
|
|
1914
|
+
if (!opts?.hideHttp && actionError.httpError instanceof HttpErrorResponse) {
|
|
1915
|
+
strBlocks.push(httpErrorResponseToString(actionError.httpError, {
|
|
1929
1916
|
hideBody: opts?.hideItems || opts?.hideBody,
|
|
1930
1917
|
hideHeaders: opts?.hideHeaders,
|
|
1931
|
-
hideMessage: error.message.indexOf(
|
|
1918
|
+
hideMessage: error.message.indexOf(actionError.httpError.message) >= 0
|
|
1932
1919
|
}));
|
|
1933
1920
|
isHttp = true;
|
|
1934
1921
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1922
|
+
}
|
|
1923
|
+
if (!opts?.hideDetails && error.details) {
|
|
1924
|
+
strBlocks.push(`Details: ${stringify(error.details)}`);
|
|
1925
|
+
}
|
|
1926
|
+
if (!opts?.hideCause && (!isHttp || !(error.cause instanceof HttpErrorResponse))) {
|
|
1927
|
+
strBlocks.push(errorCauseToString(error, opts));
|
|
1928
|
+
}
|
|
1929
|
+
if (!opts?.hideStack && error.stack) {
|
|
1930
|
+
strBlocks.push(`Stack trace:\n${error.stack}`);
|
|
1931
|
+
}
|
|
1932
|
+
return strBlocks.filter(s => s.trim().length > 0).join('\n');
|
|
1933
|
+
}
|
|
1934
|
+
/**
|
|
1935
|
+
* Writes commons action error info from context as string.
|
|
1936
|
+
* @param error Commons action error.
|
|
1937
|
+
* @param opts Options for hiding parts of error:
|
|
1938
|
+
* - hideItems Hides all item related information (item, form item, submit item, ...).
|
|
1939
|
+
* - hideActionData Hides action data.
|
|
1940
|
+
* - hideQueryParams Hides query params.
|
|
1941
|
+
*/
|
|
1942
|
+
function commonsActionErrorContextToString(error, opts) {
|
|
1943
|
+
let paramsMessage = '';
|
|
1944
|
+
if (error.actionContext?.parameters) {
|
|
1945
|
+
if (error.actionContext?.parameters.itemId) {
|
|
1946
|
+
paramsMessage += `[itemId: ${error.actionContext.parameters.itemId}]`;
|
|
1948
1947
|
}
|
|
1949
|
-
if (!opts?.
|
|
1950
|
-
|
|
1948
|
+
if (!opts?.hideItems && error.actionContext?.parameters.item) {
|
|
1949
|
+
paramsMessage += `[item: ${stringify(error.actionContext.parameters.item)}]`;
|
|
1951
1950
|
}
|
|
1952
|
-
if (!opts?.
|
|
1953
|
-
|
|
1951
|
+
if (!opts?.hideActionData && error.actionContext?.parameters.actionData) {
|
|
1952
|
+
paramsMessage += Object.entries(error.actionContext?.parameters.actionData).reduce((acc, [key, value]) => `${acc}[actionData ${key}: ${stringify(value)}]`, '');
|
|
1954
1953
|
}
|
|
1955
|
-
if (!opts?.
|
|
1956
|
-
|
|
1954
|
+
if (!opts?.hideQueryParams && error.actionContext?.parameters.dataListParams) {
|
|
1955
|
+
paramsMessage += `[dataListParams: ${stringify(error.actionContext.parameters.dataListParams)}]`;
|
|
1957
1956
|
}
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
* - hideQueryParams Hides query params.
|
|
1967
|
-
*/
|
|
1968
|
-
static commonsActionErrorContextToString(error, opts) {
|
|
1969
|
-
let paramsMessage = '';
|
|
1970
|
-
if (error.actionContext?.parameters) {
|
|
1971
|
-
if (error.actionContext?.parameters.itemId) {
|
|
1972
|
-
paramsMessage += `[itemId: ${error.actionContext.parameters.itemId}]`;
|
|
1973
|
-
}
|
|
1974
|
-
if (!opts?.hideItems && error.actionContext?.parameters.item) {
|
|
1975
|
-
paramsMessage += `[item: ${StringUtil.stringify(error.actionContext.parameters.item)}]`;
|
|
1976
|
-
}
|
|
1977
|
-
if (!opts?.hideActionData && error.actionContext?.parameters.actionData) {
|
|
1978
|
-
paramsMessage += Object.entries(error.actionContext?.parameters.actionData).reduce((acc, [key, value]) => `${acc}[actionData ${key}: ${StringUtil.stringify(value)}]`, '');
|
|
1979
|
-
}
|
|
1980
|
-
if (!opts?.hideQueryParams && error.actionContext?.parameters.dataListParams) {
|
|
1981
|
-
paramsMessage += `[dataListParams: ${StringUtil.stringify(error.actionContext.parameters.dataListParams)}]`;
|
|
1982
|
-
}
|
|
1983
|
-
if (!opts?.hideItems && error.actionContext?.parameters.formItem) {
|
|
1984
|
-
paramsMessage += `[formItem: ${StringUtil.stringify(error.actionContext.parameters.formItem)}]`;
|
|
1985
|
-
}
|
|
1986
|
-
if (!opts?.hideItems && error.actionContext?.parameters.submitResult) {
|
|
1987
|
-
paramsMessage += `[formItem: ${StringUtil.stringify(error.actionContext.parameters.submitResult)}]`;
|
|
1988
|
-
}
|
|
1989
|
-
if (error.actionContext?.parameters.locale) {
|
|
1990
|
-
paramsMessage += `[locale: ${StringUtil.stringify(error.actionContext.parameters.locale)}]`;
|
|
1991
|
-
}
|
|
1957
|
+
if (!opts?.hideItems && error.actionContext?.parameters.formItem) {
|
|
1958
|
+
paramsMessage += `[formItem: ${stringify(error.actionContext.parameters.formItem)}]`;
|
|
1959
|
+
}
|
|
1960
|
+
if (!opts?.hideItems && error.actionContext?.parameters.submitResult) {
|
|
1961
|
+
paramsMessage += `[formItem: ${stringify(error.actionContext.parameters.submitResult)}]`;
|
|
1962
|
+
}
|
|
1963
|
+
if (error.actionContext?.parameters.locale) {
|
|
1964
|
+
paramsMessage += `[locale: ${stringify(error.actionContext.parameters.locale)}]`;
|
|
1992
1965
|
}
|
|
1993
|
-
return paramsMessage;
|
|
1994
1966
|
}
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
1967
|
+
return paramsMessage;
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Writes cause of an error as string.
|
|
1971
|
+
* @param error Error.
|
|
1972
|
+
* @param opts Options for hiding parts of error:
|
|
1973
|
+
* - causeOnErrorOnly Prints only if cause is instance of error.
|
|
1974
|
+
* - causeAsJson Print error cause as a JSON (by default, if error only message and name will be printed).
|
|
1975
|
+
*/
|
|
1976
|
+
function errorCauseToString(error, opts) {
|
|
1977
|
+
// if already logged as http error, check that cause is not also http error (cause it is usually duplicated)
|
|
1978
|
+
if (error.cause && (!opts?.causeOnErrorOnly || error.cause instanceof Error)) {
|
|
1979
|
+
const needsStringify = opts?.causeAsJson || !(error.cause instanceof Error);
|
|
1980
|
+
if (!opts?.causeOnErrorOnly || error.cause instanceof Error) {
|
|
1981
|
+
return ('Caused by: ' +
|
|
1982
|
+
(needsStringify ? stringify(error.cause) : `${error.cause.message}${error.cause.name ? ` (${error.cause.name})` : ''}`));
|
|
2010
1983
|
}
|
|
2011
|
-
return '';
|
|
2012
1984
|
}
|
|
1985
|
+
return '';
|
|
2013
1986
|
}
|
|
2014
1987
|
|
|
2015
1988
|
class CommonsErrorHandler {
|
|
@@ -2019,7 +1992,7 @@ class CommonsErrorHandler {
|
|
|
2019
1992
|
static { this.logCategory = 'ErrorHandler'; }
|
|
2020
1993
|
handleError(error) {
|
|
2021
1994
|
if (error instanceof ACommonsErrorBase || error instanceof HttpErrorResponse) {
|
|
2022
|
-
const logLevel =
|
|
1995
|
+
const logLevel = getErrorLogLevel(error);
|
|
2023
1996
|
this.logger.log(error, logLevel);
|
|
2024
1997
|
}
|
|
2025
1998
|
else {
|
|
@@ -2083,6 +2056,250 @@ function toastMessage(messageService, title, message, severity = 'success', icon
|
|
|
2083
2056
|
return notification;
|
|
2084
2057
|
}
|
|
2085
2058
|
|
|
2059
|
+
function removeRouteEmptyPathSegments(path) {
|
|
2060
|
+
const filteredPath = path.filter(ps => typeof ps === 'string' && ps.length > 0);
|
|
2061
|
+
return filteredPath.length > 0 ? filteredPath : [''];
|
|
2062
|
+
}
|
|
2063
|
+
function appendRoutePathToBasePath(basePath, path) {
|
|
2064
|
+
if (path.length > 0) {
|
|
2065
|
+
if (path[0].startsWith('/')) {
|
|
2066
|
+
return path;
|
|
2067
|
+
}
|
|
2068
|
+
else if (path[0].startsWith('../')) {
|
|
2069
|
+
throw new CommonsInternalError('Not implemented', { name: 'RouteUtilsError' });
|
|
2070
|
+
}
|
|
2071
|
+
else {
|
|
2072
|
+
return removeRouteEmptyPathSegments([...basePath, ...path]);
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
else {
|
|
2076
|
+
return basePath;
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
function doesUrlMatchRouterLink(link, url) {
|
|
2080
|
+
if (typeof url === 'string' && url.startsWith('/')) {
|
|
2081
|
+
url = url.substring(1);
|
|
2082
|
+
}
|
|
2083
|
+
else if (Array.isArray(url) && url.length > 0 && url[0].startsWith('/')) {
|
|
2084
|
+
url[0] = url[0].substring(1);
|
|
2085
|
+
}
|
|
2086
|
+
const routeSegments = Array.isArray(link) ? link : link.split('/');
|
|
2087
|
+
const urlSegments = Array.isArray(url) ? url : url.split('#')[0].split('?')[0].split('/');
|
|
2088
|
+
if (routeSegments.length > 0 && urlSegments.length > 0) {
|
|
2089
|
+
for (let i = 0; i < routeSegments.length; i++) {
|
|
2090
|
+
if (i < urlSegments.length) {
|
|
2091
|
+
if (routeSegments[i] !== urlSegments[i]) {
|
|
2092
|
+
return false;
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
else {
|
|
2096
|
+
break;
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
return true;
|
|
2100
|
+
}
|
|
2101
|
+
return false;
|
|
2102
|
+
}
|
|
2103
|
+
function adjustRouteMenuLazyChildrenRouterLinks(rootMenuItem, lazyChildren) {
|
|
2104
|
+
return lazyChildren.map(i => {
|
|
2105
|
+
const childMenuItem = { ...i };
|
|
2106
|
+
if (childMenuItem.routerLink) {
|
|
2107
|
+
childMenuItem.routerLink = appendRoutePathToBasePath(rootMenuItem.routerLink, typeof childMenuItem.routerLink === 'string' ? [childMenuItem.routerLink] : childMenuItem.routerLink);
|
|
2108
|
+
}
|
|
2109
|
+
if (Array.isArray(childMenuItem.items)) {
|
|
2110
|
+
childMenuItem.items = adjustRouteMenuLazyChildrenRouterLinks(rootMenuItem, childMenuItem.items);
|
|
2111
|
+
}
|
|
2112
|
+
return childMenuItem;
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
function findTemplateByName(templates, name) {
|
|
2117
|
+
return templates.find(t => t.getType() === name)?.template ?? null;
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
function getI18nAsync(translate, params, ...keys) {
|
|
2121
|
+
return translate.stream(keys, params).pipe(map(i18n => selectI18n(keys, i18n)));
|
|
2122
|
+
}
|
|
2123
|
+
function getI18n(translate, params, ...keys) {
|
|
2124
|
+
const i18n = translate.instant(keys, params);
|
|
2125
|
+
return selectI18n(keys, i18n);
|
|
2126
|
+
}
|
|
2127
|
+
function populateI18nParams(item, params = {}) {
|
|
2128
|
+
const paramsRes = { ...params };
|
|
2129
|
+
if (item) {
|
|
2130
|
+
paramsRes.item = item;
|
|
2131
|
+
}
|
|
2132
|
+
return paramsRes;
|
|
2133
|
+
}
|
|
2134
|
+
function selectI18n(keys, i18n) {
|
|
2135
|
+
for (const key of keys) {
|
|
2136
|
+
if (key !== i18n[key]) {
|
|
2137
|
+
return i18n[key];
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
return null;
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
function getI18nForError(translate, error, params = {}) {
|
|
2144
|
+
const i18nParams = getI18nErrorParams(error, params);
|
|
2145
|
+
if (error.messageCode) {
|
|
2146
|
+
const keys = [`errors.${error.messageCode}`, `messages.${error.messageCode}`];
|
|
2147
|
+
const i18n = getI18n(translate, i18nParams, ...keys);
|
|
2148
|
+
if (i18n) {
|
|
2149
|
+
return i18n;
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
return getI18n(translate, i18nParams, error.message);
|
|
2153
|
+
}
|
|
2154
|
+
function getI18nErrorParams(error, params = {}) {
|
|
2155
|
+
const paramsRes = { ...params };
|
|
2156
|
+
paramsRes.errorStatus = '';
|
|
2157
|
+
paramsRes.errorMessage = '';
|
|
2158
|
+
if (isHttpErrorResponse(error)) {
|
|
2159
|
+
const httpError = getHttpErrorResponse(error);
|
|
2160
|
+
paramsRes.errorStatus = httpError?.status;
|
|
2161
|
+
paramsRes.errorMessage = httpError?.message;
|
|
2162
|
+
paramsRes.errorStatusDescription = httpError?.statusText;
|
|
2163
|
+
}
|
|
2164
|
+
paramsRes.error = error;
|
|
2165
|
+
return paramsRes;
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
const reflectTypeNameKey = 'typeName';
|
|
2169
|
+
const reflectEnumNameKey = 'enumName';
|
|
2170
|
+
/**
|
|
2171
|
+
* Defines type name decorator.
|
|
2172
|
+
* @param targetType class.
|
|
2173
|
+
* @param typeName Name of the type.
|
|
2174
|
+
*/
|
|
2175
|
+
function defineReflectTypeName(targetType, typeName) {
|
|
2176
|
+
if (!Reflect.hasOwnMetadata(reflectTypeNameKey, targetType)) {
|
|
2177
|
+
Reflect.defineMetadata(reflectTypeNameKey, typeName, targetType);
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
/**
|
|
2181
|
+
* Defines enum name decorator.
|
|
2182
|
+
* @param targetType enum object.
|
|
2183
|
+
* @param enumName Name of the enum.
|
|
2184
|
+
*/
|
|
2185
|
+
function defineReflectEnumName(targetType, enumName) {
|
|
2186
|
+
if (!Reflect.hasOwnMetadata(reflectEnumNameKey, targetType)) {
|
|
2187
|
+
Reflect.defineMetadata(reflectEnumNameKey, enumName, targetType);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Gets type name from reflect metadata.
|
|
2192
|
+
* @param type Class.
|
|
2193
|
+
*/
|
|
2194
|
+
function findReflectTypeName(type) {
|
|
2195
|
+
if (!type) {
|
|
2196
|
+
return null;
|
|
2197
|
+
}
|
|
2198
|
+
const typeName = Reflect.getMetadata(reflectTypeNameKey, type);
|
|
2199
|
+
if (typeName) {
|
|
2200
|
+
return typeName;
|
|
2201
|
+
}
|
|
2202
|
+
LoggerService.get().debug('WARNING: Reflect metadata could not be found for type, you might experience some issues in production build.', type?.name);
|
|
2203
|
+
return type.name;
|
|
2204
|
+
}
|
|
2205
|
+
/**
|
|
2206
|
+
* Gets type name from either decorator or reflect metadata.
|
|
2207
|
+
* @param type Class.
|
|
2208
|
+
*/
|
|
2209
|
+
function reflectTypeNameExists(type) {
|
|
2210
|
+
return Reflect.hasOwnMetadata(reflectTypeNameKey, type);
|
|
2211
|
+
}
|
|
2212
|
+
/**
|
|
2213
|
+
* Gets enum name from either decorator or reflect metadata.
|
|
2214
|
+
* @param enumType Class.
|
|
2215
|
+
*/
|
|
2216
|
+
function findReflectEnumName(enumType) {
|
|
2217
|
+
const enumName = Reflect.getMetadata(reflectEnumNameKey, enumType);
|
|
2218
|
+
if (enumName) {
|
|
2219
|
+
return enumName;
|
|
2220
|
+
}
|
|
2221
|
+
LoggerService.get().debug(`WARNING: Reflect metadata could not be found for enum ${typeof enumType === 'object' ? Object.keys(enumType) : enumType}`, {
|
|
2222
|
+
name: 'TypeUtilsError',
|
|
2223
|
+
enumType: enumType
|
|
2224
|
+
});
|
|
2225
|
+
return null;
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
function getI18nClassNameAsync(translate, classType, singular) {
|
|
2229
|
+
const typeName = findReflectTypeName(classType);
|
|
2230
|
+
return getI18nTypeNameAsync(translate, typeName ?? '', singular);
|
|
2231
|
+
}
|
|
2232
|
+
function getI18nClassName(translate, classType, singular) {
|
|
2233
|
+
const typeName = findReflectTypeName(classType);
|
|
2234
|
+
return getI18nTypeName(translate, typeName ?? '', singular);
|
|
2235
|
+
}
|
|
2236
|
+
function getI18nTypeNameAsync(translate, typeName, singular) {
|
|
2237
|
+
const keys = getI18nTypeNameKeys(typeName, singular);
|
|
2238
|
+
return getI18nAsync(translate, undefined, ...keys);
|
|
2239
|
+
}
|
|
2240
|
+
function getI18nTypeName(translate, typeName, singular) {
|
|
2241
|
+
const keys = getI18nTypeNameKeys(typeName, singular);
|
|
2242
|
+
return getI18n(translate, undefined, ...keys);
|
|
2243
|
+
}
|
|
2244
|
+
function getI18nClassTabKey(classType, tab) {
|
|
2245
|
+
const typeName = findReflectTypeName(classType);
|
|
2246
|
+
return getI18nTypeTabKey(typeName ?? '', tab);
|
|
2247
|
+
}
|
|
2248
|
+
function getI18nTypeTabKey(typeName, tab) {
|
|
2249
|
+
return getI18nTypeKeyBasePath(typeName, 'tabs', tab);
|
|
2250
|
+
}
|
|
2251
|
+
function getI18nClassGroupKey(classType, group) {
|
|
2252
|
+
const typeName = findReflectTypeName(classType);
|
|
2253
|
+
return getI18nTypeGroupKey(typeName ?? '', group);
|
|
2254
|
+
}
|
|
2255
|
+
function getI18nTypeGroupKey(typeName, group) {
|
|
2256
|
+
return getI18nTypeKeyBasePath(typeName, 'groups', group);
|
|
2257
|
+
}
|
|
2258
|
+
function getI18nClassPropertyKey(classType, property) {
|
|
2259
|
+
const typeName = findReflectTypeName(classType);
|
|
2260
|
+
return getI18nTypePropertyKey(typeName ?? '', property);
|
|
2261
|
+
}
|
|
2262
|
+
function getI18nTypePropertyKey(typeName, property) {
|
|
2263
|
+
return getI18nTypeKeyBasePath(typeName, 'properties', property);
|
|
2264
|
+
}
|
|
2265
|
+
function getI18nClassKeyBasePath(classType, ...path) {
|
|
2266
|
+
const typeName = findReflectTypeName(classType);
|
|
2267
|
+
return getI18nTypeKeyBasePath(typeName ?? '', ...path);
|
|
2268
|
+
}
|
|
2269
|
+
function getI18nTypeKeyBasePath(typeName, ...path) {
|
|
2270
|
+
return `${typeName.length ? `${typeName}.` : ''}${path.join('.')}`;
|
|
2271
|
+
}
|
|
2272
|
+
function getI18nClassParams(translate, classType, item, params = {}) {
|
|
2273
|
+
const typeName = findReflectTypeName(classType);
|
|
2274
|
+
return getI18nTypeParams(translate, typeName ?? undefined, item, params);
|
|
2275
|
+
}
|
|
2276
|
+
function getI18nTypeParams(translate, typeName, item, params = {}) {
|
|
2277
|
+
const i18nTypeName = typeName ? getI18nTypeName(translate, typeName, true) : null;
|
|
2278
|
+
return populateI18nTypeParams(i18nTypeName ?? undefined, item, params);
|
|
2279
|
+
}
|
|
2280
|
+
function getI18nClassParamsAsync(translate, classType, item, params = {}) {
|
|
2281
|
+
const typeName = findReflectTypeName(classType);
|
|
2282
|
+
return getI18nTypeParamsAsync(translate, typeName ?? undefined, item, params);
|
|
2283
|
+
}
|
|
2284
|
+
function getI18nTypeParamsAsync(translate, typeName, item, params = {}) {
|
|
2285
|
+
return (typeName ? getI18nTypeNameAsync(translate, typeName, true) : of(null)).pipe(map(i18nTypeName => populateI18nTypeParams(i18nTypeName ?? undefined, item, params)));
|
|
2286
|
+
}
|
|
2287
|
+
function populateI18nTypeParams(i18nTypeName, item, params = {}) {
|
|
2288
|
+
const paramsRes = { ...params };
|
|
2289
|
+
if (i18nTypeName) {
|
|
2290
|
+
paramsRes.typeName = i18nTypeName;
|
|
2291
|
+
}
|
|
2292
|
+
return populateI18nParams(item, paramsRes);
|
|
2293
|
+
}
|
|
2294
|
+
function getI18nTypeNameKeys(typeName, singular) {
|
|
2295
|
+
const keys = [];
|
|
2296
|
+
if (typeof singular !== 'undefined') {
|
|
2297
|
+
keys.push(singular ? `${typeName}.nameSingular` : `${typeName}.namePlural`);
|
|
2298
|
+
}
|
|
2299
|
+
keys.push(`${typeName.length ? `${typeName}.` : ''}name`);
|
|
2300
|
+
return keys;
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2086
2303
|
/* eslint-disable no-console */
|
|
2087
2304
|
class LogPublisherConsoleService {
|
|
2088
2305
|
addEntry(entry) {
|
|
@@ -2093,7 +2310,7 @@ class LogPublisherConsoleService {
|
|
|
2093
2310
|
const message = `${entry.message}${entry.messageDetails ? `\n${entry.messageDetails}` : ''}`;
|
|
2094
2311
|
const logParams = [prefix, message];
|
|
2095
2312
|
if (entry.error) {
|
|
2096
|
-
logParams.push(`\n${
|
|
2313
|
+
logParams.push(`\n${getErrorName(entry.error)}:`, entry.error);
|
|
2097
2314
|
}
|
|
2098
2315
|
if (entry.data?.length) {
|
|
2099
2316
|
logParams.push(`\nData:\n`, ...entry.data);
|
|
@@ -2135,10 +2352,10 @@ class BooleanPipe {
|
|
|
2135
2352
|
return value;
|
|
2136
2353
|
}
|
|
2137
2354
|
}
|
|
2138
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
2139
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.
|
|
2355
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: BooleanPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2356
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.4", ngImport: i0, type: BooleanPipe, isStandalone: true, name: "mngBoolean" }); }
|
|
2140
2357
|
}
|
|
2141
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
2358
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: BooleanPipe, decorators: [{
|
|
2142
2359
|
type: Pipe,
|
|
2143
2360
|
args: [{
|
|
2144
2361
|
standalone: true,
|
|
@@ -2156,10 +2373,10 @@ class ClassMapPipe {
|
|
|
2156
2373
|
return className ?? '';
|
|
2157
2374
|
}
|
|
2158
2375
|
}
|
|
2159
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
2160
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.
|
|
2376
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: ClassMapPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2377
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.4", ngImport: i0, type: ClassMapPipe, isStandalone: true, name: "mngClassMap" }); }
|
|
2161
2378
|
}
|
|
2162
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
2379
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: ClassMapPipe, decorators: [{
|
|
2163
2380
|
type: Pipe,
|
|
2164
2381
|
args: [{
|
|
2165
2382
|
standalone: true,
|
|
@@ -2168,6 +2385,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
|
|
|
2168
2385
|
}]
|
|
2169
2386
|
}] });
|
|
2170
2387
|
|
|
2388
|
+
class EnumPipe {
|
|
2389
|
+
transform(value, enumDesc, i18nPath) {
|
|
2390
|
+
if (!value || (typeof value !== 'number' && typeof value !== 'string')) {
|
|
2391
|
+
return value;
|
|
2392
|
+
}
|
|
2393
|
+
const enumConstantName = !enumDesc || enumDesc.nameAsValue ? value : getEnumConstantNameFromObject(enumDesc.type, value) ?? value;
|
|
2394
|
+
if (typeof i18nPath === 'undefined' && enumDesc) {
|
|
2395
|
+
i18nPath = enumDesc.i18nBaseKey === undefined ? findReflectEnumName(enumDesc.type) : null;
|
|
2396
|
+
}
|
|
2397
|
+
return i18nPath ? `${i18nPath}.${enumConstantName}` : enumConstantName;
|
|
2398
|
+
}
|
|
2399
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: EnumPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2400
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.4", ngImport: i0, type: EnumPipe, isStandalone: true, name: "mngEnum" }); }
|
|
2401
|
+
}
|
|
2402
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: EnumPipe, decorators: [{
|
|
2403
|
+
type: Pipe,
|
|
2404
|
+
args: [{
|
|
2405
|
+
standalone: true,
|
|
2406
|
+
name: 'mngEnum',
|
|
2407
|
+
pure: true
|
|
2408
|
+
}]
|
|
2409
|
+
}] });
|
|
2410
|
+
|
|
2171
2411
|
/**
|
|
2172
2412
|
* Imitation of JSONPath Syntax. Supports:
|
|
2173
2413
|
* - Root object notation with '$'
|
|
@@ -2176,12 +2416,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
|
|
|
2176
2416
|
*/
|
|
2177
2417
|
class JsonPathPipe {
|
|
2178
2418
|
transform(value, path = '') {
|
|
2179
|
-
return
|
|
2419
|
+
return getObjectPropertyByPath(value, path);
|
|
2180
2420
|
}
|
|
2181
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
2182
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.
|
|
2421
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: JsonPathPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2422
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.4", ngImport: i0, type: JsonPathPipe, isStandalone: true, name: "mngJsonPath" }); }
|
|
2183
2423
|
}
|
|
2184
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
2424
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: JsonPathPipe, decorators: [{
|
|
2185
2425
|
type: Pipe,
|
|
2186
2426
|
args: [{
|
|
2187
2427
|
standalone: true,
|
|
@@ -2198,20 +2438,20 @@ class EnumeratePipe {
|
|
|
2198
2438
|
if (!value) {
|
|
2199
2439
|
return emptyValueReturn;
|
|
2200
2440
|
}
|
|
2201
|
-
i18nBaseKey =
|
|
2441
|
+
i18nBaseKey = getEnumerationI18nBaseKey(i18nBaseKey);
|
|
2202
2442
|
return Array.from(value)
|
|
2203
2443
|
.map(i => {
|
|
2204
|
-
const itemEnumerate =
|
|
2444
|
+
const itemEnumerate = toEnumerationI18nEnumerate(i, jsonPath, i18nBaseKey);
|
|
2205
2445
|
itemEnumerate.i18n = this.translate.instant(itemEnumerate.i18nKey);
|
|
2206
2446
|
// return i18n only if used and transl. was found
|
|
2207
|
-
return
|
|
2447
|
+
return selectEnumerationI18n(itemEnumerate, i18nBaseKey);
|
|
2208
2448
|
})
|
|
2209
2449
|
.join(valueSeparator);
|
|
2210
2450
|
}
|
|
2211
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
2212
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.
|
|
2451
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: EnumeratePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2452
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.4", ngImport: i0, type: EnumeratePipe, isStandalone: true, name: "mngEnumerate" }); }
|
|
2213
2453
|
}
|
|
2214
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
2454
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: EnumeratePipe, decorators: [{
|
|
2215
2455
|
type: Pipe,
|
|
2216
2456
|
args: [{
|
|
2217
2457
|
standalone: true,
|
|
@@ -2219,13 +2459,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
|
|
|
2219
2459
|
pure: true
|
|
2220
2460
|
}]
|
|
2221
2461
|
}] });
|
|
2222
|
-
function
|
|
2462
|
+
function getEnumerationI18nBaseKey(baseKey) {
|
|
2223
2463
|
return baseKey.endsWith('.') ? baseKey?.substring(0, baseKey.length - 1) : baseKey;
|
|
2224
2464
|
}
|
|
2225
|
-
function
|
|
2465
|
+
function selectEnumerationI18n(value, baseKey) {
|
|
2226
2466
|
return baseKey && value.i18nKey === value.i18n ? value.value : value.i18n;
|
|
2227
2467
|
}
|
|
2228
|
-
function
|
|
2468
|
+
function toEnumerationI18nEnumerate(value, jsonPath, baseKey) {
|
|
2229
2469
|
const valueTrans = new JsonPathPipe().transform(value, jsonPath);
|
|
2230
2470
|
const valueAsString = valueTrans.toString();
|
|
2231
2471
|
return {
|
|
@@ -2240,23 +2480,23 @@ class EnumerateAsyncPipe {
|
|
|
2240
2480
|
this.translate = inject(TranslateService);
|
|
2241
2481
|
}
|
|
2242
2482
|
transform(value, jsonPath = '$', valueSeparator = ', ', emptyValueReturn = '/', i18nBaseKey = '') {
|
|
2243
|
-
i18nBaseKey =
|
|
2483
|
+
i18nBaseKey = getEnumerationI18nBaseKey(i18nBaseKey);
|
|
2244
2484
|
return value.pipe(mergeMap(v => {
|
|
2245
2485
|
if (!v) {
|
|
2246
2486
|
return of([emptyValueReturn]);
|
|
2247
2487
|
}
|
|
2248
2488
|
return combineLatest(Array.from(v)
|
|
2249
|
-
.map(ai =>
|
|
2489
|
+
.map(ai => toEnumerationI18nEnumerate(ai, jsonPath, i18nBaseKey))
|
|
2250
2490
|
.map(i => this.translate.stream(i.i18nKey).pipe(map((i18n) => {
|
|
2251
2491
|
i.i18n = i18n;
|
|
2252
|
-
return
|
|
2492
|
+
return selectEnumerationI18n(i, i18nBaseKey);
|
|
2253
2493
|
}))));
|
|
2254
2494
|
}), map(i => i.join(valueSeparator)));
|
|
2255
2495
|
}
|
|
2256
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
2257
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.
|
|
2496
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: EnumerateAsyncPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2497
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.4", ngImport: i0, type: EnumerateAsyncPipe, isStandalone: true, name: "mngEnumerateAsync" }); }
|
|
2258
2498
|
}
|
|
2259
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
2499
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: EnumerateAsyncPipe, decorators: [{
|
|
2260
2500
|
type: Pipe,
|
|
2261
2501
|
args: [{
|
|
2262
2502
|
standalone: true,
|
|
@@ -2272,10 +2512,10 @@ class GetterPipe {
|
|
|
2272
2512
|
}
|
|
2273
2513
|
return value;
|
|
2274
2514
|
}
|
|
2275
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
2276
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.
|
|
2515
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: GetterPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2516
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.4", ngImport: i0, type: GetterPipe, isStandalone: true, name: "mngGetter" }); }
|
|
2277
2517
|
}
|
|
2278
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
2518
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: GetterPipe, decorators: [{
|
|
2279
2519
|
type: Pipe,
|
|
2280
2520
|
args: [{
|
|
2281
2521
|
standalone: true,
|
|
@@ -2284,6 +2524,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
|
|
|
2284
2524
|
}]
|
|
2285
2525
|
}] });
|
|
2286
2526
|
|
|
2527
|
+
class I18nPropertyPipe {
|
|
2528
|
+
transform(property, model) {
|
|
2529
|
+
return getI18nTypePropertyKey(model.i18nBaseKey, property);
|
|
2530
|
+
}
|
|
2531
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: I18nPropertyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2532
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.4", ngImport: i0, type: I18nPropertyPipe, isStandalone: true, name: "mngI18nProperty" }); }
|
|
2533
|
+
}
|
|
2534
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: I18nPropertyPipe, decorators: [{
|
|
2535
|
+
type: Pipe,
|
|
2536
|
+
args: [{
|
|
2537
|
+
standalone: true,
|
|
2538
|
+
name: 'mngI18nProperty',
|
|
2539
|
+
pure: true
|
|
2540
|
+
}]
|
|
2541
|
+
}] });
|
|
2542
|
+
|
|
2287
2543
|
class ParametrizePipe {
|
|
2288
2544
|
constructor() {
|
|
2289
2545
|
this.jsonPath = new JsonPathPipe();
|
|
@@ -2299,7 +2555,7 @@ class ParametrizePipe {
|
|
|
2299
2555
|
if (item) {
|
|
2300
2556
|
params = {
|
|
2301
2557
|
...params,
|
|
2302
|
-
item:
|
|
2558
|
+
item: escapeHtmlAny(item)
|
|
2303
2559
|
};
|
|
2304
2560
|
}
|
|
2305
2561
|
if (itemId) {
|
|
@@ -2346,107 +2602,47 @@ class ParametrizePipe {
|
|
|
2346
2602
|
if (s.startsWith(':')) {
|
|
2347
2603
|
const itemProperty = s.substring(1);
|
|
2348
2604
|
return this.jsonPath.transform(params, itemProperty) ?? '';
|
|
2349
|
-
}
|
|
2350
|
-
else {
|
|
2351
|
-
return s;
|
|
2352
|
-
}
|
|
2353
|
-
}
|
|
2354
|
-
parametrizeString(s, params) {
|
|
2355
|
-
return s.replace(/{{\s?([^{}\s]*)\s?}}/g, (subs, key) => this.jsonPath.transform(params, key) ?? subs);
|
|
2356
|
-
}
|
|
2357
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ParametrizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2358
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.2.1", ngImport: i0, type: ParametrizePipe, isStandalone: true, name: "mngParametrize" }); }
|
|
2359
|
-
}
|
|
2360
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ParametrizePipe, decorators: [{
|
|
2361
|
-
type: Pipe,
|
|
2362
|
-
args: [{
|
|
2363
|
-
standalone: true,
|
|
2364
|
-
name: 'mngParametrize',
|
|
2365
|
-
pure: true
|
|
2366
|
-
}]
|
|
2367
|
-
}] });
|
|
2368
|
-
|
|
2369
|
-
class TemplatePipe {
|
|
2370
|
-
constructor(parametrizePipe) {
|
|
2371
|
-
this.parametrizePipe = parametrizePipe;
|
|
2372
|
-
}
|
|
2373
|
-
transform(value, template) {
|
|
2374
|
-
if (typeof template === 'string') {
|
|
2375
|
-
return this.parametrizePipe.transform(template, undefined, value);
|
|
2376
|
-
}
|
|
2377
|
-
return value;
|
|
2378
|
-
}
|
|
2379
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: TemplatePipe, deps: [{ token: ParametrizePipe }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2380
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.2.1", ngImport: i0, type: TemplatePipe, isStandalone: true, name: "template" }); }
|
|
2381
|
-
}
|
|
2382
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: TemplatePipe, decorators: [{
|
|
2383
|
-
type: Pipe,
|
|
2384
|
-
args: [{
|
|
2385
|
-
standalone: true,
|
|
2386
|
-
name: 'template',
|
|
2387
|
-
pure: true
|
|
2388
|
-
}]
|
|
2389
|
-
}], ctorParameters: () => [{ type: ParametrizePipe }] });
|
|
2390
|
-
|
|
2391
|
-
const reflectTypeNameKey = 'typeName';
|
|
2392
|
-
const reflectEnumNameKey = 'enumName';
|
|
2393
|
-
/**
|
|
2394
|
-
* Defines type name decorator.
|
|
2395
|
-
* @param targetType class.
|
|
2396
|
-
* @param typeName Name of the type.
|
|
2397
|
-
*/
|
|
2398
|
-
function defineReflectTypeName(targetType, typeName) {
|
|
2399
|
-
if (!Reflect.hasOwnMetadata(reflectTypeNameKey, targetType)) {
|
|
2400
|
-
Reflect.defineMetadata(reflectTypeNameKey, typeName, targetType);
|
|
2401
|
-
}
|
|
2402
|
-
}
|
|
2403
|
-
/**
|
|
2404
|
-
* Defines enum name decorator.
|
|
2405
|
-
* @param targetType enum object.
|
|
2406
|
-
* @param enumName Name of the enum.
|
|
2407
|
-
*/
|
|
2408
|
-
function defineReflectEnumName(targetType, enumName) {
|
|
2409
|
-
if (!Reflect.hasOwnMetadata(reflectEnumNameKey, targetType)) {
|
|
2410
|
-
Reflect.defineMetadata(reflectEnumNameKey, enumName, targetType);
|
|
2411
|
-
}
|
|
2412
|
-
}
|
|
2413
|
-
/**
|
|
2414
|
-
* Gets type name from reflect metadata.
|
|
2415
|
-
* @param type Class.
|
|
2416
|
-
*/
|
|
2417
|
-
function findReflectTypeName(type) {
|
|
2418
|
-
if (!type) {
|
|
2419
|
-
return null;
|
|
2605
|
+
}
|
|
2606
|
+
else {
|
|
2607
|
+
return s;
|
|
2608
|
+
}
|
|
2420
2609
|
}
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
return typeName;
|
|
2610
|
+
parametrizeString(s, params) {
|
|
2611
|
+
return s.replace(/{{\s?([^{}\s]*)\s?}}/g, (subs, key) => this.jsonPath.transform(params, key) ?? subs);
|
|
2424
2612
|
}
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
}
|
|
2428
|
-
/**
|
|
2429
|
-
* Gets type name from either decorator or reflect metadata.
|
|
2430
|
-
* @param type Class.
|
|
2431
|
-
*/
|
|
2432
|
-
function reflectTypeNameExists(type) {
|
|
2433
|
-
return Reflect.hasOwnMetadata(reflectTypeNameKey, type);
|
|
2613
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: ParametrizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2614
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.4", ngImport: i0, type: ParametrizePipe, isStandalone: true, name: "mngParametrize" }); }
|
|
2434
2615
|
}
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2616
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: ParametrizePipe, decorators: [{
|
|
2617
|
+
type: Pipe,
|
|
2618
|
+
args: [{
|
|
2619
|
+
standalone: true,
|
|
2620
|
+
name: 'mngParametrize',
|
|
2621
|
+
pure: true
|
|
2622
|
+
}]
|
|
2623
|
+
}] });
|
|
2624
|
+
|
|
2625
|
+
class TemplatePipe {
|
|
2626
|
+
constructor() {
|
|
2627
|
+
this.parametrizePipe = new ParametrizePipe();
|
|
2443
2628
|
}
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2629
|
+
transform(value, template) {
|
|
2630
|
+
if (typeof template === 'string') {
|
|
2631
|
+
return this.parametrizePipe.transform(template, undefined, value);
|
|
2632
|
+
}
|
|
2633
|
+
return value;
|
|
2634
|
+
}
|
|
2635
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: TemplatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
2636
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.4", ngImport: i0, type: TemplatePipe, isStandalone: true, name: "template" }); }
|
|
2449
2637
|
}
|
|
2638
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: TemplatePipe, decorators: [{
|
|
2639
|
+
type: Pipe,
|
|
2640
|
+
args: [{
|
|
2641
|
+
standalone: true,
|
|
2642
|
+
name: 'template',
|
|
2643
|
+
pure: true
|
|
2644
|
+
}]
|
|
2645
|
+
}] });
|
|
2450
2646
|
|
|
2451
2647
|
function TypeName(typeName) {
|
|
2452
2648
|
return function (target) {
|
|
@@ -2655,19 +2851,17 @@ var Permissions;
|
|
|
2655
2851
|
Permissions.Service = Service;
|
|
2656
2852
|
})(Permissions || (Permissions = {}));
|
|
2657
2853
|
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
throw new CommonsInternalError(`Permission type "${permissions.authorizationType}" not implemented`);
|
|
2665
|
-
}
|
|
2666
|
-
}
|
|
2667
|
-
static isRbacPermitted(permissions, userRoles) {
|
|
2668
|
-
return permissions.roles.some(prg => prg.every(pr => userRoles.indexOf(pr) > -1));
|
|
2854
|
+
function isPermitted(permissions, userRoles) {
|
|
2855
|
+
switch (permissions.authorizationType) {
|
|
2856
|
+
case PermissionTypeEnum.Rbac:
|
|
2857
|
+
return isRbacPermitted(permissions, userRoles);
|
|
2858
|
+
default:
|
|
2859
|
+
throw new CommonsInternalError(`Permission type "${permissions.authorizationType}" not implemented`);
|
|
2669
2860
|
}
|
|
2670
2861
|
}
|
|
2862
|
+
function isRbacPermitted(permissions, userRoles) {
|
|
2863
|
+
return permissions.roles.some(prg => prg.every(pr => userRoles.indexOf(pr) > -1));
|
|
2864
|
+
}
|
|
2671
2865
|
|
|
2672
2866
|
class PermissionService {
|
|
2673
2867
|
constructor() {
|
|
@@ -2685,7 +2879,7 @@ class PermissionService {
|
|
|
2685
2879
|
case PermissionTypeEnum.Service:
|
|
2686
2880
|
return this.isPermittedService(permissions, route, actionCtx);
|
|
2687
2881
|
default:
|
|
2688
|
-
return this.commons.userRoles$.pipe(map(ur =>
|
|
2882
|
+
return this.commons.userRoles$.pipe(map(ur => isPermitted(permissions, ur)));
|
|
2689
2883
|
}
|
|
2690
2884
|
}
|
|
2691
2885
|
isPermittedAll(permission, route, actionCtx) {
|
|
@@ -2702,10 +2896,10 @@ class PermissionService {
|
|
|
2702
2896
|
}
|
|
2703
2897
|
return serviceInstance.isPermitted(route, this.router.routerState.snapshot, actionCtx);
|
|
2704
2898
|
}
|
|
2705
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
2706
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.
|
|
2899
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: PermissionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2900
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: PermissionService }); }
|
|
2707
2901
|
}
|
|
2708
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
2902
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: PermissionService, decorators: [{
|
|
2709
2903
|
type: Injectable
|
|
2710
2904
|
}] });
|
|
2711
2905
|
|
|
@@ -2720,65 +2914,6 @@ const permissionGuard = (route) => {
|
|
|
2720
2914
|
}
|
|
2721
2915
|
};
|
|
2722
2916
|
|
|
2723
|
-
class RouteUtil {
|
|
2724
|
-
static removeEmptyPathSegments(path) {
|
|
2725
|
-
const filteredPath = path.filter(ps => typeof ps === 'string' && ps.length > 0);
|
|
2726
|
-
return filteredPath.length > 0 ? filteredPath : [''];
|
|
2727
|
-
}
|
|
2728
|
-
static appendPathToBasePath(basePath, path) {
|
|
2729
|
-
if (path.length > 0) {
|
|
2730
|
-
if (path[0].startsWith('/')) {
|
|
2731
|
-
return path;
|
|
2732
|
-
}
|
|
2733
|
-
else if (path[0].startsWith('../')) {
|
|
2734
|
-
throw new CommonsInternalError('Not implemented', { name: 'RouteUtilsError' });
|
|
2735
|
-
}
|
|
2736
|
-
else {
|
|
2737
|
-
return RouteUtil.removeEmptyPathSegments([...basePath, ...path]);
|
|
2738
|
-
}
|
|
2739
|
-
}
|
|
2740
|
-
else {
|
|
2741
|
-
return basePath;
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2744
|
-
static doesUrlMatchRouterLink(link, url) {
|
|
2745
|
-
if (typeof url === 'string' && url.startsWith('/')) {
|
|
2746
|
-
url = url.substring(1);
|
|
2747
|
-
}
|
|
2748
|
-
else if (Array.isArray(url) && url.length > 0 && url[0].startsWith('/')) {
|
|
2749
|
-
url[0] = url[0].substring(1);
|
|
2750
|
-
}
|
|
2751
|
-
const routeSegments = Array.isArray(link) ? link : link.split('/');
|
|
2752
|
-
const urlSegments = Array.isArray(url) ? url : url.split('#')[0].split('?')[0].split('/');
|
|
2753
|
-
if (routeSegments.length > 0 && urlSegments.length > 0) {
|
|
2754
|
-
for (let i = 0; i < routeSegments.length; i++) {
|
|
2755
|
-
if (i < urlSegments.length) {
|
|
2756
|
-
if (routeSegments[i] !== urlSegments[i]) {
|
|
2757
|
-
return false;
|
|
2758
|
-
}
|
|
2759
|
-
}
|
|
2760
|
-
else {
|
|
2761
|
-
break;
|
|
2762
|
-
}
|
|
2763
|
-
}
|
|
2764
|
-
return true;
|
|
2765
|
-
}
|
|
2766
|
-
return false;
|
|
2767
|
-
}
|
|
2768
|
-
static adjustMenuLazyChildrenRouterLinks(rootMenuItem, lazyChildren) {
|
|
2769
|
-
return lazyChildren.map(i => {
|
|
2770
|
-
const childMenuItem = { ...i };
|
|
2771
|
-
if (childMenuItem.routerLink) {
|
|
2772
|
-
childMenuItem.routerLink = RouteUtil.appendPathToBasePath(rootMenuItem.routerLink, typeof childMenuItem.routerLink === 'string' ? [childMenuItem.routerLink] : childMenuItem.routerLink);
|
|
2773
|
-
}
|
|
2774
|
-
if (Array.isArray(childMenuItem.items)) {
|
|
2775
|
-
childMenuItem.items = this.adjustMenuLazyChildrenRouterLinks(rootMenuItem, childMenuItem.items);
|
|
2776
|
-
}
|
|
2777
|
-
return childMenuItem;
|
|
2778
|
-
});
|
|
2779
|
-
}
|
|
2780
|
-
}
|
|
2781
|
-
|
|
2782
2917
|
class RouteBuilder {
|
|
2783
2918
|
constructor(route) {
|
|
2784
2919
|
this.routePath = [];
|
|
@@ -2791,89 +2926,95 @@ class RouteBuilder {
|
|
|
2791
2926
|
this.routePath = [this.route.path];
|
|
2792
2927
|
}
|
|
2793
2928
|
}
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
}
|
|
2800
|
-
static createRedirect(path, redirectTo, pathMatch = 'prefix') {
|
|
2801
|
-
return new RouteBuilder({
|
|
2802
|
-
path: path,
|
|
2803
|
-
redirectTo: redirectTo,
|
|
2804
|
-
pathMatch: pathMatch
|
|
2805
|
-
});
|
|
2806
|
-
}
|
|
2807
|
-
static createLazyRouteModule(path, loadChildren, canMatch) {
|
|
2808
|
-
const route = { path: path, loadChildren: loadChildren };
|
|
2809
|
-
if (canMatch?.length) {
|
|
2810
|
-
route.canMatch = canMatch;
|
|
2811
|
-
}
|
|
2812
|
-
return new RouteBuilder(route);
|
|
2813
|
-
}
|
|
2814
|
-
static createLazyRouteComponent(path, loadComponent, canMatch) {
|
|
2815
|
-
const route = { path: path, loadComponent: loadComponent };
|
|
2816
|
-
if (canMatch?.length) {
|
|
2817
|
-
route.canMatch = canMatch;
|
|
2818
|
-
}
|
|
2819
|
-
return new RouteBuilder(route);
|
|
2820
|
-
}
|
|
2821
|
-
static createFromRoute(route) {
|
|
2822
|
-
return new RouteBuilder(route);
|
|
2823
|
-
}
|
|
2929
|
+
/**
|
|
2930
|
+
* Sets the link to root Routes builder.
|
|
2931
|
+
*
|
|
2932
|
+
* @param {RoutesBuilder} routesBuilder - The routes builder to set as the root.
|
|
2933
|
+
*/
|
|
2824
2934
|
withRoot(routesBuilder) {
|
|
2825
2935
|
this.root = routesBuilder;
|
|
2826
2936
|
return this;
|
|
2827
2937
|
}
|
|
2938
|
+
/**
|
|
2939
|
+
* Sets the link to parent Route builder.
|
|
2940
|
+
*
|
|
2941
|
+
* @param {RouteBuilder} parent - The parent route builder.
|
|
2942
|
+
*/
|
|
2828
2943
|
withParent(parent) {
|
|
2829
2944
|
this.parent = parent;
|
|
2830
|
-
this.routePath =
|
|
2945
|
+
this.routePath = removeRouteEmptyPathSegments([...this.parent.routePath, this.route.path ?? '']);
|
|
2831
2946
|
return this;
|
|
2832
2947
|
}
|
|
2948
|
+
/**
|
|
2949
|
+
* Sets the breadcrumb.
|
|
2950
|
+
*
|
|
2951
|
+
* @param {BreadcrumbType} breadcrumb - Breadcrumb configuration.
|
|
2952
|
+
*/
|
|
2833
2953
|
withBreadcrumb(breadcrumb) {
|
|
2834
|
-
this.breadcrumb = breadcrumb;
|
|
2835
2954
|
this.routeData.breadcrumb = breadcrumb;
|
|
2836
2955
|
return this;
|
|
2837
2956
|
}
|
|
2957
|
+
/**
|
|
2958
|
+
* Sets the page title for the current route.
|
|
2959
|
+
*
|
|
2960
|
+
* @param {string} pageTitle - The title of the page.
|
|
2961
|
+
*/
|
|
2838
2962
|
withPageTitle(pageTitle) {
|
|
2839
|
-
this.pageTitle = pageTitle;
|
|
2840
2963
|
this.routeData.pageTitle = pageTitle;
|
|
2841
2964
|
return this;
|
|
2842
2965
|
}
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
this.route.pathMatch = pathMatch;
|
|
2849
|
-
return this;
|
|
2850
|
-
}
|
|
2966
|
+
/**
|
|
2967
|
+
* Sets the page title and the breadcrumb.
|
|
2968
|
+
*
|
|
2969
|
+
* @param {string} title - The title of the page and breadcrumb.
|
|
2970
|
+
*/
|
|
2851
2971
|
withTitle(title) {
|
|
2852
2972
|
this.withPageTitle(title);
|
|
2853
2973
|
this.withBreadcrumb(title);
|
|
2854
2974
|
return this;
|
|
2855
2975
|
}
|
|
2856
|
-
|
|
2976
|
+
/**
|
|
2977
|
+
* Adds a can activate guard to route.
|
|
2978
|
+
*
|
|
2979
|
+
* @param {CanActivateFn} fn - The CanActivate function to be added.
|
|
2980
|
+
*/
|
|
2981
|
+
withCanActivate(fn) {
|
|
2857
2982
|
if (!this.route.canActivate) {
|
|
2858
2983
|
this.route.canActivate = [];
|
|
2859
2984
|
}
|
|
2860
|
-
this.route.canActivate.push(
|
|
2985
|
+
this.route.canActivate.push(fn);
|
|
2861
2986
|
return this;
|
|
2862
2987
|
}
|
|
2863
|
-
|
|
2988
|
+
/**
|
|
2989
|
+
* Adds a can deactivate guard to route.
|
|
2990
|
+
*
|
|
2991
|
+
* @param {CanDeactivateFn} fn - The CanActivate function to be added.
|
|
2992
|
+
*/
|
|
2993
|
+
withCanDeactivate(fn) {
|
|
2864
2994
|
if (!this.route.canDeactivate) {
|
|
2865
2995
|
this.route.canDeactivate = [];
|
|
2866
2996
|
}
|
|
2867
|
-
this.route.canDeactivate.push(
|
|
2997
|
+
this.route.canDeactivate.push(fn);
|
|
2868
2998
|
return this;
|
|
2869
2999
|
}
|
|
2870
|
-
|
|
3000
|
+
/**
|
|
3001
|
+
* Adds a resolver to route.
|
|
3002
|
+
*
|
|
3003
|
+
* @param {string} name - Name of the resolver.
|
|
3004
|
+
* @param {CanDeactivateFn} fn - The CanActivate function to be added.
|
|
3005
|
+
*/
|
|
3006
|
+
withResolver(name, fn) {
|
|
2871
3007
|
if (!this.route.resolve) {
|
|
2872
3008
|
this.route.resolve = {};
|
|
2873
3009
|
}
|
|
2874
|
-
this.route.resolve[name] =
|
|
3010
|
+
this.route.resolve[name] = fn;
|
|
2875
3011
|
return this;
|
|
2876
3012
|
}
|
|
3013
|
+
/**
|
|
3014
|
+
* Adds a provider to the route.
|
|
3015
|
+
*
|
|
3016
|
+
* @param {Provider | EnvironmentProviders} provider - The provider to add.
|
|
3017
|
+
*/
|
|
2877
3018
|
withProvider(provider) {
|
|
2878
3019
|
if (!this.route.providers) {
|
|
2879
3020
|
this.route.providers = [];
|
|
@@ -2881,19 +3022,49 @@ class RouteBuilder {
|
|
|
2881
3022
|
this.route.providers.push(provider);
|
|
2882
3023
|
return this;
|
|
2883
3024
|
}
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
3025
|
+
/**
|
|
3026
|
+
* Sets the data for the route.
|
|
3027
|
+
*
|
|
3028
|
+
* @param {CommonsRouteData} data - The data to set for the route.
|
|
3029
|
+
* @param {boolean} [merge=true] - If the data should be merged with current data setup (true by default) - page title and breadcrumb config are carried over.
|
|
3030
|
+
*/
|
|
3031
|
+
withData(data, merge = true) {
|
|
3032
|
+
this.routeData = merge
|
|
3033
|
+
? {
|
|
3034
|
+
...this.routeData,
|
|
3035
|
+
...data
|
|
3036
|
+
}
|
|
3037
|
+
: {
|
|
3038
|
+
breadcrumb: null,
|
|
3039
|
+
...data
|
|
3040
|
+
};
|
|
2889
3041
|
return this;
|
|
2890
3042
|
}
|
|
2891
|
-
|
|
2892
|
-
|
|
3043
|
+
/**
|
|
3044
|
+
* Updates the menu item of route. Merging with current configuration (set with {withMenuItem}) takes place.
|
|
3045
|
+
*
|
|
3046
|
+
* @param {CommonsMenuItem} opts - The opts properties to be merged on existing menu item for route.
|
|
3047
|
+
*/
|
|
3048
|
+
withMenuItemOpts(opts) {
|
|
3049
|
+
if (!this.menuItem) {
|
|
3050
|
+
this.menuItem = {};
|
|
3051
|
+
}
|
|
3052
|
+
this.menuItem = {
|
|
3053
|
+
...this.menuItem,
|
|
3054
|
+
...opts
|
|
3055
|
+
};
|
|
2893
3056
|
return this;
|
|
2894
3057
|
}
|
|
3058
|
+
/**
|
|
3059
|
+
* Sets the menu item (basic). For more options, see the {withMenuItemFromOpts}.
|
|
3060
|
+
*
|
|
3061
|
+
* @param {string} [icon] - The icon for the menu item.
|
|
3062
|
+
* @param {string} [label] - The label for the menu item.
|
|
3063
|
+
* @param {Array<string>} [routerLink] - The router link for the menu item.
|
|
3064
|
+
* @param {boolean} [breadcrumb=false] - Indicates whether to display breadcrumb for the menu item.
|
|
3065
|
+
*/
|
|
2895
3066
|
withMenuItem(icon, label, routerLink, breadcrumb = false) {
|
|
2896
|
-
this.menuItem =
|
|
3067
|
+
this.menuItem = createMenuItem(icon, label, routerLink);
|
|
2897
3068
|
if (breadcrumb && label) {
|
|
2898
3069
|
this.withBreadcrumb({
|
|
2899
3070
|
label: label
|
|
@@ -2902,35 +3073,40 @@ class RouteBuilder {
|
|
|
2902
3073
|
return this;
|
|
2903
3074
|
}
|
|
2904
3075
|
/**
|
|
2905
|
-
* Adds menu item child to
|
|
2906
|
-
*
|
|
2907
|
-
* @param icon
|
|
2908
|
-
* @param
|
|
2909
|
-
* @param
|
|
3076
|
+
* Adds menu item child to route's menu item. If no menu item is present, children will be appended directly to parent/root menu item.
|
|
3077
|
+
*
|
|
3078
|
+
* @param {string} [icon] - The icon for the menu item.
|
|
3079
|
+
* @param {string} [label] - The label for the menu item.
|
|
3080
|
+
* @param {Array<string>} [routerLink] - The router link for the menu item.
|
|
3081
|
+
* @param {boolean} [afterRouteChildren=false] If false, menu item child will be appended before route's children menu items, at the end otherwise.
|
|
2910
3082
|
*/
|
|
2911
|
-
withMenuItemChild(
|
|
3083
|
+
withMenuItemChild(icon, label, routerLink, afterRouteChildren = false) {
|
|
2912
3084
|
if (afterRouteChildren) {
|
|
2913
|
-
this.menuItemChildrenAfter.push(
|
|
3085
|
+
this.menuItemChildrenAfter.push(createMenuItem(icon, label, routerLink));
|
|
2914
3086
|
}
|
|
2915
3087
|
else {
|
|
2916
|
-
this.menuItemChildren.push(
|
|
3088
|
+
this.menuItemChildren.push(createMenuItem(icon, label, routerLink));
|
|
2917
3089
|
}
|
|
2918
3090
|
return this;
|
|
2919
3091
|
}
|
|
2920
3092
|
/**
|
|
2921
|
-
* Adds menu item child to
|
|
2922
|
-
*
|
|
2923
|
-
* @param
|
|
3093
|
+
* Adds menu item child from opts to route's menu item. If no menu item is present, children will be appended directly to parent/root menu item.
|
|
3094
|
+
*
|
|
3095
|
+
* @param {CommonsMenuItem} opts - The opts properties to be merged on existing menu item for route.
|
|
3096
|
+
* @param {boolean} [afterRouteChildren=false] If false, menu item child will be appended before route's children menu items, at the end otherwise.
|
|
2924
3097
|
*/
|
|
2925
|
-
|
|
3098
|
+
withMenuItemChildFromOpts(opts, afterRouteChildren = false) {
|
|
2926
3099
|
if (afterRouteChildren) {
|
|
2927
|
-
this.menuItemChildrenAfter.push(
|
|
3100
|
+
this.menuItemChildrenAfter.push(opts);
|
|
2928
3101
|
}
|
|
2929
3102
|
else {
|
|
2930
|
-
this.menuItemChildren.push(
|
|
3103
|
+
this.menuItemChildren.push(opts);
|
|
2931
3104
|
}
|
|
2932
3105
|
return this;
|
|
2933
3106
|
}
|
|
3107
|
+
/**
|
|
3108
|
+
* Sets the menu item's children to be generated lazily from route's lazy loaded routes after the chunk is loaded to runtime.
|
|
3109
|
+
*/
|
|
2934
3110
|
withMenuItemLazyChildren() {
|
|
2935
3111
|
if (!this.menuItem) {
|
|
2936
3112
|
this.menuItem = {};
|
|
@@ -2938,16 +3114,34 @@ class RouteBuilder {
|
|
|
2938
3114
|
this.menuItem.lazyChildren = true;
|
|
2939
3115
|
return this;
|
|
2940
3116
|
}
|
|
3117
|
+
/**
|
|
3118
|
+
* Sets the permissions on the route.
|
|
3119
|
+
*
|
|
3120
|
+
* @param {APermissions} permissions - The permissions to be set on the route.
|
|
3121
|
+
*/
|
|
2941
3122
|
withPermissions(permissions) {
|
|
2942
3123
|
this.permissions = permissions;
|
|
2943
3124
|
this.withCanActivate(permissionGuard);
|
|
2944
3125
|
return this;
|
|
2945
3126
|
}
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
3127
|
+
/**
|
|
3128
|
+
* Adds a child route to the current route.
|
|
3129
|
+
*
|
|
3130
|
+
* @param {string} path - The path of the child route.
|
|
3131
|
+
* @param {Type<any>} component - The component associated with the child route.
|
|
3132
|
+
* @param {RouteBuilderAdjustFnType} [adjustFn] - An optional function to adjust the child route builder.
|
|
3133
|
+
*/
|
|
3134
|
+
addChild(path, component, adjustFn) {
|
|
3135
|
+
const childRouteBuilder = createRoute(path, component);
|
|
3136
|
+
adjustFn?.(childRouteBuilder);
|
|
3137
|
+
return this.addChildBuilder(childRouteBuilder);
|
|
2950
3138
|
}
|
|
3139
|
+
/**
|
|
3140
|
+
* Adds a child builder to the current route.
|
|
3141
|
+
*
|
|
3142
|
+
* @param {RouteBuilder} builder - The child builder to be added.
|
|
3143
|
+
* @return {this} - The current builder with the added child builder.
|
|
3144
|
+
*/
|
|
2951
3145
|
addChildBuilder(builder) {
|
|
2952
3146
|
builder.withParent(this);
|
|
2953
3147
|
if (this.root) {
|
|
@@ -2956,21 +3150,11 @@ class RouteBuilder {
|
|
|
2956
3150
|
this.children.push(builder);
|
|
2957
3151
|
return this;
|
|
2958
3152
|
}
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
}
|
|
2965
|
-
toRoot() {
|
|
2966
|
-
if (!this.root) {
|
|
2967
|
-
throw new CommonsInternalError('Root was not provided.', { name: 'RouteBuilderError' });
|
|
2968
|
-
}
|
|
2969
|
-
return this.root;
|
|
2970
|
-
}
|
|
2971
|
-
finish() {
|
|
2972
|
-
return this.toRoot();
|
|
2973
|
-
}
|
|
3153
|
+
/**
|
|
3154
|
+
* Builds an Angular route based on configurations.
|
|
3155
|
+
*
|
|
3156
|
+
* @returns {Route} The built Angular route.
|
|
3157
|
+
*/
|
|
2974
3158
|
build() {
|
|
2975
3159
|
const angularRoute = {
|
|
2976
3160
|
...this.route
|
|
@@ -3021,6 +3205,11 @@ class RouteBuilder {
|
|
|
3021
3205
|
}
|
|
3022
3206
|
return angularRoute;
|
|
3023
3207
|
}
|
|
3208
|
+
/**
|
|
3209
|
+
* Builds the menu items.
|
|
3210
|
+
*
|
|
3211
|
+
* @returns {Array<CommonsMenuItem>} - The built menu items.
|
|
3212
|
+
*/
|
|
3024
3213
|
buildMenu() {
|
|
3025
3214
|
const menuItemBuild = this.menuItem ? { ...this.menuItem } : null;
|
|
3026
3215
|
const routeChildrenMenuItems = this.children.flatMap(child => child.buildMenu());
|
|
@@ -3038,7 +3227,7 @@ class RouteBuilder {
|
|
|
3038
3227
|
finalChild.routerLink = [finalChild.routerLink];
|
|
3039
3228
|
}
|
|
3040
3229
|
if (finalChild.routerLink) {
|
|
3041
|
-
finalChild.routerLink =
|
|
3230
|
+
finalChild.routerLink = removeRouteEmptyPathSegments(finalChild.routerLink);
|
|
3042
3231
|
}
|
|
3043
3232
|
return finalChild;
|
|
3044
3233
|
};
|
|
@@ -3048,11 +3237,11 @@ class RouteBuilder {
|
|
|
3048
3237
|
if (!menuItemBuild) {
|
|
3049
3238
|
return menuItemChildrenBuild;
|
|
3050
3239
|
}
|
|
3051
|
-
menuItemBuild.label = menuItemBuild.label ?? this.pageTitle;
|
|
3240
|
+
menuItemBuild.label = menuItemBuild.label ?? this.routeData.pageTitle;
|
|
3052
3241
|
if (typeof menuItemBuild.routerLink === 'string') {
|
|
3053
3242
|
menuItemBuild.routerLink = [menuItemBuild.routerLink];
|
|
3054
3243
|
}
|
|
3055
|
-
menuItemBuild.routerLink =
|
|
3244
|
+
menuItemBuild.routerLink = removeRouteEmptyPathSegments(menuItemBuild.routerLink ?? this.routePath);
|
|
3056
3245
|
if (menuItemChildrenBuild.length > 0) {
|
|
3057
3246
|
menuItemBuild.items = menuItemChildrenBuild;
|
|
3058
3247
|
}
|
|
@@ -3067,19 +3256,6 @@ class RouteBuilder {
|
|
|
3067
3256
|
}
|
|
3068
3257
|
return [menuItemBuild];
|
|
3069
3258
|
}
|
|
3070
|
-
createMenuItem(icon, label, routerLink) {
|
|
3071
|
-
const menuItem = {};
|
|
3072
|
-
if (icon) {
|
|
3073
|
-
menuItem.icon = icon;
|
|
3074
|
-
}
|
|
3075
|
-
if (label) {
|
|
3076
|
-
menuItem.label = label;
|
|
3077
|
-
}
|
|
3078
|
-
if (routerLink) {
|
|
3079
|
-
menuItem.routerLink = routerLink;
|
|
3080
|
-
}
|
|
3081
|
-
return menuItem;
|
|
3082
|
-
}
|
|
3083
3259
|
findMenuItemGuards() {
|
|
3084
3260
|
const guards = [];
|
|
3085
3261
|
if (this.route.canActivate?.length) {
|
|
@@ -3111,57 +3287,128 @@ class RouteBuilder {
|
|
|
3111
3287
|
return undefined;
|
|
3112
3288
|
}
|
|
3113
3289
|
}
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
this.layoutRoute = layoutRoute?.withRoot(this);
|
|
3119
|
-
this.currentRoute = layoutRoute;
|
|
3290
|
+
function createMenuItem(icon, label, routerLink) {
|
|
3291
|
+
const menuItem = {};
|
|
3292
|
+
if (icon) {
|
|
3293
|
+
menuItem.icon = icon;
|
|
3120
3294
|
}
|
|
3121
|
-
|
|
3122
|
-
|
|
3295
|
+
if (label) {
|
|
3296
|
+
menuItem.label = label;
|
|
3297
|
+
}
|
|
3298
|
+
if (routerLink) {
|
|
3299
|
+
menuItem.routerLink = routerLink;
|
|
3123
3300
|
}
|
|
3124
|
-
|
|
3125
|
-
|
|
3301
|
+
return menuItem;
|
|
3302
|
+
}
|
|
3303
|
+
/**
|
|
3304
|
+
* Creates a new instance of RouteBuilder with the given path and component.
|
|
3305
|
+
*
|
|
3306
|
+
* @param {string} path - The path for the route.
|
|
3307
|
+
* @param {Type<any>} component - The component for the route.
|
|
3308
|
+
* @return {RouteBuilder} - A new instance of RouteBuilder.
|
|
3309
|
+
*/
|
|
3310
|
+
function createRoute(path, component) {
|
|
3311
|
+
return new RouteBuilder({
|
|
3312
|
+
path: path,
|
|
3313
|
+
component: component
|
|
3314
|
+
});
|
|
3315
|
+
}
|
|
3316
|
+
/**
|
|
3317
|
+
* Creates a redirect route for the given path.
|
|
3318
|
+
*
|
|
3319
|
+
* @param {string} path - The path to match against.
|
|
3320
|
+
* @param {string} redirectTo - The URL path to redirect to.
|
|
3321
|
+
* @param {'full' | 'prefix'} [pathMatch='prefix'] - The path matching strategy ('full' or 'prefix').
|
|
3322
|
+
* @return {RouteBuilder} - A new instance of the RouteBuilder class with the redirect route configuration.
|
|
3323
|
+
*/
|
|
3324
|
+
function createRouteRedirect(path, redirectTo, pathMatch = 'prefix') {
|
|
3325
|
+
return new RouteBuilder({
|
|
3326
|
+
path: path,
|
|
3327
|
+
redirectTo: redirectTo,
|
|
3328
|
+
pathMatch: pathMatch
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
/**
|
|
3332
|
+
* Creates a lazy route module (or routes).
|
|
3333
|
+
*
|
|
3334
|
+
* @param {string} path - The path for the route.
|
|
3335
|
+
* @param {LoadChildren} loadChildren - The function that loads the lazy module (or routes).
|
|
3336
|
+
* @param {Array<any>} [canMatch] - An optional array of objects that can match the route.
|
|
3337
|
+
* @returns {RouteBuilder} - A new instance of RouteBuilder class.
|
|
3338
|
+
*/
|
|
3339
|
+
function createLazyChildrenRoute(path, loadChildren, canMatch) {
|
|
3340
|
+
const route = { path: path, loadChildren: loadChildren };
|
|
3341
|
+
if (canMatch?.length) {
|
|
3342
|
+
route.canMatch = canMatch;
|
|
3126
3343
|
}
|
|
3127
|
-
|
|
3128
|
-
|
|
3344
|
+
return new RouteBuilder(route);
|
|
3345
|
+
}
|
|
3346
|
+
/**
|
|
3347
|
+
* Creates a lazy route component.
|
|
3348
|
+
*
|
|
3349
|
+
* @param {string} path - The path for the route.
|
|
3350
|
+
* @param {() => Type<unknown> | Observable<Type<unknown> | DefaultExport<Type<unknown>>> | Promise<Type<unknown> | DefaultExport<Type<unknown>>>} loadComponent - The function that loads the component for the route.
|
|
3351
|
+
* @param {Array<any>} [canMatch] - The array of values that determine if the route can match.
|
|
3352
|
+
* @returns {RouteBuilder} - An instance of RouteBuilder with the created route.
|
|
3353
|
+
*/
|
|
3354
|
+
function createLazyRoute(path, loadComponent, canMatch) {
|
|
3355
|
+
const route = { path: path, loadComponent: loadComponent };
|
|
3356
|
+
if (canMatch?.length) {
|
|
3357
|
+
route.canMatch = canMatch;
|
|
3129
3358
|
}
|
|
3130
|
-
|
|
3131
|
-
|
|
3359
|
+
return new RouteBuilder(route);
|
|
3360
|
+
}
|
|
3361
|
+
|
|
3362
|
+
class RoutesBuilder {
|
|
3363
|
+
constructor() {
|
|
3364
|
+
this.routes = [];
|
|
3132
3365
|
}
|
|
3133
|
-
|
|
3134
|
-
|
|
3366
|
+
/**
|
|
3367
|
+
* Adds an Angular route to the current route configuration.
|
|
3368
|
+
*
|
|
3369
|
+
* @param {Route} route - The Angular route object to be added.
|
|
3370
|
+
* @param {RouteBuilderAdjustFnType} [builderAdjustFn] - Optional function to adjust the route builder before adding.
|
|
3371
|
+
*/
|
|
3372
|
+
addFromNgRoute(route, builderAdjustFn) {
|
|
3373
|
+
const builder = new RouteBuilder(route);
|
|
3374
|
+
builderAdjustFn?.(builder);
|
|
3375
|
+
return this.add(builder);
|
|
3135
3376
|
}
|
|
3136
|
-
|
|
3137
|
-
|
|
3377
|
+
/**
|
|
3378
|
+
* Adds a route redirect to the Angular route.
|
|
3379
|
+
*
|
|
3380
|
+
* @param {string} path - The path for the redirect.
|
|
3381
|
+
* @param {string} redirectTo - The target route to redirect.
|
|
3382
|
+
* @param {'full' | 'prefix'} pathMatch - The matching strategy for the redirect. Default is 'prefix'.
|
|
3383
|
+
*/
|
|
3384
|
+
addRedirect(path, redirectTo, pathMatch = 'prefix') {
|
|
3385
|
+
return this.addFromNgRoute({
|
|
3386
|
+
path: path,
|
|
3387
|
+
redirectTo: redirectTo,
|
|
3388
|
+
pathMatch: pathMatch
|
|
3389
|
+
});
|
|
3138
3390
|
}
|
|
3139
|
-
|
|
3140
|
-
|
|
3391
|
+
/**
|
|
3392
|
+
* Adds a route to the routes.
|
|
3393
|
+
*
|
|
3394
|
+
* @param {RouteBuilder} routeBuilder - The route builder object representing the route to be added.
|
|
3395
|
+
*/
|
|
3396
|
+
add(routeBuilder) {
|
|
3141
3397
|
this.routes.push(routeBuilder);
|
|
3142
3398
|
return this;
|
|
3143
3399
|
}
|
|
3144
|
-
toRoute() {
|
|
3145
|
-
if (!this.currentRoute) {
|
|
3146
|
-
throw new CommonsInternalError('No routes were added!', { name: 'RoutesBuilderError' });
|
|
3147
|
-
}
|
|
3148
|
-
return this.currentRoute;
|
|
3149
|
-
}
|
|
3150
3400
|
build() {
|
|
3151
|
-
|
|
3152
|
-
for (const route of this.routes) {
|
|
3153
|
-
angularRoutes.push(route.build());
|
|
3154
|
-
}
|
|
3155
|
-
if (this.layoutRoute) {
|
|
3156
|
-
const layoutAngularRoute = this.layoutRoute.build();
|
|
3157
|
-
if (angularRoutes.length > 0) {
|
|
3158
|
-
layoutAngularRoute.children = angularRoutes;
|
|
3159
|
-
}
|
|
3160
|
-
angularRoutes = [layoutAngularRoute];
|
|
3161
|
-
}
|
|
3162
|
-
return angularRoutes;
|
|
3401
|
+
return this.routes.map(r => r.build());
|
|
3163
3402
|
}
|
|
3164
3403
|
}
|
|
3404
|
+
/**
|
|
3405
|
+
* Creates a new instance of the RoutesBuilder class.
|
|
3406
|
+
*
|
|
3407
|
+
* @return {RoutesBuilder} A new instance of the RoutesBuilder class.
|
|
3408
|
+
*/
|
|
3409
|
+
function createRoutes() {
|
|
3410
|
+
return new RoutesBuilder();
|
|
3411
|
+
}
|
|
3165
3412
|
|
|
3166
3413
|
/**
|
|
3167
3414
|
* Maps an Observable of data with optional totalCount and data to a data list result object with provided defaults of empty array and count 0.
|
|
@@ -3336,7 +3583,7 @@ class CommonsConfigurationService {
|
|
|
3336
3583
|
// 1. object sources have highest priority
|
|
3337
3584
|
if (this.objectSources.length) {
|
|
3338
3585
|
for (const objConfig of this.objectSources) {
|
|
3339
|
-
config =
|
|
3586
|
+
config = objectDeepMerge(config, objConfig);
|
|
3340
3587
|
}
|
|
3341
3588
|
}
|
|
3342
3589
|
// 2. JSON sources come next
|
|
@@ -3344,17 +3591,17 @@ class CommonsConfigurationService {
|
|
|
3344
3591
|
if (jsonConfigs.length) {
|
|
3345
3592
|
for (const jsonConfig of jsonConfigs) {
|
|
3346
3593
|
if (jsonConfig) {
|
|
3347
|
-
config =
|
|
3594
|
+
config = objectDeepMerge(config, jsonConfig);
|
|
3348
3595
|
}
|
|
3349
3596
|
}
|
|
3350
3597
|
}
|
|
3351
3598
|
// 3. project env has the next priority
|
|
3352
3599
|
if (this.projectEnvironment) {
|
|
3353
|
-
config =
|
|
3600
|
+
config = objectDeepMerge(config, this.projectEnvironment);
|
|
3354
3601
|
}
|
|
3355
3602
|
// 4. module config has the lowest priority
|
|
3356
3603
|
if (this.moduleConfig) {
|
|
3357
|
-
config =
|
|
3604
|
+
config = objectDeepMerge(config, this.moduleConfig);
|
|
3358
3605
|
}
|
|
3359
3606
|
this.configuration = config;
|
|
3360
3607
|
}
|
|
@@ -3526,10 +3773,10 @@ class CommonsRouterService {
|
|
|
3526
3773
|
getModulePathFromRouterLink(path) {
|
|
3527
3774
|
return ('/' + (Array.isArray(path) ? path.join('/') : path)).replace(/\/\//g, '/');
|
|
3528
3775
|
}
|
|
3529
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
3530
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.
|
|
3776
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: CommonsRouterService, deps: [{ token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3777
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: CommonsRouterService }); }
|
|
3531
3778
|
}
|
|
3532
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
3779
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: CommonsRouterService, decorators: [{
|
|
3533
3780
|
type: Injectable
|
|
3534
3781
|
}], ctorParameters: () => [{ type: i1$1.Router }] });
|
|
3535
3782
|
|
|
@@ -3625,10 +3872,10 @@ class CommonsInitService {
|
|
|
3625
3872
|
return throwError(() => err);
|
|
3626
3873
|
}));
|
|
3627
3874
|
}
|
|
3628
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
3629
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.
|
|
3875
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: CommonsInitService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3876
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: CommonsInitService }); }
|
|
3630
3877
|
}
|
|
3631
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
3878
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: CommonsInitService, decorators: [{
|
|
3632
3879
|
type: Injectable
|
|
3633
3880
|
}] });
|
|
3634
3881
|
|
|
@@ -3652,10 +3899,10 @@ class LocalStorageService {
|
|
|
3652
3899
|
removeItem(type, key) {
|
|
3653
3900
|
localStorage.removeItem(this.buildLocalStorageKey(type, key));
|
|
3654
3901
|
}
|
|
3655
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.
|
|
3656
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.
|
|
3902
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: LocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3903
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: LocalStorageService }); }
|
|
3657
3904
|
}
|
|
3658
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.
|
|
3905
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: LocalStorageService, decorators: [{
|
|
3659
3906
|
type: Injectable
|
|
3660
3907
|
}] });
|
|
3661
3908
|
|
|
@@ -3690,139 +3937,6 @@ class Styles {
|
|
|
3690
3937
|
static { this.TABLE_CELL_PADDING_X_LG = 12; }
|
|
3691
3938
|
}
|
|
3692
3939
|
|
|
3693
|
-
var I18nUtils;
|
|
3694
|
-
(function (I18nUtils) {
|
|
3695
|
-
class Common {
|
|
3696
|
-
static getAsync(translate, params, ...keys) {
|
|
3697
|
-
return translate.stream(keys, params).pipe(map(i18n => I18nUtils.Common.selectI18n(keys, i18n)));
|
|
3698
|
-
}
|
|
3699
|
-
static get(translate, params, ...keys) {
|
|
3700
|
-
const i18n = translate.instant(keys, params);
|
|
3701
|
-
return I18nUtils.Common.selectI18n(keys, i18n);
|
|
3702
|
-
}
|
|
3703
|
-
static populateParams(item, params = {}) {
|
|
3704
|
-
const paramsRes = { ...params };
|
|
3705
|
-
if (item) {
|
|
3706
|
-
paramsRes.item = item;
|
|
3707
|
-
}
|
|
3708
|
-
return paramsRes;
|
|
3709
|
-
}
|
|
3710
|
-
static selectI18n(keys, i18n) {
|
|
3711
|
-
for (const key of keys) {
|
|
3712
|
-
if (key !== i18n[key]) {
|
|
3713
|
-
return i18n[key];
|
|
3714
|
-
}
|
|
3715
|
-
}
|
|
3716
|
-
return null;
|
|
3717
|
-
}
|
|
3718
|
-
}
|
|
3719
|
-
I18nUtils.Common = Common;
|
|
3720
|
-
class Type {
|
|
3721
|
-
static getClassNameAsync(translate, classType, singular) {
|
|
3722
|
-
const typeName = findReflectTypeName(classType);
|
|
3723
|
-
return I18nUtils.Type.getNameAsync(translate, typeName ?? '', singular);
|
|
3724
|
-
}
|
|
3725
|
-
static getClassName(translate, classType, singular) {
|
|
3726
|
-
const typeName = findReflectTypeName(classType);
|
|
3727
|
-
return I18nUtils.Type.getName(translate, typeName ?? '', singular);
|
|
3728
|
-
}
|
|
3729
|
-
static getNameAsync(translate, typeName, singular) {
|
|
3730
|
-
const keys = I18nUtils.Type.getNameKeys(typeName, singular);
|
|
3731
|
-
return I18nUtils.Common.getAsync(translate, undefined, ...keys);
|
|
3732
|
-
}
|
|
3733
|
-
static getName(translate, typeName, singular) {
|
|
3734
|
-
const keys = I18nUtils.Type.getNameKeys(typeName, singular);
|
|
3735
|
-
return I18nUtils.Common.get(translate, undefined, ...keys);
|
|
3736
|
-
}
|
|
3737
|
-
static getClassTabKey(classType, tab) {
|
|
3738
|
-
const typeName = findReflectTypeName(classType);
|
|
3739
|
-
return I18nUtils.Type.getTabKey(typeName ?? '', tab);
|
|
3740
|
-
}
|
|
3741
|
-
static getTabKey(typeName, tab) {
|
|
3742
|
-
return I18nUtils.Type.getPath(typeName, 'tabs', tab);
|
|
3743
|
-
}
|
|
3744
|
-
static getClassGroupKey(classType, group) {
|
|
3745
|
-
const typeName = findReflectTypeName(classType);
|
|
3746
|
-
return I18nUtils.Type.getGroupKey(typeName ?? '', group);
|
|
3747
|
-
}
|
|
3748
|
-
static getGroupKey(typeName, group) {
|
|
3749
|
-
return I18nUtils.Type.getPath(typeName, 'groups', group);
|
|
3750
|
-
}
|
|
3751
|
-
static getClassPropertyKey(classType, property) {
|
|
3752
|
-
const typeName = findReflectTypeName(classType);
|
|
3753
|
-
return I18nUtils.Type.getPropertyKey(typeName ?? '', property);
|
|
3754
|
-
}
|
|
3755
|
-
static getPropertyKey(typeName, property) {
|
|
3756
|
-
return I18nUtils.Type.getPath(typeName, 'properties', property);
|
|
3757
|
-
}
|
|
3758
|
-
static getClassPath(classType, ...path) {
|
|
3759
|
-
const typeName = findReflectTypeName(classType);
|
|
3760
|
-
return I18nUtils.Type.getPath(typeName ?? '', ...path);
|
|
3761
|
-
}
|
|
3762
|
-
static getPath(typeName, ...path) {
|
|
3763
|
-
return `${typeName.length ? `${typeName}.` : ''}${path.join('.')}`;
|
|
3764
|
-
}
|
|
3765
|
-
static getClassParams(translate, classType, item, params = {}) {
|
|
3766
|
-
const typeName = findReflectTypeName(classType);
|
|
3767
|
-
return I18nUtils.Type.getParams(translate, typeName ?? undefined, item, params);
|
|
3768
|
-
}
|
|
3769
|
-
static getParams(translate, typeName, item, params = {}) {
|
|
3770
|
-
const i18nTypeName = typeName ? I18nUtils.Type.getName(translate, typeName, true) : null;
|
|
3771
|
-
return I18nUtils.Type.populateParams(i18nTypeName ?? undefined, item, params);
|
|
3772
|
-
}
|
|
3773
|
-
static getClassParamsAsync(translate, classType, item, params = {}) {
|
|
3774
|
-
const typeName = findReflectTypeName(classType);
|
|
3775
|
-
return I18nUtils.Type.getParamsAsync(translate, typeName ?? undefined, item, params);
|
|
3776
|
-
}
|
|
3777
|
-
static getParamsAsync(translate, typeName, item, params = {}) {
|
|
3778
|
-
return (typeName ? I18nUtils.Type.getNameAsync(translate, typeName, true) : of(null)).pipe(map(i18nTypeName => I18nUtils.Type.populateParams(i18nTypeName ?? undefined, item, params)));
|
|
3779
|
-
}
|
|
3780
|
-
static populateParams(i18nTypeName, item, params = {}) {
|
|
3781
|
-
const paramsRes = { ...params };
|
|
3782
|
-
if (i18nTypeName) {
|
|
3783
|
-
paramsRes.typeName = i18nTypeName;
|
|
3784
|
-
}
|
|
3785
|
-
return I18nUtils.Common.populateParams(item, paramsRes);
|
|
3786
|
-
}
|
|
3787
|
-
static getNameKeys(typeName, singular) {
|
|
3788
|
-
const keys = [];
|
|
3789
|
-
if (typeof singular !== 'undefined') {
|
|
3790
|
-
keys.push(singular ? `${typeName}.nameSingular` : `${typeName}.namePlural`);
|
|
3791
|
-
}
|
|
3792
|
-
keys.push(`${typeName.length ? `${typeName}.` : ''}name`);
|
|
3793
|
-
return keys;
|
|
3794
|
-
}
|
|
3795
|
-
}
|
|
3796
|
-
I18nUtils.Type = Type;
|
|
3797
|
-
class Error {
|
|
3798
|
-
static get(translate, error, params = {}) {
|
|
3799
|
-
const i18nParams = I18nUtils.Error.getParams(error, params);
|
|
3800
|
-
if (error.messageCode) {
|
|
3801
|
-
const keys = [`errors.${error.messageCode}`, `messages.${error.messageCode}`];
|
|
3802
|
-
const i18n = I18nUtils.Common.get(translate, i18nParams, ...keys);
|
|
3803
|
-
if (i18n) {
|
|
3804
|
-
return i18n;
|
|
3805
|
-
}
|
|
3806
|
-
}
|
|
3807
|
-
return I18nUtils.Common.get(translate, i18nParams, error.message);
|
|
3808
|
-
}
|
|
3809
|
-
static getParams(error, params = {}) {
|
|
3810
|
-
const paramsRes = { ...params };
|
|
3811
|
-
paramsRes.errorStatus = '';
|
|
3812
|
-
paramsRes.errorMessage = '';
|
|
3813
|
-
if (ErrorUtil.isHttpErrorResponse(error)) {
|
|
3814
|
-
const httpError = ErrorUtil.getHttpErrorResponse(error);
|
|
3815
|
-
paramsRes.errorStatus = httpError?.status;
|
|
3816
|
-
paramsRes.errorMessage = httpError?.message;
|
|
3817
|
-
paramsRes.errorStatusDescription = httpError?.statusText;
|
|
3818
|
-
}
|
|
3819
|
-
paramsRes.error = error;
|
|
3820
|
-
return paramsRes;
|
|
3821
|
-
}
|
|
3822
|
-
}
|
|
3823
|
-
I18nUtils.Error = Error;
|
|
3824
|
-
})(I18nUtils || (I18nUtils = {}));
|
|
3825
|
-
|
|
3826
3940
|
var CommonsFeatureTypeEnum;
|
|
3827
3941
|
(function (CommonsFeatureTypeEnum) {
|
|
3828
3942
|
CommonsFeatureTypeEnum[CommonsFeatureTypeEnum["Layout"] = 0] = "Layout";
|
|
@@ -3835,17 +3949,6 @@ function provideCommons(config, ...features) {
|
|
|
3835
3949
|
DialogService,
|
|
3836
3950
|
MessageService,
|
|
3837
3951
|
ConfirmationService,
|
|
3838
|
-
// angular
|
|
3839
|
-
DatePipe,
|
|
3840
|
-
// pipes
|
|
3841
|
-
BooleanPipe,
|
|
3842
|
-
ClassMapPipe,
|
|
3843
|
-
EnumeratePipe,
|
|
3844
|
-
EnumerateAsyncPipe,
|
|
3845
|
-
GetterPipe,
|
|
3846
|
-
JsonPathPipe,
|
|
3847
|
-
ParametrizePipe,
|
|
3848
|
-
TemplatePipe,
|
|
3849
3952
|
// services
|
|
3850
3953
|
CommonsInitService,
|
|
3851
3954
|
CommonsService,
|
|
@@ -3900,5 +4003,5 @@ function provideCommons(config, ...features) {
|
|
|
3900
4003
|
* Generated bundle index. Do not edit.
|
|
3901
4004
|
*/
|
|
3902
4005
|
|
|
3903
|
-
export { ACommonsErrorBase, APermissions, BROWSER_STORAGE_IT, BooleanPipe, COMMONS_INITIALIZER_IT, COMMONS_MODULE_CONFIG_IT, ClassMapPipe, CommonsConfigurationService, CommonsErrorHandler, CommonsFeatureTypeEnum, CommonsHttpError, CommonsInitEventEnum, CommonsInitService, CommonsInternalError, CommonsRouterService, CommonsService, ComponentDirective,
|
|
4006
|
+
export { ACommonsErrorBase, APermissions, BROWSER_STORAGE_IT, BooleanPipe, COMMONS_INITIALIZER_IT, COMMONS_MODULE_CONFIG_IT, ClassMapPipe, CommonsConfigurationService, CommonsErrorHandler, CommonsFeatureTypeEnum, CommonsHttpError, CommonsInitEventEnum, CommonsInitService, CommonsInternalError, CommonsRouterService, CommonsService, ComponentDirective, DataProvider, DataProviderInst, DialogKeydownHandlerDirective, EnumName, EnumPipe, EnumerateAsyncPipe, EnumeratePipe, ErrorPageComponent, FilterMatchMode, GetterPipe, I18nPropertyPipe, JsonPathPipe, LOG_PUBLISHERS, LocalStorageService, LogLevelEnum, LogPublisherConsoleService, LoggerService, NotFoundPageComponent, NotificationWrapperComponent, ParametrizePipe, PermissionService, PermissionTypeEnum, Permissions, RouteBuilder, RoutesBuilder, StyleLevelEnum, StyleSizeEnum, Styles, TemplateDirective, TemplatePipe, TypeName, TypeRegistry, adjustRouteMenuLazyChildrenRouterLinks, angularDateFormatHasSeconds, angularDateFormatHasTime, appendRoutePathToBasePath, boolean$Attribute, commonsActionErrorContextToString, commonsErrorToString, commonsInitializerProvider, copyDataListParams, createLazyChildrenRoute, createLazyRoute, createRoute, createRouteRedirect, createRoutes, dataListParamsFilterToUrlQuery, dataListParamsFilterValueToUrlString, dataListParamsFiltersToUrlQuery, dataListParamsSortToUrlQuery, dataListParamsToUrlQuery, dateToIsoString, defineReflectEnumName, defineReflectTypeName, doesUrlMatchRouterLink, errorCauseToString, errorToString, escapeHtml, escapeHtmlAny, findReflectEnumName, findReflectTypeName, findTemplateByName, flattenObjectKeys, fromAngularDateFormatToPrime, fromEnumConstantsAsValueArray, fromEnumValuesAsValueArray, fromSubscribeError, fromTableLoadToDataListParams, fromUrlQueryToDataListParams, getEnumConstantName, getEnumConstantNameFromObject, getEnumConstantNames, getEnumConstantNamesFromObject, getEnumConstantValuesAsNumber, getEnumConstantValuesAsString, getEnumerationI18nBaseKey, getErrorLogLevel, getErrorName, getHttpErrorResponse, getHttpErrorResponseStatus, getI18n, getI18nAsync, getI18nClassGroupKey, getI18nClassKeyBasePath, getI18nClassName, getI18nClassNameAsync, getI18nClassParams, getI18nClassParamsAsync, getI18nClassPropertyKey, getI18nClassTabKey, getI18nErrorParams, getI18nForError, getI18nTypeGroupKey, getI18nTypeKeyBasePath, getI18nTypeName, getI18nTypeNameAsync, getI18nTypeParams, getI18nTypeParamsAsync, getI18nTypePropertyKey, getI18nTypeTabKey, getObjectGetters, getObjectProperties, getObjectPropertyByPath, httpErrorResponseToString, isHttpErrorResponse, isPermitted, isRbacPermitted, itemIdToDefined, itemIdToNumber, itemIdToString, mapToDataList, mergeDataListParamsWithDefaults, number$Attribute, objectDeepCopy, objectDeepMerge, permissionGuard, populateI18nParams, populateI18nTypeParams, provideCommons, reflectEnumNameKey, reflectTypeNameExists, reflectTypeNameKey, removeRouteEmptyPathSegments, selectEnumerationI18n, selectI18n, stringify, toEnumerationI18nEnumerate, toObservable, toastMessage, valueToDefined };
|
|
3904
4007
|
//# sourceMappingURL=mediusinc-mng-commons-core.mjs.map
|