@mediusinc/mng-commons 5.5.0-rc.4 → 6.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/action/action-parameters.model.d.ts +4 -4
- package/core/data-providers/base.data-provider.d.ts +4 -7
- package/core/data-providers/lookup.data-provider.d.ts +2 -2
- package/core/descriptors/model.descriptor.d.ts +1 -7
- package/core/descriptors/tableview.descriptor.d.ts +5 -5
- package/core/helpers/route.d.ts +0 -1
- package/core/helpers/type-helpers.d.ts +8 -0
- package/core/index.d.ts +0 -3
- package/core/models/menu.model.d.ts +0 -4
- package/core/services/commons.service.d.ts +0 -32
- package/core/services/tokens/module-config.token.d.ts +0 -28
- package/esm2022/core/action/action-parameters.model.mjs +1 -1
- package/esm2022/core/data-providers/base.data-provider.mjs +2 -4
- package/esm2022/core/data-providers/lookup.data-provider.mjs +1 -1
- package/esm2022/core/descriptors/model.descriptor.mjs +1 -1
- package/esm2022/core/descriptors/tableview.descriptor.mjs +1 -1
- package/esm2022/core/helpers/type-helpers.mjs +1 -1
- package/esm2022/core/index.mjs +1 -4
- package/esm2022/core/models/menu.model.mjs +1 -1
- package/esm2022/core/services/commons.service.mjs +1 -34
- package/esm2022/core/services/tokens/module-config.token.mjs +1 -1
- package/esm2022/filter/descriptors/filter-lookup.descriptor.mjs +5 -86
- package/esm2022/filter/descriptors/filter.descriptor.mjs +7 -29
- package/esm2022/form/api/data-providers/lookup-data-provider.factory.mjs +14 -41
- package/esm2022/form/api/data-providers/lookup.data-provider.mjs +3 -3
- package/esm2022/model/class/data-providers/base-from-class-data-provider.factory.mjs +5 -0
- package/esm2022/model/class/descriptors/model-class.descriptor.mjs +28 -0
- package/esm2022/model/class/descriptors/type-class.descriptor.mjs +6 -0
- package/esm2022/model/class/helpers/model.mjs +53 -0
- package/esm2022/model/class/index.mjs +8 -0
- package/esm2022/model/class/mediusinc-mng-commons-model-class.mjs +5 -0
- package/esm2022/model/data-providers/base-from-type-data-provider.factory.mjs +11 -6
- package/esm2022/model/descriptors/model.descriptor.mjs +11 -54
- package/esm2022/model/descriptors/type.descriptor.mjs +2 -10
- package/esm2022/model/index.mjs +1 -2
- package/esm2022/table/api/class/class-table-attribute-converter.mjs +80 -0
- package/esm2022/table/api/class/class-table-attribute.model.mjs +2 -0
- package/esm2022/table/api/class/class-table-data-provider.factory.mjs +5 -0
- package/esm2022/table/api/class/class-table-descriptor-helpers.mjs +99 -0
- package/esm2022/table/api/class/class-table-descriptor.factory.mjs +21 -0
- package/esm2022/table/api/class/index.mjs +6 -0
- package/esm2022/table/api/class/mediusinc-mng-commons-table-api-class.mjs +5 -0
- package/esm2022/table/api/data-providers/table-data-provider.factory.mjs +14 -41
- package/esm2022/table/api/data-providers/table.data-provider.mjs +3 -9
- package/esm2022/table/api/descriptors/column.descriptor.mjs +8 -3
- package/esm2022/table/api/descriptors/table-descriptor.factory.mjs +10 -77
- package/esm2022/table/api/descriptors/table.descriptor.mjs +3 -3
- package/esm2022/table/api/helpers/column-converter.mjs +25 -0
- package/esm2022/table/api/helpers/table-data-provider-descriptor-convert.mjs +4 -4
- package/esm2022/table/api/index.mjs +2 -4
- package/esm2022/table/api/models/table-columns.model.mjs +1 -1
- package/esm2022/table/components/column-value/column-value.component.mjs +4 -3
- package/esm2022/table/components/filter/filter-active-tag/filter-active-tag.component.mjs +3 -3
- package/esm2022/table/components/filter/filter-form/filter-form.component.mjs +5 -5
- package/esm2022/table/components/table/table.component.mjs +6 -8
- package/esm2022/tableview/action/components/action/action.component.mjs +1 -1
- package/esm2022/tableview/action/components/editor/injector-context/action-editor-injector-context.component.mjs +10 -6
- package/esm2022/tableview/action/helpers/action-execution.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-executor.service.mjs +11 -11
- package/esm2022/tableview/action/services/data-provider-executor.service.mjs +18 -3
- package/esm2022/tableview/api/action/descriptors/action-confirmation.descriptor.mjs +1 -1
- package/esm2022/tableview/api/action/descriptors/action-descriptor.factory.mjs +13 -104
- package/esm2022/tableview/api/action/descriptors/action-editor-descriptor.factory.mjs +15 -62
- package/esm2022/tableview/api/action/descriptors/action-editor.descriptor.mjs +3 -63
- package/esm2022/tableview/api/action/descriptors/action-link-descriptor.factory.mjs +17 -30
- package/esm2022/tableview/api/action/descriptors/action-link.descriptor.mjs +1 -1
- package/esm2022/tableview/api/action/descriptors/action.descriptor.mjs +6 -29
- package/esm2022/tableview/api/action/descriptors/editor-action-descriptor.factory.mjs +21 -0
- package/esm2022/tableview/api/action/descriptors/editor-action-editor-descriptor.factory.mjs +21 -0
- package/esm2022/tableview/api/action/descriptors/table-action-descriptor.factory.mjs +37 -0
- package/esm2022/tableview/api/action/descriptors/table-action-editor-descriptor.factory.mjs +40 -0
- package/esm2022/tableview/api/action/helpers/data-provider-executors.mjs +25 -5
- package/esm2022/tableview/api/action/models/action-descriptor.types.mjs +1 -1
- package/esm2022/tableview/api/action/models/action-error.model.mjs +1 -1
- package/esm2022/tableview/api/action/models/execution/action-context-validation.model.mjs +1 -1
- package/esm2022/tableview/api/action/models/execution/action-context.model.mjs +1 -1
- package/esm2022/tableview/api/action/models/execution/action-instance.model.mjs +1 -1
- package/esm2022/tableview/api/action/models/tableview-action-default-categories.model.mjs +6 -6
- package/esm2022/tableview/api/action/services/data-provider-executor.service.mjs +3 -3
- package/esm2022/tableview/api/class/editor/class-editor-attribute-converter.mjs +85 -0
- package/esm2022/tableview/api/class/editor/class-editor-attribute.model.mjs +2 -0
- package/esm2022/tableview/api/class/editor/class-editor-data-provider.factory.mjs +5 -0
- package/esm2022/tableview/api/class/editor/class-editor-descriptor-helpers.mjs +95 -0
- package/esm2022/tableview/api/class/editor/class-editor-descriptor.factory.mjs +21 -0
- package/esm2022/tableview/api/class/index.mjs +13 -0
- package/esm2022/tableview/api/class/mediusinc-mng-commons-tableview-api-class.mjs +5 -0
- package/esm2022/tableview/api/class/tableview/class-tableview-attribute-converter.mjs +35 -0
- package/esm2022/tableview/api/class/tableview/class-tableview-attribute.model.mjs +2 -0
- package/esm2022/tableview/api/class/tableview/class-tableview-data-provider.factory.mjs +5 -0
- package/esm2022/tableview/api/class/tableview/class-tableview-descriptor-helpers.mjs +111 -0
- package/esm2022/tableview/api/class/tableview/class-tableview-descriptor.factory.mjs +26 -0
- package/esm2022/tableview/api/editor/data-providers/editor-data-provider.factory.mjs +14 -32
- package/esm2022/tableview/api/editor/data-providers/editor.data-provider.mjs +40 -7
- package/esm2022/tableview/api/editor/descriptors/editor-descriptor.factory.mjs +7 -73
- package/esm2022/tableview/api/editor/descriptors/editor.descriptor.mjs +49 -134
- package/esm2022/tableview/api/editor/descriptors/field-base.descriptor.mjs +11 -2
- package/esm2022/tableview/api/editor/descriptors/field-lookup.descriptor.mjs +3 -5
- package/esm2022/tableview/api/editor/descriptors/field-many.descriptor.mjs +2 -18
- package/esm2022/tableview/api/editor/descriptors/wrappers/editor-descriptor-nested-object-wrapper.mjs +51 -0
- package/esm2022/tableview/api/editor/models/editor-fields.model.mjs +1 -1
- package/esm2022/tableview/api/editor/models/form-editor.event.mjs +1 -1
- package/esm2022/tableview/api/index.mjs +8 -8
- package/esm2022/tableview/api/tableview/data-providers/tableview-data-provider.factory.mjs +13 -51
- package/esm2022/tableview/api/tableview/data-providers/tableview.data-provider.mjs +19 -11
- package/esm2022/tableview/api/tableview/descriptors/tableview-descriptor.factory.mjs +19 -96
- package/esm2022/tableview/api/tableview/descriptors/tableview.descriptor.mjs +29 -182
- package/esm2022/tableview/api/tableview/helpers/tableview-create.mjs +8 -6
- package/esm2022/tableview/api/tableview/helpers/tableview-data-provider-descriptor-convert.mjs +4 -4
- package/esm2022/tableview/api/tableview/helpers/tableview-default-actions.mjs +117 -99
- package/esm2022/tableview/api/tableview/helpers/tableview-input-builder.mjs +164 -7
- package/esm2022/tableview/api/tableview/models/tableview-descriptor-fields-manage-helper.type.mjs +2 -0
- package/esm2022/tableview/api/tableview/models/tableview-descriptor-helper.type.mjs +2 -0
- package/esm2022/tableview/api/tableview/models/tableview-input.model.mjs +1 -1
- package/esm2022/tableview/api/tableview/models/tableview-route.model.mjs +1 -1
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +6 -6
- package/esm2022/tableview/editor/helpers/editor-field.mjs +3 -3
- package/esm2022/tableview/editor/helpers/editor-formly.mjs +4 -4
- package/esm2022/tableview/editor/helpers/field-create.mjs +21 -0
- package/esm2022/tableview/index.mjs +3 -2
- package/esm2022/tableview/tableview/components/route/tableview-route.component.mjs +1 -1
- package/esm2022/tableview/tableview/components/tableview/tableview.component.mjs +3 -1
- package/fesm2022/mediusinc-mng-commons-core.mjs +687 -781
- package/fesm2022/mediusinc-mng-commons-core.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-filter.mjs +10 -113
- package/fesm2022/mediusinc-mng-commons-filter.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-form-api.mjs +15 -42
- package/fesm2022/mediusinc-mng-commons-form-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-model-class.mjs +97 -0
- package/fesm2022/mediusinc-mng-commons-model-class.mjs.map +1 -0
- package/fesm2022/mediusinc-mng-commons-model.mjs +23 -137
- package/fesm2022/mediusinc-mng-commons-model.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table-api-class.mjs +204 -0
- package/fesm2022/mediusinc-mng-commons-table-api-class.mjs.map +1 -0
- package/fesm2022/mediusinc-mng-commons-table-api.mjs +55 -319
- package/fesm2022/mediusinc-mng-commons-table-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table.mjs +14 -15
- package/fesm2022/mediusinc-mng-commons-table.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview-api-class.mjs +367 -0
- package/fesm2022/mediusinc-mng-commons-tableview-api-class.mjs.map +1 -0
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs +715 -1298
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview.mjs +67 -27
- package/fesm2022/mediusinc-mng-commons-tableview.mjs.map +1 -1
- package/filter/descriptors/filter-lookup.descriptor.d.ts +1 -26
- package/filter/descriptors/filter.descriptor.d.ts +5 -12
- package/form/api/data-providers/lookup-data-provider.factory.d.ts +17 -20
- package/form/api/data-providers/lookup.data-provider.d.ts +3 -3
- package/model/class/README.md +8 -0
- package/model/class/data-providers/base-from-class-data-provider.factory.d.ts +3 -0
- package/model/class/descriptors/model-class.descriptor.d.ts +12 -0
- package/model/class/descriptors/type-class.descriptor.d.ts +3 -0
- package/model/{helpers → class/helpers}/model.d.ts +1 -2
- package/model/class/index.d.ts +4 -0
- package/model/data-providers/base-from-type-data-provider.factory.d.ts +13 -6
- package/model/descriptors/model.descriptor.d.ts +12 -27
- package/model/descriptors/type.descriptor.d.ts +0 -5
- package/model/index.d.ts +0 -1
- package/package.json +25 -7
- package/table/api/class/README.md +10 -0
- package/table/api/{helpers/class-attribute-converter.d.ts → class/class-table-attribute-converter.d.ts} +2 -9
- package/table/api/{models → class}/class-table-attribute.model.d.ts +1 -1
- package/table/api/class/class-table-data-provider.factory.d.ts +4 -0
- package/table/api/{helpers/table-descriptor-helpers.d.ts → class/class-table-descriptor-helpers.d.ts} +2 -4
- package/table/api/class/class-table-descriptor.factory.d.ts +11 -0
- package/table/api/class/index.d.ts +5 -0
- package/table/api/data-providers/table-data-provider.factory.d.ts +17 -20
- package/table/api/data-providers/table.data-provider.d.ts +4 -12
- package/table/api/descriptors/column.descriptor.d.ts +5 -2
- package/table/api/descriptors/table-descriptor.factory.d.ts +3 -39
- package/table/api/descriptors/table.descriptor.d.ts +3 -3
- package/table/api/helpers/column-converter.d.ts +7 -0
- package/table/api/helpers/table-data-provider-descriptor-convert.d.ts +3 -3
- package/table/api/index.d.ts +1 -3
- package/table/api/models/table-columns.model.d.ts +2 -2
- package/table/components/column-value/column-value.component.d.ts +1 -0
- package/table/components/filter/filter-active-tag/filter-active-tag.component.d.ts +1 -1
- package/table/components/filter/filter-form/filter-form.component.d.ts +1 -1
- package/table/components/filter/filter-overlay-with-tag/filter-overlay-with-tag.component.d.ts +1 -1
- package/table/components/table/table.component.d.ts +0 -9
- package/tableview/action/components/action/action.component.d.ts +2 -2
- package/tableview/action/components/editor/action-editor.component.d.ts +1 -1
- package/tableview/action/components/editor/injector-context/action-editor-injector-context.component.d.ts +6 -5
- package/tableview/action/components/localization/data-language-dropdown.component.d.ts +3 -3
- package/tableview/action/components/table/action-table.component.d.ts +3 -3
- package/tableview/action/helpers/action-execution.d.ts +1 -1
- package/tableview/action/models/execution/action-context.model.d.ts +3 -3
- package/tableview/action/models/execution/action-instance.model.d.ts +5 -5
- package/tableview/action/services/action-executor.service.d.ts +7 -7
- package/tableview/action/services/data-provider-executor.service.d.ts +16 -16
- package/tableview/action/services/view-container.service.d.ts +1 -1
- package/tableview/api/action/descriptors/action-confirmation.descriptor.d.ts +1 -1
- package/tableview/api/action/descriptors/action-descriptor.factory.d.ts +20 -31
- package/tableview/api/action/descriptors/action-editor-descriptor.factory.d.ts +18 -25
- package/tableview/api/action/descriptors/action-editor.descriptor.d.ts +22 -40
- package/tableview/api/action/descriptors/action-link-descriptor.factory.d.ts +21 -13
- package/tableview/api/action/descriptors/action-link.descriptor.d.ts +3 -3
- package/tableview/api/action/descriptors/action.descriptor.d.ts +31 -33
- package/tableview/api/action/descriptors/editor-action-descriptor.factory.d.ts +21 -0
- package/tableview/api/action/descriptors/editor-action-editor-descriptor.factory.d.ts +21 -0
- package/tableview/api/action/descriptors/table-action-descriptor.factory.d.ts +36 -0
- package/tableview/api/action/descriptors/table-action-editor-descriptor.factory.d.ts +40 -0
- package/tableview/api/action/helpers/data-provider-executors.d.ts +13 -8
- package/tableview/api/action/models/action-descriptor.types.d.ts +2 -2
- package/tableview/api/action/models/action-error.model.d.ts +1 -1
- package/tableview/api/action/models/execution/action-context-validation.model.d.ts +2 -2
- package/tableview/api/action/models/execution/action-context.model.d.ts +2 -2
- package/tableview/api/action/models/execution/action-instance.model.d.ts +1 -1
- package/tableview/api/action/models/tableview-action-default-categories.model.d.ts +5 -5
- package/tableview/api/action/services/data-provider-executor.service.d.ts +26 -25
- package/tableview/api/class/README.md +13 -0
- package/tableview/api/{editor/helpers/class-attribute-converter.d.ts → class/editor/class-editor-attribute-converter.d.ts} +2 -2
- package/tableview/api/{editor/models/class-tableview-attribute.model.d.ts → class/editor/class-editor-attribute.model.d.ts} +1 -1
- package/tableview/api/class/editor/class-editor-data-provider.factory.d.ts +4 -0
- package/tableview/api/{editor/helpers/editor-descriptor-helpers.d.ts → class/editor/class-editor-descriptor-helpers.d.ts} +2 -5
- package/tableview/api/class/editor/class-editor-descriptor.factory.d.ts +11 -0
- package/tableview/api/class/index.d.ts +10 -0
- package/tableview/api/{tableview/helpers/class-attribute-converter.d.ts → class/tableview/class-tableview-attribute-converter.d.ts} +1 -1
- package/tableview/api/{tableview/models → class/tableview}/class-tableview-attribute.model.d.ts +2 -2
- package/tableview/api/class/tableview/class-tableview-data-provider.factory.d.ts +4 -0
- package/tableview/api/{tableview/helpers/tableview-descriptor-helpers.d.ts → class/tableview/class-tableview-descriptor-helpers.d.ts} +1 -2
- package/tableview/api/class/tableview/class-tableview-descriptor.factory.d.ts +12 -0
- package/tableview/api/editor/data-providers/editor-data-provider.factory.d.ts +17 -16
- package/tableview/api/editor/data-providers/editor.data-provider.d.ts +64 -29
- package/tableview/api/editor/descriptors/editor-descriptor.factory.d.ts +5 -38
- package/tableview/api/editor/descriptors/editor.descriptor.d.ts +48 -112
- package/tableview/api/editor/descriptors/field-base.descriptor.d.ts +8 -1
- package/tableview/api/editor/descriptors/field-lookup.descriptor.d.ts +2 -3
- package/tableview/api/editor/descriptors/field-many.descriptor.d.ts +3 -11
- package/tableview/api/editor/descriptors/wrappers/editor-descriptor-nested-object-wrapper.d.ts +25 -0
- package/tableview/api/editor/models/editor-fields.model.d.ts +25 -21
- package/tableview/api/editor/models/form-editor.event.d.ts +0 -4
- package/tableview/api/index.d.ts +7 -6
- package/tableview/api/tableview/data-providers/tableview-data-provider.factory.d.ts +20 -25
- package/tableview/api/tableview/data-providers/tableview.data-provider.d.ts +22 -22
- package/tableview/api/tableview/descriptors/tableview-descriptor.factory.d.ts +20 -50
- package/tableview/api/tableview/descriptors/tableview.descriptor.d.ts +69 -163
- package/tableview/api/tableview/helpers/tableview-create.d.ts +18 -5
- package/tableview/api/tableview/helpers/tableview-data-provider-descriptor-convert.d.ts +2 -2
- package/tableview/api/tableview/helpers/tableview-default-actions.d.ts +73 -20
- package/tableview/api/tableview/helpers/tableview-input-builder.d.ts +87 -9
- package/tableview/api/tableview/models/tableview-descriptor-fields-manage-helper.type.d.ts +9 -0
- package/tableview/api/tableview/models/tableview-descriptor-helper.type.d.ts +2 -0
- package/tableview/api/tableview/models/tableview-input.model.d.ts +1 -1
- package/tableview/api/tableview/models/tableview-route.model.d.ts +1 -1
- package/tableview/editor/helpers/field-create.d.ts +9 -0
- package/tableview/index.d.ts +2 -1
- package/tableview/tableview/components/route/tableview-route.component.d.ts +1 -1
- package/tableview/tableview/components/tableview/tableview.component.d.ts +6 -6
- package/version-info.json +5 -5
- package/core/components/pages/error/error.page.component.d.ts +0 -11
- package/core/components/pages/not-found/not-found.page.component.d.ts +0 -11
- package/core/data-providers/base-data-provider.factory.d.ts +0 -13
- package/esm2022/core/components/pages/error/error.page.component.mjs +0 -24
- package/esm2022/core/components/pages/not-found/not-found.page.component.mjs +0 -24
- package/esm2022/core/data-providers/base-data-provider.factory.mjs +0 -28
- package/esm2022/model/helpers/model.mjs +0 -71
- package/esm2022/table/api/helpers/class-attribute-converter.mjs +0 -104
- package/esm2022/table/api/helpers/table-descriptor-helpers.mjs +0 -98
- package/esm2022/table/api/models/class-table-attribute.model.mjs +0 -2
- package/esm2022/tableview/api/editor/helpers/class-attribute-converter.mjs +0 -85
- package/esm2022/tableview/api/editor/helpers/editor-descriptor-helpers.mjs +0 -95
- package/esm2022/tableview/api/editor/models/class-tableview-attribute.model.mjs +0 -2
- package/esm2022/tableview/api/tableview/helpers/class-attribute-converter.mjs +0 -34
- package/esm2022/tableview/api/tableview/helpers/tableview-descriptor-helpers.mjs +0 -110
- package/esm2022/tableview/api/tableview/models/class-tableview-attribute.model.mjs +0 -2
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { of, Subject, throwError,
|
|
2
|
-
import { StyleLevelEnum, CommonsInternalError, DataProviderInst, LoggerService, findReflectTypeName, StyleSizeEnum, ACommonsErrorBase, toObservable, fromEnumValuesAsValueArray, fromEnumConstantsAsValueArray, getEnumConstantName,
|
|
1
|
+
import { of, Subject, isObservable, throwError, map, tap } from 'rxjs';
|
|
2
|
+
import { StyleLevelEnum, CommonsInternalError, DataProviderInst, LoggerService, findReflectTypeName, StyleSizeEnum, ACommonsErrorBase, toObservable, fromEnumValuesAsValueArray, fromEnumConstantsAsValueArray, getEnumConstantName, GetterPipe, copyDataListParams } from '@mediusinc/mng-commons/core';
|
|
3
3
|
import { ActionButtonDescriptor, ButtonStyleBuilder, LookupDataProviderInst, ButtonStyleRoundedEnum } from '@mediusinc/mng-commons/form/api';
|
|
4
|
-
import { TypeDescriptor, ModelDescriptor, trySetLookupItemsProperties, enumModelGeneric, model, findClassTitleAttribute } from '@mediusinc/mng-commons/model';
|
|
5
4
|
import * as i0 from '@angular/core';
|
|
6
5
|
import { InjectionToken, Directive, Input, inject, Injector } from '@angular/core';
|
|
7
|
-
import { TableDataProviderInst,
|
|
6
|
+
import { TableDataProviderInst, TableDescriptorInst, TableDynamicDescriptorInst } from '@mediusinc/mng-commons/table/api';
|
|
7
|
+
import { model, ModelDescriptor } from '@mediusinc/mng-commons/model';
|
|
8
8
|
import '@angular/forms';
|
|
9
9
|
import { FieldType } from '@ngx-formly/core';
|
|
10
10
|
import { ActivatedRoute } from '@angular/router';
|
|
11
11
|
import { TranslateService } from '@ngx-translate/core';
|
|
12
|
-
import { map } from 'rxjs/operators';
|
|
12
|
+
import { map as map$1 } from 'rxjs/operators';
|
|
13
13
|
|
|
14
14
|
var ActionPositionEnum;
|
|
15
15
|
(function (ActionPositionEnum) {
|
|
@@ -37,17 +37,6 @@ var ActionEditorSubmitTypeEnum;
|
|
|
37
37
|
ActionEditorSubmitTypeEnum[ActionEditorSubmitTypeEnum["Cancel"] = 1] = "Cancel";
|
|
38
38
|
})(ActionEditorSubmitTypeEnum || (ActionEditorSubmitTypeEnum = {}));
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* Default categories for tableview actions
|
|
42
|
-
*/
|
|
43
|
-
class TableviewActionDefaultCategories {
|
|
44
|
-
static { this.READ = 'read'; }
|
|
45
|
-
static { this.ADD = 'add'; }
|
|
46
|
-
static { this.EDIT = 'edit'; }
|
|
47
|
-
static { this.DELETE = 'delete'; }
|
|
48
|
-
static { this.DETAILS = 'details'; }
|
|
49
|
-
}
|
|
50
|
-
|
|
51
40
|
class ActionConfirmationDescriptor {
|
|
52
41
|
constructor() {
|
|
53
42
|
this._closeOnEscape = true; // Defines if dialog closes when esc key is pressed.
|
|
@@ -159,7 +148,7 @@ class ActionDescriptorInst {
|
|
|
159
148
|
this._parentProperty = cfg?.parentProperty;
|
|
160
149
|
this.setI18nModelActionBaseKey();
|
|
161
150
|
if (cfg?.serviceType) {
|
|
162
|
-
this._dataProvider = new DataProviderInst(
|
|
151
|
+
this._dataProvider = new DataProviderInst(cfg.serviceType);
|
|
163
152
|
}
|
|
164
153
|
else if (cfg?.dataProvider) {
|
|
165
154
|
this._dataProvider = cfg.dataProvider;
|
|
@@ -355,8 +344,8 @@ class ActionDescriptorInst {
|
|
|
355
344
|
this._permissions = permissions;
|
|
356
345
|
return this;
|
|
357
346
|
}
|
|
358
|
-
withTableviewCategory(
|
|
359
|
-
this._tableviewCategory =
|
|
347
|
+
withTableviewCategory(category) {
|
|
348
|
+
this._tableviewCategory = category;
|
|
360
349
|
return this;
|
|
361
350
|
}
|
|
362
351
|
withButtonDescriptor(button) {
|
|
@@ -426,7 +415,7 @@ class ActionDescriptorInst {
|
|
|
426
415
|
descriptor._afterRunAction = typeof this._afterRunAction === 'function' ? this._afterRunAction : this._afterRunAction.copy();
|
|
427
416
|
}
|
|
428
417
|
if (this._onRunErrorAction != null) {
|
|
429
|
-
descriptor._onRunErrorAction = typeof this._onRunErrorAction === 'function' ? this.
|
|
418
|
+
descriptor._onRunErrorAction = typeof this._onRunErrorAction === 'function' ? this._onRunErrorAction : this._onRunErrorAction.copy();
|
|
430
419
|
}
|
|
431
420
|
descriptor._permissions = this._permissions;
|
|
432
421
|
descriptor._button = this._button.copy();
|
|
@@ -448,28 +437,6 @@ class ActionDescriptorInst {
|
|
|
448
437
|
return descriptor;
|
|
449
438
|
}
|
|
450
439
|
}
|
|
451
|
-
class ActionDeleteDescriptorInst extends ActionDescriptorInst {
|
|
452
|
-
static { this.ACTION_NAME = 'delete'; }
|
|
453
|
-
constructor(model, cfg) {
|
|
454
|
-
super(ActionDeleteDescriptorInst.ACTION_NAME, { model, ...cfg });
|
|
455
|
-
this.withPosition(ActionPositionEnum.RowInline);
|
|
456
|
-
this.button.styleClass.withSize(StyleSizeEnum.Small);
|
|
457
|
-
this.button.styleClass.withActionLevel(StyleLevelEnum.Danger);
|
|
458
|
-
this.withRunConfirmation();
|
|
459
|
-
this.withTableviewCategory(TableviewActionDefaultCategories.DELETE);
|
|
460
|
-
this.button.withLabel(null).withIcon('pi pi-trash');
|
|
461
|
-
}
|
|
462
|
-
copy() {
|
|
463
|
-
if (!this.model) {
|
|
464
|
-
throw new CommonsInternalError(`Model should be defined on action ${this.actionName} of instance ActionDeleteDescriptorInst`);
|
|
465
|
-
}
|
|
466
|
-
const descriptor = new ActionDeleteDescriptorInst(this.model.copy(), {
|
|
467
|
-
dataProvider: this._dataProvider
|
|
468
|
-
});
|
|
469
|
-
this.copyFieldsTo(descriptor);
|
|
470
|
-
return descriptor;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
440
|
|
|
474
441
|
const actionGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
475
442
|
const cfg = {};
|
|
@@ -484,115 +451,24 @@ const actionGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
|
484
451
|
}
|
|
485
452
|
return cfg;
|
|
486
453
|
};
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
static fromModel(model, actionName, cfg) {
|
|
500
|
-
return actionFromModel(model, actionName, cfg);
|
|
501
|
-
}
|
|
502
|
-
static fromModelWithProvider(model, serviceProvider, actionName, cfg) {
|
|
503
|
-
return actionFromModel(model, serviceProvider, actionName, cfg);
|
|
504
|
-
}
|
|
505
|
-
static fromClass(type, actionName, cfg) {
|
|
506
|
-
return actionFromClass(type, actionName, cfg);
|
|
507
|
-
}
|
|
508
|
-
static fromClassWithProvider(type, serviceProvider, actionName, cfg) {
|
|
509
|
-
return actionFromClass(type, serviceProvider, actionName, cfg);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
function action(typeOrActionName, actionNameOrCfg, cfg) {
|
|
513
|
-
if (typeof typeOrActionName === 'string') {
|
|
514
|
-
return new ActionDescriptorInst(typeOrActionName, typeof actionNameOrCfg === 'string'
|
|
515
|
-
? undefined
|
|
516
|
-
: {
|
|
517
|
-
...actionNameOrCfg
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
else {
|
|
521
|
-
return new ActionDescriptorInst(typeof actionNameOrCfg === 'string' ? actionNameOrCfg : 'default', {
|
|
522
|
-
...cfg
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
function actionWithProvider(typeOrServiceProvider, serviceProviderOrActionName, actionNameOrCfg, cfg) {
|
|
527
|
-
const actionName = typeof serviceProviderOrActionName === 'string' ? serviceProviderOrActionName : typeof actionNameOrCfg === 'string' ? actionNameOrCfg : 'default';
|
|
528
|
-
if (typeOrServiceProvider instanceof TypeDescriptor) {
|
|
529
|
-
return new ActionDescriptorInst(actionName, {
|
|
530
|
-
...(typeof serviceProviderOrActionName === 'string' ? {} : actionGetProviderCfgObj(serviceProviderOrActionName)),
|
|
531
|
-
...(typeof actionNameOrCfg === 'string' ? {} : actionNameOrCfg),
|
|
532
|
-
...cfg
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
else {
|
|
536
|
-
return new ActionDescriptorInst(actionName, {
|
|
537
|
-
...actionGetProviderCfgObj(typeOrServiceProvider),
|
|
538
|
-
...cfg
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
function actionFromModel(model, actionNameOrServiceProvider, cfgOrActionName, cfg) {
|
|
543
|
-
if (typeof actionNameOrServiceProvider === 'string') {
|
|
544
|
-
// no provider
|
|
545
|
-
return new ActionDescriptorInst(actionNameOrServiceProvider, {
|
|
546
|
-
model,
|
|
547
|
-
...(typeof cfgOrActionName === 'object' ? cfgOrActionName : {}),
|
|
548
|
-
...cfg
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
return new ActionDescriptorInst(typeof cfgOrActionName === 'string' ? cfgOrActionName : 'default', {
|
|
553
|
-
model,
|
|
554
|
-
...actionGetProviderCfgObj(actionNameOrServiceProvider),
|
|
555
|
-
...cfg
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
function actionFromClass(type, actionNameOrServiceProvider, cfgOrActionName, cfg) {
|
|
560
|
-
if (typeof actionNameOrServiceProvider === 'string') {
|
|
561
|
-
// no provider
|
|
562
|
-
const finalCfg = typeof cfgOrActionName === 'object' ? cfgOrActionName : cfg;
|
|
563
|
-
return new ActionDescriptorInst(actionNameOrServiceProvider, {
|
|
564
|
-
model: new ModelDescriptor(type, finalCfg?.idProperty, finalCfg?.titleProperty, finalCfg?.i18nBaseKey),
|
|
565
|
-
...(typeof cfgOrActionName === 'object' ? cfgOrActionName : {}),
|
|
566
|
-
...cfg
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
else {
|
|
570
|
-
return new ActionDescriptorInst(typeof cfgOrActionName === 'string' ? cfgOrActionName : 'default', {
|
|
571
|
-
model: new ModelDescriptor(type, cfg?.idProperty, cfg?.titleProperty, cfg?.i18nBaseKey),
|
|
572
|
-
...actionGetProviderCfgObj(actionNameOrServiceProvider),
|
|
573
|
-
...cfg
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
class ActionDeleteDescriptor {
|
|
578
|
-
static create(model) {
|
|
579
|
-
return actionDelete(model);
|
|
580
|
-
}
|
|
581
|
-
static createWithProvider(model, serviceProvider) {
|
|
582
|
-
return actionDelete(model, serviceProvider);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
function actionDelete(model, serviceProvider) {
|
|
586
|
-
return new ActionDeleteDescriptorInst(model, {
|
|
587
|
-
...(serviceProvider ? actionGetProviderCfgObj(serviceProvider) : {})
|
|
454
|
+
/**
|
|
455
|
+
* Creates and returns an instance of ActionDescriptorInst, allowing customization of the action's behavior through configuration options.
|
|
456
|
+
*
|
|
457
|
+
* @param {string} actionName - The unique name of the action.
|
|
458
|
+
* @param {ActionDescriptorCreateFromModelOptsType<Model, Service, RunInput, RunResult, ValidationInput>} [opts] - Optional configuration object to define the action's behavior, including model, service provider and other.
|
|
459
|
+
* @return {ActionDescriptorInst<Model, Service, RunInput, RunResult, ValidationInput>} An instance of ActionDescriptorInst configured with the provided parameters.
|
|
460
|
+
*/
|
|
461
|
+
function action(actionName, opts) {
|
|
462
|
+
return new ActionDescriptorInst(actionName, {
|
|
463
|
+
...(opts?.serviceProvider ? actionGetProviderCfgObj(opts.serviceProvider) : {}),
|
|
464
|
+
...opts
|
|
588
465
|
});
|
|
589
466
|
}
|
|
590
467
|
|
|
591
468
|
class EditorDataProviderInst extends DataProviderInst {
|
|
592
|
-
constructor(
|
|
593
|
-
super(
|
|
469
|
+
constructor(serviceType) {
|
|
470
|
+
super(serviceType);
|
|
594
471
|
this._editorResetSubject = new Subject();
|
|
595
|
-
this._fetch = id => throwError(() => new CommonsInternalError(`No fetch function provided for id ${id}.`));
|
|
596
472
|
}
|
|
597
473
|
get fetch() {
|
|
598
474
|
return this._fetch;
|
|
@@ -606,6 +482,12 @@ class EditorDataProviderInst extends DataProviderInst {
|
|
|
606
482
|
get delete() {
|
|
607
483
|
return this._delete;
|
|
608
484
|
}
|
|
485
|
+
get mapFetchItemToCreateItem() {
|
|
486
|
+
return this._mapFetchItemToCreateItem;
|
|
487
|
+
}
|
|
488
|
+
get mapFetchItemToUpdateItem() {
|
|
489
|
+
return this._mapFetchItemToUpdateItem;
|
|
490
|
+
}
|
|
609
491
|
get editorReset$() {
|
|
610
492
|
return this._editorResetSubject.asObservable();
|
|
611
493
|
}
|
|
@@ -625,7 +507,7 @@ class EditorDataProviderInst extends DataProviderInst {
|
|
|
625
507
|
/**
|
|
626
508
|
* Sets the create function for the EditorDataProvider.
|
|
627
509
|
*
|
|
628
|
-
* @param {EditorDataProviderCreateFnType<Model, Service>} fn - The function used for creating new items.
|
|
510
|
+
* @param {EditorDataProviderCreateFnType<CreateModel, Model, Service>} fn - The function used for creating new items.
|
|
629
511
|
* @returns {this} - Returns the instance of the class.
|
|
630
512
|
*
|
|
631
513
|
* @typeparam Model The type of data this DataProvider will handle.
|
|
@@ -662,16 +544,43 @@ class EditorDataProviderInst extends DataProviderInst {
|
|
|
662
544
|
this._delete = fn;
|
|
663
545
|
return this;
|
|
664
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* Sets the function to map data from fetch function to create model.
|
|
549
|
+
*
|
|
550
|
+
* @param {EditorDataProviderFetchMapToFnType<Model, CreateModel>} fn - The map function to be set.
|
|
551
|
+
*
|
|
552
|
+
* @returns {this} - Returns the instance of the current class.
|
|
553
|
+
*
|
|
554
|
+
* @typeparam Model The type of data from fetch function to map from.
|
|
555
|
+
* @typeparam CreateModel The type of data to map to.
|
|
556
|
+
*/
|
|
557
|
+
withMapFetchItemToCreateItem(fn) {
|
|
558
|
+
this._mapFetchItemToCreateItem = fn;
|
|
559
|
+
return this;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Sets the function to map data from fetch function to update model.
|
|
563
|
+
*
|
|
564
|
+
* @param {EditorDataProviderFetchMapToFnType<Model, UpdateModel>} fn - The map function to be set.
|
|
565
|
+
*
|
|
566
|
+
* @returns {this} - Returns the instance of the current class.
|
|
567
|
+
*
|
|
568
|
+
* @typeparam Model The type of data from fetch function to map from.
|
|
569
|
+
* @typeparam UpdateModel The type of data to map to.
|
|
570
|
+
*/
|
|
571
|
+
withMapFetchItemToUpdateItem(fn) {
|
|
572
|
+
this._mapFetchItemToUpdateItem = fn;
|
|
573
|
+
return this;
|
|
574
|
+
}
|
|
665
575
|
resetEditor(event) {
|
|
666
576
|
this._editorResetSubject.next(event ?? {});
|
|
667
577
|
}
|
|
668
578
|
}
|
|
669
579
|
|
|
670
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
671
580
|
class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
672
581
|
constructor(editorDescriptor, actionName, cfg) {
|
|
673
582
|
super(actionName, {
|
|
674
|
-
model: editorDescriptor.model,
|
|
583
|
+
model: cfg?.model ?? editorDescriptor.model,
|
|
675
584
|
...cfg
|
|
676
585
|
});
|
|
677
586
|
this._dataProvider = undefined;
|
|
@@ -682,9 +591,8 @@ class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
|
682
591
|
this._dialogSize = StyleSizeEnum.Normal;
|
|
683
592
|
this._resubmitRefetch = true;
|
|
684
593
|
this._unsavedChangesConfirmation = false;
|
|
685
|
-
this._isTableviewMainEditor = cfg?.isTableviewMainEditor ?? false;
|
|
686
594
|
if (cfg?.serviceType) {
|
|
687
|
-
this._dataProvider = new EditorDataProviderInst(
|
|
595
|
+
this._dataProvider = new EditorDataProviderInst(cfg.serviceType);
|
|
688
596
|
}
|
|
689
597
|
else if (cfg?.dataProvider) {
|
|
690
598
|
this._dataProvider = cfg.dataProvider;
|
|
@@ -693,9 +601,6 @@ class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
|
693
601
|
this._editorDescriptor = editorDescriptor;
|
|
694
602
|
this._editorActions.push(actionEditorSubmit(this), actionEditorCancel(this));
|
|
695
603
|
}
|
|
696
|
-
get isTableviewMainEditor() {
|
|
697
|
-
return this._isTableviewMainEditor;
|
|
698
|
-
}
|
|
699
604
|
get editorTitle() {
|
|
700
605
|
return this._editorTitle;
|
|
701
606
|
}
|
|
@@ -876,60 +781,6 @@ function actionEditorSubmit(editorAction, submitType = ActionEditorSubmitTypeEnu
|
|
|
876
781
|
function actionEditorCancel(editorAction, submitType = ActionEditorSubmitTypeEnum.Cancel) {
|
|
877
782
|
return new ActionEditorSubmitDescriptorInst(editorAction.actionName, editorAction.model, submitType).withButtonDescriptor(new ActionButtonDescriptor().withStyleClass(new ButtonStyleBuilder().withTextButton().withActionLevel(editorAction.level)));
|
|
878
783
|
}
|
|
879
|
-
class ActionEditorDetailsDescriptorInst extends ActionEditorDescriptorInst {
|
|
880
|
-
static { this.ACTION_NAME = 'details'; }
|
|
881
|
-
constructor(editorDescriptor, cfg) {
|
|
882
|
-
super(editorDescriptor, ActionEditorDetailsDescriptorInst.ACTION_NAME, { ...cfg, isTableviewMainEditor: true });
|
|
883
|
-
this.withPosition(ActionPositionEnum.RowClick);
|
|
884
|
-
this.withRouteTrigger(':itemId');
|
|
885
|
-
this.withEditorActions([actionEditorCancel(this)]);
|
|
886
|
-
this.withTableviewCategory(TableviewActionDefaultCategories.DETAILS);
|
|
887
|
-
}
|
|
888
|
-
copy() {
|
|
889
|
-
const descriptor = new ActionEditorDetailsDescriptorInst(this.editorDescriptor.copy(), {
|
|
890
|
-
dataProvider: this._dataProvider
|
|
891
|
-
});
|
|
892
|
-
this.copyFieldsTo(descriptor);
|
|
893
|
-
return descriptor;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
class ActionEditorAddDescriptorInst extends ActionEditorDescriptorInst {
|
|
897
|
-
static { this.ACTION_NAME = 'add'; }
|
|
898
|
-
constructor(editorDescriptor, cfg) {
|
|
899
|
-
super(editorDescriptor, ActionEditorAddDescriptorInst.ACTION_NAME, { ...cfg, isTableviewMainEditor: true });
|
|
900
|
-
this.withPosition(ActionPositionEnum.ToolbarLeft);
|
|
901
|
-
this.withRouteTrigger('add');
|
|
902
|
-
this.button.withIcon('pi pi-plus');
|
|
903
|
-
this.withTableviewCategory(TableviewActionDefaultCategories.ADD);
|
|
904
|
-
this.withUnsavedChangesConfirmation();
|
|
905
|
-
}
|
|
906
|
-
copy() {
|
|
907
|
-
const descriptor = new ActionEditorAddDescriptorInst(this.editorDescriptor.copy(), {
|
|
908
|
-
dataProvider: this._dataProvider
|
|
909
|
-
});
|
|
910
|
-
this.copyFieldsTo(descriptor);
|
|
911
|
-
return descriptor;
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
class ActionEditorEditDescriptorInst extends ActionEditorDescriptorInst {
|
|
915
|
-
static { this.ACTION_NAME = 'edit'; }
|
|
916
|
-
constructor(editorDescriptor, cfg) {
|
|
917
|
-
super(editorDescriptor, ActionEditorEditDescriptorInst.ACTION_NAME, { ...cfg, isTableviewMainEditor: true });
|
|
918
|
-
this.withPosition(ActionPositionEnum.RowInline);
|
|
919
|
-
this.button.styleClass.withSize(StyleSizeEnum.Small);
|
|
920
|
-
this.withRouteTrigger(':itemId/edit');
|
|
921
|
-
this.withTableviewCategory(TableviewActionDefaultCategories.EDIT);
|
|
922
|
-
this.button.withLabel(null).withIcon('pi pi-pencil');
|
|
923
|
-
this.withUnsavedChangesConfirmation();
|
|
924
|
-
}
|
|
925
|
-
copy() {
|
|
926
|
-
const descriptor = new ActionEditorEditDescriptorInst(this.editorDescriptor.copy(), {
|
|
927
|
-
dataProvider: this._dataProvider
|
|
928
|
-
});
|
|
929
|
-
this.copyFieldsTo(descriptor);
|
|
930
|
-
return descriptor;
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
784
|
|
|
934
785
|
const actionEditorGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
935
786
|
const cfg = {};
|
|
@@ -944,66 +795,19 @@ const actionEditorGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
|
944
795
|
}
|
|
945
796
|
return cfg;
|
|
946
797
|
};
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
function actionEditor(
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
...cfg
|
|
961
|
-
});
|
|
962
|
-
}
|
|
963
|
-
else {
|
|
964
|
-
return new ActionEditorDescriptorInst(editor, typeof cfgOrActionName === 'string' ? cfgOrActionName : 'default', {
|
|
965
|
-
...actionEditorGetProviderCfgObj(actionNameOrServiceProvider),
|
|
966
|
-
...cfg
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
class ActionEditorDetailsDescriptor {
|
|
971
|
-
static create(editor) {
|
|
972
|
-
return actionEditorDetails(editor);
|
|
973
|
-
}
|
|
974
|
-
static createWithProvider(editor, serviceProvider) {
|
|
975
|
-
return actionEditorDetails(editor, serviceProvider);
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
function actionEditorDetails(editor, serviceProvider) {
|
|
979
|
-
return new ActionEditorDetailsDescriptorInst(editor, {
|
|
980
|
-
...(serviceProvider ? actionEditorGetProviderCfgObj(serviceProvider) : {})
|
|
981
|
-
});
|
|
982
|
-
}
|
|
983
|
-
class ActionEditorAddDescriptor {
|
|
984
|
-
static create(editor) {
|
|
985
|
-
return actionEditorAdd(editor);
|
|
986
|
-
}
|
|
987
|
-
static createWithProvider(editor, serviceProvider) {
|
|
988
|
-
return actionEditorAdd(editor, serviceProvider);
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
function actionEditorAdd(editor, serviceProvider) {
|
|
992
|
-
return new ActionEditorAddDescriptorInst(editor, {
|
|
993
|
-
...(serviceProvider ? actionEditorGetProviderCfgObj(serviceProvider) : {})
|
|
994
|
-
});
|
|
995
|
-
}
|
|
996
|
-
class ActionEditorEditDescriptor {
|
|
997
|
-
static create(editor) {
|
|
998
|
-
return actionEditorEdit(editor);
|
|
999
|
-
}
|
|
1000
|
-
static createWithProvider(editor, serviceProvider) {
|
|
1001
|
-
return actionEditorEdit(editor, serviceProvider);
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
function actionEditorEdit(editor, serviceProvider) {
|
|
1005
|
-
return new ActionEditorEditDescriptorInst(editor, {
|
|
1006
|
-
...(serviceProvider ? actionEditorGetProviderCfgObj(serviceProvider) : {})
|
|
798
|
+
/**
|
|
799
|
+
* Creates an ActionEditorDescriptorInst instance with the provided editor descriptor and options.
|
|
800
|
+
*
|
|
801
|
+
* @param {string} actionName - The name of the action to associate with the editor.
|
|
802
|
+
* @param {EditorDescriptorInst<EditorModel, any>} editor - The editor descriptor instance to be used.
|
|
803
|
+
* @param {ActionEditorDescriptorOptsType<Model, Service, FetchInput, SubmitReturn, ValidationInput>} [opts] - Optional configuration options for the ActionEditor.
|
|
804
|
+
* @return {ActionEditorDescriptorInst<Model, Service, EditorModel, FetchInput, SubmitReturn, ValidationInput>} An instance of ActionEditorDescriptor with the configured parameters.
|
|
805
|
+
*/
|
|
806
|
+
function actionEditor(actionName, editor, opts) {
|
|
807
|
+
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
808
|
+
...opts,
|
|
809
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {}),
|
|
810
|
+
model: opts?.model
|
|
1007
811
|
});
|
|
1008
812
|
}
|
|
1009
813
|
|
|
@@ -1080,37 +884,25 @@ class ActionLinkDescriptorInst extends ActionDescriptorInst {
|
|
|
1080
884
|
}
|
|
1081
885
|
}
|
|
1082
886
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
return actionLinkFromClass(type, actionName, cfg);
|
|
1092
|
-
}
|
|
1093
|
-
static fromAction(action) {
|
|
1094
|
-
return actionLinkFromAction(action);
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
function actionLink(actionName, cfg) {
|
|
1098
|
-
return new ActionLinkDescriptorInst(actionName, {
|
|
1099
|
-
...cfg
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
function actionLinkFromModel(model, actionName, cfg) {
|
|
1103
|
-
return new ActionLinkDescriptorInst(actionName, {
|
|
1104
|
-
model,
|
|
1105
|
-
...cfg
|
|
1106
|
-
});
|
|
1107
|
-
}
|
|
1108
|
-
function actionLinkFromClass(type, actionName, cfg) {
|
|
887
|
+
/**
|
|
888
|
+
* Creates an instance of ActionLinkDescriptorInst with the provided action name and options.
|
|
889
|
+
*
|
|
890
|
+
* @param {string} actionName - The unique name of the action.
|
|
891
|
+
* @param {ActionLinkCreateOptsType<Model, ValidationInput>} [opts] - Optional parameters for configuring the action link, including the model and validation type.
|
|
892
|
+
* @return {ActionLinkDescriptorInst<Model, ValidationInput>} An instance of ActionLinkDescriptorInst initialized with the action name and options.
|
|
893
|
+
*/
|
|
894
|
+
function actionLink(actionName, opts) {
|
|
1109
895
|
return new ActionLinkDescriptorInst(actionName, {
|
|
1110
|
-
|
|
1111
|
-
|
|
896
|
+
...opts,
|
|
897
|
+
model: opts?.model
|
|
1112
898
|
});
|
|
1113
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* Generates an ActionLinkDescriptorInst from the provided ActionDescriptorInst.
|
|
902
|
+
*
|
|
903
|
+
* @param {ActionDescriptorInst<Model, any, any, any, ValidationInput>} action - The action descriptor instance that serves as the basis for the action link.
|
|
904
|
+
* @return {ActionLinkDescriptorInst<Model, ValidationInput>} A newly created ActionLinkDescriptorInst configured with the provided action parameters.
|
|
905
|
+
*/
|
|
1114
906
|
function actionLinkFromAction(action) {
|
|
1115
907
|
const descriptor = new ActionLinkDescriptorInst(action.actionName, { model: action.model });
|
|
1116
908
|
action.copyFieldsTo(descriptor);
|
|
@@ -1123,6 +915,113 @@ function actionLinkFromAction(action) {
|
|
|
1123
915
|
return descriptor;
|
|
1124
916
|
}
|
|
1125
917
|
|
|
918
|
+
/**
|
|
919
|
+
* Defines an action to be positioned on a specified editor with editor-specific execution context.
|
|
920
|
+
*
|
|
921
|
+
* @param {string} actionName - The name identifying the action to be performed.
|
|
922
|
+
* @param {EditorDescriptorInst<EditorModel>} editor - The descriptor of the editor on which the action will be placed and executed.
|
|
923
|
+
* @param {Object} [opts] - Options for configuring the action behavior.
|
|
924
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The model descriptor associated with the action.
|
|
925
|
+
* @param {ActionProviderType<Model, Service>} [opts.serviceProvider] - The service provider type for execution context.
|
|
926
|
+
* @param {ActionPositionEnum.FooterLeft | ActionPositionEnum.FooterRight | ActionPositionEnum.ToolbarLeft | ActionPositionEnum.ToolbarRight} [opts.position] - The position of action on editor.
|
|
927
|
+
* @return {ActionDescriptorInst<Model, Service, EditorModel, Model, EditorModel>} - An instance representing the configured action descriptor for the specified editor and model.
|
|
928
|
+
*/
|
|
929
|
+
function actionOnEditor(actionName, editor, opts) {
|
|
930
|
+
return new ActionDescriptorInst(actionName, {
|
|
931
|
+
model: opts?.model,
|
|
932
|
+
...(opts?.serviceProvider ? actionGetProviderCfgObj(opts?.serviceProvider) : {})
|
|
933
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.FooterLeft);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Creates and returns an instance of `ActionEditorDescriptorInst` when positioned on another (parent) editor.
|
|
938
|
+
*
|
|
939
|
+
* @param {string} actionName - The name of the action associated with the editor.
|
|
940
|
+
* @param {EditorDescriptorInst<EditorModel, ParentEditor>} editor - The editor descriptor defining editor on action.
|
|
941
|
+
* @param {Object} [opts] - Optional parameters for configuring the action editor.
|
|
942
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The descriptor for the model associated with the action.
|
|
943
|
+
* @param {ActionEditorProviderType<Model, Service>} [opts.serviceProvider] - The service provider type for the action editor.
|
|
944
|
+
* @param {ActionPositionEnum.FooterLeft | ActionPositionEnum.FooterRight | ActionPositionEnum.ToolbarLeft | ActionPositionEnum.ToolbarRight} [opts.position] - The desired position of action on the editor.
|
|
945
|
+
* @return {ActionEditorDescriptorInst<Model, Service, EditorModel, ParentEditor, EditorModel, ParentEditor>} A configured instance of `ActionEditorDescriptorInst` representing the action editor.
|
|
946
|
+
*/
|
|
947
|
+
function actionEditorOnEditor(actionName, editor, opts) {
|
|
948
|
+
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
949
|
+
model: opts?.model,
|
|
950
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {})
|
|
951
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.FooterLeft);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Defines an action to be positioned on a specified table with table row execution context.
|
|
956
|
+
*
|
|
957
|
+
* @param {string} actionName - The name identifying the action to be performed.
|
|
958
|
+
* @param {TableDescriptorInst<TableModel, any, any>} table - The descriptor of the table on which the action will be placed and executed.
|
|
959
|
+
* @param {Object} [opts] - Options for configuring the action behavior.
|
|
960
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The model descriptor associated with the action.
|
|
961
|
+
* @param {ActionProviderType<Model, Service>} [opts.serviceProvider] - The service provider type for execution context.
|
|
962
|
+
* @param {ActionPositionEnum.RowInline | ActionPositionEnum.RowClick} [opts.position] - The position of action on table.
|
|
963
|
+
* @return {ActionDescriptorInst<Model, Service, TableModel, Model, TableModel>} - An instance representing the configured action descriptor for the specified table row and model.
|
|
964
|
+
*/
|
|
965
|
+
function actionOnTableRow(actionName, table, opts) {
|
|
966
|
+
return new ActionDescriptorInst(actionName, {
|
|
967
|
+
model: opts?.model,
|
|
968
|
+
...(opts?.serviceProvider ? actionGetProviderCfgObj(opts?.serviceProvider) : {})
|
|
969
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.RowInline);
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Defines an action to be positioned on a specified table with table header or footer execution context.
|
|
973
|
+
*
|
|
974
|
+
* @param {string} actionName - The name identifying the action to be performed.
|
|
975
|
+
* @param {Object} [opts] - Options for configuring the action behavior.
|
|
976
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The model descriptor associated with the action.
|
|
977
|
+
* @param {ActionProviderType<Model, Service>} [opts.serviceProvider] - The service provider type for execution context.
|
|
978
|
+
* @param {ActionPositionEnum.ToolbarLeft | ActionPositionEnum.ToolbarRight | ActionPositionEnum.TableHeader} [opts.position] - The position of action on table.
|
|
979
|
+
* @return {ActionDescriptorInst<Model, Service, TableModel, Model, TableModel>} - An instance representing the configured action descriptor for the specified table top and model.
|
|
980
|
+
*/
|
|
981
|
+
function actionOnTableTop(actionName, opts) {
|
|
982
|
+
return new ActionDescriptorInst(actionName, {
|
|
983
|
+
model: opts?.model,
|
|
984
|
+
...(opts?.serviceProvider ? actionGetProviderCfgObj(opts?.serviceProvider) : {})
|
|
985
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.ToolbarLeft);
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Creates and returns an ActionEditorDescriptorInst for displaying editor action on table row.
|
|
990
|
+
*
|
|
991
|
+
* @param {string} actionName - The name of the action.
|
|
992
|
+
* @param {EditorDescriptorInst<EditorModel, any>} editor - The editor descriptor instance responsible for configuring the editor behavior.
|
|
993
|
+
* @param {TableDescriptorInst<TableModel, any, any>} table - The table descriptor instance representing the table on which the action is positioned.
|
|
994
|
+
* @param {Object} [opts] - Optional configurations for the action editor.
|
|
995
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The model descriptor associated with the action editor.
|
|
996
|
+
* @param {ActionEditorProviderType<Model, Service>} [opts.serviceProvider] - The service provider for additional configurations or services for the action editor.
|
|
997
|
+
* @param {ActionPositionEnum.RowInline | ActionPositionEnum.RowClick} [opts.position] - The position where the action should be displayed on the table row.
|
|
998
|
+
* @return {ActionEditorDescriptorInst<Model, Service, EditorModel, TableModel, EditorModel, TableModel>} The configured action editor descriptor instance.
|
|
999
|
+
*/
|
|
1000
|
+
function actionEditorOnTableRow(actionName, editor, table, opts) {
|
|
1001
|
+
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
1002
|
+
model: opts?.model,
|
|
1003
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {})
|
|
1004
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.RowInline);
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Creates and returns an action editor descriptor configured with the given parameters.
|
|
1008
|
+
* This is used to define an action editor positioned relative to a table.
|
|
1009
|
+
*
|
|
1010
|
+
* @param {string} actionName - The name of the action.
|
|
1011
|
+
* @param {EditorDescriptorInst<EditorModel, any>} editor - The editor descriptor instance responsible for configuring the editor behavior.
|
|
1012
|
+
* @param {Object} [opts] - Optional configurations for the action editor.
|
|
1013
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The model descriptor associated with the action editor.
|
|
1014
|
+
* @param {ActionEditorProviderType<Model, Service>} [opts.serviceProvider] - The service provider for additional configurations or services for the action editor.
|
|
1015
|
+
* @param {ActionPositionEnum.ToolbarLeft | ActionPositionEnum.ToolbarRight | ActionPositionEnum.TableHeader} [opts.position] - The position of the action on the table.
|
|
1016
|
+
* @return {ActionEditorDescriptorInst<Model, Service, EditorModel, undefined, EditorModel, undefined>} The configured action editor descriptor instance.
|
|
1017
|
+
*/
|
|
1018
|
+
function actionEditorOnTableTop(actionName, editor, opts) {
|
|
1019
|
+
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
1020
|
+
model: opts?.model,
|
|
1021
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {})
|
|
1022
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.ToolbarLeft);
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1126
1025
|
class CommonsActionError extends ACommonsErrorBase {
|
|
1127
1026
|
constructor(message, actionName, options) {
|
|
1128
1027
|
super(message, {
|
|
@@ -1158,11 +1057,31 @@ function runGetAllFromDataProvider(ctx) {
|
|
|
1158
1057
|
}
|
|
1159
1058
|
return null;
|
|
1160
1059
|
}
|
|
1161
|
-
function runFetchFromDataProvider(ctx) {
|
|
1060
|
+
function runFetchFromDataProvider(ctx, opts) {
|
|
1162
1061
|
if (typeof ctx.dataProvider !== 'undefined') {
|
|
1163
1062
|
const editorDataProvider = ctx.dataProvider;
|
|
1164
1063
|
if (typeof editorDataProvider.fetch === 'function') {
|
|
1165
|
-
return ctx.parameters?.itemId
|
|
1064
|
+
return ctx.parameters?.itemId
|
|
1065
|
+
? toObservable(editorDataProvider.fetch(ctx.parameters.itemId, ctx.serviceInstance, ctx.parameters.locale)).pipe(map(res => {
|
|
1066
|
+
if (opts?.reason === 'update') {
|
|
1067
|
+
if (opts?.strict && typeof editorDataProvider.mapFetchItemToUpdateItem !== 'function') {
|
|
1068
|
+
throw new CommonsInternalError(`mapFetchToUpdate function must be provided in data provider`);
|
|
1069
|
+
}
|
|
1070
|
+
else if (typeof editorDataProvider.mapFetchItemToUpdateItem === 'function') {
|
|
1071
|
+
return editorDataProvider.mapFetchItemToUpdateItem(res);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
else if (opts?.reason === 'create') {
|
|
1075
|
+
if (opts?.strict && typeof editorDataProvider.mapFetchItemToCreateItem !== 'function') {
|
|
1076
|
+
throw new CommonsInternalError(`mapFetchToCreate function must be provided in data provider`);
|
|
1077
|
+
}
|
|
1078
|
+
else if (typeof editorDataProvider.mapFetchItemToCreateItem === 'function') {
|
|
1079
|
+
return editorDataProvider.mapFetchItemToCreateItem(res);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
return res;
|
|
1083
|
+
}))
|
|
1084
|
+
: null;
|
|
1166
1085
|
}
|
|
1167
1086
|
}
|
|
1168
1087
|
return null;
|
|
@@ -1189,7 +1108,7 @@ function runDeleteFromDataProvider(ctx) {
|
|
|
1189
1108
|
if (typeof ctx.dataProvider !== 'undefined') {
|
|
1190
1109
|
const editorDataProvider = ctx.dataProvider;
|
|
1191
1110
|
if (typeof editorDataProvider.delete === 'function') {
|
|
1192
|
-
return ctx.parameters?.itemId ? toObservable(editorDataProvider.delete(ctx.parameters.itemId, ctx.
|
|
1111
|
+
return ctx.parameters?.itemId ? toObservable(editorDataProvider.delete(ctx.parameters.itemId, ctx.serviceInstance, ctx.parameters.item)) : null; // this is not exactly correct cast as the delete function should never receive Item, but in many cases it ain't so
|
|
1193
1112
|
}
|
|
1194
1113
|
}
|
|
1195
1114
|
return null;
|
|
@@ -1245,14 +1164,25 @@ var ActionInstanceStateEnum;
|
|
|
1245
1164
|
ActionInstanceStateEnum[ActionInstanceStateEnum["FinishRouteUntriggerTimeoutFinal"] = 24] = "FinishRouteUntriggerTimeoutFinal";
|
|
1246
1165
|
})(ActionInstanceStateEnum || (ActionInstanceStateEnum = {}));
|
|
1247
1166
|
|
|
1167
|
+
/**
|
|
1168
|
+
* Default categories for tableview actions
|
|
1169
|
+
*/
|
|
1170
|
+
class TableviewActionDefaultCategories {
|
|
1171
|
+
static { this.READ = '_defaultTwRead'; }
|
|
1172
|
+
static { this.ADD = '_defaultTwAdd'; }
|
|
1173
|
+
static { this.EDIT = '_defaultTwEdit'; }
|
|
1174
|
+
static { this.DELETE = '_defaultTwDelete'; }
|
|
1175
|
+
static { this.DETAILS = '_defaultTwDetails'; }
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1248
1178
|
const DATA_LANGUAGE_DROPDOWN_COMPONENT_IT = new InjectionToken('DATA_LANGUAGE_DROPDOWN_COMPONENT');
|
|
1249
1179
|
|
|
1250
1180
|
class DataProviderExecutor {
|
|
1251
1181
|
runGetAllOrFail(ctx) {
|
|
1252
1182
|
return runFnFromDataProviderOrFail(ctx, this.runGetAll.bind(this));
|
|
1253
1183
|
}
|
|
1254
|
-
runFetchOrFail(ctx) {
|
|
1255
|
-
return runFnFromDataProviderOrFail(ctx, this.runFetch
|
|
1184
|
+
runFetchOrFail(ctx, fetchReason) {
|
|
1185
|
+
return runFnFromDataProviderOrFail(ctx, ctx => this.runFetch(ctx, fetchReason));
|
|
1256
1186
|
}
|
|
1257
1187
|
runCreateOrFail(ctx) {
|
|
1258
1188
|
return runFnFromDataProviderOrFail(ctx, this.runCreate.bind(this));
|
|
@@ -1274,36 +1204,68 @@ class DataProviderExecutor {
|
|
|
1274
1204
|
}
|
|
1275
1205
|
}
|
|
1276
1206
|
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1207
|
+
/**
|
|
1208
|
+
* Creates and returns an instance of `EditorDataProviderInst` with the specified options for managing editor data.
|
|
1209
|
+
*
|
|
1210
|
+
* @param {Object} [opts] - The options object to configure the data provider.
|
|
1211
|
+
* @param {TypeDescriptor<Model> | ModelDescriptor<Model>} [opts.type] - The descriptor defining the type of model.
|
|
1212
|
+
* @param {ServiceClassType<Service>} [opts.service] - The service class type associated with the data provider.
|
|
1213
|
+
* @param {TypeDescriptor<CreateModel> | ModelDescriptor<CreateModel>} [opts.createType] - The descriptor defining the create type.
|
|
1214
|
+
* @param {TypeDescriptor<UpdateModel> | ModelDescriptor<UpdateModel>} [opts.updateType] - The descriptor defining the update type.
|
|
1215
|
+
* @return {EditorDataProviderInst<Model, Service, ServiceClass, CreateModel, UpdateModel>} An instance of `EditorDataProviderInst` configured according to the provided options.
|
|
1216
|
+
*/
|
|
1217
|
+
function editorDataProvider(opts) {
|
|
1218
|
+
return new EditorDataProviderInst(opts?.service);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* @experimental
|
|
1223
|
+
*/
|
|
1224
|
+
class EditorDescriptorNestedObjectWrapper {
|
|
1225
|
+
#path;
|
|
1226
|
+
#editor;
|
|
1227
|
+
constructor(editor, basePath) {
|
|
1228
|
+
this.#editor = editor;
|
|
1229
|
+
this.#path = basePath;
|
|
1280
1230
|
}
|
|
1281
|
-
|
|
1282
|
-
return
|
|
1231
|
+
nested(property) {
|
|
1232
|
+
return new EditorDescriptorNestedObjectWrapper(this.#editor, this.getNestedPropertyPath(property));
|
|
1283
1233
|
}
|
|
1284
|
-
|
|
1285
|
-
return
|
|
1234
|
+
getNestedPropertyPath(p) {
|
|
1235
|
+
return `${this.#path}.${p}`;
|
|
1286
1236
|
}
|
|
1287
|
-
|
|
1288
|
-
return
|
|
1237
|
+
getField(property) {
|
|
1238
|
+
return this.#editor.getFieldUnsafe(this.getNestedPropertyPath(property));
|
|
1289
1239
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1240
|
+
removeField(property) {
|
|
1241
|
+
this.#editor.removeFieldUnsafe(this.getNestedPropertyPath(property));
|
|
1242
|
+
}
|
|
1243
|
+
addField(property) {
|
|
1244
|
+
return this.#editor.addFieldUnsafe(this.getNestedPropertyPath(property));
|
|
1245
|
+
}
|
|
1246
|
+
withFields(...properties) {
|
|
1247
|
+
properties.forEach(p => this.#editor.addFieldUnsafe(this.getNestedPropertyPath(p)));
|
|
1248
|
+
return this;
|
|
1249
|
+
}
|
|
1250
|
+
addFieldLookup(property, opts) {
|
|
1251
|
+
return this.#editor.addFieldLookupUnsafe(this.getNestedPropertyPath(property), opts);
|
|
1252
|
+
}
|
|
1253
|
+
addFieldLookupEnum(property, enumModel, options) {
|
|
1254
|
+
return this.#editor.addFieldLookupEnumUnsafe(this.getNestedPropertyPath(property), enumModel, options);
|
|
1255
|
+
}
|
|
1256
|
+
addFieldManyEditor(property, tableviewDescriptor) {
|
|
1257
|
+
return this.#editor.addFieldManyEditorUnsafe(this.getNestedPropertyPath(property), tableviewDescriptor);
|
|
1258
|
+
}
|
|
1259
|
+
addFieldManyToManyEditor(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
1260
|
+
return this.#editor.addFieldManyToManyEditorUnsafe(this.getNestedPropertyPath(property), mainTableDescriptor, lookupTableDescriptor, lookupDataProvider);
|
|
1261
|
+
}
|
|
1262
|
+
addFieldDescriptor(field) {
|
|
1263
|
+
if (!field.property.startsWith(this.#path)) {
|
|
1264
|
+
throw new CommonsInternalError(`Field ${field.property} cannot be added to nested object property ${this.#path}: Paths do not match.`);
|
|
1265
|
+
}
|
|
1266
|
+
this.#editor.addFieldDescriptor(field);
|
|
1267
|
+
return this;
|
|
1292
1268
|
}
|
|
1293
|
-
}
|
|
1294
|
-
function editorDataProvider(type, serviceType) {
|
|
1295
|
-
return new EditorDataProviderInst(undefined, serviceType);
|
|
1296
|
-
}
|
|
1297
|
-
function editorDataProviderWithService(serviceType) {
|
|
1298
|
-
return new EditorDataProviderInst(undefined, serviceType);
|
|
1299
|
-
}
|
|
1300
|
-
function editorDataProviderFromClass(type, serviceType) {
|
|
1301
|
-
return new EditorDataProviderInst(type, serviceType);
|
|
1302
|
-
}
|
|
1303
|
-
function editorDataProviderFromModel(model, serviceType) {
|
|
1304
|
-
return typeof serviceType !== 'undefined'
|
|
1305
|
-
? new EditorDataProviderInst(model.type, serviceType)
|
|
1306
|
-
: new EditorDataProviderInst(model.type, undefined);
|
|
1307
1269
|
}
|
|
1308
1270
|
|
|
1309
1271
|
var TableviewEditorTypeEnum;
|
|
@@ -1444,6 +1406,9 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1444
1406
|
get label() {
|
|
1445
1407
|
return this._label;
|
|
1446
1408
|
}
|
|
1409
|
+
get labelUseModelBase() {
|
|
1410
|
+
return this._labelUseModelBase;
|
|
1411
|
+
}
|
|
1447
1412
|
get placeholder() {
|
|
1448
1413
|
return this._placeholder;
|
|
1449
1414
|
}
|
|
@@ -1537,8 +1502,14 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1537
1502
|
get isLocalized() {
|
|
1538
1503
|
return this._isLocalized;
|
|
1539
1504
|
}
|
|
1540
|
-
|
|
1505
|
+
/**
|
|
1506
|
+
* Set label for field.
|
|
1507
|
+
* @param label Full label (i18n path or other string). If null, no label will be used.
|
|
1508
|
+
* @param useModelBase If set to true, label will be appended to model's i18n base path.
|
|
1509
|
+
*/
|
|
1510
|
+
withLabel(label, useModelBase) {
|
|
1541
1511
|
this._label = label;
|
|
1512
|
+
this._labelUseModelBase = useModelBase;
|
|
1542
1513
|
return this;
|
|
1543
1514
|
}
|
|
1544
1515
|
withPlaceholder(placeholder) {
|
|
@@ -1863,10 +1834,9 @@ class FieldLookupDescriptor extends AFieldDescriptor {
|
|
|
1863
1834
|
this._dataProvider = cfg.dataProvider;
|
|
1864
1835
|
}
|
|
1865
1836
|
else {
|
|
1866
|
-
this._dataProvider = new LookupDataProviderInst(cfg?.
|
|
1837
|
+
this._dataProvider = new LookupDataProviderInst(cfg?.serviceType);
|
|
1867
1838
|
}
|
|
1868
1839
|
this._optionsValueProperty = cfg?.optionsValueProperty;
|
|
1869
|
-
trySetLookupItemsProperties(this);
|
|
1870
1840
|
}
|
|
1871
1841
|
get lookupType() {
|
|
1872
1842
|
return this._lookupType;
|
|
@@ -1992,7 +1962,7 @@ class FieldLookupDescriptor extends AFieldDescriptor {
|
|
|
1992
1962
|
class FieldLookupEnumDescriptor extends FieldLookupDescriptor {
|
|
1993
1963
|
constructor(property, enumModel, options) {
|
|
1994
1964
|
super(property, {
|
|
1995
|
-
dataProvider: new LookupDataProviderInst(undefined
|
|
1965
|
+
dataProvider: new LookupDataProviderInst(undefined),
|
|
1996
1966
|
optionsValueProperty: 'value'
|
|
1997
1967
|
});
|
|
1998
1968
|
this._enumModel = enumModel;
|
|
@@ -2075,7 +2045,7 @@ class FieldManyToManyEditorDescriptor extends AFieldDescriptor {
|
|
|
2075
2045
|
this._lookupTableDataProvider = cfg.lookupDataProvider;
|
|
2076
2046
|
}
|
|
2077
2047
|
else {
|
|
2078
|
-
this._lookupTableDataProvider = new TableDataProviderInst(
|
|
2048
|
+
this._lookupTableDataProvider = new TableDataProviderInst(cfg?.lookupServiceType);
|
|
2079
2049
|
}
|
|
2080
2050
|
}
|
|
2081
2051
|
get fieldType() {
|
|
@@ -2119,22 +2089,6 @@ class FieldManyToManyEditorDescriptor extends AFieldDescriptor {
|
|
|
2119
2089
|
this._excludeValueProperty = valueProperty;
|
|
2120
2090
|
return this;
|
|
2121
2091
|
}
|
|
2122
|
-
/**
|
|
2123
|
-
* @deprecated Use directly on lookup table descriptor.
|
|
2124
|
-
*/
|
|
2125
|
-
withSearch(enabled = true, searchFields) {
|
|
2126
|
-
return this.withSearchUnsafe(enabled, searchFields);
|
|
2127
|
-
}
|
|
2128
|
-
/**
|
|
2129
|
-
* @deprecated Use directly on lookup table descriptor.
|
|
2130
|
-
*/
|
|
2131
|
-
withSearchUnsafe(enabled = true, searchFields) {
|
|
2132
|
-
this.lookupTableDescriptor.withSearchUnsafe(enabled, {
|
|
2133
|
-
fields: searchFields,
|
|
2134
|
-
limitMaxWords: 100
|
|
2135
|
-
});
|
|
2136
|
-
return this;
|
|
2137
|
-
}
|
|
2138
2092
|
copy() {
|
|
2139
2093
|
const field = new FieldManyToManyEditorDescriptor(this._property, this._mainTableDescriptor.copy(), this._lookupTableDescriptor.copy(), {
|
|
2140
2094
|
lookupDataProvider: this.lookupTableDataProvider
|
|
@@ -2670,28 +2624,58 @@ class EditorDescriptorInst {
|
|
|
2670
2624
|
get autofocusOnField() {
|
|
2671
2625
|
return this._autofocusOnField;
|
|
2672
2626
|
}
|
|
2627
|
+
/**
|
|
2628
|
+
* Dives into nested object to add fields from the nested object on property.
|
|
2629
|
+
*
|
|
2630
|
+
* @experimental
|
|
2631
|
+
*
|
|
2632
|
+
* @param property Model property name.
|
|
2633
|
+
*/
|
|
2634
|
+
nested(property) {
|
|
2635
|
+
return new EditorDescriptorNestedObjectWrapper(this, property);
|
|
2636
|
+
}
|
|
2673
2637
|
/**
|
|
2674
2638
|
* Creates new tab group. Next added fields are added to newly created tab group.
|
|
2675
2639
|
* @param name Name of the group.
|
|
2676
|
-
* @param title Title key for the tab.
|
|
2640
|
+
* @param title Title key for the tab.7@return Newly created group descriptor.
|
|
2641
|
+
* @return Newly created group descriptor.
|
|
2677
2642
|
*/
|
|
2678
|
-
|
|
2643
|
+
addTabGroup(name, title) {
|
|
2679
2644
|
const tabGroup = new FieldTabGroupDescriptor(name);
|
|
2680
2645
|
tabGroup.withTitle(title);
|
|
2681
2646
|
this.createTabGroupDescriptor(tabGroup);
|
|
2682
2647
|
return tabGroup;
|
|
2683
2648
|
}
|
|
2649
|
+
/**
|
|
2650
|
+
* Creates new tab group. Next added fields are added to newly created tab group.
|
|
2651
|
+
* @param name Name of the group.
|
|
2652
|
+
* @param title Title key for the tab.7@return Newly created group descriptor.
|
|
2653
|
+
*/
|
|
2654
|
+
withTabGroup(name, title) {
|
|
2655
|
+
this.addTabGroup(name, title);
|
|
2656
|
+
return this;
|
|
2657
|
+
}
|
|
2684
2658
|
/**
|
|
2685
2659
|
* Creates new field group. Next added fields are added to newly created field group.
|
|
2686
2660
|
* @param name Name of the group.
|
|
2687
2661
|
* @param title Title key for the group.
|
|
2662
|
+
* @return Newly created group descriptor.
|
|
2688
2663
|
*/
|
|
2689
|
-
|
|
2664
|
+
addFieldGroup(name, title) {
|
|
2690
2665
|
const fieldGroup = new FieldGroupDescriptor(name);
|
|
2691
2666
|
fieldGroup.withTitle(title);
|
|
2692
2667
|
this.createFieldGroupDescriptor(fieldGroup);
|
|
2693
2668
|
return fieldGroup;
|
|
2694
2669
|
}
|
|
2670
|
+
/**
|
|
2671
|
+
* Creates new field group. Next added fields are added to newly created field group.
|
|
2672
|
+
* @param name Name of the group.
|
|
2673
|
+
* @param title Title key for the group.
|
|
2674
|
+
*/
|
|
2675
|
+
withFieldGroup(name, title) {
|
|
2676
|
+
this.addFieldGroup(name, title);
|
|
2677
|
+
return this;
|
|
2678
|
+
}
|
|
2695
2679
|
/**
|
|
2696
2680
|
* Gets field by the model property name.
|
|
2697
2681
|
* @param property Model property name.
|
|
@@ -2761,7 +2745,7 @@ class EditorDescriptorInst {
|
|
|
2761
2745
|
this.addFieldDescriptor(field);
|
|
2762
2746
|
return field;
|
|
2763
2747
|
}
|
|
2764
|
-
|
|
2748
|
+
withFields(...properties) {
|
|
2765
2749
|
properties.forEach(p => this.addField(p));
|
|
2766
2750
|
return this;
|
|
2767
2751
|
}
|
|
@@ -2774,155 +2758,39 @@ class EditorDescriptorInst {
|
|
|
2774
2758
|
* Adds lookup field.
|
|
2775
2759
|
*
|
|
2776
2760
|
* @param {Property} property - The property key of the editor.
|
|
2777
|
-
* @param {
|
|
2761
|
+
* @param {FieldsManageAddFieldLookupOpts<LookupModel, Service>} opts - Optional parameters configuring type and/or service provider.
|
|
2778
2762
|
* @typeparam Property - The property key of the EditorModel.
|
|
2779
2763
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
2764
|
+
* @typeparam Service - Service used for data provider.
|
|
2780
2765
|
* @typeparam FieldValue - The value type of field on editor.
|
|
2781
2766
|
*
|
|
2782
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel,
|
|
2767
|
+
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue>} - The field lookup descriptor.
|
|
2783
2768
|
*/
|
|
2784
|
-
addFieldLookup(property,
|
|
2785
|
-
return this.addFieldLookupUnsafe(property,
|
|
2769
|
+
addFieldLookup(property, opts) {
|
|
2770
|
+
return this.addFieldLookupUnsafe(property, opts);
|
|
2786
2771
|
}
|
|
2787
2772
|
/**
|
|
2788
2773
|
* [UNSAFE] Adds lookup field.
|
|
2789
2774
|
* This function is UNSAFE because property is not type-checked.
|
|
2790
2775
|
*
|
|
2791
2776
|
* @param {string} property Model property name.
|
|
2792
|
-
* @param {
|
|
2777
|
+
* @param {FieldsManageAddFieldLookupOpts<LookupModel, Service>} opts - Optional parameters configuring type and/or service provider.
|
|
2793
2778
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
2779
|
+
* @typeparam Service - Service used for data provider.
|
|
2794
2780
|
* @typeparam FieldValue - The value type of field on editor.
|
|
2795
2781
|
*
|
|
2796
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel,
|
|
2782
|
+
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue>} - The field lookup descriptor.
|
|
2797
2783
|
*/
|
|
2798
|
-
|
|
2784
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2785
|
+
addFieldLookupUnsafe(property, opts) {
|
|
2799
2786
|
const field = new FieldLookupDescriptor(property, {
|
|
2800
|
-
|
|
2787
|
+
...(opts?.serviceProvider ? fieldLookupGetProviderCfgObj(opts.serviceProvider) : {})
|
|
2801
2788
|
});
|
|
2802
2789
|
this.addFieldDescriptor(field);
|
|
2803
2790
|
return field;
|
|
2804
2791
|
}
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
*
|
|
2808
|
-
* @param {Property} property - The property key of the editor.
|
|
2809
|
-
* @param {TypeDescriptor<FieldModel>} type - The type descriptor for the lookup model.
|
|
2810
|
-
* @param {LookupValueProperty} lookupOptionsValueProperty - The value property used as value in the lookup options.
|
|
2811
|
-
* @typeparam Property - The property key of the EditorModel.
|
|
2812
|
-
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
2813
|
-
* @typeparam LookupValueProperty - The property of lookup model type.
|
|
2814
|
-
* @typeparam FieldValue - The value type of field on editor.
|
|
2815
|
-
*
|
|
2816
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, undefined, FieldValue>} - The field lookup descriptor.
|
|
2817
|
-
*/
|
|
2818
|
-
addFieldLookupWithOptionsValueProperty(property, type, lookupOptionsValueProperty) {
|
|
2819
|
-
return this.addFieldLookupWithOptionsValuePropertyUnsafe(property, type, lookupOptionsValueProperty);
|
|
2820
|
-
}
|
|
2821
|
-
/**
|
|
2822
|
-
* [UNSAFE] Adds a field lookup with options value property for lookup model.
|
|
2823
|
-
* This function is UNSAFE because property is not type-checked.
|
|
2824
|
-
*
|
|
2825
|
-
* @param {Property} property - The property key of the editor.
|
|
2826
|
-
* @param {TypeDescriptor<FieldModel>} type - The type descriptor for the lookup model.
|
|
2827
|
-
* @param {LookupValueProperty} lookupOptionsValueProperty - The value property used as value in the lookup options.
|
|
2828
|
-
* @typeparam Property - The property key of the EditorModel.
|
|
2829
|
-
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
2830
|
-
* @typeparam LookupValueProperty - The property of lookup model type.
|
|
2831
|
-
* @typeparam FieldValue - The value type of field on editor.
|
|
2832
|
-
* @typeparam ParentEditorModel - The value type of parent form.
|
|
2833
|
-
*
|
|
2834
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, undefined, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
2835
|
-
*/
|
|
2836
|
-
addFieldLookupWithOptionsValuePropertyUnsafe(property, type, lookupOptionsValueProperty) {
|
|
2837
|
-
const field = new FieldLookupDescriptor(property, {
|
|
2838
|
-
type: type?.classType,
|
|
2839
|
-
optionsValueProperty: lookupOptionsValueProperty
|
|
2840
|
-
});
|
|
2841
|
-
this.addFieldDescriptor(field);
|
|
2842
|
-
return field;
|
|
2843
|
-
}
|
|
2844
|
-
/**
|
|
2845
|
-
* Adds a field lookup with a data provider or service to the editor model.
|
|
2846
|
-
*
|
|
2847
|
-
* @param {Property} property - The property key of the editor.
|
|
2848
|
-
* @param {FieldLookupProviderType<LookupModel, Service>} provider - The field lookup data provider or service.
|
|
2849
|
-
* @param {TypeDescriptor<LookupModel>} [type] - The type of lookup - if data provider is passed as previous parameter, type can be omitted. If service is provider, type parameter is proposed in favour of correct typing.
|
|
2850
|
-
* @typeparam Property - The property key of the EditorModel.
|
|
2851
|
-
* @typeparam Service - The lookup service type.
|
|
2852
|
-
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
2853
|
-
* @typeparam FieldValue - The field value type, defaults to the editor's property type.
|
|
2854
|
-
*
|
|
2855
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue>} Created field lookup descriptor.
|
|
2856
|
-
*/
|
|
2857
|
-
addFieldLookupWithProvider(property, provider, type) {
|
|
2858
|
-
return this.addFieldLookupWithProviderUnsafe(property, provider, type);
|
|
2859
|
-
}
|
|
2860
|
-
/**
|
|
2861
|
-
* [UNSAFE] Adds a field lookup with a data provider or service to the editor model.
|
|
2862
|
-
* This function is UNSAFE because property is not type-checked.
|
|
2863
|
-
*
|
|
2864
|
-
* @param {string} property - The property key of the editor.
|
|
2865
|
-
* @param {FieldLookupProviderType<LookupModel, Service>} provider - The lookup provider or service for the field lookup.
|
|
2866
|
-
* @param {TypeDescriptor<LookupModel>?} type - Optional type descriptor for the field lookup.
|
|
2867
|
-
* @typeparam LookupModel - The field lookup model type.
|
|
2868
|
-
* @typeparam Service - The lookup service type.
|
|
2869
|
-
* @typeparam FieldValue - The value type of field on editor.
|
|
2870
|
-
*
|
|
2871
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue>} - The field lookup descriptor added to the instance.
|
|
2872
|
-
*/
|
|
2873
|
-
addFieldLookupWithProviderUnsafe(property, provider, type) {
|
|
2874
|
-
const cfg = fieldLookupGetProviderCfgObj(provider);
|
|
2875
|
-
const field = new FieldLookupDescriptor(property, {
|
|
2876
|
-
type: type?.classType,
|
|
2877
|
-
...cfg
|
|
2878
|
-
});
|
|
2879
|
-
this.addFieldDescriptor(field);
|
|
2880
|
-
return field;
|
|
2881
|
-
}
|
|
2882
|
-
/**
|
|
2883
|
-
* Adds a field lookup with data provider or service and options value property for lookup model.
|
|
2884
|
-
*
|
|
2885
|
-
* @param {Property} property - The property key of the editor.
|
|
2886
|
-
* @param {FieldLookupProviderType<FieldModel, Service>} provider - The lookup provider.
|
|
2887
|
-
* @param {TypeDescriptor<FieldModel>} type - The type descriptor for the lookup model.
|
|
2888
|
-
* @param {LookupValueProperty} lookupOptionsValueProperty - The value property used as value in the lookup options.
|
|
2889
|
-
* @typeparam Property - The property key of the EditorModel.
|
|
2890
|
-
* @typeparam Service - The lookup service type.
|
|
2891
|
-
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
2892
|
-
* @typeparam LookupValueProperty - The property of lookup model type.
|
|
2893
|
-
* @typeparam FieldValue - The value type of field on editor.
|
|
2894
|
-
*
|
|
2895
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
2896
|
-
*/
|
|
2897
|
-
addFieldLookupWithProviderAndOptionsValueProperty(property, provider, type, lookupOptionsValueProperty) {
|
|
2898
|
-
return this.addFieldLookupWithProviderAndOptionsValuePropertyUnsafe(property, provider, type, lookupOptionsValueProperty);
|
|
2899
|
-
}
|
|
2900
|
-
/**
|
|
2901
|
-
* [UNSAFE] Adds a field lookup with data provider or service and options value property for lookup model.
|
|
2902
|
-
* This function is UNSAFE because property is not type-checked.
|
|
2903
|
-
*
|
|
2904
|
-
* @param {string} property - The property key of the editor.
|
|
2905
|
-
* @param {FieldLookupProviderType<FieldModel, Service>} provider - The lookup provider.
|
|
2906
|
-
* @param {TypeDescriptor<FieldModel>} type - The type descriptor for the lookup model.
|
|
2907
|
-
* @param {string} lookupOptionsValueProperty - The value property used in the lookup options.
|
|
2908
|
-
* @typeparam Service - The service type.
|
|
2909
|
-
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
2910
|
-
* @typeparam FieldValue - The value type of field on editor.
|
|
2911
|
-
*
|
|
2912
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
2913
|
-
*/
|
|
2914
|
-
addFieldLookupWithProviderAndOptionsValuePropertyUnsafe(property, provider, type, lookupOptionsValueProperty) {
|
|
2915
|
-
const cfg = fieldLookupGetProviderCfgObj(provider);
|
|
2916
|
-
const field = new FieldLookupDescriptor(property, {
|
|
2917
|
-
type: type?.classType,
|
|
2918
|
-
optionsValueProperty: lookupOptionsValueProperty,
|
|
2919
|
-
...cfg
|
|
2920
|
-
});
|
|
2921
|
-
this.addFieldDescriptor(field);
|
|
2922
|
-
return field;
|
|
2923
|
-
}
|
|
2924
|
-
addFieldLookupEnum(property, enumDesc, options) {
|
|
2925
|
-
return this.addFieldLookupEnumUnsafe(property, enumDesc, options);
|
|
2792
|
+
addFieldLookupEnum(property, enumDesc, options) {
|
|
2793
|
+
return this.addFieldLookupEnumUnsafe(property, enumDesc, options);
|
|
2926
2794
|
}
|
|
2927
2795
|
/**
|
|
2928
2796
|
* Adds enum lookup field.
|
|
@@ -3074,7 +2942,7 @@ class EditorDescriptorInst {
|
|
|
3074
2942
|
createDefaultGroup() {
|
|
3075
2943
|
this.createDefaultTabGroup();
|
|
3076
2944
|
if (this._currentTabGroup?.fields.length === 0) {
|
|
3077
|
-
this.
|
|
2945
|
+
this.addFieldGroup(EditorDescriptorInst.defaultGroupName, null);
|
|
3078
2946
|
}
|
|
3079
2947
|
}
|
|
3080
2948
|
/**
|
|
@@ -3083,7 +2951,7 @@ class EditorDescriptorInst {
|
|
|
3083
2951
|
*/
|
|
3084
2952
|
createDefaultTabGroup() {
|
|
3085
2953
|
if (this._tabs.length === 0) {
|
|
3086
|
-
this.
|
|
2954
|
+
this.addTabGroup(EditorDescriptorInst.defaultGroupName, 'general.general');
|
|
3087
2955
|
}
|
|
3088
2956
|
}
|
|
3089
2957
|
/**
|
|
@@ -3115,252 +2983,18 @@ class EditorDescriptorInst {
|
|
|
3115
2983
|
}
|
|
3116
2984
|
}
|
|
3117
2985
|
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
* @param attributeType
|
|
3121
|
-
*/
|
|
3122
|
-
function getFieldInputTypeFromClassAttributeDefType(attributeType) {
|
|
3123
|
-
switch (attributeType) {
|
|
3124
|
-
case 'hidden':
|
|
3125
|
-
return FieldInputTypeEnum.Hidden;
|
|
3126
|
-
case 'label':
|
|
3127
|
-
return FieldInputTypeEnum.Label;
|
|
3128
|
-
case 'textarea':
|
|
3129
|
-
return FieldInputTypeEnum.Textarea;
|
|
3130
|
-
case 'number':
|
|
3131
|
-
return FieldInputTypeEnum.Number;
|
|
3132
|
-
case 'currency':
|
|
3133
|
-
return FieldInputTypeEnum.Currency;
|
|
3134
|
-
case 'switch':
|
|
3135
|
-
case 'boolean':
|
|
3136
|
-
return FieldInputTypeEnum.Switch;
|
|
3137
|
-
case 'radio':
|
|
3138
|
-
return FieldInputTypeEnum.Radio;
|
|
3139
|
-
case 'datepicker':
|
|
3140
|
-
return FieldInputTypeEnum.Datepicker;
|
|
3141
|
-
case 'mask':
|
|
3142
|
-
return FieldInputTypeEnum.Mask;
|
|
3143
|
-
case 'file':
|
|
3144
|
-
return FieldInputTypeEnum.File;
|
|
3145
|
-
case 'custom':
|
|
3146
|
-
return FieldInputTypeEnum.Custom;
|
|
3147
|
-
case 'text':
|
|
3148
|
-
default:
|
|
3149
|
-
return FieldInputTypeEnum.Text;
|
|
3150
|
-
}
|
|
3151
|
-
}
|
|
3152
|
-
/**
|
|
3153
|
-
* convert column type to equivalent field input type
|
|
3154
|
-
* @param type column type
|
|
3155
|
-
* @param displayType column display type
|
|
3156
|
-
*/
|
|
3157
|
-
function getFieldInputTypeFromColumnType(type, displayType) {
|
|
3158
|
-
switch (type) {
|
|
3159
|
-
case ColumnTypeEnum.Number:
|
|
3160
|
-
return displayType === ColumnDisplayTypeEnum.Currency ? FieldInputTypeEnum.Currency : FieldInputTypeEnum.Number;
|
|
3161
|
-
case ColumnTypeEnum.Boolean:
|
|
3162
|
-
return FieldInputTypeEnum.Switch;
|
|
3163
|
-
case ColumnTypeEnum.Date:
|
|
3164
|
-
return FieldInputTypeEnum.Datepicker;
|
|
3165
|
-
case ColumnTypeEnum.Custom:
|
|
3166
|
-
return FieldInputTypeEnum.Custom;
|
|
3167
|
-
case ColumnTypeEnum.String:
|
|
3168
|
-
case ColumnTypeEnum.Enum:
|
|
3169
|
-
default:
|
|
3170
|
-
return FieldInputTypeEnum.Text;
|
|
3171
|
-
}
|
|
3172
|
-
}
|
|
3173
|
-
function expandClassAttributeDefWithEditorDef(attributes) {
|
|
3174
|
-
if (!attributes) {
|
|
3175
|
-
throw new CommonsInternalError('Class attribute definition is null, problem with TypeRegistry::findAttributesDefinitionByClassType?', { name: 'TableviewUtilsError' });
|
|
3176
|
-
}
|
|
3177
|
-
const typeRegistry = TypeRegistry.get();
|
|
3178
|
-
const editorClassAttributeDef = [];
|
|
3179
|
-
for (const attribute of attributes) {
|
|
3180
|
-
editorClassAttributeDef.push({
|
|
3181
|
-
name: attribute.name,
|
|
3182
|
-
baseName: attribute.baseName,
|
|
3183
|
-
type: attribute.type,
|
|
3184
|
-
subtype: attribute.subtype,
|
|
3185
|
-
fieldType: getFieldInputTypeFromClassAttributeDefType(attribute.type),
|
|
3186
|
-
classType: typeRegistry.findType(attribute.type),
|
|
3187
|
-
enumType: typeRegistry.findEnum(attribute.type)
|
|
3188
|
-
});
|
|
3189
|
-
}
|
|
3190
|
-
return editorClassAttributeDef;
|
|
3191
|
-
}
|
|
3192
|
-
/**
|
|
3193
|
-
* returns attributes from class type and extends to typed def with column and field enum type
|
|
3194
|
-
* @param type class type
|
|
3195
|
-
*/
|
|
3196
|
-
function getEditorClassAttributeDef(type) {
|
|
3197
|
-
return expandClassAttributeDefWithEditorDef(TypeRegistry.get().findAttributesDefinitionByClassType(type));
|
|
3198
|
-
}
|
|
3199
|
-
|
|
3200
|
-
/**
|
|
3201
|
-
* Generates field based on attribute definition, used for auto model
|
|
3202
|
-
* @param descriptor Editor descriptor instance.
|
|
3203
|
-
* @param attribute Attribute definition.
|
|
3204
|
-
* @param field Optional, if defined will be replaced, otherwise new will be generated.
|
|
3205
|
-
* @param args Optional additional arguments mapped to filed type. Arguments depend on possible arguments on fields.
|
|
3206
|
-
* @internal
|
|
3207
|
-
*/
|
|
3208
|
-
function upsertEditorFieldFromAttributeDef(descriptor, attribute, field, ...args) {
|
|
3209
|
-
if (field == null) {
|
|
3210
|
-
field = descriptor.addFieldUnsafe(attribute.name);
|
|
3211
|
-
}
|
|
3212
|
-
if (field instanceof FieldInputDescriptor) {
|
|
3213
|
-
if (attribute.enumType) {
|
|
3214
|
-
return field.asRadioFromEnum(enumModelGeneric(attribute.enumType));
|
|
3215
|
-
}
|
|
3216
|
-
else {
|
|
3217
|
-
const tableColumnType = getColumnTypeFromClassAttributeDefType(attribute.type);
|
|
3218
|
-
const tableColumnDisplayType = getColumnDisplayTypeFromColumnType(tableColumnType, attribute.type);
|
|
3219
|
-
return field.asType(attribute.fieldType ?? getFieldInputTypeFromColumnType(tableColumnType, tableColumnDisplayType), ...args);
|
|
3220
|
-
}
|
|
3221
|
-
}
|
|
3222
|
-
return field;
|
|
3223
|
-
}
|
|
3224
|
-
/**
|
|
3225
|
-
* Modifies selected field by field property. For enums use {withFieldModifiedEnum} instead.
|
|
3226
|
-
* @param descriptor Editor descriptor.
|
|
3227
|
-
* @param property Model's property name.
|
|
3228
|
-
* @param fieldType new field type for selected field
|
|
3229
|
-
* @param args additional parameters for field
|
|
3230
|
-
*/
|
|
3231
|
-
function modifyEditorClassAttributeFieldType(descriptor, property, fieldType, ...args) {
|
|
3232
|
-
return modifyEditorClassAttributeFieldTypeUnsafe(descriptor, property, fieldType, ...args);
|
|
3233
|
-
}
|
|
3234
|
-
function modifyEditorClassAttributeFieldTypeUnsafe(descriptor, property, fieldType, ...args) {
|
|
3235
|
-
if (!descriptor.model.type) {
|
|
3236
|
-
throw new CommonsInternalError(`withFieldModifiedType cannot be executed for property ${property}: Model type is not defined.`);
|
|
3237
|
-
}
|
|
3238
|
-
const attribute = getEditorClassAttributeDef(descriptor.model.type).find(attribute => attribute.name === property);
|
|
3239
|
-
if (attribute) {
|
|
3240
|
-
attribute.fieldType = fieldType;
|
|
3241
|
-
return upsertEditorFieldFromAttributeDef(descriptor, attribute, descriptor.fields.find(fi => fi.property === property), ...args);
|
|
3242
|
-
}
|
|
3243
|
-
return null;
|
|
3244
|
-
}
|
|
3245
|
-
/**
|
|
3246
|
-
* Modifies selected field with enum type.
|
|
3247
|
-
* @param descriptor Editor descriptor.
|
|
3248
|
-
* @param property Model's property name.
|
|
3249
|
-
* @param enumModel Enum descriptor.
|
|
3250
|
-
* @param values
|
|
3251
|
-
*/
|
|
3252
|
-
function modifyEditorClassAttributeFieldEnum(descriptor, property, enumModel, values) {
|
|
3253
|
-
return modifyEditorClassAttributeFieldEnumUnsafe(descriptor, property, enumModel, values);
|
|
3254
|
-
}
|
|
3255
|
-
function modifyEditorClassAttributeFieldEnumUnsafe(descriptor, property, enumDesc, values) {
|
|
3256
|
-
if (!descriptor.model.type) {
|
|
3257
|
-
throw new CommonsInternalError(`withFieldModifiedEnum cannot be executed for property ${property}: Model type is not defined.`);
|
|
3258
|
-
}
|
|
3259
|
-
const attribute = getEditorClassAttributeDef(descriptor.model.type).find(a => a.name === property);
|
|
3260
|
-
if (attribute) {
|
|
3261
|
-
attribute.fieldType = FieldInputTypeEnum.Radio;
|
|
3262
|
-
const field = descriptor.fields.find(f => f.property === property);
|
|
3263
|
-
if (field && field instanceof FieldInputDescriptor) {
|
|
3264
|
-
field.asRadioFromEnum(enumDesc ?? enumModelGeneric(TypeRegistry.get().findEnum(attribute.type)), values);
|
|
3265
|
-
}
|
|
3266
|
-
return field ?? null;
|
|
3267
|
-
}
|
|
3268
|
-
return null;
|
|
3269
|
-
}
|
|
3270
|
-
/**
|
|
3271
|
-
* Modifies selected field with lookup field.
|
|
3272
|
-
* @param descriptor Editor descriptor.
|
|
3273
|
-
* @param property Model's property name.
|
|
3274
|
-
* @param lookupProvider provider to be added to field
|
|
3275
|
-
* @param titleProperty
|
|
3276
|
-
*/
|
|
3277
|
-
function modifyEditorFieldLookup(descriptor, property, lookupProvider, titleProperty) {
|
|
3278
|
-
return modifyEditorFieldLookupUnsafe(descriptor, property, lookupProvider, titleProperty);
|
|
3279
|
-
}
|
|
3280
|
-
function modifyEditorFieldLookupUnsafe(descriptor, property, lookupProvider, titleProperty) {
|
|
3281
|
-
descriptor.removeFieldUnsafe(property);
|
|
3282
|
-
const field = descriptor.addFieldLookupWithProviderUnsafe(property, lookupProvider).asAutocomplete();
|
|
3283
|
-
if (titleProperty) {
|
|
3284
|
-
field.withOptionsLabelPropertyUnsafe(titleProperty);
|
|
3285
|
-
}
|
|
3286
|
-
return field;
|
|
3287
|
-
}
|
|
3288
|
-
|
|
3289
|
-
class EditorDescriptor extends EditorDescriptorInst {
|
|
3290
|
-
constructor() {
|
|
3291
|
-
super(ModelDescriptor.create());
|
|
3292
|
-
}
|
|
3293
|
-
static create(idProperty, titleProperty, i18nBaseKey, tableviewEditorType = TableviewEditorTypeEnum.None) {
|
|
3294
|
-
return editorDescriptor({ id: idProperty, title: titleProperty, i18nBase: i18nBaseKey, tableviewEditorType: tableviewEditorType });
|
|
3295
|
-
}
|
|
3296
|
-
static fromClass(type, idProperty, titleProperty, i18nBaseKey, tableviewEditorType = TableviewEditorTypeEnum.None) {
|
|
3297
|
-
return editorDescriptorFromClass(type, {
|
|
3298
|
-
id: idProperty,
|
|
3299
|
-
title: titleProperty,
|
|
3300
|
-
i18nBase: i18nBaseKey,
|
|
3301
|
-
tableviewEditorType: tableviewEditorType
|
|
3302
|
-
});
|
|
3303
|
-
}
|
|
3304
|
-
static fromModel(model, tableviewEditorType = TableviewEditorTypeEnum.None) {
|
|
3305
|
-
return editorDescriptor(model, { tableviewEditorType: tableviewEditorType });
|
|
3306
|
-
}
|
|
3307
|
-
/**
|
|
3308
|
-
* Creates editor descriptor automatically based on openapi model's attributes definition which is automatically extracted. All fields will be included.
|
|
3309
|
-
* @param type Model's class.
|
|
3310
|
-
* @param idProperty Id property representing model (optional).
|
|
3311
|
-
* @param titleProperty Title property representing model (optional). If not provided, it will be automatically chosen.
|
|
3312
|
-
* @param tableEditorType Type of editor in tableview (add, edit, view or none).
|
|
3313
|
-
*/
|
|
3314
|
-
static fromClassWithAutoAttrsDef(type, idProperty, titleProperty, tableEditorType = TableviewEditorTypeEnum.None) {
|
|
3315
|
-
return EditorDescriptor.fromClassWithCustomAttrsDef(type, getEditorClassAttributeDef(type), idProperty, titleProperty, tableEditorType);
|
|
3316
|
-
}
|
|
3317
|
-
/**
|
|
3318
|
-
* Creates editor descriptor automatically based on openapi model's attributes definition provided in parameters. Only fields for provided attributes will be included.
|
|
3319
|
-
* @param type Model's class.
|
|
3320
|
-
* @param attributes List of attribute definitions from which fields should be created.
|
|
3321
|
-
* @param idProperty Id property representing model (optional).
|
|
3322
|
-
* @param titleProperty Title property representing model (optional). If not provided, it will be automatically chosen.
|
|
3323
|
-
* @param tableviewEditorType Type of editor in tableview (add, edit, view or none).
|
|
3324
|
-
*/
|
|
3325
|
-
static fromClassWithCustomAttrsDef(type, attributes, idProperty, titleProperty, tableviewEditorType = TableviewEditorTypeEnum.None) {
|
|
3326
|
-
return editorDescriptorFromClassAttrsDef(type, attributes, {
|
|
3327
|
-
id: idProperty,
|
|
3328
|
-
title: titleProperty,
|
|
3329
|
-
tableviewEditorType: tableviewEditorType
|
|
3330
|
-
});
|
|
3331
|
-
}
|
|
3332
|
-
}
|
|
3333
|
-
function editorDescriptor(typeOrModelOrClassOrOpts, opts) {
|
|
3334
|
-
if (typeOrModelOrClassOrOpts == null) {
|
|
2986
|
+
function editorDescriptor(modelOrOpts, opts) {
|
|
2987
|
+
if (modelOrOpts == null) {
|
|
3335
2988
|
return new EditorDescriptorInst(model(), opts?.tableviewEditorType);
|
|
3336
2989
|
}
|
|
3337
|
-
else if (
|
|
3338
|
-
return new EditorDescriptorInst(
|
|
3339
|
-
}
|
|
3340
|
-
else if (typeOrModelOrClassOrOpts instanceof ModelDescriptor) {
|
|
3341
|
-
return new EditorDescriptorInst(typeOrModelOrClassOrOpts, opts?.tableviewEditorType);
|
|
2990
|
+
else if (modelOrOpts instanceof ModelDescriptor) {
|
|
2991
|
+
return new EditorDescriptorInst(modelOrOpts, opts?.tableviewEditorType);
|
|
3342
2992
|
}
|
|
3343
2993
|
else {
|
|
3344
2994
|
// this could have autoGenerated if model descriptor is class
|
|
3345
|
-
return new EditorDescriptorInst(model(
|
|
2995
|
+
return new EditorDescriptorInst(model(modelOrOpts), modelOrOpts?.tableviewEditorType);
|
|
3346
2996
|
}
|
|
3347
2997
|
}
|
|
3348
|
-
function editorDescriptorFromClass(type, opts) {
|
|
3349
|
-
return new EditorDescriptorInst(model(type, opts), opts?.tableviewEditorType);
|
|
3350
|
-
}
|
|
3351
|
-
/**
|
|
3352
|
-
* Generates descriptor based on type attribute definition
|
|
3353
|
-
* @param type class type
|
|
3354
|
-
* @param attributes
|
|
3355
|
-
* @param opts
|
|
3356
|
-
*/
|
|
3357
|
-
function editorDescriptorFromClassAttrsDef(type, attributes, opts) {
|
|
3358
|
-
const descriptor = new EditorDescriptorInst(model(type, opts), opts?.tableviewEditorType);
|
|
3359
|
-
(attributes ?? getEditorClassAttributeDef(type))
|
|
3360
|
-
.filter(attr => !attr.type.includes('Set') && !attr.type.includes('Array'))
|
|
3361
|
-
.forEach(attr => upsertEditorFieldFromAttributeDef(descriptor, attr));
|
|
3362
|
-
return descriptor;
|
|
3363
|
-
}
|
|
3364
2998
|
|
|
3365
2999
|
var FormFieldEventTypeEnum;
|
|
3366
3000
|
(function (FormFieldEventTypeEnum) {
|
|
@@ -3457,10 +3091,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
|
|
|
3457
3091
|
}] } });
|
|
3458
3092
|
|
|
3459
3093
|
class TableviewDataProviderInst extends DataProviderInst {
|
|
3460
|
-
constructor(
|
|
3461
|
-
super(
|
|
3462
|
-
this.editorDataProvider = new EditorDataProviderInst(
|
|
3463
|
-
this.tableDataProvider = new TableDataProviderInst(
|
|
3094
|
+
constructor(serviceType) {
|
|
3095
|
+
super(serviceType);
|
|
3096
|
+
this.editorDataProvider = new EditorDataProviderInst(serviceType);
|
|
3097
|
+
this.tableDataProvider = new TableDataProviderInst(serviceType);
|
|
3464
3098
|
}
|
|
3465
3099
|
get isLazy() {
|
|
3466
3100
|
return this.tableDataProvider.isLazy;
|
|
@@ -3486,6 +3120,12 @@ class TableviewDataProviderInst extends DataProviderInst {
|
|
|
3486
3120
|
get delete() {
|
|
3487
3121
|
return this.editorDataProvider.delete;
|
|
3488
3122
|
}
|
|
3123
|
+
get mapFetchItemToCreateItem() {
|
|
3124
|
+
return this.editorDataProvider.mapFetchItemToCreateItem;
|
|
3125
|
+
}
|
|
3126
|
+
get mapFetchItemToUpdateItem() {
|
|
3127
|
+
return this.editorDataProvider.mapFetchItemToUpdateItem;
|
|
3128
|
+
}
|
|
3489
3129
|
withGetAll(fn) {
|
|
3490
3130
|
this.tableDataProvider.withGetAll(fn);
|
|
3491
3131
|
return this;
|
|
@@ -3510,11 +3150,13 @@ class TableviewDataProviderInst extends DataProviderInst {
|
|
|
3510
3150
|
this.editorDataProvider.withDelete(fn);
|
|
3511
3151
|
return this;
|
|
3512
3152
|
}
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3153
|
+
withMapFetchItemToCreateItem(fn) {
|
|
3154
|
+
this.editorDataProvider.withMapFetchItemToCreateItem(fn);
|
|
3155
|
+
return this;
|
|
3156
|
+
}
|
|
3157
|
+
withMapFetchItemToUpdateItem(fn) {
|
|
3158
|
+
this.editorDataProvider.withMapFetchItemToUpdateItem(fn);
|
|
3159
|
+
return this;
|
|
3518
3160
|
}
|
|
3519
3161
|
reloadTable(event) {
|
|
3520
3162
|
this.tableDataProvider.reloadTable(event);
|
|
@@ -3525,75 +3167,37 @@ class TableviewDataProviderInst extends DataProviderInst {
|
|
|
3525
3167
|
}
|
|
3526
3168
|
class DynamicTableviewDataProviderInst extends TableviewDataProviderInst {
|
|
3527
3169
|
constructor(serviceType) {
|
|
3528
|
-
super(
|
|
3170
|
+
super(serviceType);
|
|
3529
3171
|
}
|
|
3530
3172
|
}
|
|
3531
3173
|
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
}
|
|
3545
|
-
static fromService(serviceType) {
|
|
3546
|
-
return tableviewDataProviderWithService(serviceType);
|
|
3547
|
-
}
|
|
3548
|
-
}
|
|
3549
|
-
function tableviewDataProvider(type, serviceTypeOrOpts,
|
|
3550
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3551
|
-
opts) {
|
|
3552
|
-
if (serviceTypeOrOpts === undefined || typeof serviceTypeOrOpts === 'function') {
|
|
3553
|
-
return new TableviewDataProviderInst(undefined, serviceTypeOrOpts);
|
|
3554
|
-
}
|
|
3555
|
-
else {
|
|
3556
|
-
return new TableviewDataProviderInst(undefined, undefined);
|
|
3557
|
-
}
|
|
3558
|
-
}
|
|
3559
|
-
function tableviewDataProviderWithService(serviceType,
|
|
3560
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3561
|
-
opts) {
|
|
3562
|
-
return new TableviewDataProviderInst(undefined, serviceType);
|
|
3563
|
-
}
|
|
3564
|
-
function tableviewDataProviderFromClass(type, serviceType) {
|
|
3565
|
-
return new TableviewDataProviderInst(type, serviceType);
|
|
3566
|
-
}
|
|
3567
|
-
function tableviewDataProviderFromModel(model, serviceTypeOrOpts, opts) {
|
|
3568
|
-
return typeof serviceTypeOrOpts === 'function'
|
|
3569
|
-
? new TableviewDataProviderInst(model.type, serviceTypeOrOpts)
|
|
3570
|
-
: new TableviewDataProviderInst(model.type, undefined);
|
|
3571
|
-
}
|
|
3572
|
-
class DynamicTableviewDataProvider extends DynamicTableviewDataProviderInst {
|
|
3573
|
-
constructor() {
|
|
3574
|
-
super(undefined);
|
|
3575
|
-
}
|
|
3576
|
-
static create() {
|
|
3577
|
-
return tableviewDynamicDataProvider();
|
|
3578
|
-
}
|
|
3579
|
-
static fromService(serviceType) {
|
|
3580
|
-
return tableviewDynamicDataProvider(serviceType);
|
|
3581
|
-
}
|
|
3174
|
+
/**
|
|
3175
|
+
* Creates and returns an instance of `TableviewDataProviderInst` with the specified options for managing tableview data.
|
|
3176
|
+
*
|
|
3177
|
+
* @param {Object} [opts] - The options object to configure the data provider.
|
|
3178
|
+
* @param {TypeDescriptor<Model> | ModelDescriptor<Model>} [opts.type] - The descriptor defining the type of model.
|
|
3179
|
+
* @param {ServiceClassType<Service>} [opts.service] - The service class type associated with the data provider.
|
|
3180
|
+
* @param {TypeDescriptor<CreateModel> | ModelDescriptor<CreateModel>} [opts.filtersType] - The descriptor defining the filters type.
|
|
3181
|
+
* @param {TypeDescriptor<UpdateModel> | ModelDescriptor<UpdateModel>} [opts.sortsType] - The descriptor defining the sorts type.
|
|
3182
|
+
* @return {TableviewDataProviderInst<Model, Service, Sorts, Filters, ServiceClass, TableModel, CreateModel, UpdateModel>} An instance of `TableviewDataProviderInst` configured according to the provided options.
|
|
3183
|
+
*/
|
|
3184
|
+
function tableviewDataProvider(opts) {
|
|
3185
|
+
return new TableviewDataProviderInst(opts?.service);
|
|
3582
3186
|
}
|
|
3583
3187
|
function tableviewDynamicDataProvider(serviceType) {
|
|
3584
3188
|
return new DynamicTableviewDataProviderInst(serviceType);
|
|
3585
3189
|
}
|
|
3586
3190
|
|
|
3587
3191
|
class TableviewDescriptorInst {
|
|
3588
|
-
constructor(model) {
|
|
3192
|
+
constructor(model, opts) {
|
|
3589
3193
|
this._isLocalized = false;
|
|
3590
3194
|
this._model = model;
|
|
3591
|
-
this._table = new TableDescriptorInst(model);
|
|
3195
|
+
this._table = new TableDescriptorInst(opts?.tableModel ?? model);
|
|
3592
3196
|
this._table.withTitle(`${this._model.i18nBaseKey}.name`);
|
|
3593
3197
|
this._detailsEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Details);
|
|
3594
3198
|
this._detailsEditor.withDisabled();
|
|
3595
|
-
this._addEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Add);
|
|
3596
|
-
this._editEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Edit);
|
|
3199
|
+
this._addEditor = new EditorDescriptorInst(opts?.addModel ?? model, TableviewEditorTypeEnum.Add);
|
|
3200
|
+
this._editEditor = new EditorDescriptorInst(opts?.editModel ?? model, TableviewEditorTypeEnum.Edit);
|
|
3597
3201
|
}
|
|
3598
3202
|
get table() {
|
|
3599
3203
|
return this._table;
|
|
@@ -3652,14 +3256,6 @@ class TableviewDescriptorInst {
|
|
|
3652
3256
|
}
|
|
3653
3257
|
return this;
|
|
3654
3258
|
}
|
|
3655
|
-
/**
|
|
3656
|
-
* @deprecated Use {table.withTitle} directly
|
|
3657
|
-
* @param title
|
|
3658
|
-
*/
|
|
3659
|
-
withTableTitle(title) {
|
|
3660
|
-
this._table.withTitle(title);
|
|
3661
|
-
return this;
|
|
3662
|
-
}
|
|
3663
3259
|
withValidation(name, expression, message, opts) {
|
|
3664
3260
|
return this.withValidationUnsafe(name, expression, message, opts);
|
|
3665
3261
|
}
|
|
@@ -3800,21 +3396,6 @@ class TableviewDescriptorInst {
|
|
|
3800
3396
|
this._table.withFilterUnsafe(filter);
|
|
3801
3397
|
return this;
|
|
3802
3398
|
}
|
|
3803
|
-
getField(property, editorType) {
|
|
3804
|
-
return this.getFieldUnsafe(property, editorType);
|
|
3805
|
-
}
|
|
3806
|
-
getFieldUnsafe(property, editorType) {
|
|
3807
|
-
switch (editorType) {
|
|
3808
|
-
case TableviewEditorTypeEnum.Edit:
|
|
3809
|
-
return this._editEditor.getFieldUnsafe(property);
|
|
3810
|
-
case TableviewEditorTypeEnum.Add:
|
|
3811
|
-
return this._addEditor.getFieldUnsafe(property);
|
|
3812
|
-
case TableviewEditorTypeEnum.Details:
|
|
3813
|
-
return this._detailsEditor.getFieldUnsafe(property);
|
|
3814
|
-
case TableviewEditorTypeEnum.None:
|
|
3815
|
-
return null;
|
|
3816
|
-
}
|
|
3817
|
-
}
|
|
3818
3399
|
removeField(property) {
|
|
3819
3400
|
this.removeFieldUnsafe(property);
|
|
3820
3401
|
}
|
|
@@ -3830,16 +3411,14 @@ class TableviewDescriptorInst {
|
|
|
3830
3411
|
return this;
|
|
3831
3412
|
}
|
|
3832
3413
|
addField(property) {
|
|
3833
|
-
|
|
3834
|
-
this.addFieldToEditAndAdd(field);
|
|
3835
|
-
return field;
|
|
3414
|
+
return this.addFieldUnsafe(property);
|
|
3836
3415
|
}
|
|
3837
3416
|
addFieldUnsafe(property) {
|
|
3838
3417
|
const field = this._detailsEditor.addFieldUnsafe(property);
|
|
3839
3418
|
this.addFieldToEditAndAdd(field);
|
|
3840
3419
|
return field;
|
|
3841
3420
|
}
|
|
3842
|
-
|
|
3421
|
+
withFields(...properties) {
|
|
3843
3422
|
properties.forEach(p => this.addField(p));
|
|
3844
3423
|
return this;
|
|
3845
3424
|
}
|
|
@@ -3856,150 +3435,36 @@ class TableviewDescriptorInst {
|
|
|
3856
3435
|
* Adds lookup field.
|
|
3857
3436
|
*
|
|
3858
3437
|
* @param {Property} property - The property key of the editor.
|
|
3859
|
-
* @param {
|
|
3438
|
+
* @param {FieldsManageAddFieldLookupOpts<LookupModel, Service>} opts - Optional parameters configuring type and/or service provider.
|
|
3860
3439
|
* @typeparam Property - The property key of the EditorModel.
|
|
3861
3440
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3441
|
+
* @typeparam Service - Service used for data provider.
|
|
3862
3442
|
* @typeparam FieldValue - The value type of field on editor.
|
|
3863
3443
|
*
|
|
3864
|
-
* @returns {FieldLookupDescriptor<LookupModel,
|
|
3444
|
+
* @returns {FieldLookupDescriptor<LookupModel, FieldsManageModel, Service, FieldValue>} - The field lookup descriptor.
|
|
3865
3445
|
*/
|
|
3866
|
-
addFieldLookup(property,
|
|
3867
|
-
|
|
3868
|
-
this.addFieldToEditAndAdd(field);
|
|
3869
|
-
return field;
|
|
3446
|
+
addFieldLookup(property, opts) {
|
|
3447
|
+
return this.addFieldLookupUnsafe(property, opts);
|
|
3870
3448
|
}
|
|
3871
3449
|
/**
|
|
3872
3450
|
* [UNSAFE] Adds lookup field.
|
|
3873
3451
|
* This function is UNSAFE because property is not type-checked.
|
|
3874
3452
|
*
|
|
3875
3453
|
* @param {string} property Model property name.
|
|
3876
|
-
* @param {
|
|
3877
|
-
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3878
|
-
* @typeparam FieldValue - The value type of field on editor.
|
|
3879
|
-
*
|
|
3880
|
-
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, undefined, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
3881
|
-
*/
|
|
3882
|
-
addFieldLookupUnsafe(property, type) {
|
|
3883
|
-
const field = this._detailsEditor.addFieldLookupUnsafe(property, type);
|
|
3884
|
-
this.addFieldToEditAndAdd(field);
|
|
3885
|
-
return field;
|
|
3886
|
-
}
|
|
3887
|
-
/**
|
|
3888
|
-
* Adds a field lookup with options value property for lookup model.
|
|
3889
|
-
*
|
|
3890
|
-
* @param {Property} property - The property key of the editor.
|
|
3891
|
-
* @param {TypeDescriptor<FieldModel>} type - The type descriptor for the lookup model.
|
|
3892
|
-
* @param {LookupValueProperty} lookupOptionsValueProperty - The value property used as value in the lookup options.
|
|
3893
|
-
* @typeparam Property - The property key of the EditorModel.
|
|
3894
|
-
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3895
|
-
* @typeparam LookupValueProperty - The property of lookup model type.
|
|
3896
|
-
* @typeparam FieldValue - The value type of field on editor.
|
|
3897
|
-
*
|
|
3898
|
-
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, undefined, FieldValue>} - The field lookup descriptor.
|
|
3899
|
-
*/
|
|
3900
|
-
addFieldLookupWithOptionsValueProperty(property, type, lookupOptionsValueProperty) {
|
|
3901
|
-
const field = this._detailsEditor.addFieldLookupWithOptionsValueProperty(property, type, lookupOptionsValueProperty);
|
|
3902
|
-
this.addFieldToEditAndAdd(field);
|
|
3903
|
-
return field;
|
|
3904
|
-
}
|
|
3905
|
-
/**
|
|
3906
|
-
* [UNSAFE] Adds a field lookup with options value property for lookup model.
|
|
3907
|
-
* This function is UNSAFE because property is not type-checked.
|
|
3908
|
-
*
|
|
3909
|
-
* @param {Property} property - The property key of the editor.
|
|
3910
|
-
* @param {TypeDescriptor<FieldModel>} type - The type descriptor for the lookup model.
|
|
3911
|
-
* @param {LookupValueProperty} lookupOptionsValueProperty - The value property used as value in the lookup options.
|
|
3912
|
-
* @typeparam Property - The property key of the EditorModel.
|
|
3913
|
-
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3914
|
-
* @typeparam LookupValueProperty - The property of lookup model type.
|
|
3915
|
-
* @typeparam FieldValue - The value type of field on editor.
|
|
3916
|
-
*
|
|
3917
|
-
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, undefined, FieldValue>} - The field lookup descriptor.
|
|
3918
|
-
*/
|
|
3919
|
-
addFieldLookupWithOptionsValuePropertyUnsafe(property, type, lookupOptionsValueProperty) {
|
|
3920
|
-
const field = this._detailsEditor.addFieldLookupWithOptionsValuePropertyUnsafe(property, type, lookupOptionsValueProperty);
|
|
3921
|
-
this.addFieldToEditAndAdd(field);
|
|
3922
|
-
return field;
|
|
3923
|
-
}
|
|
3924
|
-
/**
|
|
3925
|
-
* Adds a field lookup with a data provider or service to the editor model.
|
|
3926
|
-
*
|
|
3927
|
-
* @param {Property} property - The property key of the editor.
|
|
3928
|
-
* @param {FieldLookupProviderType<LookupModel, Service>} provider - The field lookup data provider or service.
|
|
3929
|
-
* @param {TypeDescriptor<LookupModel>} [type] - The type of lookup - if data provider is passed as previous parameter, type can be omitted. If service is provider, type parameter is proposed in favour of correct typing.
|
|
3930
|
-
* @typeparam Property - The property key of the EditorModel.
|
|
3931
|
-
* @typeparam Service - The lookup service type.
|
|
3932
|
-
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3933
|
-
* @typeparam FieldValue - The field value type, defaults to the editor's property type.
|
|
3934
|
-
*
|
|
3935
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue>} Created field lookup descriptor.
|
|
3936
|
-
*/
|
|
3937
|
-
addFieldLookupWithProvider(property, provider, type) {
|
|
3938
|
-
const field = this._detailsEditor.addFieldLookupWithProvider(property, provider, type);
|
|
3939
|
-
this.addFieldToEditAndAdd(field);
|
|
3940
|
-
return field;
|
|
3941
|
-
}
|
|
3942
|
-
/**
|
|
3943
|
-
* [UNSAFE] Adds a field lookup with a data provider or service to the editor model.
|
|
3944
|
-
* This function is UNSAFE because property is not type-checked.
|
|
3945
|
-
*
|
|
3946
|
-
* @param {string} property - The property key of the editor.
|
|
3947
|
-
* @param {FieldLookupProviderType<LookupModel, Service>} provider - The lookup provider or service for the field lookup.
|
|
3948
|
-
* @param {TypeDescriptor<LookupModel>?} type - Optional type descriptor for the field lookup.
|
|
3949
|
-
* @typeparam LookupModel - The field lookup model type.
|
|
3950
|
-
* @typeparam Service - The lookup service type.
|
|
3951
|
-
* @typeparam FieldValue - The value type of field on editor.
|
|
3952
|
-
*
|
|
3953
|
-
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, Service, FieldValue>} - The field lookup descriptor added to the instance.
|
|
3954
|
-
*/
|
|
3955
|
-
addFieldLookupWithProviderUnsafe(property, provider, type) {
|
|
3956
|
-
const field = this._detailsEditor.addFieldLookupWithProviderUnsafe(property, provider, type);
|
|
3957
|
-
this.addFieldToEditAndAdd(field);
|
|
3958
|
-
return field;
|
|
3959
|
-
}
|
|
3960
|
-
/**
|
|
3961
|
-
* Adds a field lookup with data provider or service and options value property for lookup model.
|
|
3962
|
-
*
|
|
3963
|
-
* @param {Property} property - The property key of the editor.
|
|
3964
|
-
* @param {FieldLookupProviderType<FieldModel, Service>} provider - The lookup provider.
|
|
3965
|
-
* @param {TypeDescriptor<FieldModel>} type - The type descriptor for the lookup model.
|
|
3966
|
-
* @param {LookupValueProperty} lookupOptionsValueProperty - The value property used as value in the lookup options.
|
|
3967
|
-
* @typeparam Property - The property key of the EditorModel.
|
|
3968
|
-
* @typeparam Service - The lookup service type.
|
|
3454
|
+
* @param {FieldsManageAddFieldLookupOpts<LookupModel, Service>} opts - Optional parameters configuring type and/or service provider.
|
|
3969
3455
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3970
|
-
* @typeparam
|
|
3456
|
+
* @typeparam Service - Service used for data provider.
|
|
3971
3457
|
* @typeparam FieldValue - The value type of field on editor.
|
|
3972
3458
|
*
|
|
3973
|
-
* @returns {FieldLookupDescriptor<LookupModel,
|
|
3459
|
+
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue>} - The field lookup descriptor.
|
|
3974
3460
|
*/
|
|
3975
|
-
|
|
3976
|
-
const field = this._detailsEditor.
|
|
3977
|
-
this.addFieldToEditAndAdd(field);
|
|
3978
|
-
return field;
|
|
3979
|
-
}
|
|
3980
|
-
/**
|
|
3981
|
-
* [UNSAFE] Adds a field lookup with data provider or service and options value property for lookup model.
|
|
3982
|
-
* This function is UNSAFE because property is not type-checked.
|
|
3983
|
-
*
|
|
3984
|
-
* @param {string} property - The property key of the editor.
|
|
3985
|
-
* @param {FieldLookupProviderType<FieldModel, Service>} provider - The lookup provider.
|
|
3986
|
-
* @param {TypeDescriptor<FieldModel>} type - The type descriptor for the lookup model.
|
|
3987
|
-
* @param {string} lookupOptionsValueProperty - The value property used in the lookup options.
|
|
3988
|
-
* @typeparam Service - The service type.
|
|
3989
|
-
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3990
|
-
* @typeparam FieldValue - The value type of field on editor.
|
|
3991
|
-
*
|
|
3992
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
3993
|
-
*/
|
|
3994
|
-
addFieldLookupWithProviderAndOptionsValuePropertyUnsafe(property, provider, type, lookupOptionsValueProperty) {
|
|
3995
|
-
const field = this._detailsEditor.addFieldLookupWithProviderAndOptionsValuePropertyUnsafe(property, provider, type, lookupOptionsValueProperty);
|
|
3461
|
+
addFieldLookupUnsafe(property, opts) {
|
|
3462
|
+
const field = this._detailsEditor.addFieldLookupUnsafe(property, opts);
|
|
3996
3463
|
this.addFieldToEditAndAdd(field);
|
|
3997
3464
|
return field;
|
|
3998
3465
|
}
|
|
3999
3466
|
addFieldLookupEnum(property, enumDesc, options) {
|
|
4000
|
-
|
|
4001
|
-
this.addFieldToEditAndAdd(field);
|
|
4002
|
-
return field;
|
|
3467
|
+
return this.addFieldLookupEnumUnsafe(property, enumDesc, options);
|
|
4003
3468
|
}
|
|
4004
3469
|
addFieldLookupEnumUnsafe(property, enumDesc, options) {
|
|
4005
3470
|
const field = this._detailsEditor.addFieldLookupEnumUnsafe(property, enumDesc, options);
|
|
@@ -4007,47 +3472,33 @@ class TableviewDescriptorInst {
|
|
|
4007
3472
|
return field;
|
|
4008
3473
|
}
|
|
4009
3474
|
addFieldManyEditor(property, tableviewDescriptor) {
|
|
4010
|
-
|
|
4011
|
-
this.addFieldToEditAndAdd(field);
|
|
4012
|
-
return field;
|
|
3475
|
+
return this.addFieldManyEditorUnsafe(property, tableviewDescriptor);
|
|
4013
3476
|
}
|
|
4014
3477
|
addFieldManyEditorUnsafe(property, tableviewDescriptor) {
|
|
4015
|
-
const field = this._detailsEditor.addFieldManyEditorUnsafe(property,
|
|
3478
|
+
const field = this._detailsEditor.addFieldManyEditorUnsafe(property,
|
|
3479
|
+
// cast is needed, because the parent model of TableviewDescriptorInst is expected to be TableviewModel, but it cannot be in case there are different types across details, add or edit
|
|
3480
|
+
tableviewDescriptor);
|
|
4016
3481
|
this.addFieldToEditAndAdd(field);
|
|
4017
3482
|
return field;
|
|
4018
3483
|
}
|
|
4019
3484
|
addFieldManyToManyEditor(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
4020
|
-
|
|
4021
|
-
this.addFieldToEditAndAdd(field);
|
|
4022
|
-
return field;
|
|
3485
|
+
return this.addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider);
|
|
4023
3486
|
}
|
|
4024
3487
|
addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
4025
3488
|
const field = this._detailsEditor.addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider);
|
|
4026
3489
|
this.addFieldToEditAndAdd(field);
|
|
4027
3490
|
return field;
|
|
4028
3491
|
}
|
|
4029
|
-
/**
|
|
4030
|
-
* @deprecated Use withTabGroup config instead
|
|
4031
|
-
*/
|
|
4032
|
-
createTabGroup(name, title) {
|
|
4033
|
-
return this.withTabGroup(name, title);
|
|
4034
|
-
}
|
|
4035
|
-
/**
|
|
4036
|
-
* @deprecated Use withTabGroup config instead
|
|
4037
|
-
*/
|
|
4038
|
-
createFieldGroup(name, title) {
|
|
4039
|
-
return this.withFieldGroup(name, title);
|
|
4040
|
-
}
|
|
4041
3492
|
withTabGroup(name, title) {
|
|
4042
|
-
this._detailsEditor.
|
|
4043
|
-
this._addEditor.
|
|
4044
|
-
this._editEditor.
|
|
3493
|
+
this._detailsEditor.addTabGroup(name, title);
|
|
3494
|
+
this._addEditor.addTabGroup(name, title);
|
|
3495
|
+
this._editEditor.addTabGroup(name, title);
|
|
4045
3496
|
return this;
|
|
4046
3497
|
}
|
|
4047
3498
|
withFieldGroup(name, title) {
|
|
4048
|
-
this._detailsEditor.
|
|
4049
|
-
this._addEditor.
|
|
4050
|
-
this._editEditor.
|
|
3499
|
+
this._detailsEditor.addFieldGroup(name, title);
|
|
3500
|
+
this._addEditor.addFieldGroup(name, title);
|
|
3501
|
+
this._editEditor.addFieldGroup(name, title);
|
|
4051
3502
|
return this;
|
|
4052
3503
|
}
|
|
4053
3504
|
copy() {
|
|
@@ -4111,141 +3562,36 @@ class TableviewDynamicDescriptorInt extends TableviewDescriptorInst {
|
|
|
4111
3562
|
}
|
|
4112
3563
|
}
|
|
4113
3564
|
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
static create(idProperty, titleProperty, i18nBaseKey) {
|
|
4119
|
-
return new TableviewDescriptorInst(ModelDescriptor.create(idProperty, titleProperty, i18nBaseKey));
|
|
4120
|
-
}
|
|
4121
|
-
static fromClass(type, idProperty, titleProperty, i18nBaseKey) {
|
|
4122
|
-
return new TableviewDescriptorInst(ModelDescriptor.fromClass(type, idProperty, titleProperty, i18nBaseKey));
|
|
4123
|
-
}
|
|
4124
|
-
static fromModel(model) {
|
|
4125
|
-
return new TableviewDescriptorInst(model);
|
|
4126
|
-
}
|
|
4127
|
-
/**
|
|
4128
|
-
* generates descriptor from attribute definition of openapi model
|
|
4129
|
-
* @param type class type
|
|
4130
|
-
* @param idProperty
|
|
4131
|
-
* @param titleProperty
|
|
4132
|
-
*/
|
|
4133
|
-
static fromClassWithAutoAttrsDef(type, idProperty, titleProperty) {
|
|
4134
|
-
const descriptor = tableviewDescriptor(model(type, { id: idProperty, title: titleProperty }));
|
|
4135
|
-
const optsBase = { id: idProperty, title: titleProperty };
|
|
4136
|
-
descriptor.withTableDescriptor(tableDescriptorFromClassAttrsDef(type, undefined, optsBase));
|
|
4137
|
-
descriptor.withEditDescriptor(editorDescriptorFromClassAttrsDef(type, undefined, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Edit }));
|
|
4138
|
-
descriptor.withDetailsDescriptor(editorDescriptorFromClassAttrsDef(type, undefined, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Details }).withDisabled());
|
|
4139
|
-
descriptor.withAddDescriptor(editorDescriptorFromClassAttrsDef(type, undefined, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Add }));
|
|
4140
|
-
return descriptor;
|
|
4141
|
-
}
|
|
4142
|
-
/**
|
|
4143
|
-
* generates descriptor from given attribute definition
|
|
4144
|
-
* @param type class type
|
|
4145
|
-
* @param columnAttributes attribute definition to generate columns
|
|
4146
|
-
* @param fieldAttributes attribute definition to generate fields, if undefined columnDefinition is used, if null editors are not generated
|
|
4147
|
-
* @param idProperty
|
|
4148
|
-
* @param titleProperty
|
|
4149
|
-
*/
|
|
4150
|
-
static fromClassWithCustomAttrsDef(type, columnAttributes, fieldAttributes, idProperty, titleProperty) {
|
|
4151
|
-
const optsBase = { id: idProperty, title: titleProperty };
|
|
4152
|
-
const descriptor = tableviewDescriptor(model(type, optsBase));
|
|
4153
|
-
descriptor.withTableDescriptor(tableDescriptorFromClassAttrsDef(type, columnAttributes, optsBase));
|
|
4154
|
-
if (fieldAttributes !== null) {
|
|
4155
|
-
descriptor.withEditDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Edit }));
|
|
4156
|
-
descriptor.withDetailsDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Details }));
|
|
4157
|
-
descriptor.withAddDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Add }));
|
|
4158
|
-
}
|
|
4159
|
-
return descriptor;
|
|
4160
|
-
}
|
|
4161
|
-
}
|
|
4162
|
-
function tableviewDescriptor(typeOrModelOrClassOrOpts, opts) {
|
|
4163
|
-
if (typeOrModelOrClassOrOpts == null) {
|
|
3565
|
+
function tableviewDescriptor(modelOrOpts,
|
|
3566
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3567
|
+
opts) {
|
|
3568
|
+
if (modelOrOpts == null) {
|
|
4164
3569
|
return new TableviewDescriptorInst(model());
|
|
4165
3570
|
}
|
|
4166
|
-
else if (
|
|
4167
|
-
return new TableviewDescriptorInst(
|
|
4168
|
-
}
|
|
4169
|
-
else if (typeOrModelOrClassOrOpts instanceof ModelDescriptor) {
|
|
4170
|
-
return new TableviewDescriptorInst(typeOrModelOrClassOrOpts);
|
|
3571
|
+
else if (modelOrOpts instanceof ModelDescriptor) {
|
|
3572
|
+
return new TableviewDescriptorInst(modelOrOpts);
|
|
4171
3573
|
}
|
|
4172
3574
|
else {
|
|
4173
|
-
|
|
4174
|
-
return new TableviewDescriptorInst(model(typeOrModelOrClassOrOpts));
|
|
3575
|
+
return new TableviewDescriptorInst(model(modelOrOpts));
|
|
4175
3576
|
}
|
|
4176
3577
|
}
|
|
4177
|
-
function
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
* @param type class type
|
|
4183
|
-
* @param columnAttributes
|
|
4184
|
-
* @param fieldAttributes
|
|
4185
|
-
* @param opts
|
|
4186
|
-
*/
|
|
4187
|
-
function tableviewDescriptorFromClassAttrsDef(type, columnAttributes, fieldAttributes, opts) {
|
|
4188
|
-
const model = new ModelDescriptor(type, opts?.id, opts?.title, opts?.i18nBase);
|
|
4189
|
-
const descriptor = new TableviewDescriptorInst(model);
|
|
4190
|
-
descriptor.withTableDescriptor(tableDescriptorFromClassAttrsDef(type, columnAttributes, opts));
|
|
4191
|
-
if (fieldAttributes !== null) {
|
|
4192
|
-
descriptor.withEditDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...opts, tableviewEditorType: TableviewEditorTypeEnum.Edit }));
|
|
4193
|
-
descriptor.withDetailsDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...opts, tableviewEditorType: TableviewEditorTypeEnum.Details }).withDisabled());
|
|
4194
|
-
descriptor.withAddDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...opts, tableviewEditorType: TableviewEditorTypeEnum.Add }));
|
|
4195
|
-
}
|
|
4196
|
-
return descriptor;
|
|
4197
|
-
}
|
|
4198
|
-
function tableviewDescriptorFromParent(descriptor, classOrType, idProperty, titleProperty, i18nBaseKey) {
|
|
4199
|
-
return classOrType instanceof ModelDescriptor
|
|
4200
|
-
? new TableviewDescriptorInst(classOrType)
|
|
4201
|
-
: new TableviewDescriptorInst(model(classOrType, { id: idProperty, title: titleProperty, i18nBase: i18nBaseKey }));
|
|
4202
|
-
}
|
|
4203
|
-
class TableviewDynamicDescriptor extends TableviewDynamicDescriptorInt {
|
|
4204
|
-
constructor() {
|
|
4205
|
-
super(ModelDescriptor.create());
|
|
3578
|
+
function tableviewDescriptorMultiModel(modelOrOpts,
|
|
3579
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3580
|
+
opts) {
|
|
3581
|
+
if (modelOrOpts == null) {
|
|
3582
|
+
return new TableviewDescriptorInst(model());
|
|
4206
3583
|
}
|
|
4207
|
-
|
|
4208
|
-
return
|
|
3584
|
+
else if (modelOrOpts instanceof ModelDescriptor) {
|
|
3585
|
+
return new TableviewDescriptorInst(modelOrOpts);
|
|
4209
3586
|
}
|
|
4210
|
-
|
|
4211
|
-
return
|
|
3587
|
+
else {
|
|
3588
|
+
return new TableviewDescriptorInst(model(modelOrOpts));
|
|
4212
3589
|
}
|
|
4213
3590
|
}
|
|
4214
3591
|
function tableviewDynamicDescriptor(modelOrOpts) {
|
|
4215
3592
|
return modelOrOpts instanceof ModelDescriptor
|
|
4216
3593
|
? new TableviewDynamicDescriptorInt(modelOrOpts)
|
|
4217
|
-
: new TableviewDynamicDescriptorInt(new ModelDescriptor(
|
|
4218
|
-
}
|
|
4219
|
-
|
|
4220
|
-
function expandClassAttributeDefWithTableviewDef(attributes) {
|
|
4221
|
-
if (!attributes) {
|
|
4222
|
-
throw new CommonsInternalError('Class attribute definition is null, problem with TypeRegistry::findAttributesDefinitionByClassType?', { name: 'TableviewUtilsError' });
|
|
4223
|
-
}
|
|
4224
|
-
const typeRegistry = TypeRegistry.get();
|
|
4225
|
-
const tableClassAttributeDef = [];
|
|
4226
|
-
for (const attribute of attributes) {
|
|
4227
|
-
const enumType = typeRegistry.findEnum(attribute.type);
|
|
4228
|
-
const columnType = enumType ? ColumnTypeEnum.Enum : getColumnTypeFromClassAttributeDefType(attribute.type);
|
|
4229
|
-
tableClassAttributeDef.push({
|
|
4230
|
-
name: attribute.name,
|
|
4231
|
-
baseName: attribute.baseName,
|
|
4232
|
-
type: attribute.type,
|
|
4233
|
-
subtype: attribute.subtype,
|
|
4234
|
-
columnType: enumType ? ColumnTypeEnum.Enum : getColumnTypeFromClassAttributeDefType(attribute.type),
|
|
4235
|
-
columnDisplayType: getColumnDisplayTypeFromColumnType(columnType, attribute.type),
|
|
4236
|
-
fieldType: getFieldInputTypeFromClassAttributeDefType(attribute.type),
|
|
4237
|
-
enumType: typeRegistry.findEnum(attribute.type),
|
|
4238
|
-
classType: typeRegistry.findType(attribute.type)
|
|
4239
|
-
});
|
|
4240
|
-
}
|
|
4241
|
-
return tableClassAttributeDef;
|
|
4242
|
-
}
|
|
4243
|
-
/**
|
|
4244
|
-
* returns attributes from class type and extends to typed def with column and field enum type
|
|
4245
|
-
* @param type class type
|
|
4246
|
-
*/
|
|
4247
|
-
function getTableviewClassAttributeDef(type) {
|
|
4248
|
-
return expandClassAttributeDefWithTableviewDef(TypeRegistry.get().findAttributesDefinitionByClassType(type));
|
|
3594
|
+
: new TableviewDynamicDescriptorInt(new ModelDescriptor(modelOrOpts?.id, modelOrOpts?.title, modelOrOpts?.i18nBase));
|
|
4249
3595
|
}
|
|
4250
3596
|
|
|
4251
3597
|
function convertDataToStringWithDelimiter(data, delimiter, descriptor, translate) {
|
|
@@ -4308,44 +3654,42 @@ const tableviewDefaultActions = [
|
|
|
4308
3654
|
TableviewDefaultActionsEnum.ExportCsv,
|
|
4309
3655
|
TableviewDefaultActionsEnum.LocalizationLanguageSelect
|
|
4310
3656
|
];
|
|
4311
|
-
function
|
|
3657
|
+
function tableviewGetDefaultActions() {
|
|
4312
3658
|
return [...tableviewDefaultActions];
|
|
4313
3659
|
}
|
|
4314
|
-
function
|
|
4315
|
-
return (defaultActions ??
|
|
4316
|
-
.map(t =>
|
|
3660
|
+
function tableviewCreateDefaultActions(tableview, defaultActions, defaultActionsOverrides, injector) {
|
|
3661
|
+
return (defaultActions ?? tableviewGetDefaultActions())
|
|
3662
|
+
.map(t => tableviewCreateDefaultAction(t, tableview, defaultActions, defaultActionsOverrides, injector))
|
|
4317
3663
|
.filter(e => e != null);
|
|
4318
3664
|
}
|
|
4319
|
-
function
|
|
3665
|
+
function tableviewCreateDefaultAction(type, tableview, defaultActions, defaultActionsOverrides, injector) {
|
|
4320
3666
|
if (defaultActionsOverrides != null && defaultActionsOverrides[type] !== undefined) {
|
|
4321
3667
|
return defaultActionsOverrides[type];
|
|
4322
3668
|
}
|
|
4323
3669
|
switch (type) {
|
|
4324
3670
|
// table row actions
|
|
4325
3671
|
case TableviewDefaultActionsEnum.Details:
|
|
4326
|
-
return
|
|
3672
|
+
return tableviewActionDetailsOnTable(tableview.detailsEditor, { injector });
|
|
4327
3673
|
case TableviewDefaultActionsEnum.Edit:
|
|
4328
|
-
return
|
|
3674
|
+
return tableviewActionEditOnTable(tableview.model, tableview.editEditor, { table: tableview.table, injector });
|
|
4329
3675
|
case TableviewDefaultActionsEnum.Delete:
|
|
4330
|
-
return
|
|
3676
|
+
return tableviewActionDeleteOnTable(tableview.model, { table: tableview.table, injector });
|
|
4331
3677
|
// table toolbar actions
|
|
4332
3678
|
case TableviewDefaultActionsEnum.Add:
|
|
4333
|
-
return
|
|
3679
|
+
return tableviewActionAddOnTable(tableview.model, tableview.addEditor, { injector });
|
|
4334
3680
|
case TableviewDefaultActionsEnum.LocalizationLanguageSelect:
|
|
4335
|
-
return
|
|
3681
|
+
return tableviewActionLocalizationLangSelectOnTable(tableview);
|
|
4336
3682
|
case TableviewDefaultActionsEnum.Refresh:
|
|
4337
|
-
return
|
|
3683
|
+
return tableviewActionRefreshOnTable(tableview.model);
|
|
4338
3684
|
case TableviewDefaultActionsEnum.Export:
|
|
4339
3685
|
return defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.ExportJson) || defaultActions.includes(TableviewDefaultActionsEnum.ExportCsv)
|
|
4340
|
-
?
|
|
3686
|
+
? tableviewActionExportOnTable(tableview, { injector: injector, defaultActions: defaultActions })
|
|
4341
3687
|
: null;
|
|
4342
3688
|
//details actions
|
|
4343
3689
|
case TableviewDefaultActionsEnum.EditOnDetails:
|
|
4344
|
-
return defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.Edit)
|
|
4345
|
-
? tableviewEditOnDetailsAction(tableview.model, tableviewEditAction(tableview.editEditor, injector), injector)
|
|
4346
|
-
: null;
|
|
3690
|
+
return defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.Edit) ? tableviewActionEditOnDetails(tableview.model, { injector }) : null;
|
|
4347
3691
|
case TableviewDefaultActionsEnum.DeleteOnDetails:
|
|
4348
|
-
return defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.Delete) ?
|
|
3692
|
+
return defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.Delete) ? tableviewActionDeleteOnDetails(tableview.model, { injector }) : null;
|
|
4349
3693
|
// subactions
|
|
4350
3694
|
case TableviewDefaultActionsEnum.ExportJson:
|
|
4351
3695
|
case TableviewDefaultActionsEnum.ExportCsv:
|
|
@@ -4360,81 +3704,100 @@ function getInjector(injector) {
|
|
|
4360
3704
|
function getRouteData(injector) {
|
|
4361
3705
|
return getInjector(injector)?.get(ActivatedRoute)?.snapshot.data;
|
|
4362
3706
|
}
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
}
|
|
4379
|
-
|
|
4380
|
-
const routeData = getRouteData(injector);
|
|
4381
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasAdd
|
|
4382
|
-
? new ActionEditorAddDescriptorInst(descriptor, {
|
|
4383
|
-
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
4384
|
-
})
|
|
4385
|
-
: null;
|
|
3707
|
+
const tableviewActionEditorDetailsActionName = 'details';
|
|
3708
|
+
const tableviewActionEditorDetailsRoute = ':itemId';
|
|
3709
|
+
function tableviewActionDetailsOnTable(descriptor, opts) {
|
|
3710
|
+
const routeData = getRouteData(opts?.injector);
|
|
3711
|
+
if (!routeData?.tableviewActions || routeData.tableviewActions.hasDetails) {
|
|
3712
|
+
const action = new ActionEditorDescriptorInst(descriptor, tableviewActionEditorDetailsActionName, {
|
|
3713
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts?.serviceProvider) : {}),
|
|
3714
|
+
isTableviewMainEditor: true
|
|
3715
|
+
});
|
|
3716
|
+
action.withPosition(opts?.position ?? ActionPositionEnum.RowClick);
|
|
3717
|
+
action.withPosition(ActionPositionEnum.RowClick);
|
|
3718
|
+
action.withRouteTrigger(tableviewActionEditorDetailsRoute);
|
|
3719
|
+
action.withEditorActions([actionEditorCancel(action)]);
|
|
3720
|
+
action.withTableviewCategory(TableviewActionDefaultCategories.DETAILS);
|
|
3721
|
+
return action;
|
|
3722
|
+
}
|
|
3723
|
+
return null;
|
|
4386
3724
|
}
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
3725
|
+
const tableviewActionEditorAddActionName = 'add';
|
|
3726
|
+
const tableviewActionEditorAddRoute = 'add';
|
|
3727
|
+
function tableviewActionAddOnTable(model, descriptor, opts) {
|
|
3728
|
+
const routeData = getRouteData(opts?.injector);
|
|
3729
|
+
if (!routeData?.tableviewActions || routeData.tableviewActions.hasAdd) {
|
|
3730
|
+
const action = new ActionEditorDescriptorInst(descriptor, tableviewActionEditorAddActionName, {
|
|
3731
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {}),
|
|
3732
|
+
isTableviewMainEditor: true,
|
|
3733
|
+
model: model
|
|
3734
|
+
});
|
|
3735
|
+
action.withPosition(opts?.position ?? ActionPositionEnum.ToolbarLeft);
|
|
3736
|
+
action.withRouteTrigger(tableviewActionEditorAddRoute);
|
|
3737
|
+
action.button.withIcon('pi pi-plus');
|
|
3738
|
+
action.withTableviewCategory(TableviewActionDefaultCategories.ADD);
|
|
3739
|
+
action.withUnsavedChangesConfirmation();
|
|
3740
|
+
return action;
|
|
3741
|
+
}
|
|
3742
|
+
return null;
|
|
4390
3743
|
}
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
3744
|
+
const tableviewActionEditorEditActionName = 'edit';
|
|
3745
|
+
const tableviewActionEditorEditRoute = ':itemId/edit';
|
|
3746
|
+
function tableviewActionEditOnTable(model, descriptor, opts) {
|
|
3747
|
+
const routeData = getRouteData(opts?.injector);
|
|
3748
|
+
if (!routeData?.tableviewActions || routeData.tableviewActions.hasEdit) {
|
|
3749
|
+
const action = new ActionEditorDescriptorInst(descriptor, tableviewActionEditorEditActionName, {
|
|
3750
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {}),
|
|
3751
|
+
isTableviewMainEditor: true,
|
|
3752
|
+
model: model
|
|
3753
|
+
});
|
|
3754
|
+
action.withPosition(opts?.position ?? ActionPositionEnum.RowInline);
|
|
3755
|
+
action.button.styleClass.withSize(StyleSizeEnum.Small);
|
|
3756
|
+
action.withRouteTrigger(tableviewActionEditorEditRoute);
|
|
3757
|
+
action.withTableviewCategory(TableviewActionDefaultCategories.EDIT);
|
|
3758
|
+
action.button.withLabel(null).withIcon('pi pi-pencil');
|
|
3759
|
+
action.withUnsavedChangesConfirmation();
|
|
3760
|
+
return action;
|
|
3761
|
+
}
|
|
3762
|
+
return null;
|
|
4398
3763
|
}
|
|
4399
|
-
function
|
|
4400
|
-
const routeData = getRouteData(injector);
|
|
3764
|
+
function tableviewActionEditOnDetails(model, opts) {
|
|
3765
|
+
const routeData = getRouteData(opts?.injector);
|
|
4401
3766
|
if (routeData?.tableviewActions && !routeData.tableviewActions.hasEdit) {
|
|
4402
3767
|
return null;
|
|
4403
3768
|
}
|
|
4404
|
-
const
|
|
4405
|
-
|
|
4406
|
-
: new ActionLinkDescriptorInst(ActionEditorEditDescriptorInst.ACTION_NAME, {
|
|
4407
|
-
model: descriptor
|
|
4408
|
-
});
|
|
4409
|
-
action
|
|
3769
|
+
const linkAction = actionLink(tableviewActionEditorEditActionName, { model: model });
|
|
3770
|
+
linkAction
|
|
4410
3771
|
.withTableviewCategory(TableviewActionDefaultCategories.EDIT)
|
|
4411
3772
|
.withPositionTableviewCategories([TableviewActionDefaultCategories.DETAILS])
|
|
4412
|
-
.withPosition(ActionPositionEnum.FooterLeft)
|
|
3773
|
+
.withPosition(opts?.position ?? ActionPositionEnum.FooterLeft)
|
|
4413
3774
|
.withRouterLink('./edit')
|
|
4414
3775
|
.withQueryParams({}, 'merge');
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
function
|
|
4424
|
-
const routeData = getRouteData(injector);
|
|
4425
|
-
|
|
4426
|
-
}
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
3776
|
+
linkAction.button.styleClass.withActionLevel(StyleLevelEnum.Secondary);
|
|
3777
|
+
linkAction.button.styleClass.withSize(StyleSizeEnum.Normal);
|
|
3778
|
+
linkAction.button.styleClass.withRoundedButton(ButtonStyleRoundedEnum.DEFAULT);
|
|
3779
|
+
linkAction.button.withLabel();
|
|
3780
|
+
linkAction.button.withIcon('pi pi-pencil');
|
|
3781
|
+
return linkAction;
|
|
3782
|
+
}
|
|
3783
|
+
const tableviewActionDeleteActionName = 'delete';
|
|
3784
|
+
function tableviewActionDeleteOnTable(model, opts) {
|
|
3785
|
+
const routeData = getRouteData(opts?.injector);
|
|
3786
|
+
if (!routeData?.tableviewActions || routeData.tableviewActions.hasDelete) {
|
|
3787
|
+
const action = new ActionDescriptorInst(tableviewActionDeleteActionName, opts?.serviceProvider ? actionGetProviderCfgObj(opts.serviceProvider) : {});
|
|
3788
|
+
action.withPosition(opts?.position ?? ActionPositionEnum.RowInline);
|
|
3789
|
+
action.button.styleClass.withSize(StyleSizeEnum.Small);
|
|
3790
|
+
action.button.styleClass.withActionLevel(StyleLevelEnum.Danger);
|
|
3791
|
+
action.withRunConfirmation();
|
|
3792
|
+
action.withTableviewCategory(TableviewActionDefaultCategories.DELETE);
|
|
3793
|
+
action.button.withLabel(null).withIcon('pi pi-trash');
|
|
3794
|
+
return action;
|
|
3795
|
+
}
|
|
3796
|
+
return null;
|
|
4434
3797
|
}
|
|
4435
|
-
function
|
|
4436
|
-
const action =
|
|
4437
|
-
const dataProviderExecutor = getInjector(injector)?.get(DataProviderExecutor);
|
|
3798
|
+
function tableviewActionDeleteOnDetails(model, opts) {
|
|
3799
|
+
const action = tableviewActionDeleteOnTable(model, opts);
|
|
3800
|
+
const dataProviderExecutor = getInjector(opts?.injector)?.get(DataProviderExecutor);
|
|
4438
3801
|
if (action) {
|
|
4439
3802
|
action
|
|
4440
3803
|
.withTableviewCategory(TableviewActionDefaultCategories.DELETE)
|
|
@@ -4452,22 +3815,23 @@ function tableviewDeleteOnDetailsAction(model, injector) {
|
|
|
4452
3815
|
}
|
|
4453
3816
|
return null;
|
|
4454
3817
|
}
|
|
4455
|
-
function
|
|
3818
|
+
function tableviewActionExportOnTable(descriptor, opts) {
|
|
4456
3819
|
const exportAction = new ActionDescriptorInst('export', {
|
|
4457
3820
|
model: descriptor.model
|
|
4458
3821
|
})
|
|
4459
3822
|
.withButtonDescriptor(new ActionButtonDescriptor().withIcon('pi pi-download'))
|
|
4460
3823
|
.withSubactionsAsMenu();
|
|
4461
3824
|
const subactions = [];
|
|
4462
|
-
if (defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.ExportJson))
|
|
4463
|
-
subactions.push(
|
|
4464
|
-
if (defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.ExportCsv))
|
|
4465
|
-
subactions.push(
|
|
3825
|
+
if (opts?.defaultActions == null || opts?.defaultActions.includes(TableviewDefaultActionsEnum.ExportJson))
|
|
3826
|
+
subactions.push(tableviewActionExportJsonOnTable(descriptor, opts));
|
|
3827
|
+
if (opts?.defaultActions == null || opts?.defaultActions.includes(TableviewDefaultActionsEnum.ExportCsv))
|
|
3828
|
+
subactions.push(tableviewActionExportCsvOnTable(descriptor, opts));
|
|
4466
3829
|
exportAction.withSubactions(...subactions);
|
|
3830
|
+
exportAction.withPosition(opts?.position ?? ActionPositionEnum.ToolbarRight);
|
|
4467
3831
|
return exportAction;
|
|
4468
3832
|
}
|
|
4469
|
-
function
|
|
4470
|
-
const dataProviderExecutor = getInjector(injector)?.get(DataProviderExecutor);
|
|
3833
|
+
function tableviewActionExportJsonOnTable(descriptor, opts) {
|
|
3834
|
+
const dataProviderExecutor = getInjector(opts?.injector)?.get(DataProviderExecutor);
|
|
4471
3835
|
return new ActionDescriptorInst('exportJson', {
|
|
4472
3836
|
model: descriptor.model
|
|
4473
3837
|
})
|
|
@@ -4477,7 +3841,7 @@ function tableviewExportJsonAction(descriptor, injector) {
|
|
|
4477
3841
|
params.limit = 500;
|
|
4478
3842
|
ctx.parameters.dataListParams = params;
|
|
4479
3843
|
return dataProviderExecutor
|
|
4480
|
-
? dataProviderExecutor.runGetAllOrFail(ctx).pipe(map(res => {
|
|
3844
|
+
? dataProviderExecutor.runGetAllOrFail(ctx).pipe(map$1(res => {
|
|
4481
3845
|
const blob = new Blob([JSON.stringify(res.data, undefined, 4)], { type: 'application/json;charset=utf-8' });
|
|
4482
3846
|
const typeName = ctx.instance.action.model?.i18nBaseKey ?? '';
|
|
4483
3847
|
saveFileAs(blob, `${typeName ? typeName + '_' : ''}${ctx.instance.action.actionName}.json`);
|
|
@@ -4486,10 +3850,10 @@ function tableviewExportJsonAction(descriptor, injector) {
|
|
|
4486
3850
|
: ctx.parameters.item;
|
|
4487
3851
|
})
|
|
4488
3852
|
.withButtonDescriptor(new ActionButtonDescriptor().withIcon('pi pi-code'))
|
|
4489
|
-
.withPosition(ActionPositionEnum.ToolbarRight);
|
|
3853
|
+
.withPosition(opts?.position ?? ActionPositionEnum.ToolbarRight);
|
|
4490
3854
|
}
|
|
4491
|
-
function
|
|
4492
|
-
const dataProviderExecutor = getInjector(injector)?.get(DataProviderExecutor);
|
|
3855
|
+
function tableviewActionExportCsvOnTable(descriptor, opts) {
|
|
3856
|
+
const dataProviderExecutor = getInjector(opts?.injector)?.get(DataProviderExecutor);
|
|
4493
3857
|
return new ActionDescriptorInst('exportCsv', {
|
|
4494
3858
|
model: descriptor.model
|
|
4495
3859
|
})
|
|
@@ -4499,7 +3863,7 @@ function tableviewExportCsvAction(descriptor, injector) {
|
|
|
4499
3863
|
params.limit = 500;
|
|
4500
3864
|
ctx.parameters.dataListParams = params;
|
|
4501
3865
|
return dataProviderExecutor
|
|
4502
|
-
? dataProviderExecutor.runGetAllOrFail(ctx).pipe(map(res => {
|
|
3866
|
+
? dataProviderExecutor.runGetAllOrFail(ctx).pipe(map$1(res => {
|
|
4503
3867
|
if (!res.data) {
|
|
4504
3868
|
return undefined;
|
|
4505
3869
|
}
|
|
@@ -4513,9 +3877,9 @@ function tableviewExportCsvAction(descriptor, injector) {
|
|
|
4513
3877
|
: ctx.parameters.item;
|
|
4514
3878
|
})
|
|
4515
3879
|
.withButtonDescriptor(new ActionButtonDescriptor().withIcon('pi pi-file'))
|
|
4516
|
-
.withPosition(ActionPositionEnum.ToolbarRight);
|
|
3880
|
+
.withPosition(opts?.position ?? ActionPositionEnum.ToolbarRight);
|
|
4517
3881
|
}
|
|
4518
|
-
function
|
|
3882
|
+
function tableviewActionRefreshOnTable(descriptor, opts) {
|
|
4519
3883
|
const action = new ActionDescriptorInst('refresh', {
|
|
4520
3884
|
model: descriptor
|
|
4521
3885
|
})
|
|
@@ -4525,16 +3889,17 @@ function tableviewRefreshAction(descriptor) {
|
|
|
4525
3889
|
.withRunFunction(ctx => {
|
|
4526
3890
|
ctx.viewContainer?.reloadTable({});
|
|
4527
3891
|
return of(null);
|
|
4528
|
-
})
|
|
3892
|
+
})
|
|
3893
|
+
.withPosition(opts?.position ?? ActionPositionEnum.ToolbarRight);
|
|
4529
3894
|
action.button.withIcon('pi pi-refresh').styleClass.withActionLevel(StyleLevelEnum.Secondary);
|
|
4530
3895
|
return action;
|
|
4531
3896
|
}
|
|
4532
|
-
function
|
|
3897
|
+
function tableviewActionLocalizationLangSelectOnTable(descriptor, opts) {
|
|
4533
3898
|
return descriptor.isLocalized()
|
|
4534
3899
|
? new ActionDescriptorInst('translator', {
|
|
4535
3900
|
model: descriptor.model
|
|
4536
3901
|
})
|
|
4537
|
-
.withPosition(ActionPositionEnum.ToolbarLeft)
|
|
3902
|
+
.withPosition(opts?.position ?? ActionPositionEnum.ToolbarLeft)
|
|
4538
3903
|
.withComponentFromDi(DATA_LANGUAGE_DROPDOWN_COMPONENT_IT)
|
|
4539
3904
|
: null;
|
|
4540
3905
|
}
|
|
@@ -4556,7 +3921,7 @@ class TableviewInputBuilder {
|
|
|
4556
3921
|
this._descriptor = _descriptor;
|
|
4557
3922
|
this._dataProvider = _dataProvider;
|
|
4558
3923
|
this.injector = injector;
|
|
4559
|
-
this.defaultActions =
|
|
3924
|
+
this.defaultActions = tableviewGetDefaultActions().map(a => ({ type: a, descriptor: undefined }));
|
|
4560
3925
|
this._customActions = [];
|
|
4561
3926
|
}
|
|
4562
3927
|
prepareSetterParams() {
|
|
@@ -4612,6 +3977,73 @@ class TableviewInputBuilder {
|
|
|
4612
3977
|
adjustFn(this.prepareSetterParams());
|
|
4613
3978
|
return this;
|
|
4614
3979
|
}
|
|
3980
|
+
/**
|
|
3981
|
+
* Associates a fetch function for a data provider API service with the specified parameters.
|
|
3982
|
+
*
|
|
3983
|
+
* @param {ServiceFn} serviceFn The function from the service class that performs the fetch API call.
|
|
3984
|
+
* Must be a key of the service with a parameter and return an Observable.
|
|
3985
|
+
* @param {ClassFunctionKeyParam1ObjKeyExtendsOfTargetType<Service, ServiceFn, IdType>} fnItemIdParamName The parameter name for itemId used as the key within the request object of fetch function on API service.
|
|
3986
|
+
*/
|
|
3987
|
+
withDataServiceFetchFn(serviceFn, itemIdParamName) {
|
|
3988
|
+
if (this._dataProvider instanceof TableviewDataProviderInst) {
|
|
3989
|
+
this._dataProvider.withFetch((itemId, service) => service[serviceFn]({ [itemIdParamName]: itemId }));
|
|
3990
|
+
}
|
|
3991
|
+
return this;
|
|
3992
|
+
}
|
|
3993
|
+
/**
|
|
3994
|
+
* Associates a create function for a data provider API service with the specified parameters.
|
|
3995
|
+
*
|
|
3996
|
+
* @param {ServiceFn} serviceFn The function from the service class that performs the create API call.
|
|
3997
|
+
* Must be a key of the service with a parameter and return an Observable.
|
|
3998
|
+
* @param {ClassFunctionKeyParam1ObjKeyExtendsOfTargetType<Service, ServiceFn, Undefined<EditModel>>} serviceFnItemParamName The parameter name for item used as the key within the request object of create function on API service.
|
|
3999
|
+
* @param {EditorDataProviderFetchMapToFnType<Model, AddModel>} [mapFetchItem] Map function to transform model from fetch to form's add model.
|
|
4000
|
+
*/
|
|
4001
|
+
withDataServiceCreateFn(serviceFn, serviceFnItemParamName, mapFetchItem) {
|
|
4002
|
+
if (this._dataProvider instanceof TableviewDataProviderInst) {
|
|
4003
|
+
this._dataProvider.withCreate((item, service) => service[serviceFn]({ [serviceFnItemParamName]: item }));
|
|
4004
|
+
if (mapFetchItem) {
|
|
4005
|
+
this._dataProvider.withMapFetchItemToCreateItem(mapFetchItem);
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
4008
|
+
return this;
|
|
4009
|
+
}
|
|
4010
|
+
/**
|
|
4011
|
+
* Associates an update function for a data provider API service with the specified parameters.
|
|
4012
|
+
*
|
|
4013
|
+
* @param {ServiceFn} serviceFn The function from the service class that performs the update API call.
|
|
4014
|
+
* Must be a key of the service with a parameter and return an Observable.
|
|
4015
|
+
* @param {ClassFunctionKeyParam1ObjKeyExtendsOfTargetType<Service, ServiceFn, Undefined<EditModel>>} fnItemParamName The parameter name for item used as the key within the request object of update function on API service.
|
|
4016
|
+
* @param {ClassFunctionKeyParam1ObjKeyExtendsOfTargetType<Service, ServiceFn, IdType>} [fnItemIdParamName] The parameter name for itemId used as the key within the request object of update function on API service.
|
|
4017
|
+
* @param {EditorDataProviderFetchMapToFnType<Model, EditModel>} [mapFetchItem] Map function to transform model from fetch to form' edit model.
|
|
4018
|
+
*/
|
|
4019
|
+
withDataServiceUpdateFn(serviceFn, fnItemParamName, fnItemIdParamName, mapFetchItem) {
|
|
4020
|
+
if (this._dataProvider instanceof TableviewDataProviderInst) {
|
|
4021
|
+
this._dataProvider.withUpdate((id, item, service) => {
|
|
4022
|
+
const params = { [fnItemParamName]: item };
|
|
4023
|
+
if (fnItemIdParamName) {
|
|
4024
|
+
params[fnItemIdParamName] = id;
|
|
4025
|
+
}
|
|
4026
|
+
return service[serviceFn](params);
|
|
4027
|
+
});
|
|
4028
|
+
if (mapFetchItem) {
|
|
4029
|
+
this._dataProvider.withMapFetchItemToUpdateItem(mapFetchItem);
|
|
4030
|
+
}
|
|
4031
|
+
}
|
|
4032
|
+
return this;
|
|
4033
|
+
}
|
|
4034
|
+
/**
|
|
4035
|
+
* Associates a delete function for a data provider API service with the specified parameters.
|
|
4036
|
+
*
|
|
4037
|
+
* @param {ServiceFn} serviceFn The function from the service class that performs the delete API call.
|
|
4038
|
+
* Must be a key of the service with a parameter and return an Observable.
|
|
4039
|
+
* @param {ClassFunctionKeyParam1ObjKeyExtendsOfTargetType<Service, ServiceFn, IdType>} fnItemIdParamName The parameter name for itemId used as the key within the request object of delete function on API service.
|
|
4040
|
+
*/
|
|
4041
|
+
withDataServiceDeleteFn(serviceFn, fnItemIdParamName) {
|
|
4042
|
+
if (this._dataProvider instanceof TableviewDataProviderInst) {
|
|
4043
|
+
this._dataProvider.withDelete((itemId, service) => service[serviceFn]({ [fnItemIdParamName]: itemId }));
|
|
4044
|
+
}
|
|
4045
|
+
return this;
|
|
4046
|
+
}
|
|
4615
4047
|
/**
|
|
4616
4048
|
* Removes all the default tableview actions.
|
|
4617
4049
|
*
|
|
@@ -4655,7 +4087,7 @@ class TableviewInputBuilder {
|
|
|
4655
4087
|
* Overrides the default action.
|
|
4656
4088
|
*
|
|
4657
4089
|
* @param {TableviewDefaultActionsEnum} type - The default actions to override.
|
|
4658
|
-
* @param {TvBuilderActionSetterFnType<Model, ActionService, Descriptor, DataProvider>} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4090
|
+
* @param {TvBuilderActionSetterFnType<Model, ActionService , ActionRunInput, ActionRunResult, Descriptor, DataProvider>} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4659
4091
|
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4660
4092
|
* @returns {this} - Returns the current instance of the builder.
|
|
4661
4093
|
*/
|
|
@@ -4669,7 +4101,9 @@ class TableviewInputBuilder {
|
|
|
4669
4101
|
/**
|
|
4670
4102
|
* Adds a custom action.
|
|
4671
4103
|
*
|
|
4672
|
-
* @
|
|
4104
|
+
* @deprecated Use on of {withActionOnTable}, {withActionOnDetailsEditor}, {withActionOnEditEditor} or {withActionOnAddEditor} instead.
|
|
4105
|
+
*
|
|
4106
|
+
* @param {TvBuilderActionSetterFnType<Model, ActionService, ActionRunInput, ActionRunResult, Descriptor, DataProvider>} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4673
4107
|
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4674
4108
|
* @returns {this} - Returns the current instance of the builder.
|
|
4675
4109
|
*/
|
|
@@ -4681,14 +4115,98 @@ class TableviewInputBuilder {
|
|
|
4681
4115
|
return this;
|
|
4682
4116
|
}
|
|
4683
4117
|
/**
|
|
4118
|
+
* Adds a custom action on table row or top (header or toolbar).
|
|
4119
|
+
*
|
|
4120
|
+
* @param {TvBuilderActionSetterFnType<Model, ActionService, ActionRunResult, Descriptor, DataProvider>} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4121
|
+
* @param {ActionPositionEnum} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4122
|
+
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4123
|
+
* @returns {this} - Returns the current instance of the builder.
|
|
4124
|
+
*/
|
|
4125
|
+
withActionOnTable(fn) {
|
|
4126
|
+
const action = fn(this.prepareSetterParams());
|
|
4127
|
+
if (action) {
|
|
4128
|
+
action.withPositionTableviewCategories([TableviewActionDefaultCategories.READ]);
|
|
4129
|
+
if (![
|
|
4130
|
+
ActionPositionEnum.ToolbarLeft,
|
|
4131
|
+
ActionPositionEnum.ToolbarRight,
|
|
4132
|
+
ActionPositionEnum.TableHeader,
|
|
4133
|
+
ActionPositionEnum.RowInline,
|
|
4134
|
+
ActionPositionEnum.RowClick
|
|
4135
|
+
].includes(action.position)) {
|
|
4136
|
+
throw new CommonsInternalError(`Action ${action.actionNameLong} can not be positioned on table (${action.position}), define valid position.`);
|
|
4137
|
+
}
|
|
4138
|
+
this._customActions.push(action);
|
|
4139
|
+
}
|
|
4140
|
+
return this;
|
|
4141
|
+
}
|
|
4142
|
+
/**
|
|
4143
|
+
* Adds a custom action on details editor.
|
|
4144
|
+
*
|
|
4145
|
+
* @param {TvBuilderActionSetterFnType<Model, ActionService, ActionRunResult, Descriptor, DataProvider>} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4146
|
+
* @param {ActionPositionEnum} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4147
|
+
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4148
|
+
* @returns {this} - Returns the current instance of the builder.
|
|
4149
|
+
*/
|
|
4150
|
+
withActionOnDetailsEditor(fn) {
|
|
4151
|
+
const action = fn(this.prepareSetterParams());
|
|
4152
|
+
if (action) {
|
|
4153
|
+
action.withPositionTableviewCategories([TableviewActionDefaultCategories.DETAILS]);
|
|
4154
|
+
if (![ActionPositionEnum.ToolbarLeft, ActionPositionEnum.ToolbarRight, ActionPositionEnum.FooterLeft, ActionPositionEnum.FooterRight].includes(action.position)) {
|
|
4155
|
+
throw new CommonsInternalError(`Action ${action.actionNameLong} can not be positioned on details (${action.position}), define valid position.`);
|
|
4156
|
+
}
|
|
4157
|
+
this._customActions.push(action);
|
|
4158
|
+
}
|
|
4159
|
+
return this;
|
|
4160
|
+
}
|
|
4161
|
+
/**
|
|
4162
|
+
* Adds a custom action on edit editor.
|
|
4163
|
+
*
|
|
4164
|
+
* @param {TvBuilderActionSetterFnType<Model, ActionService, ActionRunResult, Descriptor, DataProvider>} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4165
|
+
* @param {ActionPositionEnum} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4166
|
+
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4167
|
+
* @returns {this} - Returns the current instance of the builder.
|
|
4168
|
+
*/
|
|
4169
|
+
withActionOnEditEditor(fn) {
|
|
4170
|
+
const action = fn(this.prepareSetterParams());
|
|
4171
|
+
if (action) {
|
|
4172
|
+
action.withPositionTableviewCategories([TableviewActionDefaultCategories.EDIT]);
|
|
4173
|
+
if (![ActionPositionEnum.ToolbarLeft, ActionPositionEnum.ToolbarRight, ActionPositionEnum.FooterLeft, ActionPositionEnum.FooterRight].includes(action.position)) {
|
|
4174
|
+
throw new CommonsInternalError(`Action ${action.actionNameLong} can not be positioned on edit (${action.position}), define valid position.`);
|
|
4175
|
+
}
|
|
4176
|
+
this._customActions.push(action);
|
|
4177
|
+
}
|
|
4178
|
+
return this;
|
|
4179
|
+
}
|
|
4180
|
+
/**
|
|
4181
|
+
* Adds a custom action on add editor.
|
|
4182
|
+
*
|
|
4183
|
+
* @param {TvBuilderActionSetterFnType<Model, ActionService, ActionRunResult, Descriptor, DataProvider>} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4184
|
+
* @param {ActionPositionEnum} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4185
|
+
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4186
|
+
* @returns {this} - Returns the current instance of the builder.
|
|
4187
|
+
*/
|
|
4188
|
+
withActionOnAddEditor(fn) {
|
|
4189
|
+
const action = fn(this.prepareSetterParams());
|
|
4190
|
+
if (action) {
|
|
4191
|
+
action.withPositionTableviewCategories([TableviewActionDefaultCategories.ADD]);
|
|
4192
|
+
if (![ActionPositionEnum.ToolbarLeft, ActionPositionEnum.ToolbarRight, ActionPositionEnum.FooterLeft, ActionPositionEnum.FooterRight].includes(action.position)) {
|
|
4193
|
+
throw new CommonsInternalError(`Action ${action.actionNameLong} can not be positioned on add (${action.position}), define valid position.`);
|
|
4194
|
+
}
|
|
4195
|
+
this._customActions.push(action);
|
|
4196
|
+
}
|
|
4197
|
+
return this;
|
|
4198
|
+
}
|
|
4199
|
+
/**
|
|
4200
|
+
* @internal
|
|
4201
|
+
*
|
|
4684
4202
|
* Builds and returns an instance of ITableview.
|
|
4685
4203
|
* DO NOT CALL this within tableview create callback function!
|
|
4686
4204
|
*
|
|
4687
|
-
* @return {TableviewInput<Model, Service, Sorts, Filters, Descriptor, DataProvider>} - The built ITableview instance.
|
|
4205
|
+
* @return {TableviewInput<Model, Service, Sorts, Filters, TableModel, AddModel, EditModel, Descriptor, DataProvider>} - The built ITableview instance.
|
|
4688
4206
|
*/
|
|
4689
4207
|
build() {
|
|
4690
4208
|
return {
|
|
4691
|
-
actions:
|
|
4209
|
+
actions: tableviewCreateDefaultActions(this._descriptor, this.defaultActions.filter(a => a.descriptor !== null).map(a => a.type), this.defaultActions
|
|
4692
4210
|
.filter(a => a.descriptor != null)
|
|
4693
4211
|
.reduce((acc, a) => ({
|
|
4694
4212
|
...acc,
|
|
@@ -4704,129 +4222,28 @@ class TableviewInputBuilder {
|
|
|
4704
4222
|
* Creates a tableview with the given model, service.
|
|
4705
4223
|
*
|
|
4706
4224
|
* @param {ModelDescriptor<Model>} model - The model descriptor.
|
|
4707
|
-
* @param {ServiceClassType<Service>} service - The class type of the service.
|
|
4225
|
+
* @param {ServiceClassType<Service>} [opts.service] - The class type of the service.
|
|
4226
|
+
* @param {TypeDescriptor<Sorts> | ModelDescriptor<Sorts>} [opts.sortsType] - Type of sorts
|
|
4227
|
+
* @param {TypeDescriptor<Filters> | ModelDescriptor<Filters>} [opts.filtersType] - Type of filters.
|
|
4708
4228
|
* @param {(builder: TableviewBuilder) => void} [buildFn] - The optional callback function to customize the tableview using the prepared builder.
|
|
4709
4229
|
*
|
|
4710
4230
|
* @returns A tableview instance with descriptor, data provider and actions.
|
|
4711
4231
|
*/
|
|
4712
|
-
function tableview(model,
|
|
4713
|
-
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model), new TableviewDataProviderInst(
|
|
4232
|
+
function tableview(model, opts, buildFn) {
|
|
4233
|
+
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model), new TableviewDataProviderInst(opts?.service), inject(Injector));
|
|
4714
4234
|
buildFn?.(builder);
|
|
4715
4235
|
return builder.build();
|
|
4716
4236
|
}
|
|
4717
|
-
function
|
|
4718
|
-
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model), new TableviewDataProviderInst(
|
|
4237
|
+
function tableviewMultiModel(model, opts, buildFn) {
|
|
4238
|
+
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model, opts), new TableviewDataProviderInst(opts?.service), inject(Injector));
|
|
4719
4239
|
buildFn?.(builder);
|
|
4720
4240
|
return builder.build();
|
|
4721
4241
|
}
|
|
4722
4242
|
|
|
4723
|
-
function
|
|
4243
|
+
function tableviewDataProviderFromDescriptor(descriptor, serviceType) {
|
|
4724
4244
|
return typeof serviceType !== 'undefined'
|
|
4725
|
-
? new TableviewDataProviderInst(
|
|
4726
|
-
: new TableviewDataProviderInst(undefined
|
|
4727
|
-
}
|
|
4728
|
-
|
|
4729
|
-
/**
|
|
4730
|
-
* creates column and field with custom type, for example currency
|
|
4731
|
-
* if field exists, it is replaced
|
|
4732
|
-
* DO NOT USE WITH TYPES WHERE ARGS ARE REQUIRED - ERROR WILL BE THROWN
|
|
4733
|
-
* for enum use withEnumType
|
|
4734
|
-
* for custom class use withClassType
|
|
4735
|
-
* @param descriptor Tableview descriptor
|
|
4736
|
-
* @param property name of field
|
|
4737
|
-
* @param columnType required column type
|
|
4738
|
-
* @param fieldType optional, if not provided it is converted from column type
|
|
4739
|
-
* @param columnDisplayType optional
|
|
4740
|
-
*/
|
|
4741
|
-
function modifyTableviewClassAttributeType(descriptor, property, columnType, fieldType, columnDisplayType) {
|
|
4742
|
-
return modifyTableviewClassAttributeTypeUnsafe(descriptor, property, columnType, fieldType, columnDisplayType);
|
|
4743
|
-
}
|
|
4744
|
-
function modifyTableviewClassAttributeTypeUnsafe(descriptor, property, columnType, fieldType, columnDisplayType) {
|
|
4745
|
-
if (!descriptor.model.type) {
|
|
4746
|
-
throw new CommonsInternalError(`withModifiedType cannot be executed for property ${property}: Model type is not defined.`);
|
|
4747
|
-
}
|
|
4748
|
-
if (columnType === ColumnTypeEnum.Enum) {
|
|
4749
|
-
throw new CommonsInternalError('Do not use with types where args are required', { name: 'TableviewDescriptorError' });
|
|
4750
|
-
}
|
|
4751
|
-
const attributeDef = getTableviewClassAttributeDef(descriptor.model.type).find(attr => attr.name === property);
|
|
4752
|
-
if (attributeDef != null) {
|
|
4753
|
-
fieldType ??= getFieldInputTypeFromColumnType(columnType, columnDisplayType);
|
|
4754
|
-
attributeDef.fieldType = fieldType;
|
|
4755
|
-
modifyTableClassAttributeColumnTypeUnsafe(descriptor.table, property, columnType, columnDisplayType);
|
|
4756
|
-
modifyEditorClassAttributeFieldTypeUnsafe(descriptor.editEditor, property, fieldType);
|
|
4757
|
-
modifyEditorClassAttributeFieldTypeUnsafe(descriptor.addEditor, property, fieldType);
|
|
4758
|
-
modifyEditorClassAttributeFieldTypeUnsafe(descriptor.detailsEditor, property, fieldType);
|
|
4759
|
-
return true;
|
|
4760
|
-
}
|
|
4761
|
-
return false;
|
|
4762
|
-
}
|
|
4763
|
-
/**
|
|
4764
|
-
* creates column with enum type
|
|
4765
|
-
* if fields exists, it is replaced
|
|
4766
|
-
* @param descriptor Tableview descriptor
|
|
4767
|
-
* @param property property name
|
|
4768
|
-
* @param enumDesc type of enum
|
|
4769
|
-
* @param fieldType type of field, optional, default is Text
|
|
4770
|
-
*/
|
|
4771
|
-
function modifyTableviewClassAttributeEnum(descriptor, property, enumDesc, fieldType) {
|
|
4772
|
-
return modifyTableviewClassAttributeEnumUnsafe(descriptor, property, enumDesc, fieldType);
|
|
4773
|
-
}
|
|
4774
|
-
function modifyTableviewClassAttributeEnumUnsafe(descriptor, property, enumDesc, fieldType) {
|
|
4775
|
-
if (!descriptor.model.type) {
|
|
4776
|
-
throw new CommonsInternalError(`withModifiedEnum cannot be executed for property ${property}: Model type is not defined.`);
|
|
4777
|
-
}
|
|
4778
|
-
const attributeDef = getTableviewClassAttributeDef(descriptor.model.type).find(attr => attr.name === property);
|
|
4779
|
-
if (attributeDef != null) {
|
|
4780
|
-
attributeDef.fieldType = fieldType ?? FieldInputTypeEnum.Text;
|
|
4781
|
-
tableDescriptorModifyEnumColumnUnsafe(descriptor.table, property, enumDesc);
|
|
4782
|
-
modifyEditorClassAttributeFieldEnumUnsafe(descriptor.editEditor, property, enumDesc);
|
|
4783
|
-
modifyEditorClassAttributeFieldEnumUnsafe(descriptor.addEditor, property, enumDesc);
|
|
4784
|
-
modifyEditorClassAttributeFieldEnumUnsafe(descriptor.detailsEditor, property, enumDesc);
|
|
4785
|
-
return true;
|
|
4786
|
-
}
|
|
4787
|
-
return false;
|
|
4788
|
-
}
|
|
4789
|
-
/**
|
|
4790
|
-
* generates column with custom class type
|
|
4791
|
-
* field is generated only if lookupProvider is provided
|
|
4792
|
-
* @param descriptor Tableview descriptor
|
|
4793
|
-
* @param property property name
|
|
4794
|
-
* @param type class type of object
|
|
4795
|
-
* @param titleProperty
|
|
4796
|
-
* @param lookupProvider
|
|
4797
|
-
* @param optionsLabelProperty
|
|
4798
|
-
* @param filterProperty
|
|
4799
|
-
*/
|
|
4800
|
-
function modifyTableviewLookup(descriptor, property, type, lookupProvider, titleProperty, optionsLabelProperty, filterProperty) {
|
|
4801
|
-
return modifyTableviewLookupUnsafe(descriptor, property, type, lookupProvider, titleProperty, optionsLabelProperty, filterProperty);
|
|
4802
|
-
}
|
|
4803
|
-
function modifyTableviewLookupUnsafe(descriptor, property, type, lookupProvider, titleProperty, optionsLabelProperty, filterProperty) {
|
|
4804
|
-
if (!descriptor.model.type) {
|
|
4805
|
-
throw new CommonsInternalError(`withModifiedLookup cannot be executed for property ${property}: Model type is not defined.`);
|
|
4806
|
-
}
|
|
4807
|
-
const attributeDef = getTableviewClassAttributeDef(descriptor.model.type).find(attr => attr.name === property);
|
|
4808
|
-
if (attributeDef != null) {
|
|
4809
|
-
type ??= attributeDef.classType ?? TypeRegistry.get().findType(attributeDef.type);
|
|
4810
|
-
titleProperty ??= type ? (findClassTitleAttribute(type) ?? undefined) : undefined;
|
|
4811
|
-
optionsLabelProperty ??= titleProperty;
|
|
4812
|
-
attributeDef.columnType = ColumnTypeEnum.String;
|
|
4813
|
-
attributeDef.fieldType = FieldInputTypeEnum.Text;
|
|
4814
|
-
if (lookupProvider != null) {
|
|
4815
|
-
modifyTableColumnFilterLookupUnsafe(descriptor.table, property, lookupProvider, optionsLabelProperty, filterProperty);
|
|
4816
|
-
modifyEditorFieldLookupUnsafe(descriptor.addEditor, property, lookupProvider, optionsLabelProperty);
|
|
4817
|
-
modifyEditorFieldLookupUnsafe(descriptor.detailsEditor, property, lookupProvider, optionsLabelProperty);
|
|
4818
|
-
modifyEditorFieldLookupUnsafe(descriptor.editEditor, property, lookupProvider, optionsLabelProperty);
|
|
4819
|
-
return true;
|
|
4820
|
-
}
|
|
4821
|
-
else {
|
|
4822
|
-
const column = descriptor.table.getColumnUnsafe(property) ?? descriptor.addColumnUnsafe(property);
|
|
4823
|
-
if (titleProperty) {
|
|
4824
|
-
column.withGetter(value => value?.[titleProperty]);
|
|
4825
|
-
}
|
|
4826
|
-
return true;
|
|
4827
|
-
}
|
|
4828
|
-
}
|
|
4829
|
-
return false;
|
|
4245
|
+
? new TableviewDataProviderInst(serviceType)
|
|
4246
|
+
: new TableviewDataProviderInst(undefined);
|
|
4830
4247
|
}
|
|
4831
4248
|
|
|
4832
4249
|
// action descriptors
|
|
@@ -4835,5 +4252,5 @@ function modifyTableviewLookupUnsafe(descriptor, property, type, lookupProvider,
|
|
|
4835
4252
|
* Generated bundle index. Do not edit.
|
|
4836
4253
|
*/
|
|
4837
4254
|
|
|
4838
|
-
export { AFieldDescriptor, AFieldGroupDescriptor, AFormlyCustomFieldComponent, AGenericFieldDescriptor, ActionActivationTriggerEnum, ActionConfirmationDescriptor,
|
|
4255
|
+
export { AFieldDescriptor, AFieldGroupDescriptor, AFormlyCustomFieldComponent, AGenericFieldDescriptor, ActionActivationTriggerEnum, ActionConfirmationDescriptor, ActionDescriptorInst, ActionEditorDescriptorInst, ActionEditorSubmitDescriptorInst, ActionEditorSubmitTypeEnum, ActionInstanceStateEnum, ActionLinkDescriptorInst, ActionPositionEnum, ActionTypeEnum, CommonsActionError, DATA_LANGUAGE_DROPDOWN_COMPONENT_IT, DataProviderExecutor, DynamicTableviewDataProviderInst, EDITOR_DEFAULT_GROUP_NAME, EditorDataProviderInst, EditorDescriptorInst, EditorDescriptorNestedObjectWrapper, FieldActionDescriptor, FieldGroupDescriptor, FieldGroupTypeEnum, FieldInputDescriptor, FieldInputTypeEnum, FieldLookupDescriptor, FieldLookupEnumDescriptor, FieldLookupTypeEnum, FieldManyEditorActionEnum, FieldManyEditorDescriptor, FieldManyEditorTypeEnum, FieldManyToManyEditorActionEnum, FieldManyToManyEditorDescriptor, FieldManyToManyEditorTypeEnum, FieldSizeEnum, FieldTabGroupDescriptor, FieldValidationDescriptor, FormEventTypeEnum, FormFieldEventComponentSubtype, FormFieldEventDialogSubtype, FormFieldEventTypeEnum, TableviewActionDefaultCategories, TableviewDataProviderInst, TableviewDefaultActionsEnum, TableviewDescriptorInst, TableviewDynamicDescriptorInt, TableviewEditorTypeEnum, TableviewInputBuilder, action, actionEditor, actionEditorCancel, actionEditorGetProviderCfgObj, actionEditorOnEditor, actionEditorOnTableRow, actionEditorOnTableTop, actionEditorSubmit, actionGetProviderCfgObj, actionLink, actionLinkFromAction, actionOnEditor, actionOnTableRow, actionOnTableTop, convertDataToStringWithDelimiter, editorDataProvider, editorDescriptor, fieldLookupGetProviderCfgObj, fieldManyToManyGetProviderCfgObj, getDataProviderService, runCreateFromDataProvider, runDeleteFromDataProvider, runFetchFromDataProvider, runFnFromDataProviderOrFail, runFnFromDataProviderOrFallback, runGetAllFromDataProvider, runUpdateFromDataProvider, saveFileAs, tableview, tableviewActionAddOnTable, tableviewActionDeleteActionName, tableviewActionDeleteOnDetails, tableviewActionDeleteOnTable, tableviewActionDetailsOnTable, tableviewActionEditOnDetails, tableviewActionEditOnTable, tableviewActionEditorAddActionName, tableviewActionEditorAddRoute, tableviewActionEditorDetailsActionName, tableviewActionEditorDetailsRoute, tableviewActionEditorEditActionName, tableviewActionEditorEditRoute, tableviewActionExportCsvOnTable, tableviewActionExportJsonOnTable, tableviewActionExportOnTable, tableviewActionLocalizationLangSelectOnTable, tableviewActionRefreshOnTable, tableviewCreateDefaultAction, tableviewCreateDefaultActions, tableviewDataProvider, tableviewDataProviderFromDescriptor, tableviewDescriptor, tableviewDescriptorMultiModel, tableviewDynamicDataProvider, tableviewDynamicDescriptor, tableviewGetDefaultActions, tableviewMultiModel };
|
|
4839
4256
|
//# sourceMappingURL=mediusinc-mng-commons-tableview-api.mjs.map
|