@mediusinc/mng-commons 5.5.0 → 6.0.0-rc.3
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/notification.d.ts +17 -1
- package/core/helpers/route.d.ts +0 -1
- package/core/helpers/type-helpers.d.ts +8 -0
- package/core/i18n/i18n-error.d.ts +2 -3
- package/core/index.d.ts +0 -3
- package/core/models/menu.model.d.ts +0 -4
- package/core/router/route-builder.d.ts +1 -1
- 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/notification.mjs +19 -4
- package/esm2022/core/helpers/type-helpers.mjs +1 -1
- package/esm2022/core/i18n/i18n-error.mjs +10 -8
- package/esm2022/core/index.mjs +1 -4
- package/esm2022/core/models/menu.model.mjs +1 -1
- package/esm2022/core/router/route-builder.mjs +2 -2
- 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/form/api/descriptors/action-button.descriptor.mjs +5 -17
- package/esm2022/form/api/descriptors/button-style.builder.mjs +80 -101
- package/esm2022/form/api/index.mjs +2 -1
- package/esm2022/form/api/models/button.model.mjs +2 -0
- 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/helpers/i18n.mjs +14 -9
- 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 +7 -5
- 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 +17 -18
- package/esm2022/table/helpers/notification.mjs +19 -13
- package/esm2022/tableview/action/components/action/action.component.mjs +41 -37
- package/esm2022/tableview/action/components/editor/injector-context/action-editor-injector-context.component.mjs +22 -13
- package/esm2022/tableview/action/helpers/action-execution.mjs +1 -1
- package/esm2022/tableview/action/helpers/i18n.mjs +50 -30
- package/esm2022/tableview/action/helpers/notification.mjs +73 -12
- package/esm2022/tableview/action/helpers/styles.mjs +2 -2
- 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 +92 -75
- package/esm2022/tableview/action/services/data-provider-executor.service.mjs +18 -3
- 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 +35 -82
- package/esm2022/tableview/api/action/descriptors/action-link-descriptor.factory.mjs +20 -33
- package/esm2022/tableview/api/action/descriptors/action-link.descriptor.mjs +1 -1
- package/esm2022/tableview/api/action/descriptors/action.descriptor.mjs +54 -95
- 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-confirmation.model.mjs +2 -0
- 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-action.descriptor.mjs +14 -8
- 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/editor/models/formly-custom-field.model.mjs +1 -1
- package/esm2022/tableview/api/index.mjs +9 -9
- 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 +154 -106
- 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/editor/form-editor.component.mjs +5 -8
- package/esm2022/tableview/editor/components/formly/fields/formly-field-action/formly-field-action.component.mjs +7 -5
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +34 -23
- 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/provide.mjs +44 -1
- 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 +715 -792
- 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 +144 -203
- 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 +35 -144
- 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 +45 -38
- 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 +850 -1483
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview.mjs +421 -220
- 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/form/api/descriptors/action-button.descriptor.d.ts +11 -13
- package/form/api/descriptors/button-style.builder.d.ts +30 -44
- package/form/api/index.d.ts +1 -0
- package/form/api/models/button.model.d.ts +19 -0
- package/i18n/sl.json +56 -6
- 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/helpers/i18n.d.ts +8 -3
- 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 +2 -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 -10
- package/table/helpers/notification.d.ts +10 -1
- package/tableview/action/components/action/action.component.d.ts +10 -13
- 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/helpers/i18n.d.ts +36 -11
- package/tableview/action/helpers/notification.d.ts +37 -3
- 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-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 +39 -47
- 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 +49 -60
- 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-confirmation.model.d.ts +14 -0
- package/tableview/api/action/models/action-descriptor.types.d.ts +6 -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-action.descriptor.d.ts +5 -5
- 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 +8 -7
- 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/provide.d.ts +7 -0
- 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 +6 -6
- 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/action/descriptors/action-confirmation.descriptor.mjs +0 -88
- 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
- package/tableview/api/action/descriptors/action-confirmation.descriptor.d.ts +0 -37
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { of, Subject, throwError,
|
|
2
|
-
import { StyleLevelEnum, CommonsInternalError, DataProviderInst, LoggerService, findReflectTypeName, StyleSizeEnum, ACommonsErrorBase, toObservable, fromEnumValuesAsValueArray, fromEnumConstantsAsValueArray, getEnumConstantName,
|
|
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';
|
|
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';
|
|
5
3
|
import * as i0 from '@angular/core';
|
|
6
4
|
import { InjectionToken, Directive, Input, inject, Injector } from '@angular/core';
|
|
7
|
-
import {
|
|
5
|
+
import { LookupDataProviderInst } from '@mediusinc/mng-commons/form/api';
|
|
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,103 +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
|
-
class ActionConfirmationDescriptor {
|
|
52
|
-
constructor() {
|
|
53
|
-
this._closeOnEscape = true; // Defines if dialog closes when esc key is pressed.
|
|
54
|
-
this._closable = true; // Defines if dialog is closable.
|
|
55
|
-
this._acceptButton = new ActionButtonDescriptor().withIcon('pi pi-check').withStyleClass(new ButtonStyleBuilder(StyleLevelEnum.Default));
|
|
56
|
-
this._rejectButton = new ActionButtonDescriptor().withIcon('pi pi-times').withStyleClass(new ButtonStyleBuilder(StyleLevelEnum.Default).withTextButton());
|
|
57
|
-
this._icon = 'pi pi-exclamation-triangle';
|
|
58
|
-
}
|
|
59
|
-
withIcon(icon) {
|
|
60
|
-
this._icon = icon;
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
withTitle(title) {
|
|
64
|
-
this._title = title;
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
withMessage(message) {
|
|
68
|
-
this._message = message;
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
withAcceptButton(actionButtonDescriptor) {
|
|
72
|
-
this._acceptButton = actionButtonDescriptor;
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
withRejectButton(actionButtonDescriptor) {
|
|
76
|
-
this._rejectButton = actionButtonDescriptor;
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* set if dialog can be closed on escaped pressed
|
|
81
|
-
* if true, then closable is also set to true
|
|
82
|
-
* @param closeOnEscape
|
|
83
|
-
*/
|
|
84
|
-
withCloseOnEscape(closeOnEscape) {
|
|
85
|
-
if (closeOnEscape) {
|
|
86
|
-
this._closable = true;
|
|
87
|
-
}
|
|
88
|
-
this._closeOnEscape = closeOnEscape;
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
withClosable(closable) {
|
|
92
|
-
this._closable = closable;
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
95
|
-
withRunConfirmationConfigMapFn(runConfirmationConfigMapFn) {
|
|
96
|
-
this._runConfirmationConfigMapFn = runConfirmationConfigMapFn;
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
get icon() {
|
|
100
|
-
return this._icon;
|
|
101
|
-
}
|
|
102
|
-
get title() {
|
|
103
|
-
return this._title;
|
|
104
|
-
}
|
|
105
|
-
get message() {
|
|
106
|
-
return this._message;
|
|
107
|
-
}
|
|
108
|
-
get closeOnEscape() {
|
|
109
|
-
return this._closeOnEscape;
|
|
110
|
-
}
|
|
111
|
-
get closable() {
|
|
112
|
-
return this._closable;
|
|
113
|
-
}
|
|
114
|
-
get runConfirmationConfigMapFn() {
|
|
115
|
-
return this._runConfirmationConfigMapFn;
|
|
116
|
-
}
|
|
117
|
-
get acceptButton() {
|
|
118
|
-
return this._acceptButton;
|
|
119
|
-
}
|
|
120
|
-
get rejectButton() {
|
|
121
|
-
return this._rejectButton;
|
|
122
|
-
}
|
|
123
|
-
copy() {
|
|
124
|
-
const descriptor = new ActionConfirmationDescriptor();
|
|
125
|
-
descriptor._icon = this._icon;
|
|
126
|
-
descriptor._title = this._title;
|
|
127
|
-
descriptor._message = this._message;
|
|
128
|
-
descriptor._acceptButton = this._acceptButton;
|
|
129
|
-
descriptor._rejectButton = this._rejectButton;
|
|
130
|
-
descriptor._closeOnEscape = this._closeOnEscape;
|
|
131
|
-
descriptor._closable = this._closable;
|
|
132
|
-
descriptor._runConfirmationConfigMapFn = this._runConfirmationConfigMapFn;
|
|
133
|
-
return descriptor;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
40
|
class ActionDescriptorInst {
|
|
138
41
|
constructor(actionName, cfg) {
|
|
139
42
|
this._type = ActionTypeEnum.Direct;
|
|
@@ -141,10 +44,6 @@ class ActionDescriptorInst {
|
|
|
141
44
|
this._position = ActionPositionEnum.ToolbarRight;
|
|
142
45
|
this._level = StyleLevelEnum.Default;
|
|
143
46
|
this._routeUrl = null;
|
|
144
|
-
this._hasRunNotificationSuccess = true;
|
|
145
|
-
this._hasRunNotificationError = true;
|
|
146
|
-
//button
|
|
147
|
-
this._button = new ActionButtonDescriptor();
|
|
148
47
|
// multiple row selection
|
|
149
48
|
this._hasItemsSelection = false;
|
|
150
49
|
// subactions
|
|
@@ -159,7 +58,7 @@ class ActionDescriptorInst {
|
|
|
159
58
|
this._parentProperty = cfg?.parentProperty;
|
|
160
59
|
this.setI18nModelActionBaseKey();
|
|
161
60
|
if (cfg?.serviceType) {
|
|
162
|
-
this._dataProvider = new DataProviderInst(
|
|
61
|
+
this._dataProvider = new DataProviderInst(cfg.serviceType);
|
|
163
62
|
}
|
|
164
63
|
else if (cfg?.dataProvider) {
|
|
165
64
|
this._dataProvider = cfg.dataProvider;
|
|
@@ -193,9 +92,6 @@ class ActionDescriptorInst {
|
|
|
193
92
|
get position() {
|
|
194
93
|
return this._position;
|
|
195
94
|
}
|
|
196
|
-
get level() {
|
|
197
|
-
return this._level;
|
|
198
|
-
}
|
|
199
95
|
get routeUrl() {
|
|
200
96
|
return this._routeUrl;
|
|
201
97
|
}
|
|
@@ -223,32 +119,14 @@ class ActionDescriptorInst {
|
|
|
223
119
|
get actionNameLong() {
|
|
224
120
|
return this._actionNameLong;
|
|
225
121
|
}
|
|
226
|
-
get
|
|
227
|
-
return this.
|
|
228
|
-
}
|
|
229
|
-
get runConfirmationDialogDescriptor() {
|
|
230
|
-
return this._runConfirmationDialogDescriptor;
|
|
231
|
-
}
|
|
232
|
-
get hasRunConfirmation() {
|
|
233
|
-
return this._runConfirmationDialogDescriptor !== null && this._runConfirmationDialogDescriptor !== undefined;
|
|
234
|
-
}
|
|
235
|
-
get hasRunNotificationSuccess() {
|
|
236
|
-
return this._hasRunNotificationSuccess;
|
|
122
|
+
get runConfirmation() {
|
|
123
|
+
return this._runConfirmation;
|
|
237
124
|
}
|
|
238
|
-
get
|
|
239
|
-
return this.
|
|
125
|
+
get runNotificationOnSuccess() {
|
|
126
|
+
return this._runNotificationOnSuccess;
|
|
240
127
|
}
|
|
241
|
-
get
|
|
242
|
-
return this.
|
|
243
|
-
}
|
|
244
|
-
get hasRunNotificationError() {
|
|
245
|
-
return this._hasRunNotificationError;
|
|
246
|
-
}
|
|
247
|
-
get runNotificationErrorTitle() {
|
|
248
|
-
return this._runNotificationErrorTitle;
|
|
249
|
-
}
|
|
250
|
-
get runNotificationErrorMessage() {
|
|
251
|
-
return this._runNotificationErrorMessage;
|
|
128
|
+
get runNotificationOnError() {
|
|
129
|
+
return this._runNotificationOnError;
|
|
252
130
|
}
|
|
253
131
|
get afterRunAction() {
|
|
254
132
|
return this._afterRunAction;
|
|
@@ -312,32 +190,20 @@ class ActionDescriptorInst {
|
|
|
312
190
|
return this;
|
|
313
191
|
}
|
|
314
192
|
/**
|
|
315
|
-
*
|
|
193
|
+
* Creates confirmation action with default style based on action descriptor
|
|
316
194
|
*/
|
|
317
|
-
withRunConfirmation() {
|
|
318
|
-
this.
|
|
319
|
-
this
|
|
320
|
-
this._runConfirmationDialogDescriptor.rejectButton?.styleClass.withActionLevel(this._level);
|
|
321
|
-
return this._runConfirmationDialogDescriptor;
|
|
195
|
+
withRunConfirmation(opts = true) {
|
|
196
|
+
this._runConfirmation = opts === true ? {} : opts === false ? undefined : opts;
|
|
197
|
+
return this;
|
|
322
198
|
}
|
|
323
199
|
/**
|
|
324
|
-
*
|
|
325
|
-
*
|
|
200
|
+
* Override default notifications setup. Notifications can either be overridden with custom text or turned on/off.
|
|
201
|
+
*
|
|
202
|
+
* @param opts Provide config for texts or on/off flag for run success/error notifications.
|
|
326
203
|
*/
|
|
327
|
-
|
|
328
|
-
this.
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
withRunNotificationSuccess(title, message, hasNotification = true) {
|
|
332
|
-
this._hasRunNotificationSuccess = hasNotification;
|
|
333
|
-
this._runNotificationSuccessTitle = title;
|
|
334
|
-
this._runNotificationSuccessMessage = message;
|
|
335
|
-
return this;
|
|
336
|
-
}
|
|
337
|
-
withRunNotificationError(title, message, hasNotification = true) {
|
|
338
|
-
this._hasRunNotificationError = hasNotification;
|
|
339
|
-
this._runNotificationErrorTitle = title;
|
|
340
|
-
this._runNotificationErrorMessage = message;
|
|
204
|
+
withNotifications(opts) {
|
|
205
|
+
this._runNotificationOnSuccess = typeof opts === 'boolean' ? opts : opts?.runOnSuccess;
|
|
206
|
+
this._runNotificationOnError = typeof opts === 'boolean' ? opts : opts?.runOnError;
|
|
341
207
|
return this;
|
|
342
208
|
}
|
|
343
209
|
withAfterRunAction(action) {
|
|
@@ -355,16 +221,24 @@ class ActionDescriptorInst {
|
|
|
355
221
|
this._permissions = permissions;
|
|
356
222
|
return this;
|
|
357
223
|
}
|
|
358
|
-
withTableviewCategory(
|
|
359
|
-
this._tableviewCategory =
|
|
224
|
+
withTableviewCategory(category) {
|
|
225
|
+
this._tableviewCategory = category;
|
|
360
226
|
return this;
|
|
361
227
|
}
|
|
362
|
-
|
|
228
|
+
withButtonOpts(button) {
|
|
363
229
|
this._button = button;
|
|
364
230
|
return this;
|
|
365
231
|
}
|
|
366
|
-
withButton(label, icon = null,
|
|
367
|
-
this._button =
|
|
232
|
+
withButton(label, icon = null, level = StyleLevelEnum.Default) {
|
|
233
|
+
this._button = {
|
|
234
|
+
...this._button,
|
|
235
|
+
label,
|
|
236
|
+
icon,
|
|
237
|
+
style: {
|
|
238
|
+
...this._button?.style,
|
|
239
|
+
level: level
|
|
240
|
+
}
|
|
241
|
+
};
|
|
368
242
|
return this;
|
|
369
243
|
}
|
|
370
244
|
withItemsSelection(hasSelection = true) {
|
|
@@ -415,21 +289,34 @@ class ActionDescriptorInst {
|
|
|
415
289
|
descriptor._runFunction = this._runFunction;
|
|
416
290
|
descriptor._isVisibleFunction = this._isVisibleFunction;
|
|
417
291
|
descriptor._isEnabledFunction = this._isEnabledFunction;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
292
|
+
if (this._runConfirmation) {
|
|
293
|
+
descriptor._runConfirmation = { ...this._runConfirmation };
|
|
294
|
+
if (this._runConfirmation.acceptButton) {
|
|
295
|
+
descriptor._runConfirmation.acceptButton = { ...this._runConfirmation.acceptButton };
|
|
296
|
+
}
|
|
297
|
+
if (this._runConfirmation.rejectButton) {
|
|
298
|
+
descriptor._runConfirmation.rejectButton = { ...this._runConfirmation.rejectButton };
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
descriptor._runNotificationOnSuccess = typeof this._runNotificationOnSuccess === 'object' ? { ...this._runNotificationOnSuccess } : this._runNotificationOnSuccess;
|
|
302
|
+
descriptor._runNotificationOnError = typeof this._runNotificationOnError === 'object' ? { ...this._runNotificationOnError } : this._runNotificationOnError;
|
|
425
303
|
if (this._afterRunAction != null) {
|
|
426
304
|
descriptor._afterRunAction = typeof this._afterRunAction === 'function' ? this._afterRunAction : this._afterRunAction.copy();
|
|
427
305
|
}
|
|
428
306
|
if (this._onRunErrorAction != null) {
|
|
429
|
-
descriptor._onRunErrorAction = typeof this._onRunErrorAction === 'function' ? this.
|
|
307
|
+
descriptor._onRunErrorAction = typeof this._onRunErrorAction === 'function' ? this._onRunErrorAction : this._onRunErrorAction.copy();
|
|
430
308
|
}
|
|
431
309
|
descriptor._permissions = this._permissions;
|
|
432
|
-
|
|
310
|
+
if (this._button) {
|
|
311
|
+
descriptor._button = {
|
|
312
|
+
...this._button
|
|
313
|
+
};
|
|
314
|
+
if (this._button.style) {
|
|
315
|
+
descriptor._button.style = {
|
|
316
|
+
...this._button.style
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
433
320
|
descriptor._hasItemsSelection = this._hasItemsSelection;
|
|
434
321
|
descriptor._component = this._component;
|
|
435
322
|
descriptor._componentFromDi = this._componentFromDi;
|
|
@@ -448,28 +335,6 @@ class ActionDescriptorInst {
|
|
|
448
335
|
return descriptor;
|
|
449
336
|
}
|
|
450
337
|
}
|
|
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
338
|
|
|
474
339
|
const actionGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
475
340
|
const cfg = {};
|
|
@@ -484,115 +349,24 @@ const actionGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
|
484
349
|
}
|
|
485
350
|
return cfg;
|
|
486
351
|
};
|
|
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) : {})
|
|
352
|
+
/**
|
|
353
|
+
* Creates and returns an instance of ActionDescriptorInst, allowing customization of the action's behavior through configuration options.
|
|
354
|
+
*
|
|
355
|
+
* @param {string} actionName - The unique name of the action.
|
|
356
|
+
* @param {ActionDescriptorCreateFromModelOptsType<Model, Service, RunInput, RunResult, ValidationInput>} [opts] - Optional configuration object to define the action's behavior, including model, service provider and other.
|
|
357
|
+
* @return {ActionDescriptorInst<Model, Service, RunInput, RunResult, ValidationInput>} An instance of ActionDescriptorInst configured with the provided parameters.
|
|
358
|
+
*/
|
|
359
|
+
function action(actionName, opts) {
|
|
360
|
+
return new ActionDescriptorInst(actionName, {
|
|
361
|
+
...(opts?.serviceProvider ? actionGetProviderCfgObj(opts.serviceProvider) : {}),
|
|
362
|
+
...opts
|
|
588
363
|
});
|
|
589
364
|
}
|
|
590
365
|
|
|
591
366
|
class EditorDataProviderInst extends DataProviderInst {
|
|
592
|
-
constructor(
|
|
593
|
-
super(
|
|
367
|
+
constructor(serviceType) {
|
|
368
|
+
super(serviceType);
|
|
594
369
|
this._editorResetSubject = new Subject();
|
|
595
|
-
this._fetch = id => throwError(() => new CommonsInternalError(`No fetch function provided for id ${id}.`));
|
|
596
370
|
}
|
|
597
371
|
get fetch() {
|
|
598
372
|
return this._fetch;
|
|
@@ -606,6 +380,12 @@ class EditorDataProviderInst extends DataProviderInst {
|
|
|
606
380
|
get delete() {
|
|
607
381
|
return this._delete;
|
|
608
382
|
}
|
|
383
|
+
get mapFetchItemToCreateItem() {
|
|
384
|
+
return this._mapFetchItemToCreateItem;
|
|
385
|
+
}
|
|
386
|
+
get mapFetchItemToUpdateItem() {
|
|
387
|
+
return this._mapFetchItemToUpdateItem;
|
|
388
|
+
}
|
|
609
389
|
get editorReset$() {
|
|
610
390
|
return this._editorResetSubject.asObservable();
|
|
611
391
|
}
|
|
@@ -625,7 +405,7 @@ class EditorDataProviderInst extends DataProviderInst {
|
|
|
625
405
|
/**
|
|
626
406
|
* Sets the create function for the EditorDataProvider.
|
|
627
407
|
*
|
|
628
|
-
* @param {EditorDataProviderCreateFnType<Model, Service>} fn - The function used for creating new items.
|
|
408
|
+
* @param {EditorDataProviderCreateFnType<CreateModel, Model, Service>} fn - The function used for creating new items.
|
|
629
409
|
* @returns {this} - Returns the instance of the class.
|
|
630
410
|
*
|
|
631
411
|
* @typeparam Model The type of data this DataProvider will handle.
|
|
@@ -662,29 +442,54 @@ class EditorDataProviderInst extends DataProviderInst {
|
|
|
662
442
|
this._delete = fn;
|
|
663
443
|
return this;
|
|
664
444
|
}
|
|
445
|
+
/**
|
|
446
|
+
* Sets the function to map data from fetch function to create model.
|
|
447
|
+
*
|
|
448
|
+
* @param {EditorDataProviderFetchMapToFnType<Model, CreateModel>} fn - The map function to be set.
|
|
449
|
+
*
|
|
450
|
+
* @returns {this} - Returns the instance of the current class.
|
|
451
|
+
*
|
|
452
|
+
* @typeparam Model The type of data from fetch function to map from.
|
|
453
|
+
* @typeparam CreateModel The type of data to map to.
|
|
454
|
+
*/
|
|
455
|
+
withMapFetchItemToCreateItem(fn) {
|
|
456
|
+
this._mapFetchItemToCreateItem = fn;
|
|
457
|
+
return this;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Sets the function to map data from fetch function to update model.
|
|
461
|
+
*
|
|
462
|
+
* @param {EditorDataProviderFetchMapToFnType<Model, UpdateModel>} fn - The map function to be set.
|
|
463
|
+
*
|
|
464
|
+
* @returns {this} - Returns the instance of the current class.
|
|
465
|
+
*
|
|
466
|
+
* @typeparam Model The type of data from fetch function to map from.
|
|
467
|
+
* @typeparam UpdateModel The type of data to map to.
|
|
468
|
+
*/
|
|
469
|
+
withMapFetchItemToUpdateItem(fn) {
|
|
470
|
+
this._mapFetchItemToUpdateItem = fn;
|
|
471
|
+
return this;
|
|
472
|
+
}
|
|
665
473
|
resetEditor(event) {
|
|
666
474
|
this._editorResetSubject.next(event ?? {});
|
|
667
475
|
}
|
|
668
476
|
}
|
|
669
477
|
|
|
670
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
671
478
|
class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
672
479
|
constructor(editorDescriptor, actionName, cfg) {
|
|
673
480
|
super(actionName, {
|
|
674
|
-
|
|
675
|
-
|
|
481
|
+
...cfg,
|
|
482
|
+
model: cfg?.model ?? editorDescriptor.model
|
|
676
483
|
});
|
|
677
484
|
this._dataProvider = undefined;
|
|
678
485
|
this._editorActions = [];
|
|
679
486
|
this._editorTitle = undefined;
|
|
680
487
|
this._editorTitleParams = undefined;
|
|
681
|
-
this._hasFetchNotificationSuccess = false;
|
|
682
488
|
this._dialogSize = StyleSizeEnum.Normal;
|
|
683
489
|
this._resubmitRefetch = true;
|
|
684
490
|
this._unsavedChangesConfirmation = false;
|
|
685
|
-
this._isTableviewMainEditor = cfg?.isTableviewMainEditor ?? false;
|
|
686
491
|
if (cfg?.serviceType) {
|
|
687
|
-
this._dataProvider = new EditorDataProviderInst(
|
|
492
|
+
this._dataProvider = new EditorDataProviderInst(cfg.serviceType);
|
|
688
493
|
}
|
|
689
494
|
else if (cfg?.dataProvider) {
|
|
690
495
|
this._dataProvider = cfg.dataProvider;
|
|
@@ -693,9 +498,6 @@ class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
|
693
498
|
this._editorDescriptor = editorDescriptor;
|
|
694
499
|
this._editorActions.push(actionEditorSubmit(this), actionEditorCancel(this));
|
|
695
500
|
}
|
|
696
|
-
get isTableviewMainEditor() {
|
|
697
|
-
return this._isTableviewMainEditor;
|
|
698
|
-
}
|
|
699
501
|
get editorTitle() {
|
|
700
502
|
return this._editorTitle;
|
|
701
503
|
}
|
|
@@ -711,14 +513,11 @@ class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
|
711
513
|
get dialogClassName() {
|
|
712
514
|
return this._dialogClassName;
|
|
713
515
|
}
|
|
714
|
-
get
|
|
715
|
-
return this.
|
|
716
|
-
}
|
|
717
|
-
get fetchNotificationSuccessTitle() {
|
|
718
|
-
return this._fetchNotificationSuccessTitle;
|
|
516
|
+
get fetchNotificationOnSuccess() {
|
|
517
|
+
return this._fetchNotificationOnSuccess;
|
|
719
518
|
}
|
|
720
|
-
get
|
|
721
|
-
return this.
|
|
519
|
+
get fetchNotificationOnError() {
|
|
520
|
+
return this._fetchNotificationOnError;
|
|
722
521
|
}
|
|
723
522
|
get dataProvider() {
|
|
724
523
|
return this._dataProvider;
|
|
@@ -780,10 +579,20 @@ class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
|
780
579
|
this._submitFunction = fn;
|
|
781
580
|
return this;
|
|
782
581
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
582
|
+
/**
|
|
583
|
+
* Override default notifications setup. Notifications can either be overridden with custom text or turned on/off.
|
|
584
|
+
*
|
|
585
|
+
* @param opts Provide config for texts or on/off flag for submit (is same as run) or fetch success/error notifications.
|
|
586
|
+
*/
|
|
587
|
+
withNotifications(opts) {
|
|
588
|
+
super.withNotifications(typeof opts === 'boolean'
|
|
589
|
+
? opts
|
|
590
|
+
: {
|
|
591
|
+
runOnSuccess: opts?.submitOnSuccess ?? opts?.runOnSuccess,
|
|
592
|
+
runOnError: opts?.submitOnError ?? opts?.runOnError
|
|
593
|
+
});
|
|
594
|
+
this._fetchNotificationOnSuccess = typeof opts === 'boolean' ? opts : opts?.fetchOnSuccess;
|
|
595
|
+
this._fetchNotificationOnError = typeof opts === 'boolean' ? opts : opts?.fetchOnError;
|
|
787
596
|
return this;
|
|
788
597
|
}
|
|
789
598
|
withEditorAction(action) {
|
|
@@ -820,9 +629,8 @@ class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
|
820
629
|
descriptor._editorActions = this._editorActions.map(a => a.copy());
|
|
821
630
|
descriptor._editorTitle = this._editorTitle;
|
|
822
631
|
descriptor._editorTitleParams = this._editorTitleParams != null ? { ...this._editorTitleParams } : undefined;
|
|
823
|
-
descriptor.
|
|
824
|
-
descriptor.
|
|
825
|
-
descriptor._fetchNotificationSuccessMessage = this._fetchNotificationSuccessMessage;
|
|
632
|
+
descriptor._fetchNotificationOnSuccess = typeof this._fetchNotificationOnSuccess === 'object' ? { ...this._fetchNotificationOnSuccess } : this._fetchNotificationOnSuccess;
|
|
633
|
+
descriptor._fetchNotificationOnError = typeof this._fetchNotificationOnError === 'object' ? { ...this._fetchNotificationOnError } : this._fetchNotificationOnError;
|
|
826
634
|
descriptor._dialogSize = this._dialogSize;
|
|
827
635
|
descriptor._dialogClassName = this._dialogClassName;
|
|
828
636
|
descriptor._fetchFunction = this._fetchFunction;
|
|
@@ -866,7 +674,11 @@ class ActionEditorSubmitDescriptorInst extends ActionDescriptorInst {
|
|
|
866
674
|
* @param submitType
|
|
867
675
|
*/
|
|
868
676
|
function actionEditorSubmit(editorAction, submitType = ActionEditorSubmitTypeEnum.Submit) {
|
|
869
|
-
return new ActionEditorSubmitDescriptorInst(editorAction.actionName, editorAction.model, submitType).
|
|
677
|
+
return new ActionEditorSubmitDescriptorInst(editorAction.actionName, editorAction.model, submitType).withButtonOpts({
|
|
678
|
+
style: {
|
|
679
|
+
level: editorAction.button?.style?.level
|
|
680
|
+
}
|
|
681
|
+
});
|
|
870
682
|
}
|
|
871
683
|
/**
|
|
872
684
|
* creates secondary button with text button style
|
|
@@ -874,61 +686,12 @@ function actionEditorSubmit(editorAction, submitType = ActionEditorSubmitTypeEnu
|
|
|
874
686
|
* @param submitType
|
|
875
687
|
*/
|
|
876
688
|
function actionEditorCancel(editorAction, submitType = ActionEditorSubmitTypeEnum.Cancel) {
|
|
877
|
-
return new ActionEditorSubmitDescriptorInst(editorAction.actionName, editorAction.model, submitType).
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
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
|
-
}
|
|
689
|
+
return new ActionEditorSubmitDescriptorInst(editorAction.actionName, editorAction.model, submitType).withButtonOpts({
|
|
690
|
+
style: {
|
|
691
|
+
textButton: true,
|
|
692
|
+
level: editorAction.button?.style?.level
|
|
693
|
+
}
|
|
694
|
+
});
|
|
932
695
|
}
|
|
933
696
|
|
|
934
697
|
const actionEditorGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
@@ -944,66 +707,19 @@ const actionEditorGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
|
944
707
|
}
|
|
945
708
|
return cfg;
|
|
946
709
|
};
|
|
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) : {})
|
|
710
|
+
/**
|
|
711
|
+
* Creates an ActionEditorDescriptorInst instance with the provided editor descriptor and options.
|
|
712
|
+
*
|
|
713
|
+
* @param {string} actionName - The name of the action to associate with the editor.
|
|
714
|
+
* @param {EditorDescriptorInst<EditorModel, any>} editor - The editor descriptor instance to be used.
|
|
715
|
+
* @param {ActionEditorDescriptorOptsType<Model, Service, FetchInput, SubmitReturn, ValidationInput>} [opts] - Optional configuration options for the ActionEditor.
|
|
716
|
+
* @return {ActionEditorDescriptorInst<Model, Service, EditorModel, FetchInput, SubmitReturn, ValidationInput>} An instance of ActionEditorDescriptor with the configured parameters.
|
|
717
|
+
*/
|
|
718
|
+
function actionEditor(actionName, editor, opts) {
|
|
719
|
+
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
720
|
+
...opts,
|
|
721
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {}),
|
|
722
|
+
model: opts?.model
|
|
1007
723
|
});
|
|
1008
724
|
}
|
|
1009
725
|
|
|
@@ -1080,49 +796,144 @@ class ActionLinkDescriptorInst extends ActionDescriptorInst {
|
|
|
1080
796
|
}
|
|
1081
797
|
}
|
|
1082
798
|
|
|
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) {
|
|
799
|
+
/**
|
|
800
|
+
* Creates an instance of ActionLinkDescriptorInst with the provided action name and options.
|
|
801
|
+
*
|
|
802
|
+
* @param {string} actionName - The unique name of the action.
|
|
803
|
+
* @param {ActionLinkCreateOptsType<Model, ValidationInput>} [opts] - Optional parameters for configuring the action link, including the model and validation type.
|
|
804
|
+
* @return {ActionLinkDescriptorInst<Model, ValidationInput>} An instance of ActionLinkDescriptorInst initialized with the action name and options.
|
|
805
|
+
*/
|
|
806
|
+
function actionLink(actionName, opts) {
|
|
1109
807
|
return new ActionLinkDescriptorInst(actionName, {
|
|
1110
|
-
|
|
1111
|
-
|
|
808
|
+
...opts,
|
|
809
|
+
model: opts?.model
|
|
1112
810
|
});
|
|
1113
811
|
}
|
|
812
|
+
/**
|
|
813
|
+
* Generates an ActionLinkDescriptorInst from the provided ActionDescriptorInst.
|
|
814
|
+
*
|
|
815
|
+
* @param {ActionDescriptorInst<Model, any, any, any, ValidationInput>} action - The action descriptor instance that serves as the basis for the action link.
|
|
816
|
+
* @return {ActionLinkDescriptorInst<Model, ValidationInput>} A newly created ActionLinkDescriptorInst configured with the provided action parameters.
|
|
817
|
+
*/
|
|
1114
818
|
function actionLinkFromAction(action) {
|
|
1115
819
|
const descriptor = new ActionLinkDescriptorInst(action.actionName, { model: action.model });
|
|
1116
820
|
action.copyFieldsTo(descriptor);
|
|
1117
|
-
|
|
1118
|
-
descriptor.
|
|
1119
|
-
descriptor.
|
|
821
|
+
// disable confirmation and notifications
|
|
822
|
+
descriptor.withRunConfirmation(false);
|
|
823
|
+
descriptor.withNotifications(false);
|
|
1120
824
|
descriptor.withAfterRunAction();
|
|
1121
825
|
descriptor.withOnRunErrorAction();
|
|
1122
826
|
descriptor.withSubactionsAsMenu(false);
|
|
1123
827
|
return descriptor;
|
|
1124
828
|
}
|
|
1125
829
|
|
|
830
|
+
/**
|
|
831
|
+
* Defines an action to be positioned on a specified editor with editor-specific execution context.
|
|
832
|
+
*
|
|
833
|
+
* @param {string} actionName - The name identifying the action to be performed.
|
|
834
|
+
* @param {EditorDescriptorInst<EditorModel>} editor - The descriptor of the editor on which the action will be placed and executed.
|
|
835
|
+
* @param {Object} [opts] - Options for configuring the action behavior.
|
|
836
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The model descriptor associated with the action.
|
|
837
|
+
* @param {ActionProviderType<Model, Service>} [opts.serviceProvider] - The service provider type for execution context.
|
|
838
|
+
* @param {ActionPositionEnum.FooterLeft | ActionPositionEnum.FooterRight | ActionPositionEnum.ToolbarLeft | ActionPositionEnum.ToolbarRight} [opts.position] - The position of action on editor.
|
|
839
|
+
* @return {ActionDescriptorInst<Model, Service, EditorModel, Model, EditorModel>} - An instance representing the configured action descriptor for the specified editor and model.
|
|
840
|
+
*/
|
|
841
|
+
function actionOnEditor(actionName, editor, opts) {
|
|
842
|
+
return new ActionDescriptorInst(actionName, {
|
|
843
|
+
model: opts?.model,
|
|
844
|
+
...(opts?.serviceProvider ? actionGetProviderCfgObj(opts?.serviceProvider) : {})
|
|
845
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.FooterLeft);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Creates and returns an instance of `ActionEditorDescriptorInst` when positioned on another (parent) editor.
|
|
850
|
+
*
|
|
851
|
+
* @param {string} actionName - The name of the action associated with the editor.
|
|
852
|
+
* @param {EditorDescriptorInst<EditorModel, ParentEditor>} editor - The editor descriptor defining editor on action.
|
|
853
|
+
* @param {Object} [opts] - Optional parameters for configuring the action editor.
|
|
854
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The descriptor for the model associated with the action.
|
|
855
|
+
* @param {ActionEditorProviderType<Model, Service>} [opts.serviceProvider] - The service provider type for the action editor.
|
|
856
|
+
* @param {ActionPositionEnum.FooterLeft | ActionPositionEnum.FooterRight | ActionPositionEnum.ToolbarLeft | ActionPositionEnum.ToolbarRight} [opts.position] - The desired position of action on the editor.
|
|
857
|
+
* @return {ActionEditorDescriptorInst<Model, Service, EditorModel, ParentEditor, EditorModel, ParentEditor>} A configured instance of `ActionEditorDescriptorInst` representing the action editor.
|
|
858
|
+
*/
|
|
859
|
+
function actionEditorOnEditor(actionName, editor, opts) {
|
|
860
|
+
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
861
|
+
model: opts?.model,
|
|
862
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {})
|
|
863
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.FooterLeft);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Defines an action to be positioned on a specified table with table row execution context.
|
|
868
|
+
*
|
|
869
|
+
* @param {string} actionName - The name identifying the action to be performed.
|
|
870
|
+
* @param {TableDescriptorInst<TableModel, any, any>} table - The descriptor of the table on which the action will be placed and executed.
|
|
871
|
+
* @param {Object} [opts] - Options for configuring the action behavior.
|
|
872
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The model descriptor associated with the action.
|
|
873
|
+
* @param {ActionProviderType<Model, Service>} [opts.serviceProvider] - The service provider type for execution context.
|
|
874
|
+
* @param {ActionPositionEnum.RowInline | ActionPositionEnum.RowClick} [opts.position] - The position of action on table.
|
|
875
|
+
* @return {ActionDescriptorInst<Model, Service, TableModel, Model, TableModel>} - An instance representing the configured action descriptor for the specified table row and model.
|
|
876
|
+
*/
|
|
877
|
+
function actionOnTableRow(actionName, table, opts) {
|
|
878
|
+
return new ActionDescriptorInst(actionName, {
|
|
879
|
+
model: opts?.model,
|
|
880
|
+
...(opts?.serviceProvider ? actionGetProviderCfgObj(opts?.serviceProvider) : {})
|
|
881
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.RowInline);
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Defines an action to be positioned on a specified table with table header or footer execution context.
|
|
885
|
+
*
|
|
886
|
+
* @param {string} actionName - The name identifying the action to be performed.
|
|
887
|
+
* @param {Object} [opts] - Options for configuring the action behavior.
|
|
888
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The model descriptor associated with the action.
|
|
889
|
+
* @param {ActionProviderType<Model, Service>} [opts.serviceProvider] - The service provider type for execution context.
|
|
890
|
+
* @param {ActionPositionEnum.ToolbarLeft | ActionPositionEnum.ToolbarRight | ActionPositionEnum.TableHeader} [opts.position] - The position of action on table.
|
|
891
|
+
* @return {ActionDescriptorInst<Model, Service, TableModel, Model, TableModel>} - An instance representing the configured action descriptor for the specified table top and model.
|
|
892
|
+
*/
|
|
893
|
+
function actionOnTableTop(actionName, opts) {
|
|
894
|
+
return new ActionDescriptorInst(actionName, {
|
|
895
|
+
model: opts?.model,
|
|
896
|
+
...(opts?.serviceProvider ? actionGetProviderCfgObj(opts?.serviceProvider) : {})
|
|
897
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.ToolbarLeft);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* Creates and returns an ActionEditorDescriptorInst for displaying editor action on table row.
|
|
902
|
+
*
|
|
903
|
+
* @param {string} actionName - The name of the action.
|
|
904
|
+
* @param {EditorDescriptorInst<EditorModel, any>} editor - The editor descriptor instance responsible for configuring the editor behavior.
|
|
905
|
+
* @param {TableDescriptorInst<TableModel, any, any>} table - The table descriptor instance representing the table on which the action is positioned.
|
|
906
|
+
* @param {Object} [opts] - Optional configurations for the action editor.
|
|
907
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The model descriptor associated with the action editor.
|
|
908
|
+
* @param {ActionEditorProviderType<Model, Service>} [opts.serviceProvider] - The service provider for additional configurations or services for the action editor.
|
|
909
|
+
* @param {ActionPositionEnum.RowInline | ActionPositionEnum.RowClick} [opts.position] - The position where the action should be displayed on the table row.
|
|
910
|
+
* @return {ActionEditorDescriptorInst<Model, Service, EditorModel, TableModel, EditorModel, TableModel>} The configured action editor descriptor instance.
|
|
911
|
+
*/
|
|
912
|
+
function actionEditorOnTableRow(actionName, editor, table, opts) {
|
|
913
|
+
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
914
|
+
model: opts?.model,
|
|
915
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {})
|
|
916
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.RowInline);
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Creates and returns an action editor descriptor configured with the given parameters.
|
|
920
|
+
* This is used to define an action editor positioned relative to a table.
|
|
921
|
+
*
|
|
922
|
+
* @param {string} actionName - The name of the action.
|
|
923
|
+
* @param {EditorDescriptorInst<EditorModel, any>} editor - The editor descriptor instance responsible for configuring the editor behavior.
|
|
924
|
+
* @param {Object} [opts] - Optional configurations for the action editor.
|
|
925
|
+
* @param {ModelDescriptor<Model>} [opts.model] - The model descriptor associated with the action editor.
|
|
926
|
+
* @param {ActionEditorProviderType<Model, Service>} [opts.serviceProvider] - The service provider for additional configurations or services for the action editor.
|
|
927
|
+
* @param {ActionPositionEnum.ToolbarLeft | ActionPositionEnum.ToolbarRight | ActionPositionEnum.TableHeader} [opts.position] - The position of the action on the table.
|
|
928
|
+
* @return {ActionEditorDescriptorInst<Model, Service, EditorModel, undefined, EditorModel, undefined>} The configured action editor descriptor instance.
|
|
929
|
+
*/
|
|
930
|
+
function actionEditorOnTableTop(actionName, editor, opts) {
|
|
931
|
+
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
932
|
+
model: opts?.model,
|
|
933
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {})
|
|
934
|
+
}).withPosition(opts?.position ?? ActionPositionEnum.ToolbarLeft);
|
|
935
|
+
}
|
|
936
|
+
|
|
1126
937
|
class CommonsActionError extends ACommonsErrorBase {
|
|
1127
938
|
constructor(message, actionName, options) {
|
|
1128
939
|
super(message, {
|
|
@@ -1158,11 +969,31 @@ function runGetAllFromDataProvider(ctx) {
|
|
|
1158
969
|
}
|
|
1159
970
|
return null;
|
|
1160
971
|
}
|
|
1161
|
-
function runFetchFromDataProvider(ctx) {
|
|
972
|
+
function runFetchFromDataProvider(ctx, opts) {
|
|
1162
973
|
if (typeof ctx.dataProvider !== 'undefined') {
|
|
1163
974
|
const editorDataProvider = ctx.dataProvider;
|
|
1164
975
|
if (typeof editorDataProvider.fetch === 'function') {
|
|
1165
|
-
return ctx.parameters?.itemId
|
|
976
|
+
return ctx.parameters?.itemId
|
|
977
|
+
? toObservable(editorDataProvider.fetch(ctx.parameters.itemId, ctx.serviceInstance, ctx.parameters.locale)).pipe(map(res => {
|
|
978
|
+
if (opts?.reason === 'update') {
|
|
979
|
+
if (opts?.strict && typeof editorDataProvider.mapFetchItemToUpdateItem !== 'function') {
|
|
980
|
+
throw new CommonsInternalError(`mapFetchToUpdate function must be provided in data provider`);
|
|
981
|
+
}
|
|
982
|
+
else if (typeof editorDataProvider.mapFetchItemToUpdateItem === 'function') {
|
|
983
|
+
return editorDataProvider.mapFetchItemToUpdateItem(res);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
else if (opts?.reason === 'create') {
|
|
987
|
+
if (opts?.strict && typeof editorDataProvider.mapFetchItemToCreateItem !== 'function') {
|
|
988
|
+
throw new CommonsInternalError(`mapFetchToCreate function must be provided in data provider`);
|
|
989
|
+
}
|
|
990
|
+
else if (typeof editorDataProvider.mapFetchItemToCreateItem === 'function') {
|
|
991
|
+
return editorDataProvider.mapFetchItemToCreateItem(res);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
return res;
|
|
995
|
+
}))
|
|
996
|
+
: null;
|
|
1166
997
|
}
|
|
1167
998
|
}
|
|
1168
999
|
return null;
|
|
@@ -1189,7 +1020,7 @@ function runDeleteFromDataProvider(ctx) {
|
|
|
1189
1020
|
if (typeof ctx.dataProvider !== 'undefined') {
|
|
1190
1021
|
const editorDataProvider = ctx.dataProvider;
|
|
1191
1022
|
if (typeof editorDataProvider.delete === 'function') {
|
|
1192
|
-
return ctx.parameters?.itemId ? toObservable(editorDataProvider.delete(ctx.parameters.itemId, ctx.
|
|
1023
|
+
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
1024
|
}
|
|
1194
1025
|
}
|
|
1195
1026
|
return null;
|
|
@@ -1245,14 +1076,25 @@ var ActionInstanceStateEnum;
|
|
|
1245
1076
|
ActionInstanceStateEnum[ActionInstanceStateEnum["FinishRouteUntriggerTimeoutFinal"] = 24] = "FinishRouteUntriggerTimeoutFinal";
|
|
1246
1077
|
})(ActionInstanceStateEnum || (ActionInstanceStateEnum = {}));
|
|
1247
1078
|
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1079
|
+
/**
|
|
1080
|
+
* Default categories for tableview actions
|
|
1081
|
+
*/
|
|
1082
|
+
class TableviewActionDefaultCategories {
|
|
1083
|
+
static { this.READ = '_defaultTwRead'; }
|
|
1084
|
+
static { this.ADD = '_defaultTwAdd'; }
|
|
1085
|
+
static { this.EDIT = '_defaultTwEdit'; }
|
|
1086
|
+
static { this.DELETE = '_defaultTwDelete'; }
|
|
1087
|
+
static { this.DETAILS = '_defaultTwDetails'; }
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
const DATA_LANGUAGE_DROPDOWN_COMPONENT_IT = new InjectionToken('DATA_LANGUAGE_DROPDOWN_COMPONENT');
|
|
1091
|
+
|
|
1092
|
+
class DataProviderExecutor {
|
|
1251
1093
|
runGetAllOrFail(ctx) {
|
|
1252
1094
|
return runFnFromDataProviderOrFail(ctx, this.runGetAll.bind(this));
|
|
1253
1095
|
}
|
|
1254
|
-
runFetchOrFail(ctx) {
|
|
1255
|
-
return runFnFromDataProviderOrFail(ctx, this.runFetch
|
|
1096
|
+
runFetchOrFail(ctx, fetchReason) {
|
|
1097
|
+
return runFnFromDataProviderOrFail(ctx, ctx => this.runFetch(ctx, fetchReason));
|
|
1256
1098
|
}
|
|
1257
1099
|
runCreateOrFail(ctx) {
|
|
1258
1100
|
return runFnFromDataProviderOrFail(ctx, this.runCreate.bind(this));
|
|
@@ -1274,36 +1116,68 @@ class DataProviderExecutor {
|
|
|
1274
1116
|
}
|
|
1275
1117
|
}
|
|
1276
1118
|
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1119
|
+
/**
|
|
1120
|
+
* Creates and returns an instance of `EditorDataProviderInst` with the specified options for managing editor data.
|
|
1121
|
+
*
|
|
1122
|
+
* @param {Object} [opts] - The options object to configure the data provider.
|
|
1123
|
+
* @param {TypeDescriptor<Model> | ModelDescriptor<Model>} [opts.type] - The descriptor defining the type of model.
|
|
1124
|
+
* @param {ServiceClassType<Service>} [opts.service] - The service class type associated with the data provider.
|
|
1125
|
+
* @param {TypeDescriptor<CreateModel> | ModelDescriptor<CreateModel>} [opts.createType] - The descriptor defining the create type.
|
|
1126
|
+
* @param {TypeDescriptor<UpdateModel> | ModelDescriptor<UpdateModel>} [opts.updateType] - The descriptor defining the update type.
|
|
1127
|
+
* @return {EditorDataProviderInst<Model, Service, ServiceClass, CreateModel, UpdateModel>} An instance of `EditorDataProviderInst` configured according to the provided options.
|
|
1128
|
+
*/
|
|
1129
|
+
function editorDataProvider(opts) {
|
|
1130
|
+
return new EditorDataProviderInst(opts?.service);
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* @experimental
|
|
1135
|
+
*/
|
|
1136
|
+
class EditorDescriptorNestedObjectWrapper {
|
|
1137
|
+
#path;
|
|
1138
|
+
#editor;
|
|
1139
|
+
constructor(editor, basePath) {
|
|
1140
|
+
this.#editor = editor;
|
|
1141
|
+
this.#path = basePath;
|
|
1280
1142
|
}
|
|
1281
|
-
|
|
1282
|
-
return
|
|
1143
|
+
nested(property) {
|
|
1144
|
+
return new EditorDescriptorNestedObjectWrapper(this.#editor, this.getNestedPropertyPath(property));
|
|
1283
1145
|
}
|
|
1284
|
-
|
|
1285
|
-
return
|
|
1146
|
+
getNestedPropertyPath(p) {
|
|
1147
|
+
return `${this.#path}.${p}`;
|
|
1286
1148
|
}
|
|
1287
|
-
|
|
1288
|
-
return
|
|
1149
|
+
getField(property) {
|
|
1150
|
+
return this.#editor.getFieldUnsafe(this.getNestedPropertyPath(property));
|
|
1289
1151
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1152
|
+
removeField(property) {
|
|
1153
|
+
this.#editor.removeFieldUnsafe(this.getNestedPropertyPath(property));
|
|
1154
|
+
}
|
|
1155
|
+
addField(property) {
|
|
1156
|
+
return this.#editor.addFieldUnsafe(this.getNestedPropertyPath(property));
|
|
1157
|
+
}
|
|
1158
|
+
withFields(...properties) {
|
|
1159
|
+
properties.forEach(p => this.#editor.addFieldUnsafe(this.getNestedPropertyPath(p)));
|
|
1160
|
+
return this;
|
|
1161
|
+
}
|
|
1162
|
+
addFieldLookup(property, opts) {
|
|
1163
|
+
return this.#editor.addFieldLookupUnsafe(this.getNestedPropertyPath(property), opts);
|
|
1164
|
+
}
|
|
1165
|
+
addFieldLookupEnum(property, enumModel, options) {
|
|
1166
|
+
return this.#editor.addFieldLookupEnumUnsafe(this.getNestedPropertyPath(property), enumModel, options);
|
|
1167
|
+
}
|
|
1168
|
+
addFieldManyEditor(property, tableviewDescriptor) {
|
|
1169
|
+
return this.#editor.addFieldManyEditorUnsafe(this.getNestedPropertyPath(property), tableviewDescriptor);
|
|
1170
|
+
}
|
|
1171
|
+
addFieldManyToManyEditor(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
1172
|
+
return this.#editor.addFieldManyToManyEditorUnsafe(this.getNestedPropertyPath(property), mainTableDescriptor, lookupTableDescriptor, lookupDataProvider);
|
|
1173
|
+
}
|
|
1174
|
+
addFieldDescriptor(field) {
|
|
1175
|
+
if (!field.property.startsWith(this.#path)) {
|
|
1176
|
+
throw new CommonsInternalError(`Field ${field.property} cannot be added to nested object property ${this.#path}: Paths do not match.`);
|
|
1177
|
+
}
|
|
1178
|
+
this.#editor.addFieldDescriptor(field);
|
|
1179
|
+
return this;
|
|
1292
1180
|
}
|
|
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
1181
|
}
|
|
1308
1182
|
|
|
1309
1183
|
var TableviewEditorTypeEnum;
|
|
@@ -1444,6 +1318,9 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1444
1318
|
get label() {
|
|
1445
1319
|
return this._label;
|
|
1446
1320
|
}
|
|
1321
|
+
get labelUseModelBase() {
|
|
1322
|
+
return this._labelUseModelBase;
|
|
1323
|
+
}
|
|
1447
1324
|
get placeholder() {
|
|
1448
1325
|
return this._placeholder;
|
|
1449
1326
|
}
|
|
@@ -1537,8 +1414,14 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1537
1414
|
get isLocalized() {
|
|
1538
1415
|
return this._isLocalized;
|
|
1539
1416
|
}
|
|
1540
|
-
|
|
1417
|
+
/**
|
|
1418
|
+
* Set label for field.
|
|
1419
|
+
* @param label Full label (i18n path or other string). If null, no label will be used.
|
|
1420
|
+
* @param useModelBase If set to true, label will be appended to model's i18n base path.
|
|
1421
|
+
*/
|
|
1422
|
+
withLabel(label, useModelBase) {
|
|
1541
1423
|
this._label = label;
|
|
1424
|
+
this._labelUseModelBase = useModelBase;
|
|
1542
1425
|
return this;
|
|
1543
1426
|
}
|
|
1544
1427
|
withPlaceholder(placeholder) {
|
|
@@ -1702,7 +1585,6 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1702
1585
|
class FieldActionDescriptor extends AFieldDescriptor {
|
|
1703
1586
|
constructor(property) {
|
|
1704
1587
|
super(property);
|
|
1705
|
-
this._button = new ActionButtonDescriptor();
|
|
1706
1588
|
this._wrappers = ['field'];
|
|
1707
1589
|
this._fieldActionName = property;
|
|
1708
1590
|
}
|
|
@@ -1715,12 +1597,20 @@ class FieldActionDescriptor extends AFieldDescriptor {
|
|
|
1715
1597
|
get wrappers() {
|
|
1716
1598
|
return this._wrappers;
|
|
1717
1599
|
}
|
|
1718
|
-
|
|
1719
|
-
this._button =
|
|
1600
|
+
withButton(label, icon = null, level = StyleLevelEnum.Default) {
|
|
1601
|
+
this._button = {
|
|
1602
|
+
...this._button,
|
|
1603
|
+
label,
|
|
1604
|
+
icon,
|
|
1605
|
+
style: {
|
|
1606
|
+
...this._button?.style,
|
|
1607
|
+
level: level
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1720
1610
|
return this;
|
|
1721
1611
|
}
|
|
1722
|
-
|
|
1723
|
-
this._button =
|
|
1612
|
+
withButtonOpts(button) {
|
|
1613
|
+
this._button = button;
|
|
1724
1614
|
return this;
|
|
1725
1615
|
}
|
|
1726
1616
|
withRunFunction(fn) {
|
|
@@ -1734,7 +1624,7 @@ class FieldActionDescriptor extends AFieldDescriptor {
|
|
|
1734
1624
|
copy() {
|
|
1735
1625
|
const field = new FieldActionDescriptor(this._property);
|
|
1736
1626
|
this.copyFieldsTo(field);
|
|
1737
|
-
field._button = this._button.
|
|
1627
|
+
field._button = { ...this._button, style: { ...this._button?.style } };
|
|
1738
1628
|
field._runFunction = this._runFunction?.bind(field);
|
|
1739
1629
|
field._wrappers = [...this._wrappers];
|
|
1740
1630
|
return field;
|
|
@@ -1863,10 +1753,9 @@ class FieldLookupDescriptor extends AFieldDescriptor {
|
|
|
1863
1753
|
this._dataProvider = cfg.dataProvider;
|
|
1864
1754
|
}
|
|
1865
1755
|
else {
|
|
1866
|
-
this._dataProvider = new LookupDataProviderInst(cfg?.
|
|
1756
|
+
this._dataProvider = new LookupDataProviderInst(cfg?.serviceType);
|
|
1867
1757
|
}
|
|
1868
1758
|
this._optionsValueProperty = cfg?.optionsValueProperty;
|
|
1869
|
-
trySetLookupItemsProperties(this);
|
|
1870
1759
|
}
|
|
1871
1760
|
get lookupType() {
|
|
1872
1761
|
return this._lookupType;
|
|
@@ -1992,7 +1881,7 @@ class FieldLookupDescriptor extends AFieldDescriptor {
|
|
|
1992
1881
|
class FieldLookupEnumDescriptor extends FieldLookupDescriptor {
|
|
1993
1882
|
constructor(property, enumModel, options) {
|
|
1994
1883
|
super(property, {
|
|
1995
|
-
dataProvider: new LookupDataProviderInst(undefined
|
|
1884
|
+
dataProvider: new LookupDataProviderInst(undefined),
|
|
1996
1885
|
optionsValueProperty: 'value'
|
|
1997
1886
|
});
|
|
1998
1887
|
this._enumModel = enumModel;
|
|
@@ -2075,7 +1964,7 @@ class FieldManyToManyEditorDescriptor extends AFieldDescriptor {
|
|
|
2075
1964
|
this._lookupTableDataProvider = cfg.lookupDataProvider;
|
|
2076
1965
|
}
|
|
2077
1966
|
else {
|
|
2078
|
-
this._lookupTableDataProvider = new TableDataProviderInst(
|
|
1967
|
+
this._lookupTableDataProvider = new TableDataProviderInst(cfg?.lookupServiceType);
|
|
2079
1968
|
}
|
|
2080
1969
|
}
|
|
2081
1970
|
get fieldType() {
|
|
@@ -2119,22 +2008,6 @@ class FieldManyToManyEditorDescriptor extends AFieldDescriptor {
|
|
|
2119
2008
|
this._excludeValueProperty = valueProperty;
|
|
2120
2009
|
return this;
|
|
2121
2010
|
}
|
|
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
2011
|
copy() {
|
|
2139
2012
|
const field = new FieldManyToManyEditorDescriptor(this._property, this._mainTableDescriptor.copy(), this._lookupTableDescriptor.copy(), {
|
|
2140
2013
|
lookupDataProvider: this.lookupTableDataProvider
|
|
@@ -2670,28 +2543,58 @@ class EditorDescriptorInst {
|
|
|
2670
2543
|
get autofocusOnField() {
|
|
2671
2544
|
return this._autofocusOnField;
|
|
2672
2545
|
}
|
|
2546
|
+
/**
|
|
2547
|
+
* Dives into nested object to add fields from the nested object on property.
|
|
2548
|
+
*
|
|
2549
|
+
* @experimental
|
|
2550
|
+
*
|
|
2551
|
+
* @param property Model property name.
|
|
2552
|
+
*/
|
|
2553
|
+
nested(property) {
|
|
2554
|
+
return new EditorDescriptorNestedObjectWrapper(this, property);
|
|
2555
|
+
}
|
|
2673
2556
|
/**
|
|
2674
2557
|
* Creates new tab group. Next added fields are added to newly created tab group.
|
|
2675
2558
|
* @param name Name of the group.
|
|
2676
|
-
* @param title Title key for the tab.
|
|
2559
|
+
* @param title Title key for the tab.7@return Newly created group descriptor.
|
|
2560
|
+
* @return Newly created group descriptor.
|
|
2677
2561
|
*/
|
|
2678
|
-
|
|
2562
|
+
addTabGroup(name, title) {
|
|
2679
2563
|
const tabGroup = new FieldTabGroupDescriptor(name);
|
|
2680
2564
|
tabGroup.withTitle(title);
|
|
2681
2565
|
this.createTabGroupDescriptor(tabGroup);
|
|
2682
2566
|
return tabGroup;
|
|
2683
2567
|
}
|
|
2568
|
+
/**
|
|
2569
|
+
* Creates new tab group. Next added fields are added to newly created tab group.
|
|
2570
|
+
* @param name Name of the group.
|
|
2571
|
+
* @param title Title key for the tab.7@return Newly created group descriptor.
|
|
2572
|
+
*/
|
|
2573
|
+
withTabGroup(name, title) {
|
|
2574
|
+
this.addTabGroup(name, title);
|
|
2575
|
+
return this;
|
|
2576
|
+
}
|
|
2684
2577
|
/**
|
|
2685
2578
|
* Creates new field group. Next added fields are added to newly created field group.
|
|
2686
2579
|
* @param name Name of the group.
|
|
2687
2580
|
* @param title Title key for the group.
|
|
2581
|
+
* @return Newly created group descriptor.
|
|
2688
2582
|
*/
|
|
2689
|
-
|
|
2583
|
+
addFieldGroup(name, title) {
|
|
2690
2584
|
const fieldGroup = new FieldGroupDescriptor(name);
|
|
2691
2585
|
fieldGroup.withTitle(title);
|
|
2692
2586
|
this.createFieldGroupDescriptor(fieldGroup);
|
|
2693
2587
|
return fieldGroup;
|
|
2694
2588
|
}
|
|
2589
|
+
/**
|
|
2590
|
+
* Creates new field group. Next added fields are added to newly created field group.
|
|
2591
|
+
* @param name Name of the group.
|
|
2592
|
+
* @param title Title key for the group.
|
|
2593
|
+
*/
|
|
2594
|
+
withFieldGroup(name, title) {
|
|
2595
|
+
this.addFieldGroup(name, title);
|
|
2596
|
+
return this;
|
|
2597
|
+
}
|
|
2695
2598
|
/**
|
|
2696
2599
|
* Gets field by the model property name.
|
|
2697
2600
|
* @param property Model property name.
|
|
@@ -2761,7 +2664,7 @@ class EditorDescriptorInst {
|
|
|
2761
2664
|
this.addFieldDescriptor(field);
|
|
2762
2665
|
return field;
|
|
2763
2666
|
}
|
|
2764
|
-
|
|
2667
|
+
withFields(...properties) {
|
|
2765
2668
|
properties.forEach(p => this.addField(p));
|
|
2766
2669
|
return this;
|
|
2767
2670
|
}
|
|
@@ -2774,149 +2677,33 @@ class EditorDescriptorInst {
|
|
|
2774
2677
|
* Adds lookup field.
|
|
2775
2678
|
*
|
|
2776
2679
|
* @param {Property} property - The property key of the editor.
|
|
2777
|
-
* @param {
|
|
2680
|
+
* @param {FieldsManageAddFieldLookupOpts<LookupModel, Service>} opts - Optional parameters configuring type and/or service provider.
|
|
2778
2681
|
* @typeparam Property - The property key of the EditorModel.
|
|
2779
2682
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
2683
|
+
* @typeparam Service - Service used for data provider.
|
|
2780
2684
|
* @typeparam FieldValue - The value type of field on editor.
|
|
2781
2685
|
*
|
|
2782
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel,
|
|
2686
|
+
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue>} - The field lookup descriptor.
|
|
2783
2687
|
*/
|
|
2784
|
-
addFieldLookup(property,
|
|
2785
|
-
return this.addFieldLookupUnsafe(property,
|
|
2688
|
+
addFieldLookup(property, opts) {
|
|
2689
|
+
return this.addFieldLookupUnsafe(property, opts);
|
|
2786
2690
|
}
|
|
2787
2691
|
/**
|
|
2788
2692
|
* [UNSAFE] Adds lookup field.
|
|
2789
2693
|
* This function is UNSAFE because property is not type-checked.
|
|
2790
2694
|
*
|
|
2791
2695
|
* @param {string} property Model property name.
|
|
2792
|
-
* @param {
|
|
2696
|
+
* @param {FieldsManageAddFieldLookupOpts<LookupModel, Service>} opts - Optional parameters configuring type and/or service provider.
|
|
2793
2697
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
2698
|
+
* @typeparam Service - Service used for data provider.
|
|
2794
2699
|
* @typeparam FieldValue - The value type of field on editor.
|
|
2795
2700
|
*
|
|
2796
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel,
|
|
2701
|
+
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue>} - The field lookup descriptor.
|
|
2797
2702
|
*/
|
|
2798
|
-
|
|
2703
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2704
|
+
addFieldLookupUnsafe(property, opts) {
|
|
2799
2705
|
const field = new FieldLookupDescriptor(property, {
|
|
2800
|
-
|
|
2801
|
-
});
|
|
2802
|
-
this.addFieldDescriptor(field);
|
|
2803
|
-
return field;
|
|
2804
|
-
}
|
|
2805
|
-
/**
|
|
2806
|
-
* Adds a field lookup with options value property for lookup model.
|
|
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
|
|
2706
|
+
...(opts?.serviceProvider ? fieldLookupGetProviderCfgObj(opts.serviceProvider) : {})
|
|
2920
2707
|
});
|
|
2921
2708
|
this.addFieldDescriptor(field);
|
|
2922
2709
|
return field;
|
|
@@ -3074,7 +2861,7 @@ class EditorDescriptorInst {
|
|
|
3074
2861
|
createDefaultGroup() {
|
|
3075
2862
|
this.createDefaultTabGroup();
|
|
3076
2863
|
if (this._currentTabGroup?.fields.length === 0) {
|
|
3077
|
-
this.
|
|
2864
|
+
this.addFieldGroup(EditorDescriptorInst.defaultGroupName, null);
|
|
3078
2865
|
}
|
|
3079
2866
|
}
|
|
3080
2867
|
/**
|
|
@@ -3083,7 +2870,7 @@ class EditorDescriptorInst {
|
|
|
3083
2870
|
*/
|
|
3084
2871
|
createDefaultTabGroup() {
|
|
3085
2872
|
if (this._tabs.length === 0) {
|
|
3086
|
-
this.
|
|
2873
|
+
this.addTabGroup(EditorDescriptorInst.defaultGroupName, 'general.general');
|
|
3087
2874
|
}
|
|
3088
2875
|
}
|
|
3089
2876
|
/**
|
|
@@ -3115,252 +2902,18 @@ class EditorDescriptorInst {
|
|
|
3115
2902
|
}
|
|
3116
2903
|
}
|
|
3117
2904
|
|
|
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) {
|
|
2905
|
+
function editorDescriptor(modelOrOpts, opts) {
|
|
2906
|
+
if (modelOrOpts == null) {
|
|
3335
2907
|
return new EditorDescriptorInst(model(), opts?.tableviewEditorType);
|
|
3336
2908
|
}
|
|
3337
|
-
else if (
|
|
3338
|
-
return new EditorDescriptorInst(
|
|
3339
|
-
}
|
|
3340
|
-
else if (typeOrModelOrClassOrOpts instanceof ModelDescriptor) {
|
|
3341
|
-
return new EditorDescriptorInst(typeOrModelOrClassOrOpts, opts?.tableviewEditorType);
|
|
2909
|
+
else if (modelOrOpts instanceof ModelDescriptor) {
|
|
2910
|
+
return new EditorDescriptorInst(modelOrOpts, opts?.tableviewEditorType);
|
|
3342
2911
|
}
|
|
3343
2912
|
else {
|
|
3344
2913
|
// this could have autoGenerated if model descriptor is class
|
|
3345
|
-
return new EditorDescriptorInst(model(
|
|
2914
|
+
return new EditorDescriptorInst(model(modelOrOpts), modelOrOpts?.tableviewEditorType);
|
|
3346
2915
|
}
|
|
3347
2916
|
}
|
|
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
2917
|
|
|
3365
2918
|
var FormFieldEventTypeEnum;
|
|
3366
2919
|
(function (FormFieldEventTypeEnum) {
|
|
@@ -3457,10 +3010,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
|
|
|
3457
3010
|
}] } });
|
|
3458
3011
|
|
|
3459
3012
|
class TableviewDataProviderInst extends DataProviderInst {
|
|
3460
|
-
constructor(
|
|
3461
|
-
super(
|
|
3462
|
-
this.editorDataProvider = new EditorDataProviderInst(
|
|
3463
|
-
this.tableDataProvider = new TableDataProviderInst(
|
|
3013
|
+
constructor(serviceType) {
|
|
3014
|
+
super(serviceType);
|
|
3015
|
+
this.editorDataProvider = new EditorDataProviderInst(serviceType);
|
|
3016
|
+
this.tableDataProvider = new TableDataProviderInst(serviceType);
|
|
3464
3017
|
}
|
|
3465
3018
|
get isLazy() {
|
|
3466
3019
|
return this.tableDataProvider.isLazy;
|
|
@@ -3486,6 +3039,12 @@ class TableviewDataProviderInst extends DataProviderInst {
|
|
|
3486
3039
|
get delete() {
|
|
3487
3040
|
return this.editorDataProvider.delete;
|
|
3488
3041
|
}
|
|
3042
|
+
get mapFetchItemToCreateItem() {
|
|
3043
|
+
return this.editorDataProvider.mapFetchItemToCreateItem;
|
|
3044
|
+
}
|
|
3045
|
+
get mapFetchItemToUpdateItem() {
|
|
3046
|
+
return this.editorDataProvider.mapFetchItemToUpdateItem;
|
|
3047
|
+
}
|
|
3489
3048
|
withGetAll(fn) {
|
|
3490
3049
|
this.tableDataProvider.withGetAll(fn);
|
|
3491
3050
|
return this;
|
|
@@ -3510,11 +3069,13 @@ class TableviewDataProviderInst extends DataProviderInst {
|
|
|
3510
3069
|
this.editorDataProvider.withDelete(fn);
|
|
3511
3070
|
return this;
|
|
3512
3071
|
}
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3072
|
+
withMapFetchItemToCreateItem(fn) {
|
|
3073
|
+
this.editorDataProvider.withMapFetchItemToCreateItem(fn);
|
|
3074
|
+
return this;
|
|
3075
|
+
}
|
|
3076
|
+
withMapFetchItemToUpdateItem(fn) {
|
|
3077
|
+
this.editorDataProvider.withMapFetchItemToUpdateItem(fn);
|
|
3078
|
+
return this;
|
|
3518
3079
|
}
|
|
3519
3080
|
reloadTable(event) {
|
|
3520
3081
|
this.tableDataProvider.reloadTable(event);
|
|
@@ -3525,75 +3086,37 @@ class TableviewDataProviderInst extends DataProviderInst {
|
|
|
3525
3086
|
}
|
|
3526
3087
|
class DynamicTableviewDataProviderInst extends TableviewDataProviderInst {
|
|
3527
3088
|
constructor(serviceType) {
|
|
3528
|
-
super(
|
|
3089
|
+
super(serviceType);
|
|
3529
3090
|
}
|
|
3530
3091
|
}
|
|
3531
3092
|
|
|
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
|
-
}
|
|
3093
|
+
/**
|
|
3094
|
+
* Creates and returns an instance of `TableviewDataProviderInst` with the specified options for managing tableview data.
|
|
3095
|
+
*
|
|
3096
|
+
* @param {Object} [opts] - The options object to configure the data provider.
|
|
3097
|
+
* @param {TypeDescriptor<Model> | ModelDescriptor<Model>} [opts.type] - The descriptor defining the type of model.
|
|
3098
|
+
* @param {ServiceClassType<Service>} [opts.service] - The service class type associated with the data provider.
|
|
3099
|
+
* @param {TypeDescriptor<CreateModel> | ModelDescriptor<CreateModel>} [opts.filtersType] - The descriptor defining the filters type.
|
|
3100
|
+
* @param {TypeDescriptor<UpdateModel> | ModelDescriptor<UpdateModel>} [opts.sortsType] - The descriptor defining the sorts type.
|
|
3101
|
+
* @return {TableviewDataProviderInst<Model, Service, Sorts, Filters, ServiceClass, TableModel, CreateModel, UpdateModel>} An instance of `TableviewDataProviderInst` configured according to the provided options.
|
|
3102
|
+
*/
|
|
3103
|
+
function tableviewDataProvider(opts) {
|
|
3104
|
+
return new TableviewDataProviderInst(opts?.service);
|
|
3582
3105
|
}
|
|
3583
3106
|
function tableviewDynamicDataProvider(serviceType) {
|
|
3584
3107
|
return new DynamicTableviewDataProviderInst(serviceType);
|
|
3585
3108
|
}
|
|
3586
3109
|
|
|
3587
3110
|
class TableviewDescriptorInst {
|
|
3588
|
-
constructor(model) {
|
|
3111
|
+
constructor(model, opts) {
|
|
3589
3112
|
this._isLocalized = false;
|
|
3590
3113
|
this._model = model;
|
|
3591
|
-
this._table = new TableDescriptorInst(model);
|
|
3114
|
+
this._table = new TableDescriptorInst(opts?.tableModel ?? model);
|
|
3592
3115
|
this._table.withTitle(`${this._model.i18nBaseKey}.name`);
|
|
3593
3116
|
this._detailsEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Details);
|
|
3594
3117
|
this._detailsEditor.withDisabled();
|
|
3595
|
-
this._addEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Add);
|
|
3596
|
-
this._editEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Edit);
|
|
3118
|
+
this._addEditor = new EditorDescriptorInst(opts?.addModel ?? model, TableviewEditorTypeEnum.Add);
|
|
3119
|
+
this._editEditor = new EditorDescriptorInst(opts?.editModel ?? model, TableviewEditorTypeEnum.Edit);
|
|
3597
3120
|
}
|
|
3598
3121
|
get table() {
|
|
3599
3122
|
return this._table;
|
|
@@ -3652,14 +3175,6 @@ class TableviewDescriptorInst {
|
|
|
3652
3175
|
}
|
|
3653
3176
|
return this;
|
|
3654
3177
|
}
|
|
3655
|
-
/**
|
|
3656
|
-
* @deprecated Use {table.withTitle} directly
|
|
3657
|
-
* @param title
|
|
3658
|
-
*/
|
|
3659
|
-
withTableTitle(title) {
|
|
3660
|
-
this._table.withTitle(title);
|
|
3661
|
-
return this;
|
|
3662
|
-
}
|
|
3663
3178
|
withValidation(name, expression, message, opts) {
|
|
3664
3179
|
return this.withValidationUnsafe(name, expression, message, opts);
|
|
3665
3180
|
}
|
|
@@ -3800,21 +3315,6 @@ class TableviewDescriptorInst {
|
|
|
3800
3315
|
this._table.withFilterUnsafe(filter);
|
|
3801
3316
|
return this;
|
|
3802
3317
|
}
|
|
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
3318
|
removeField(property) {
|
|
3819
3319
|
this.removeFieldUnsafe(property);
|
|
3820
3320
|
}
|
|
@@ -3830,16 +3330,14 @@ class TableviewDescriptorInst {
|
|
|
3830
3330
|
return this;
|
|
3831
3331
|
}
|
|
3832
3332
|
addField(property) {
|
|
3833
|
-
|
|
3834
|
-
this.addFieldToEditAndAdd(field);
|
|
3835
|
-
return field;
|
|
3333
|
+
return this.addFieldUnsafe(property);
|
|
3836
3334
|
}
|
|
3837
3335
|
addFieldUnsafe(property) {
|
|
3838
3336
|
const field = this._detailsEditor.addFieldUnsafe(property);
|
|
3839
3337
|
this.addFieldToEditAndAdd(field);
|
|
3840
3338
|
return field;
|
|
3841
3339
|
}
|
|
3842
|
-
|
|
3340
|
+
withFields(...properties) {
|
|
3843
3341
|
properties.forEach(p => this.addField(p));
|
|
3844
3342
|
return this;
|
|
3845
3343
|
}
|
|
@@ -3856,150 +3354,36 @@ class TableviewDescriptorInst {
|
|
|
3856
3354
|
* Adds lookup field.
|
|
3857
3355
|
*
|
|
3858
3356
|
* @param {Property} property - The property key of the editor.
|
|
3859
|
-
* @param {
|
|
3357
|
+
* @param {FieldsManageAddFieldLookupOpts<LookupModel, Service>} opts - Optional parameters configuring type and/or service provider.
|
|
3860
3358
|
* @typeparam Property - The property key of the EditorModel.
|
|
3861
3359
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3360
|
+
* @typeparam Service - Service used for data provider.
|
|
3862
3361
|
* @typeparam FieldValue - The value type of field on editor.
|
|
3863
3362
|
*
|
|
3864
|
-
* @returns {FieldLookupDescriptor<LookupModel,
|
|
3363
|
+
* @returns {FieldLookupDescriptor<LookupModel, FieldsManageModel, Service, FieldValue>} - The field lookup descriptor.
|
|
3865
3364
|
*/
|
|
3866
|
-
addFieldLookup(property,
|
|
3867
|
-
|
|
3868
|
-
this.addFieldToEditAndAdd(field);
|
|
3869
|
-
return field;
|
|
3365
|
+
addFieldLookup(property, opts) {
|
|
3366
|
+
return this.addFieldLookupUnsafe(property, opts);
|
|
3870
3367
|
}
|
|
3871
3368
|
/**
|
|
3872
3369
|
* [UNSAFE] Adds lookup field.
|
|
3873
3370
|
* This function is UNSAFE because property is not type-checked.
|
|
3874
3371
|
*
|
|
3875
3372
|
* @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.
|
|
3969
|
-
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3970
|
-
* @typeparam LookupValueProperty - The property of lookup model type.
|
|
3971
|
-
* @typeparam FieldValue - The value type of field on editor.
|
|
3972
|
-
*
|
|
3973
|
-
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, Service, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
3974
|
-
*/
|
|
3975
|
-
addFieldLookupWithProviderAndOptionsValueProperty(property, provider, type, lookupOptionsValueProperty) {
|
|
3976
|
-
const field = this._detailsEditor.addFieldLookupWithProviderAndOptionsValueProperty(property, provider, type, lookupOptionsValueProperty);
|
|
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.
|
|
3373
|
+
* @param {FieldsManageAddFieldLookupOpts<LookupModel, Service>} opts - Optional parameters configuring type and/or service provider.
|
|
3989
3374
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3375
|
+
* @typeparam Service - Service used for data provider.
|
|
3990
3376
|
* @typeparam FieldValue - The value type of field on editor.
|
|
3991
3377
|
*
|
|
3992
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue
|
|
3378
|
+
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, Service, FieldValue>} - The field lookup descriptor.
|
|
3993
3379
|
*/
|
|
3994
|
-
|
|
3995
|
-
const field = this._detailsEditor.
|
|
3380
|
+
addFieldLookupUnsafe(property, opts) {
|
|
3381
|
+
const field = this._detailsEditor.addFieldLookupUnsafe(property, opts);
|
|
3996
3382
|
this.addFieldToEditAndAdd(field);
|
|
3997
3383
|
return field;
|
|
3998
3384
|
}
|
|
3999
3385
|
addFieldLookupEnum(property, enumDesc, options) {
|
|
4000
|
-
|
|
4001
|
-
this.addFieldToEditAndAdd(field);
|
|
4002
|
-
return field;
|
|
3386
|
+
return this.addFieldLookupEnumUnsafe(property, enumDesc, options);
|
|
4003
3387
|
}
|
|
4004
3388
|
addFieldLookupEnumUnsafe(property, enumDesc, options) {
|
|
4005
3389
|
const field = this._detailsEditor.addFieldLookupEnumUnsafe(property, enumDesc, options);
|
|
@@ -4007,47 +3391,33 @@ class TableviewDescriptorInst {
|
|
|
4007
3391
|
return field;
|
|
4008
3392
|
}
|
|
4009
3393
|
addFieldManyEditor(property, tableviewDescriptor) {
|
|
4010
|
-
|
|
4011
|
-
this.addFieldToEditAndAdd(field);
|
|
4012
|
-
return field;
|
|
3394
|
+
return this.addFieldManyEditorUnsafe(property, tableviewDescriptor);
|
|
4013
3395
|
}
|
|
4014
3396
|
addFieldManyEditorUnsafe(property, tableviewDescriptor) {
|
|
4015
|
-
const field = this._detailsEditor.addFieldManyEditorUnsafe(property,
|
|
3397
|
+
const field = this._detailsEditor.addFieldManyEditorUnsafe(property,
|
|
3398
|
+
// 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
|
|
3399
|
+
tableviewDescriptor);
|
|
4016
3400
|
this.addFieldToEditAndAdd(field);
|
|
4017
3401
|
return field;
|
|
4018
3402
|
}
|
|
4019
3403
|
addFieldManyToManyEditor(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
4020
|
-
|
|
4021
|
-
this.addFieldToEditAndAdd(field);
|
|
4022
|
-
return field;
|
|
3404
|
+
return this.addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider);
|
|
4023
3405
|
}
|
|
4024
3406
|
addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
4025
3407
|
const field = this._detailsEditor.addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider);
|
|
4026
3408
|
this.addFieldToEditAndAdd(field);
|
|
4027
3409
|
return field;
|
|
4028
3410
|
}
|
|
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
3411
|
withTabGroup(name, title) {
|
|
4042
|
-
this._detailsEditor.
|
|
4043
|
-
this._addEditor.
|
|
4044
|
-
this._editEditor.
|
|
3412
|
+
this._detailsEditor.addTabGroup(name, title);
|
|
3413
|
+
this._addEditor.addTabGroup(name, title);
|
|
3414
|
+
this._editEditor.addTabGroup(name, title);
|
|
4045
3415
|
return this;
|
|
4046
3416
|
}
|
|
4047
3417
|
withFieldGroup(name, title) {
|
|
4048
|
-
this._detailsEditor.
|
|
4049
|
-
this._addEditor.
|
|
4050
|
-
this._editEditor.
|
|
3418
|
+
this._detailsEditor.addFieldGroup(name, title);
|
|
3419
|
+
this._addEditor.addFieldGroup(name, title);
|
|
3420
|
+
this._editEditor.addFieldGroup(name, title);
|
|
4051
3421
|
return this;
|
|
4052
3422
|
}
|
|
4053
3423
|
copy() {
|
|
@@ -4111,141 +3481,36 @@ class TableviewDynamicDescriptorInt extends TableviewDescriptorInst {
|
|
|
4111
3481
|
}
|
|
4112
3482
|
}
|
|
4113
3483
|
|
|
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) {
|
|
3484
|
+
function tableviewDescriptor(modelOrOpts,
|
|
3485
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3486
|
+
opts) {
|
|
3487
|
+
if (modelOrOpts == null) {
|
|
4164
3488
|
return new TableviewDescriptorInst(model());
|
|
4165
3489
|
}
|
|
4166
|
-
else if (
|
|
4167
|
-
return new TableviewDescriptorInst(
|
|
4168
|
-
}
|
|
4169
|
-
else if (typeOrModelOrClassOrOpts instanceof ModelDescriptor) {
|
|
4170
|
-
return new TableviewDescriptorInst(typeOrModelOrClassOrOpts);
|
|
3490
|
+
else if (modelOrOpts instanceof ModelDescriptor) {
|
|
3491
|
+
return new TableviewDescriptorInst(modelOrOpts);
|
|
4171
3492
|
}
|
|
4172
3493
|
else {
|
|
4173
|
-
|
|
4174
|
-
return new TableviewDescriptorInst(model(typeOrModelOrClassOrOpts));
|
|
3494
|
+
return new TableviewDescriptorInst(model(modelOrOpts));
|
|
4175
3495
|
}
|
|
4176
3496
|
}
|
|
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());
|
|
3497
|
+
function tableviewDescriptorMultiModel(modelOrOpts,
|
|
3498
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3499
|
+
opts) {
|
|
3500
|
+
if (modelOrOpts == null) {
|
|
3501
|
+
return new TableviewDescriptorInst(model());
|
|
4206
3502
|
}
|
|
4207
|
-
|
|
4208
|
-
return
|
|
3503
|
+
else if (modelOrOpts instanceof ModelDescriptor) {
|
|
3504
|
+
return new TableviewDescriptorInst(modelOrOpts);
|
|
4209
3505
|
}
|
|
4210
|
-
|
|
4211
|
-
return
|
|
3506
|
+
else {
|
|
3507
|
+
return new TableviewDescriptorInst(model(modelOrOpts));
|
|
4212
3508
|
}
|
|
4213
3509
|
}
|
|
4214
3510
|
function tableviewDynamicDescriptor(modelOrOpts) {
|
|
4215
3511
|
return modelOrOpts instanceof ModelDescriptor
|
|
4216
3512
|
? 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));
|
|
3513
|
+
: new TableviewDynamicDescriptorInt(new ModelDescriptor(modelOrOpts?.id, modelOrOpts?.title, modelOrOpts?.i18nBase));
|
|
4249
3514
|
}
|
|
4250
3515
|
|
|
4251
3516
|
function convertDataToStringWithDelimiter(data, delimiter, descriptor, translate) {
|
|
@@ -4308,44 +3573,42 @@ const tableviewDefaultActions = [
|
|
|
4308
3573
|
TableviewDefaultActionsEnum.ExportCsv,
|
|
4309
3574
|
TableviewDefaultActionsEnum.LocalizationLanguageSelect
|
|
4310
3575
|
];
|
|
4311
|
-
function
|
|
3576
|
+
function tableviewGetDefaultActions() {
|
|
4312
3577
|
return [...tableviewDefaultActions];
|
|
4313
3578
|
}
|
|
4314
|
-
function
|
|
4315
|
-
return (defaultActions ??
|
|
4316
|
-
.map(t =>
|
|
3579
|
+
function tableviewCreateDefaultActions(tableview, defaultActions, defaultActionsOverrides, injector) {
|
|
3580
|
+
return (defaultActions ?? tableviewGetDefaultActions())
|
|
3581
|
+
.map(t => tableviewCreateDefaultAction(t, tableview, defaultActions, defaultActionsOverrides, injector))
|
|
4317
3582
|
.filter(e => e != null);
|
|
4318
3583
|
}
|
|
4319
|
-
function
|
|
3584
|
+
function tableviewCreateDefaultAction(type, tableview, defaultActions, defaultActionsOverrides, injector) {
|
|
4320
3585
|
if (defaultActionsOverrides != null && defaultActionsOverrides[type] !== undefined) {
|
|
4321
3586
|
return defaultActionsOverrides[type];
|
|
4322
3587
|
}
|
|
4323
3588
|
switch (type) {
|
|
4324
3589
|
// table row actions
|
|
4325
3590
|
case TableviewDefaultActionsEnum.Details:
|
|
4326
|
-
return
|
|
3591
|
+
return tableviewActionDetailsOnTable(tableview.model, tableview.detailsEditor, { injector });
|
|
4327
3592
|
case TableviewDefaultActionsEnum.Edit:
|
|
4328
|
-
return
|
|
3593
|
+
return tableviewActionEditOnTable(tableview.model, tableview.editEditor, { table: tableview.table, injector });
|
|
4329
3594
|
case TableviewDefaultActionsEnum.Delete:
|
|
4330
|
-
return
|
|
3595
|
+
return tableviewActionDeleteOnTable(tableview.model, { table: tableview.table, injector });
|
|
4331
3596
|
// table toolbar actions
|
|
4332
3597
|
case TableviewDefaultActionsEnum.Add:
|
|
4333
|
-
return
|
|
3598
|
+
return tableviewActionAddOnTable(tableview.model, tableview.addEditor, { injector });
|
|
4334
3599
|
case TableviewDefaultActionsEnum.LocalizationLanguageSelect:
|
|
4335
|
-
return
|
|
3600
|
+
return tableviewActionLocalizationLangSelectOnTable(tableview);
|
|
4336
3601
|
case TableviewDefaultActionsEnum.Refresh:
|
|
4337
|
-
return
|
|
3602
|
+
return tableviewActionRefreshOnTable(tableview.model);
|
|
4338
3603
|
case TableviewDefaultActionsEnum.Export:
|
|
4339
3604
|
return defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.ExportJson) || defaultActions.includes(TableviewDefaultActionsEnum.ExportCsv)
|
|
4340
|
-
?
|
|
3605
|
+
? tableviewActionExportOnTable(tableview, { injector: injector, defaultActions: defaultActions })
|
|
4341
3606
|
: null;
|
|
4342
3607
|
//details actions
|
|
4343
3608
|
case TableviewDefaultActionsEnum.EditOnDetails:
|
|
4344
|
-
return defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.Edit)
|
|
4345
|
-
? tableviewEditOnDetailsAction(tableview.model, tableviewEditAction(tableview.editEditor, injector), injector)
|
|
4346
|
-
: null;
|
|
3609
|
+
return defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.Edit) ? tableviewActionEditOnDetails(tableview.model, { injector }) : null;
|
|
4347
3610
|
case TableviewDefaultActionsEnum.DeleteOnDetails:
|
|
4348
|
-
return defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.Delete) ?
|
|
3611
|
+
return defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.Delete) ? tableviewActionDeleteOnDetails(tableview.model, { injector }) : null;
|
|
4349
3612
|
// subactions
|
|
4350
3613
|
case TableviewDefaultActionsEnum.ExportJson:
|
|
4351
3614
|
case TableviewDefaultActionsEnum.ExportCsv:
|
|
@@ -4360,81 +3623,118 @@ function getInjector(injector) {
|
|
|
4360
3623
|
function getRouteData(injector) {
|
|
4361
3624
|
return getInjector(injector)?.get(ActivatedRoute)?.snapshot.data;
|
|
4362
3625
|
}
|
|
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;
|
|
3626
|
+
const tableviewActionEditorDetailsActionName = 'details';
|
|
3627
|
+
const tableviewActionEditorDetailsRoute = ':itemId';
|
|
3628
|
+
function tableviewActionDetailsOnTable(model, descriptor, opts) {
|
|
3629
|
+
const routeData = getRouteData(opts?.injector);
|
|
3630
|
+
if (!routeData?.tableviewActions || routeData.tableviewActions.hasDetails) {
|
|
3631
|
+
const action = new ActionEditorDescriptorInst(descriptor, tableviewActionEditorDetailsActionName, {
|
|
3632
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts?.serviceProvider) : {}),
|
|
3633
|
+
isTableviewMainEditor: true,
|
|
3634
|
+
model: model
|
|
3635
|
+
});
|
|
3636
|
+
action.withPosition(opts?.position ?? ActionPositionEnum.RowClick);
|
|
3637
|
+
action.withRouteTrigger(tableviewActionEditorDetailsRoute);
|
|
3638
|
+
action.withEditorActions([actionEditorCancel(action)]);
|
|
3639
|
+
action.withTableviewCategory(TableviewActionDefaultCategories.DETAILS);
|
|
3640
|
+
return action;
|
|
3641
|
+
}
|
|
3642
|
+
return null;
|
|
4386
3643
|
}
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
3644
|
+
const tableviewActionEditorAddActionName = 'add';
|
|
3645
|
+
const tableviewActionEditorAddRoute = 'add';
|
|
3646
|
+
function tableviewActionAddOnTable(model, descriptor, opts) {
|
|
3647
|
+
const routeData = getRouteData(opts?.injector);
|
|
3648
|
+
if (!routeData?.tableviewActions || routeData.tableviewActions.hasAdd) {
|
|
3649
|
+
const action = new ActionEditorDescriptorInst(descriptor, tableviewActionEditorAddActionName, {
|
|
3650
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {}),
|
|
3651
|
+
isTableviewMainEditor: true,
|
|
3652
|
+
model: model
|
|
3653
|
+
});
|
|
3654
|
+
action
|
|
3655
|
+
.withPosition(opts?.position ?? ActionPositionEnum.ToolbarLeft)
|
|
3656
|
+
.withRouteTrigger(tableviewActionEditorAddRoute)
|
|
3657
|
+
.withButtonOpts({
|
|
3658
|
+
icon: 'pi pi-plus'
|
|
3659
|
+
});
|
|
3660
|
+
action.withTableviewCategory(TableviewActionDefaultCategories.ADD);
|
|
3661
|
+
action.withUnsavedChangesConfirmation();
|
|
3662
|
+
return action;
|
|
3663
|
+
}
|
|
3664
|
+
return null;
|
|
4390
3665
|
}
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
3666
|
+
const tableviewActionEditorEditActionName = 'edit';
|
|
3667
|
+
const tableviewActionEditorEditRoute = ':itemId/edit';
|
|
3668
|
+
function tableviewActionEditOnTable(model, descriptor, opts) {
|
|
3669
|
+
const routeData = getRouteData(opts?.injector);
|
|
3670
|
+
if (!routeData?.tableviewActions || routeData.tableviewActions.hasEdit) {
|
|
3671
|
+
const action = new ActionEditorDescriptorInst(descriptor, tableviewActionEditorEditActionName, {
|
|
3672
|
+
...(opts?.serviceProvider ? actionEditorGetProviderCfgObj(opts.serviceProvider) : {}),
|
|
3673
|
+
isTableviewMainEditor: true,
|
|
3674
|
+
model: model
|
|
3675
|
+
});
|
|
3676
|
+
action
|
|
3677
|
+
.withPosition(opts?.position ?? ActionPositionEnum.RowInline)
|
|
3678
|
+
.withButtonOpts({
|
|
3679
|
+
label: null,
|
|
3680
|
+
icon: 'pi pi-pencil',
|
|
3681
|
+
style: {
|
|
3682
|
+
size: StyleSizeEnum.Small
|
|
3683
|
+
}
|
|
4396
3684
|
})
|
|
4397
|
-
|
|
3685
|
+
.withRouteTrigger(tableviewActionEditorEditRoute)
|
|
3686
|
+
.withTableviewCategory(TableviewActionDefaultCategories.EDIT)
|
|
3687
|
+
.withUnsavedChangesConfirmation();
|
|
3688
|
+
return action;
|
|
3689
|
+
}
|
|
3690
|
+
return null;
|
|
4398
3691
|
}
|
|
4399
|
-
function
|
|
4400
|
-
const routeData = getRouteData(injector);
|
|
3692
|
+
function tableviewActionEditOnDetails(model, opts) {
|
|
3693
|
+
const routeData = getRouteData(opts?.injector);
|
|
4401
3694
|
if (routeData?.tableviewActions && !routeData.tableviewActions.hasEdit) {
|
|
4402
3695
|
return null;
|
|
4403
3696
|
}
|
|
4404
|
-
const
|
|
4405
|
-
|
|
4406
|
-
: new ActionLinkDescriptorInst(ActionEditorEditDescriptorInst.ACTION_NAME, {
|
|
4407
|
-
model: descriptor
|
|
4408
|
-
});
|
|
4409
|
-
action
|
|
3697
|
+
const linkAction = actionLink(tableviewActionEditorEditActionName, { model: model });
|
|
3698
|
+
linkAction
|
|
4410
3699
|
.withTableviewCategory(TableviewActionDefaultCategories.EDIT)
|
|
4411
3700
|
.withPositionTableviewCategories([TableviewActionDefaultCategories.DETAILS])
|
|
4412
|
-
.withPosition(ActionPositionEnum.FooterLeft)
|
|
3701
|
+
.withPosition(opts?.position ?? ActionPositionEnum.FooterLeft)
|
|
4413
3702
|
.withRouterLink('./edit')
|
|
4414
|
-
.withQueryParams({}, 'merge')
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
return
|
|
4422
|
-
}
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
? new ActionDeleteDescriptorInst(descriptor, {
|
|
4431
|
-
...actionGetProviderCfgObj(serviceProvider)
|
|
3703
|
+
.withQueryParams({}, 'merge')
|
|
3704
|
+
.withButtonOpts({
|
|
3705
|
+
icon: 'pi pi-pencil',
|
|
3706
|
+
style: {
|
|
3707
|
+
level: StyleLevelEnum.Secondary
|
|
3708
|
+
}
|
|
3709
|
+
});
|
|
3710
|
+
return linkAction;
|
|
3711
|
+
}
|
|
3712
|
+
const tableviewActionDeleteActionName = 'delete';
|
|
3713
|
+
function tableviewActionDeleteOnTable(model, opts) {
|
|
3714
|
+
const routeData = getRouteData(opts?.injector);
|
|
3715
|
+
if (!routeData?.tableviewActions || routeData.tableviewActions.hasDelete) {
|
|
3716
|
+
const action = new ActionDescriptorInst(tableviewActionDeleteActionName, {
|
|
3717
|
+
...(opts?.serviceProvider ? actionGetProviderCfgObj(opts.serviceProvider) : {}),
|
|
3718
|
+
model: model
|
|
4432
3719
|
})
|
|
4433
|
-
|
|
3720
|
+
.withButtonOpts({
|
|
3721
|
+
label: null,
|
|
3722
|
+
icon: 'pi pi-trash',
|
|
3723
|
+
style: {
|
|
3724
|
+
size: StyleSizeEnum.Small,
|
|
3725
|
+
level: StyleLevelEnum.Danger
|
|
3726
|
+
}
|
|
3727
|
+
})
|
|
3728
|
+
.withPosition(opts?.position ?? ActionPositionEnum.RowInline)
|
|
3729
|
+
.withRunConfirmation()
|
|
3730
|
+
.withTableviewCategory(TableviewActionDefaultCategories.DELETE);
|
|
3731
|
+
return action;
|
|
3732
|
+
}
|
|
3733
|
+
return null;
|
|
4434
3734
|
}
|
|
4435
|
-
function
|
|
4436
|
-
const action =
|
|
4437
|
-
const dataProviderExecutor = getInjector(injector)?.get(DataProviderExecutor);
|
|
3735
|
+
function tableviewActionDeleteOnDetails(model, opts) {
|
|
3736
|
+
const action = tableviewActionDeleteOnTable(model, opts);
|
|
3737
|
+
const dataProviderExecutor = getInjector(opts?.injector)?.get(DataProviderExecutor);
|
|
4438
3738
|
if (action) {
|
|
4439
3739
|
action
|
|
4440
3740
|
.withTableviewCategory(TableviewActionDefaultCategories.DELETE)
|
|
@@ -4445,29 +3745,36 @@ function tableviewDeleteOnDetailsAction(model, injector) {
|
|
|
4445
3745
|
ctx.viewContainer?.reloadTable({});
|
|
4446
3746
|
ctx.viewContainer?.closeEditor();
|
|
4447
3747
|
}))
|
|
4448
|
-
: null)
|
|
4449
|
-
|
|
4450
|
-
|
|
3748
|
+
: null)
|
|
3749
|
+
.withButtonOpts({
|
|
3750
|
+
...action.button,
|
|
3751
|
+
label: undefined,
|
|
3752
|
+
style: {
|
|
3753
|
+
...action.button?.style,
|
|
3754
|
+
size: StyleSizeEnum.Normal
|
|
3755
|
+
}
|
|
3756
|
+
});
|
|
4451
3757
|
return action;
|
|
4452
3758
|
}
|
|
4453
3759
|
return null;
|
|
4454
3760
|
}
|
|
4455
|
-
function
|
|
3761
|
+
function tableviewActionExportOnTable(descriptor, opts) {
|
|
4456
3762
|
const exportAction = new ActionDescriptorInst('export', {
|
|
4457
3763
|
model: descriptor.model
|
|
4458
3764
|
})
|
|
4459
|
-
.
|
|
3765
|
+
.withButton(undefined, 'pi pi-download')
|
|
4460
3766
|
.withSubactionsAsMenu();
|
|
4461
3767
|
const subactions = [];
|
|
4462
|
-
if (defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.ExportJson))
|
|
4463
|
-
subactions.push(
|
|
4464
|
-
if (defaultActions == null || defaultActions.includes(TableviewDefaultActionsEnum.ExportCsv))
|
|
4465
|
-
subactions.push(
|
|
3768
|
+
if (opts?.defaultActions == null || opts?.defaultActions.includes(TableviewDefaultActionsEnum.ExportJson))
|
|
3769
|
+
subactions.push(tableviewActionExportJsonOnTable(descriptor, opts));
|
|
3770
|
+
if (opts?.defaultActions == null || opts?.defaultActions.includes(TableviewDefaultActionsEnum.ExportCsv))
|
|
3771
|
+
subactions.push(tableviewActionExportCsvOnTable(descriptor, opts));
|
|
4466
3772
|
exportAction.withSubactions(...subactions);
|
|
3773
|
+
exportAction.withPosition(opts?.position ?? ActionPositionEnum.ToolbarRight);
|
|
4467
3774
|
return exportAction;
|
|
4468
3775
|
}
|
|
4469
|
-
function
|
|
4470
|
-
const dataProviderExecutor = getInjector(injector)?.get(DataProviderExecutor);
|
|
3776
|
+
function tableviewActionExportJsonOnTable(descriptor, opts) {
|
|
3777
|
+
const dataProviderExecutor = getInjector(opts?.injector)?.get(DataProviderExecutor);
|
|
4471
3778
|
return new ActionDescriptorInst('exportJson', {
|
|
4472
3779
|
model: descriptor.model
|
|
4473
3780
|
})
|
|
@@ -4477,7 +3784,7 @@ function tableviewExportJsonAction(descriptor, injector) {
|
|
|
4477
3784
|
params.limit = 500;
|
|
4478
3785
|
ctx.parameters.dataListParams = params;
|
|
4479
3786
|
return dataProviderExecutor
|
|
4480
|
-
? dataProviderExecutor.runGetAllOrFail(ctx).pipe(map(res => {
|
|
3787
|
+
? dataProviderExecutor.runGetAllOrFail(ctx).pipe(map$1(res => {
|
|
4481
3788
|
const blob = new Blob([JSON.stringify(res.data, undefined, 4)], { type: 'application/json;charset=utf-8' });
|
|
4482
3789
|
const typeName = ctx.instance.action.model?.i18nBaseKey ?? '';
|
|
4483
3790
|
saveFileAs(blob, `${typeName ? typeName + '_' : ''}${ctx.instance.action.actionName}.json`);
|
|
@@ -4485,11 +3792,12 @@ function tableviewExportJsonAction(descriptor, injector) {
|
|
|
4485
3792
|
}))
|
|
4486
3793
|
: ctx.parameters.item;
|
|
4487
3794
|
})
|
|
4488
|
-
.
|
|
4489
|
-
.
|
|
3795
|
+
.withNotifications({ runOnSuccess: false })
|
|
3796
|
+
.withButton(undefined, 'pi pi-code')
|
|
3797
|
+
.withPosition(opts?.position ?? ActionPositionEnum.ToolbarRight);
|
|
4490
3798
|
}
|
|
4491
|
-
function
|
|
4492
|
-
const dataProviderExecutor = getInjector(injector)?.get(DataProviderExecutor);
|
|
3799
|
+
function tableviewActionExportCsvOnTable(descriptor, opts) {
|
|
3800
|
+
const dataProviderExecutor = getInjector(opts?.injector)?.get(DataProviderExecutor);
|
|
4493
3801
|
return new ActionDescriptorInst('exportCsv', {
|
|
4494
3802
|
model: descriptor.model
|
|
4495
3803
|
})
|
|
@@ -4499,7 +3807,7 @@ function tableviewExportCsvAction(descriptor, injector) {
|
|
|
4499
3807
|
params.limit = 500;
|
|
4500
3808
|
ctx.parameters.dataListParams = params;
|
|
4501
3809
|
return dataProviderExecutor
|
|
4502
|
-
? dataProviderExecutor.runGetAllOrFail(ctx).pipe(map(res => {
|
|
3810
|
+
? dataProviderExecutor.runGetAllOrFail(ctx).pipe(map$1(res => {
|
|
4503
3811
|
if (!res.data) {
|
|
4504
3812
|
return undefined;
|
|
4505
3813
|
}
|
|
@@ -4512,29 +3820,36 @@ function tableviewExportCsvAction(descriptor, injector) {
|
|
|
4512
3820
|
}))
|
|
4513
3821
|
: ctx.parameters.item;
|
|
4514
3822
|
})
|
|
4515
|
-
.
|
|
4516
|
-
.
|
|
3823
|
+
.withNotifications({ runOnSuccess: false })
|
|
3824
|
+
.withButton(undefined, 'pi pi-file')
|
|
3825
|
+
.withPosition(opts?.position ?? ActionPositionEnum.ToolbarRight);
|
|
4517
3826
|
}
|
|
4518
|
-
function
|
|
3827
|
+
function tableviewActionRefreshOnTable(descriptor, opts) {
|
|
4519
3828
|
const action = new ActionDescriptorInst('refresh', {
|
|
4520
3829
|
model: descriptor
|
|
4521
3830
|
})
|
|
4522
3831
|
.withPosition(ActionPositionEnum.ToolbarRight)
|
|
4523
3832
|
.withTableviewCategory(TableviewActionDefaultCategories.READ)
|
|
4524
|
-
.
|
|
3833
|
+
.withNotifications({ runOnSuccess: false })
|
|
4525
3834
|
.withRunFunction(ctx => {
|
|
4526
3835
|
ctx.viewContainer?.reloadTable({});
|
|
4527
3836
|
return of(null);
|
|
3837
|
+
})
|
|
3838
|
+
.withPosition(opts?.position ?? ActionPositionEnum.ToolbarRight)
|
|
3839
|
+
.withButtonOpts({
|
|
3840
|
+
icon: 'pi pi-refresh',
|
|
3841
|
+
style: {
|
|
3842
|
+
level: StyleLevelEnum.Secondary
|
|
3843
|
+
}
|
|
4528
3844
|
});
|
|
4529
|
-
action.button.withIcon('pi pi-refresh').styleClass.withActionLevel(StyleLevelEnum.Secondary);
|
|
4530
3845
|
return action;
|
|
4531
3846
|
}
|
|
4532
|
-
function
|
|
3847
|
+
function tableviewActionLocalizationLangSelectOnTable(descriptor, opts) {
|
|
4533
3848
|
return descriptor.isLocalized()
|
|
4534
3849
|
? new ActionDescriptorInst('translator', {
|
|
4535
3850
|
model: descriptor.model
|
|
4536
3851
|
})
|
|
4537
|
-
.withPosition(ActionPositionEnum.ToolbarLeft)
|
|
3852
|
+
.withPosition(opts?.position ?? ActionPositionEnum.ToolbarLeft)
|
|
4538
3853
|
.withComponentFromDi(DATA_LANGUAGE_DROPDOWN_COMPONENT_IT)
|
|
4539
3854
|
: null;
|
|
4540
3855
|
}
|
|
@@ -4556,7 +3871,7 @@ class TableviewInputBuilder {
|
|
|
4556
3871
|
this._descriptor = _descriptor;
|
|
4557
3872
|
this._dataProvider = _dataProvider;
|
|
4558
3873
|
this.injector = injector;
|
|
4559
|
-
this.defaultActions =
|
|
3874
|
+
this.defaultActions = tableviewGetDefaultActions().map(a => ({ type: a, descriptor: undefined }));
|
|
4560
3875
|
this._customActions = [];
|
|
4561
3876
|
}
|
|
4562
3877
|
prepareSetterParams() {
|
|
@@ -4612,6 +3927,73 @@ class TableviewInputBuilder {
|
|
|
4612
3927
|
adjustFn(this.prepareSetterParams());
|
|
4613
3928
|
return this;
|
|
4614
3929
|
}
|
|
3930
|
+
/**
|
|
3931
|
+
* Associates a fetch function for a data provider API service with the specified parameters.
|
|
3932
|
+
*
|
|
3933
|
+
* @param {ServiceFn} serviceFn The function from the service class that performs the fetch API call.
|
|
3934
|
+
* Must be a key of the service with a parameter and return an Observable.
|
|
3935
|
+
* @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.
|
|
3936
|
+
*/
|
|
3937
|
+
withDataServiceFetchFn(serviceFn, itemIdParamName) {
|
|
3938
|
+
if (this._dataProvider instanceof TableviewDataProviderInst) {
|
|
3939
|
+
this._dataProvider.withFetch((itemId, service) => service[serviceFn]({ [itemIdParamName]: itemId }));
|
|
3940
|
+
}
|
|
3941
|
+
return this;
|
|
3942
|
+
}
|
|
3943
|
+
/**
|
|
3944
|
+
* Associates a create function for a data provider API service with the specified parameters.
|
|
3945
|
+
*
|
|
3946
|
+
* @param {ServiceFn} serviceFn The function from the service class that performs the create API call.
|
|
3947
|
+
* Must be a key of the service with a parameter and return an Observable.
|
|
3948
|
+
* @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.
|
|
3949
|
+
* @param {EditorDataProviderFetchMapToFnType<Model, AddModel>} [mapFetchItem] Map function to transform model from fetch to form's add model.
|
|
3950
|
+
*/
|
|
3951
|
+
withDataServiceCreateFn(serviceFn, serviceFnItemParamName, mapFetchItem) {
|
|
3952
|
+
if (this._dataProvider instanceof TableviewDataProviderInst) {
|
|
3953
|
+
this._dataProvider.withCreate((item, service) => service[serviceFn]({ [serviceFnItemParamName]: item }));
|
|
3954
|
+
if (mapFetchItem) {
|
|
3955
|
+
this._dataProvider.withMapFetchItemToCreateItem(mapFetchItem);
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
return this;
|
|
3959
|
+
}
|
|
3960
|
+
/**
|
|
3961
|
+
* Associates an update function for a data provider API service with the specified parameters.
|
|
3962
|
+
*
|
|
3963
|
+
* @param {ServiceFn} serviceFn The function from the service class that performs the update API call.
|
|
3964
|
+
* Must be a key of the service with a parameter and return an Observable.
|
|
3965
|
+
* @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.
|
|
3966
|
+
* @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.
|
|
3967
|
+
* @param {EditorDataProviderFetchMapToFnType<Model, EditModel>} [mapFetchItem] Map function to transform model from fetch to form' edit model.
|
|
3968
|
+
*/
|
|
3969
|
+
withDataServiceUpdateFn(serviceFn, fnItemParamName, fnItemIdParamName, mapFetchItem) {
|
|
3970
|
+
if (this._dataProvider instanceof TableviewDataProviderInst) {
|
|
3971
|
+
this._dataProvider.withUpdate((id, item, service) => {
|
|
3972
|
+
const params = { [fnItemParamName]: item };
|
|
3973
|
+
if (fnItemIdParamName) {
|
|
3974
|
+
params[fnItemIdParamName] = id;
|
|
3975
|
+
}
|
|
3976
|
+
return service[serviceFn](params);
|
|
3977
|
+
});
|
|
3978
|
+
if (mapFetchItem) {
|
|
3979
|
+
this._dataProvider.withMapFetchItemToUpdateItem(mapFetchItem);
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
return this;
|
|
3983
|
+
}
|
|
3984
|
+
/**
|
|
3985
|
+
* Associates a delete function for a data provider API service with the specified parameters.
|
|
3986
|
+
*
|
|
3987
|
+
* @param {ServiceFn} serviceFn The function from the service class that performs the delete API call.
|
|
3988
|
+
* Must be a key of the service with a parameter and return an Observable.
|
|
3989
|
+
* @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.
|
|
3990
|
+
*/
|
|
3991
|
+
withDataServiceDeleteFn(serviceFn, fnItemIdParamName) {
|
|
3992
|
+
if (this._dataProvider instanceof TableviewDataProviderInst) {
|
|
3993
|
+
this._dataProvider.withDelete((itemId, service) => service[serviceFn]({ [fnItemIdParamName]: itemId }));
|
|
3994
|
+
}
|
|
3995
|
+
return this;
|
|
3996
|
+
}
|
|
4615
3997
|
/**
|
|
4616
3998
|
* Removes all the default tableview actions.
|
|
4617
3999
|
*
|
|
@@ -4655,7 +4037,7 @@ class TableviewInputBuilder {
|
|
|
4655
4037
|
* Overrides the default action.
|
|
4656
4038
|
*
|
|
4657
4039
|
* @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>`.
|
|
4040
|
+
* @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
4041
|
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4660
4042
|
* @returns {this} - Returns the current instance of the builder.
|
|
4661
4043
|
*/
|
|
@@ -4669,7 +4051,9 @@ class TableviewInputBuilder {
|
|
|
4669
4051
|
/**
|
|
4670
4052
|
* Adds a custom action.
|
|
4671
4053
|
*
|
|
4672
|
-
* @
|
|
4054
|
+
* @deprecated Use on of {withActionOnTable}, {withActionOnDetailsEditor}, {withActionOnEditEditor} or {withActionOnAddEditor} instead.
|
|
4055
|
+
*
|
|
4056
|
+
* @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
4057
|
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4674
4058
|
* @returns {this} - Returns the current instance of the builder.
|
|
4675
4059
|
*/
|
|
@@ -4681,14 +4065,98 @@ class TableviewInputBuilder {
|
|
|
4681
4065
|
return this;
|
|
4682
4066
|
}
|
|
4683
4067
|
/**
|
|
4068
|
+
* Adds a custom action on table row or top (header or toolbar).
|
|
4069
|
+
*
|
|
4070
|
+
* @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>`.
|
|
4071
|
+
* @param {ActionPositionEnum} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4072
|
+
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4073
|
+
* @returns {this} - Returns the current instance of the builder.
|
|
4074
|
+
*/
|
|
4075
|
+
withActionOnTable(fn) {
|
|
4076
|
+
const action = fn(this.prepareSetterParams());
|
|
4077
|
+
if (action) {
|
|
4078
|
+
action.withPositionTableviewCategories([TableviewActionDefaultCategories.READ]);
|
|
4079
|
+
if (![
|
|
4080
|
+
ActionPositionEnum.ToolbarLeft,
|
|
4081
|
+
ActionPositionEnum.ToolbarRight,
|
|
4082
|
+
ActionPositionEnum.TableHeader,
|
|
4083
|
+
ActionPositionEnum.RowInline,
|
|
4084
|
+
ActionPositionEnum.RowClick
|
|
4085
|
+
].includes(action.position)) {
|
|
4086
|
+
throw new CommonsInternalError(`Action ${action.actionNameLong} can not be positioned on table (${action.position}), define valid position.`);
|
|
4087
|
+
}
|
|
4088
|
+
this._customActions.push(action);
|
|
4089
|
+
}
|
|
4090
|
+
return this;
|
|
4091
|
+
}
|
|
4092
|
+
/**
|
|
4093
|
+
* Adds a custom action on details editor.
|
|
4094
|
+
*
|
|
4095
|
+
* @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>`.
|
|
4096
|
+
* @param {ActionPositionEnum} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4097
|
+
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4098
|
+
* @returns {this} - Returns the current instance of the builder.
|
|
4099
|
+
*/
|
|
4100
|
+
withActionOnDetailsEditor(fn) {
|
|
4101
|
+
const action = fn(this.prepareSetterParams());
|
|
4102
|
+
if (action) {
|
|
4103
|
+
action.withPositionTableviewCategories([TableviewActionDefaultCategories.DETAILS]);
|
|
4104
|
+
if (![ActionPositionEnum.ToolbarLeft, ActionPositionEnum.ToolbarRight, ActionPositionEnum.FooterLeft, ActionPositionEnum.FooterRight].includes(action.position)) {
|
|
4105
|
+
throw new CommonsInternalError(`Action ${action.actionNameLong} can not be positioned on details (${action.position}), define valid position.`);
|
|
4106
|
+
}
|
|
4107
|
+
this._customActions.push(action);
|
|
4108
|
+
}
|
|
4109
|
+
return this;
|
|
4110
|
+
}
|
|
4111
|
+
/**
|
|
4112
|
+
* Adds a custom action on edit editor.
|
|
4113
|
+
*
|
|
4114
|
+
* @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>`.
|
|
4115
|
+
* @param {ActionPositionEnum} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4116
|
+
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4117
|
+
* @returns {this} - Returns the current instance of the builder.
|
|
4118
|
+
*/
|
|
4119
|
+
withActionOnEditEditor(fn) {
|
|
4120
|
+
const action = fn(this.prepareSetterParams());
|
|
4121
|
+
if (action) {
|
|
4122
|
+
action.withPositionTableviewCategories([TableviewActionDefaultCategories.EDIT]);
|
|
4123
|
+
if (![ActionPositionEnum.ToolbarLeft, ActionPositionEnum.ToolbarRight, ActionPositionEnum.FooterLeft, ActionPositionEnum.FooterRight].includes(action.position)) {
|
|
4124
|
+
throw new CommonsInternalError(`Action ${action.actionNameLong} can not be positioned on edit (${action.position}), define valid position.`);
|
|
4125
|
+
}
|
|
4126
|
+
this._customActions.push(action);
|
|
4127
|
+
}
|
|
4128
|
+
return this;
|
|
4129
|
+
}
|
|
4130
|
+
/**
|
|
4131
|
+
* Adds a custom action on add editor.
|
|
4132
|
+
*
|
|
4133
|
+
* @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>`.
|
|
4134
|
+
* @param {ActionPositionEnum} fn - The function that returns the new action descriptor. It accepts a single parameter of type `TvBuilderSetterParamsType<Descriptor, DataProvider>`.
|
|
4135
|
+
* @typeParam ActionService - The service type (same as build `Service` by default).
|
|
4136
|
+
* @returns {this} - Returns the current instance of the builder.
|
|
4137
|
+
*/
|
|
4138
|
+
withActionOnAddEditor(fn) {
|
|
4139
|
+
const action = fn(this.prepareSetterParams());
|
|
4140
|
+
if (action) {
|
|
4141
|
+
action.withPositionTableviewCategories([TableviewActionDefaultCategories.ADD]);
|
|
4142
|
+
if (![ActionPositionEnum.ToolbarLeft, ActionPositionEnum.ToolbarRight, ActionPositionEnum.FooterLeft, ActionPositionEnum.FooterRight].includes(action.position)) {
|
|
4143
|
+
throw new CommonsInternalError(`Action ${action.actionNameLong} can not be positioned on add (${action.position}), define valid position.`);
|
|
4144
|
+
}
|
|
4145
|
+
this._customActions.push(action);
|
|
4146
|
+
}
|
|
4147
|
+
return this;
|
|
4148
|
+
}
|
|
4149
|
+
/**
|
|
4150
|
+
* @internal
|
|
4151
|
+
*
|
|
4684
4152
|
* Builds and returns an instance of ITableview.
|
|
4685
4153
|
* DO NOT CALL this within tableview create callback function!
|
|
4686
4154
|
*
|
|
4687
|
-
* @return {TableviewInput<Model, Service, Sorts, Filters, Descriptor, DataProvider>} - The built ITableview instance.
|
|
4155
|
+
* @return {TableviewInput<Model, Service, Sorts, Filters, TableModel, AddModel, EditModel, Descriptor, DataProvider>} - The built ITableview instance.
|
|
4688
4156
|
*/
|
|
4689
4157
|
build() {
|
|
4690
4158
|
return {
|
|
4691
|
-
actions:
|
|
4159
|
+
actions: tableviewCreateDefaultActions(this._descriptor, this.defaultActions.filter(a => a.descriptor !== null).map(a => a.type), this.defaultActions
|
|
4692
4160
|
.filter(a => a.descriptor != null)
|
|
4693
4161
|
.reduce((acc, a) => ({
|
|
4694
4162
|
...acc,
|
|
@@ -4704,129 +4172,28 @@ class TableviewInputBuilder {
|
|
|
4704
4172
|
* Creates a tableview with the given model, service.
|
|
4705
4173
|
*
|
|
4706
4174
|
* @param {ModelDescriptor<Model>} model - The model descriptor.
|
|
4707
|
-
* @param {ServiceClassType<Service>} service - The class type of the service.
|
|
4175
|
+
* @param {ServiceClassType<Service>} [opts.service] - The class type of the service.
|
|
4176
|
+
* @param {TypeDescriptor<Sorts> | ModelDescriptor<Sorts>} [opts.sortsType] - Type of sorts
|
|
4177
|
+
* @param {TypeDescriptor<Filters> | ModelDescriptor<Filters>} [opts.filtersType] - Type of filters.
|
|
4708
4178
|
* @param {(builder: TableviewBuilder) => void} [buildFn] - The optional callback function to customize the tableview using the prepared builder.
|
|
4709
4179
|
*
|
|
4710
4180
|
* @returns A tableview instance with descriptor, data provider and actions.
|
|
4711
4181
|
*/
|
|
4712
|
-
function tableview(model,
|
|
4713
|
-
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model), new TableviewDataProviderInst(
|
|
4182
|
+
function tableview(model, opts, buildFn) {
|
|
4183
|
+
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model), new TableviewDataProviderInst(opts?.service), inject(Injector));
|
|
4714
4184
|
buildFn?.(builder);
|
|
4715
4185
|
return builder.build();
|
|
4716
4186
|
}
|
|
4717
|
-
function
|
|
4718
|
-
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model), new TableviewDataProviderInst(
|
|
4187
|
+
function tableviewMultiModel(model, opts, buildFn) {
|
|
4188
|
+
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model, opts), new TableviewDataProviderInst(opts?.service), inject(Injector));
|
|
4719
4189
|
buildFn?.(builder);
|
|
4720
4190
|
return builder.build();
|
|
4721
4191
|
}
|
|
4722
4192
|
|
|
4723
|
-
function
|
|
4193
|
+
function tableviewDataProviderFromDescriptor(descriptor, serviceType) {
|
|
4724
4194
|
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;
|
|
4195
|
+
? new TableviewDataProviderInst(serviceType)
|
|
4196
|
+
: new TableviewDataProviderInst(undefined);
|
|
4830
4197
|
}
|
|
4831
4198
|
|
|
4832
4199
|
// action descriptors
|
|
@@ -4835,5 +4202,5 @@ function modifyTableviewLookupUnsafe(descriptor, property, type, lookupProvider,
|
|
|
4835
4202
|
* Generated bundle index. Do not edit.
|
|
4836
4203
|
*/
|
|
4837
4204
|
|
|
4838
|
-
export { AFieldDescriptor, AFieldGroupDescriptor, AFormlyCustomFieldComponent, AGenericFieldDescriptor, ActionActivationTriggerEnum,
|
|
4205
|
+
export { AFieldDescriptor, AFieldGroupDescriptor, AFormlyCustomFieldComponent, AGenericFieldDescriptor, ActionActivationTriggerEnum, 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
4206
|
//# sourceMappingURL=mediusinc-mng-commons-tableview-api.mjs.map
|