@mediusinc/mng-commons 5.0.0-rc.1 → 5.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/data-providers/base-data-provider.factory.d.ts +13 -0
- package/core/data-providers/base.data-provider.d.ts +2 -14
- package/core/descriptors/editor.descriptor.d.ts +1 -1
- package/core/descriptors/tableview.descriptor.d.ts +5 -5
- package/core/directives/component.directive.d.ts +2 -2
- package/core/index.d.ts +1 -0
- package/core/router/route-builder.d.ts +149 -26
- package/core/router/routes-builder.d.ts +28 -13
- package/core/security/permission.service.d.ts +1 -0
- package/core/services/commons-router.service.d.ts +3 -3
- package/core/services/commons.service.d.ts +31 -42
- package/core/services/tokens/module-config.token.d.ts +2 -2
- package/esm2022/core/components/notification/notification-wrapper.component.mjs +5 -5
- package/esm2022/core/components/pages/error/error.page.component.mjs +5 -5
- package/esm2022/core/components/pages/not-found/not-found.page.component.mjs +5 -5
- package/esm2022/core/data-providers/base-data-provider.factory.mjs +28 -0
- package/esm2022/core/data-providers/base.data-provider.mjs +1 -31
- package/esm2022/core/descriptors/editor.descriptor.mjs +1 -1
- package/esm2022/core/descriptors/tableview.descriptor.mjs +1 -1
- package/esm2022/core/directives/component.directive.mjs +12 -9
- package/esm2022/core/directives/dialog-keydown-handler.directive.mjs +3 -3
- package/esm2022/core/directives/template.directive.mjs +3 -3
- package/esm2022/core/index.mjs +2 -1
- package/esm2022/core/pipes/boolean.pipe.mjs +3 -3
- package/esm2022/core/pipes/class-map.pipe.mjs +3 -3
- package/esm2022/core/pipes/enum.pipe.mjs +3 -3
- package/esm2022/core/pipes/enumerate-async.pipe.mjs +3 -3
- package/esm2022/core/pipes/enumerate.pipe.mjs +3 -3
- package/esm2022/core/pipes/getter.pipe.mjs +3 -3
- package/esm2022/core/pipes/i18n-property.pipe.mjs +3 -3
- package/esm2022/core/pipes/json-path.pipe.mjs +3 -3
- package/esm2022/core/pipes/parametrize.pipe.mjs +3 -3
- package/esm2022/core/pipes/template.pipe.mjs +3 -3
- package/esm2022/core/router/route-builder.mjs +211 -84
- package/esm2022/core/router/routes-builder.mjs +41 -43
- package/esm2022/core/security/permission.service.mjs +7 -5
- package/esm2022/core/services/commons-init.service.mjs +5 -5
- package/esm2022/core/services/commons-router.service.mjs +18 -17
- package/esm2022/core/services/commons.service.mjs +112 -169
- package/esm2022/core/services/local-storage-config.service.mjs +3 -3
- package/esm2022/core/services/tokens/module-config.token.mjs +1 -1
- package/esm2022/filter/descriptors/filter-lookup.descriptor.mjs +4 -4
- package/esm2022/form/api/data-providers/lookup-data-provider.factory.mjs +31 -0
- package/esm2022/form/api/data-providers/lookup.data-provider.mjs +1 -31
- package/esm2022/form/api/index.mjs +2 -1
- package/esm2022/form/components/autocomplete/autocomplete.component.mjs +105 -102
- package/esm2022/form/components/date-range/date-range.component.mjs +3 -3
- package/esm2022/form/components/dropdown/dropdown.component.mjs +148 -90
- package/esm2022/form/directives/input-trim.directive.mjs +3 -3
- package/esm2022/model/data-providers/base-from-type-data-provider.factory.mjs +8 -0
- package/esm2022/model/descriptors/enum.descriptor.mjs +3 -6
- package/esm2022/model/descriptors/model.descriptor.mjs +22 -9
- package/esm2022/model/descriptors/type.descriptor.mjs +3 -9
- package/esm2022/model/index.mjs +3 -1
- package/esm2022/table/api/data-providers/table-data-provider.factory.mjs +33 -0
- package/esm2022/table/api/data-providers/table.data-provider.mjs +1 -31
- package/esm2022/table/api/descriptors/sort.descriptor.mjs +2 -2
- package/esm2022/table/api/descriptors/table-descriptor.factory.mjs +89 -0
- package/esm2022/table/api/descriptors/table.descriptor.mjs +4 -139
- package/esm2022/table/api/helpers/table-descriptor-helpers.mjs +97 -0
- package/esm2022/table/api/index.mjs +4 -1
- package/esm2022/table/components/column-filter-full/column-filter-full.component.mjs +8 -9
- package/esm2022/table/components/column-value/column-value.component.mjs +4 -4
- package/esm2022/table/components/table/table.component.mjs +7 -7
- package/esm2022/table/pipes/locale-default-row-class.pipe.mjs +5 -5
- package/esm2022/table/pipes/table-column-filter-class.pipe.mjs +3 -3
- package/esm2022/table/services/data-list.service.mjs +4 -4
- package/esm2022/tableview/action/components/action/action.component.mjs +142 -190
- package/esm2022/tableview/action/components/editor/action-editor.component.mjs +58 -68
- package/esm2022/tableview/action/components/editor/injector-context/action-editor-injector-context.component.mjs +133 -154
- package/esm2022/tableview/action/components/localization/data-language-dropdown.component.mjs +22 -40
- package/esm2022/tableview/action/components/route/action-route.component.mjs +21 -26
- package/esm2022/tableview/action/components/table/action-table.component.mjs +4 -4
- package/esm2022/tableview/action/models/execution/action-instance.model.mjs +1 -1
- package/esm2022/tableview/action/services/action-executor.service.mjs +10 -10
- package/esm2022/tableview/action/services/component-action-executor.service.mjs +3 -3
- package/esm2022/tableview/action/services/data-provider-executor.service.mjs +3 -3
- package/esm2022/tableview/action/services/navigation.service.mjs +6 -5
- package/esm2022/tableview/action/services/root-action-executor.service.mjs +3 -3
- package/esm2022/tableview/action/services/view-container.service.mjs +8 -24
- package/esm2022/tableview/api/action/descriptors/action-descriptor.factory.mjs +119 -0
- package/esm2022/tableview/api/action/descriptors/action-editor-descriptor.factory.mjs +77 -0
- package/esm2022/tableview/api/action/descriptors/action-editor.descriptor.mjs +28 -80
- package/esm2022/tableview/api/action/descriptors/action-link-descriptor.factory.mjs +45 -0
- package/esm2022/tableview/api/action/descriptors/action-link.descriptor.mjs +1 -32
- package/esm2022/tableview/api/action/descriptors/action.descriptor.mjs +3 -69
- package/esm2022/tableview/api/action/models/action-component.model.mjs +1 -1
- package/esm2022/tableview/api/action/models/execution/action-instance.model.mjs +1 -1
- package/esm2022/tableview/api/action/models/execution/view-container.model.mjs +1 -1
- package/esm2022/tableview/api/editor/data-providers/editor-data-provider.factory.mjs +33 -0
- package/esm2022/tableview/api/editor/data-providers/editor.data-provider.mjs +1 -31
- package/esm2022/tableview/api/editor/descriptors/editor-descriptor.factory.mjs +81 -0
- package/esm2022/tableview/api/editor/descriptors/editor.descriptor.mjs +24 -161
- package/esm2022/tableview/api/editor/descriptors/field-action.descriptor.mjs +1 -1
- package/esm2022/tableview/api/editor/descriptors/field-base.descriptor.mjs +13 -5
- package/esm2022/tableview/api/editor/descriptors/field-group.descriptor.mjs +3 -3
- package/esm2022/tableview/api/editor/descriptors/field-lookup.descriptor.mjs +4 -4
- package/esm2022/tableview/api/editor/descriptors/field-many.descriptor.mjs +3 -3
- package/esm2022/tableview/api/editor/descriptors/field-validation.descriptor.mjs +1 -1
- package/esm2022/tableview/api/editor/descriptors/field.descriptor.mjs +36 -7
- package/esm2022/tableview/api/editor/helpers/editor-descriptor-helpers.mjs +95 -0
- package/esm2022/tableview/api/editor/helpers/field-validators.mjs +17 -27
- package/esm2022/tableview/api/editor/models/editor-fields.model.mjs +1 -1
- package/esm2022/tableview/api/editor/models/field-action-context.model.mjs +1 -1
- package/esm2022/tableview/api/editor/models/field-validation.model.mjs +2 -0
- package/esm2022/tableview/api/editor/models/field.model.mjs +1 -1
- package/esm2022/tableview/api/editor/models/form-editor.event.mjs +1 -1
- package/esm2022/tableview/api/editor/models/form-editor.interface.mjs +1 -1
- package/esm2022/tableview/api/editor/models/formly-custom-field.model.mjs +3 -3
- package/esm2022/tableview/api/editor/models/formly-field.model.mjs +1 -1
- package/esm2022/tableview/api/index.mjs +11 -1
- package/esm2022/tableview/api/tableview/data-providers/tableview-data-provider.factory.mjs +47 -0
- package/esm2022/tableview/api/tableview/data-providers/tableview.data-provider.mjs +5 -46
- package/esm2022/tableview/api/tableview/descriptors/tableview-descriptor.factory.mjs +111 -0
- package/esm2022/tableview/api/tableview/descriptors/tableview.descriptor.mjs +26 -186
- package/esm2022/tableview/api/tableview/helpers/files-export.mjs +2 -2
- package/esm2022/tableview/api/tableview/helpers/tableview-create.mjs +5 -5
- package/esm2022/tableview/api/tableview/helpers/tableview-default-actions.mjs +53 -18
- package/esm2022/tableview/api/tableview/helpers/tableview-descriptor-helpers.mjs +110 -0
- package/esm2022/tableview/api/tableview/helpers/tableview-input-builder.mjs +2 -2
- package/esm2022/tableview/editor/components/editor/form-editor.component.mjs +163 -138
- package/esm2022/tableview/editor/components/formly/fields/formly-field-action/formly-field-action.component.mjs +9 -5
- package/esm2022/tableview/editor/components/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.mjs +13 -16
- package/esm2022/tableview/editor/components/formly/fields/formly-field-custom/formly-field-custom.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-datepicker/formly-field-datepicker.component.mjs +103 -0
- package/esm2022/tableview/editor/components/formly/fields/formly-field-dropdown/formly-field-dropdown.component.mjs +12 -16
- package/esm2022/tableview/editor/components/formly/fields/formly-field-fieldset/formly-field-fieldset.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-input/formly-field-input.component.mjs +36 -53
- package/esm2022/tableview/editor/components/formly/fields/formly-field-label/formly-field-label.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.mjs +20 -24
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +24 -28
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +30 -31
- package/esm2022/tableview/editor/components/formly/fields/formly-field-tabs/formly-field-tabs.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/wrappers/formly-field-no-label-wrapper/formly-field-no-label-wrapper.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.mjs +3 -3
- package/esm2022/tableview/editor/helpers/editor-formly.mjs +85 -56
- package/esm2022/tableview/editor/helpers/formly-config.mjs +5 -3
- package/esm2022/tableview/editor/models/formly-config.model.mjs +1 -1
- package/esm2022/tableview/editor/services/form-editor.service.mjs +96 -0
- package/esm2022/tableview/index.mjs +2 -1
- package/esm2022/tableview/tableview/components/route/tableview-route.component.mjs +10 -10
- package/esm2022/tableview/tableview/components/tableview/tableview.component.mjs +26 -43
- package/esm2022/tableview/tableview/router/tableview-route-builder.mjs +17 -43
- package/fesm2022/mediusinc-mng-commons-core.mjs +460 -390
- package/fesm2022/mediusinc-mng-commons-core.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-filter.mjs +3 -3
- package/fesm2022/mediusinc-mng-commons-filter.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-form-api.mjs +18 -18
- package/fesm2022/mediusinc-mng-commons-form-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-form.mjs +257 -195
- package/fesm2022/mediusinc-mng-commons-form.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-model.mjs +43 -33
- package/fesm2022/mediusinc-mng-commons-model.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table-api.mjs +192 -146
- package/fesm2022/mediusinc-mng-commons-table-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table.mjs +26 -27
- package/fesm2022/mediusinc-mng-commons-table.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs +906 -665
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview.mjs +1015 -960
- package/fesm2022/mediusinc-mng-commons-tableview.mjs.map +1 -1
- package/form/api/data-providers/lookup-data-provider.factory.d.ts +18 -0
- package/form/api/data-providers/lookup.data-provider.d.ts +2 -14
- package/form/api/index.d.ts +1 -0
- package/form/components/autocomplete/autocomplete.component.d.ts +33 -24
- package/form/components/dropdown/dropdown.component.d.ts +38 -25
- package/model/data-providers/base-from-type-data-provider.factory.d.ts +8 -0
- package/model/descriptors/enum.descriptor.d.ts +1 -2
- package/model/descriptors/model.descriptor.d.ts +11 -4
- package/model/descriptors/type.descriptor.d.ts +2 -4
- package/model/index.d.ts +1 -0
- package/package.json +1 -1
- package/table/api/data-providers/table-data-provider.factory.d.ts +18 -0
- package/table/api/data-providers/table.data-provider.d.ts +2 -14
- package/table/api/descriptors/table-descriptor.factory.d.ts +44 -0
- package/table/api/descriptors/table.descriptor.d.ts +4 -65
- package/table/api/helpers/table-descriptor-helpers.d.ts +44 -0
- package/table/api/index.d.ts +3 -0
- package/table/components/column-filter-full/column-filter-full.component.d.ts +5 -4
- package/table/components/table/table.component.d.ts +11 -11
- package/table/services/data-list.service.d.ts +9 -10
- package/tableview/action/components/action/action.component.d.ts +37 -44
- package/tableview/action/components/editor/action-editor.component.d.ts +20 -18
- package/tableview/action/components/editor/injector-context/action-editor-injector-context.component.d.ts +24 -26
- package/tableview/action/components/localization/data-language-dropdown.component.d.ts +11 -14
- package/tableview/action/components/route/action-route.component.d.ts +7 -12
- package/tableview/action/components/table/action-table.component.d.ts +3 -3
- package/tableview/action/models/execution/action-instance.model.d.ts +2 -1
- package/tableview/action/services/view-container.service.d.ts +3 -9
- package/tableview/api/action/descriptors/action-descriptor.factory.d.ts +36 -0
- package/tableview/api/action/descriptors/action-editor-descriptor.factory.d.ts +31 -0
- package/tableview/api/action/descriptors/action-editor.descriptor.d.ts +25 -37
- package/tableview/api/action/descriptors/action-link-descriptor.factory.d.ts +15 -0
- package/tableview/api/action/descriptors/action-link.descriptor.d.ts +1 -9
- package/tableview/api/action/descriptors/action.descriptor.d.ts +4 -27
- package/tableview/api/action/models/action-component.model.d.ts +8 -8
- package/tableview/api/action/models/execution/action-instance.model.d.ts +2 -1
- package/tableview/api/action/models/execution/view-container.model.d.ts +4 -3
- package/tableview/api/editor/data-providers/editor-data-provider.factory.d.ts +18 -0
- package/tableview/api/editor/data-providers/editor.data-provider.d.ts +2 -14
- package/tableview/api/editor/descriptors/editor-descriptor.factory.d.ts +44 -0
- package/tableview/api/editor/descriptors/editor.descriptor.d.ts +44 -105
- package/tableview/api/editor/descriptors/field-action.descriptor.d.ts +3 -3
- package/tableview/api/editor/descriptors/field-base.descriptor.d.ts +35 -33
- package/tableview/api/editor/descriptors/field-group.descriptor.d.ts +8 -7
- package/tableview/api/editor/descriptors/field-lookup.descriptor.d.ts +2 -2
- package/tableview/api/editor/descriptors/field-many.descriptor.d.ts +8 -8
- package/tableview/api/editor/descriptors/field-validation.descriptor.d.ts +10 -13
- package/tableview/api/editor/descriptors/field.descriptor.d.ts +16 -1
- package/tableview/api/editor/helpers/editor-descriptor-helpers.d.ts +43 -0
- package/tableview/api/editor/helpers/field-validators.d.ts +7 -3
- package/tableview/api/editor/models/editor-fields.model.d.ts +25 -21
- package/tableview/api/editor/models/field-action-context.model.d.ts +10 -8
- package/tableview/api/editor/models/field-validation.model.d.ts +26 -0
- package/tableview/api/editor/models/field.model.d.ts +0 -10
- package/tableview/api/editor/models/form-editor.event.d.ts +26 -16
- package/tableview/api/editor/models/form-editor.interface.d.ts +38 -8
- package/tableview/api/editor/models/formly-custom-field.model.d.ts +1 -1
- package/tableview/api/editor/models/formly-field.model.d.ts +9 -7
- package/tableview/api/index.d.ts +10 -0
- package/tableview/api/tableview/data-providers/tableview-data-provider.factory.d.ts +25 -0
- package/tableview/api/tableview/data-providers/tableview.data-provider.d.ts +3 -20
- package/tableview/api/tableview/descriptors/tableview-descriptor.factory.d.ts +49 -0
- package/tableview/api/tableview/descriptors/tableview.descriptor.d.ts +41 -102
- package/tableview/api/tableview/helpers/tableview-create.d.ts +2 -2
- package/tableview/api/tableview/helpers/tableview-default-actions.d.ts +4 -2
- package/tableview/api/tableview/helpers/tableview-descriptor-helpers.d.ts +42 -0
- package/tableview/api/tableview/helpers/tableview-input-builder.d.ts +1 -1
- package/tableview/editor/components/editor/form-editor.component.d.ts +54 -36
- package/tableview/editor/components/formly/fields/formly-field-action/formly-field-action.component.d.ts +5 -3
- package/tableview/editor/components/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.d.ts +1 -0
- package/tableview/editor/components/formly/fields/formly-field-datepicker/formly-field-datepicker.component.d.ts +22 -0
- package/tableview/editor/components/formly/fields/formly-field-dropdown/formly-field-dropdown.component.d.ts +1 -1
- package/tableview/editor/components/formly/fields/formly-field-input/formly-field-input.component.d.ts +5 -7
- package/tableview/editor/components/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.d.ts +1 -1
- package/tableview/editor/components/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.d.ts +3 -4
- package/tableview/editor/components/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.d.ts +3 -5
- package/tableview/editor/helpers/editor-formly.d.ts +11 -10
- package/tableview/editor/models/formly-config.model.d.ts +1 -1
- package/tableview/editor/services/form-editor.service.d.ts +39 -0
- package/tableview/index.d.ts +1 -0
- package/tableview/tableview/components/route/tableview-route.component.d.ts +2 -2
- package/tableview/tableview/components/tableview/tableview.component.d.ts +11 -10
- package/tableview/tableview/router/tableview-route-builder.d.ts +7 -13
- package/version-info.json +11 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { of, throwError, isObservable, Subject, tap } from 'rxjs';
|
|
2
|
-
import { StyleLevelEnum, CommonsInternalError, findReflectTypeName,
|
|
3
|
-
import { ActionButtonDescriptor, ButtonStyleBuilder,
|
|
4
|
-
import { ModelDescriptor, trySetLookupItemsProperties, enumModelGeneric, findClassTitleAttribute } from '@mediusinc/mng-commons/model';
|
|
2
|
+
import { StyleLevelEnum, CommonsInternalError, findReflectTypeName, DataProviderInst, LoggerService, StyleSizeEnum, ACommonsErrorBase, toObservable, getI18nTypePropertyKey, fromEnumValuesAsValueArray, fromEnumConstantsAsValueArray, getEnumConstantName, getI18nTypeTabKey, getI18nTypeGroupKey, TypeRegistry, GetterPipe, copyDataListParams } from '@mediusinc/mng-commons/core';
|
|
3
|
+
import { ActionButtonDescriptor, ButtonStyleBuilder, LookupDataProviderInst, ButtonStyleRoundedEnum } from '@mediusinc/mng-commons/form/api';
|
|
4
|
+
import { TypeDescriptor, ModelDescriptor, trySetLookupItemsProperties, enumModelGeneric, model, findClassTitleAttribute } from '@mediusinc/mng-commons/model';
|
|
5
5
|
import * as i0 from '@angular/core';
|
|
6
6
|
import { InjectionToken, Directive, Input, inject, Injector } from '@angular/core';
|
|
7
|
-
import { ColumnTypeEnum, ColumnDisplayTypeEnum,
|
|
7
|
+
import { TableDataProviderInst, ColumnTypeEnum, ColumnDisplayTypeEnum, getColumnTypeFromClassAttributeDefType, getColumnDisplayTypeFromColumnType, TableDescriptorInst, TableDynamicDescriptorInst, tableDescriptorFromClassAttrsDef, modifyTableClassAttributeColumnTypeUnsafe, tableDescriptorModifyEnumColumnUnsafe, modifyTableColumnFilterLookupUnsafe } from '@mediusinc/mng-commons/table/api';
|
|
8
8
|
import { Validators } from '@angular/forms';
|
|
9
9
|
import { FieldType } from '@ngx-formly/core';
|
|
10
10
|
import { ActivatedRoute } from '@angular/router';
|
|
@@ -122,19 +122,6 @@ class ActionConfirmationDescriptor {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
const actionGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
126
|
-
const cfg = {};
|
|
127
|
-
if (serviceOrDataProvider) {
|
|
128
|
-
if (serviceOrDataProvider.isDataProvider) {
|
|
129
|
-
// type casting needed, cause there was no other way found to differentiate the types
|
|
130
|
-
cfg.dataProvider = serviceOrDataProvider;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
cfg.serviceType = serviceOrDataProvider;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return cfg;
|
|
137
|
-
};
|
|
138
125
|
class ActionDescriptorInst {
|
|
139
126
|
constructor(actionName, cfg) {
|
|
140
127
|
this._type = ActionTypeEnum.Direct;
|
|
@@ -161,7 +148,7 @@ class ActionDescriptorInst {
|
|
|
161
148
|
this._parentProperty = cfg?.parentProperty;
|
|
162
149
|
this.setI18nModelActionBaseKey();
|
|
163
150
|
if (cfg?.serviceType) {
|
|
164
|
-
this._dataProvider =
|
|
151
|
+
this._dataProvider = new DataProviderInst(this._model?.type, cfg.serviceType);
|
|
165
152
|
}
|
|
166
153
|
else if (cfg?.dataProvider) {
|
|
167
154
|
this._dataProvider = cfg.dataProvider;
|
|
@@ -435,70 +422,135 @@ class ActionDescriptorInst {
|
|
|
435
422
|
return descriptor;
|
|
436
423
|
}
|
|
437
424
|
}
|
|
425
|
+
class ActionDeleteDescriptorInst extends ActionDescriptorInst {
|
|
426
|
+
static { this.ACTION_NAME = 'delete'; }
|
|
427
|
+
constructor(model, cfg) {
|
|
428
|
+
super(ActionDeleteDescriptorInst.ACTION_NAME, { model, ...cfg });
|
|
429
|
+
this.withPosition(ActionPositionEnum.RowInline);
|
|
430
|
+
this.button.styleClass.withSize(StyleSizeEnum.Small);
|
|
431
|
+
this.button.styleClass.withActionLevel(StyleLevelEnum.Danger);
|
|
432
|
+
this.withRunConfirmation();
|
|
433
|
+
this.withTableviewCategory(TableviewActionDefaultCategories.DELETE);
|
|
434
|
+
this.button.withLabel(null).withIcon('pi pi-trash');
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const actionGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
439
|
+
const cfg = {};
|
|
440
|
+
if (serviceOrDataProvider) {
|
|
441
|
+
if (serviceOrDataProvider.isDataProvider) {
|
|
442
|
+
// type casting needed, cause there was no other way found to differentiate the types
|
|
443
|
+
cfg.dataProvider = serviceOrDataProvider;
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
cfg.serviceType = serviceOrDataProvider;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return cfg;
|
|
450
|
+
};
|
|
438
451
|
class ActionDescriptor extends ActionDescriptorInst {
|
|
439
452
|
constructor() {
|
|
440
453
|
super('internal');
|
|
441
454
|
}
|
|
442
455
|
static create(actionName, cfg) {
|
|
443
|
-
return
|
|
456
|
+
return action(actionName, {
|
|
444
457
|
...cfg
|
|
445
458
|
});
|
|
446
459
|
}
|
|
447
460
|
static createWithProvider(serviceProvider, actionName, cfg) {
|
|
448
|
-
return
|
|
449
|
-
|
|
461
|
+
return actionWithProvider(serviceProvider, actionName, cfg);
|
|
462
|
+
}
|
|
463
|
+
static fromModel(model, actionName, cfg) {
|
|
464
|
+
return actionFromModel(model, actionName, cfg);
|
|
465
|
+
}
|
|
466
|
+
static fromModelWithProvider(model, serviceProvider, actionName, cfg) {
|
|
467
|
+
return actionFromModel(model, serviceProvider, actionName, cfg);
|
|
468
|
+
}
|
|
469
|
+
static fromClass(type, actionName, cfg) {
|
|
470
|
+
return actionFromClass(type, actionName, cfg);
|
|
471
|
+
}
|
|
472
|
+
static fromClassWithProvider(type, serviceProvider, actionName, cfg) {
|
|
473
|
+
return actionFromClass(type, serviceProvider, actionName, cfg);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
function action(typeOrActionName, actionNameOrCfg, cfg) {
|
|
477
|
+
if (typeof typeOrActionName === 'string') {
|
|
478
|
+
return new ActionDescriptorInst(typeOrActionName, typeof actionNameOrCfg === 'string'
|
|
479
|
+
? undefined
|
|
480
|
+
: {
|
|
481
|
+
...actionNameOrCfg
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
return new ActionDescriptorInst(typeof actionNameOrCfg === 'string' ? actionNameOrCfg : 'default', {
|
|
450
486
|
...cfg
|
|
451
487
|
});
|
|
452
488
|
}
|
|
453
|
-
|
|
489
|
+
}
|
|
490
|
+
function actionWithProvider(typeOrServiceProvider, serviceProviderOrActionName, actionNameOrCfg, cfg) {
|
|
491
|
+
const actionName = serviceProviderOrActionName === 'string' ? serviceProviderOrActionName : typeof actionNameOrCfg === 'string' ? actionNameOrCfg : 'default';
|
|
492
|
+
if (typeOrServiceProvider instanceof TypeDescriptor) {
|
|
454
493
|
return new ActionDescriptorInst(actionName, {
|
|
455
|
-
|
|
494
|
+
...(typeof serviceProviderOrActionName === 'string' ? {} : actionGetProviderCfgObj(serviceProviderOrActionName)),
|
|
495
|
+
...(typeof actionNameOrCfg === 'string' ? {} : actionNameOrCfg),
|
|
456
496
|
...cfg
|
|
457
497
|
});
|
|
458
498
|
}
|
|
459
|
-
|
|
499
|
+
else {
|
|
460
500
|
return new ActionDescriptorInst(actionName, {
|
|
461
|
-
|
|
462
|
-
...actionGetProviderCfgObj(serviceProvider),
|
|
501
|
+
...actionGetProviderCfgObj(typeOrServiceProvider),
|
|
463
502
|
...cfg
|
|
464
503
|
});
|
|
465
504
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
505
|
+
}
|
|
506
|
+
function actionFromModel(model, actionNameOrServiceProvider, cfgOrActionName, cfg) {
|
|
507
|
+
if (typeof actionNameOrServiceProvider === 'string') {
|
|
508
|
+
// no provider
|
|
509
|
+
return new ActionDescriptorInst(actionNameOrServiceProvider, {
|
|
510
|
+
model,
|
|
511
|
+
...(typeof cfgOrActionName === 'object' ? cfgOrActionName : {}),
|
|
469
512
|
...cfg
|
|
470
513
|
});
|
|
471
514
|
}
|
|
472
|
-
|
|
473
|
-
return new ActionDescriptorInst(
|
|
474
|
-
model
|
|
475
|
-
...actionGetProviderCfgObj(
|
|
515
|
+
else {
|
|
516
|
+
return new ActionDescriptorInst(typeof cfgOrActionName === 'string' ? cfgOrActionName : 'default', {
|
|
517
|
+
model,
|
|
518
|
+
...actionGetProviderCfgObj(actionNameOrServiceProvider),
|
|
476
519
|
...cfg
|
|
477
520
|
});
|
|
478
521
|
}
|
|
479
522
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
523
|
+
function actionFromClass(type, actionNameOrServiceProvider, cfgOrActionName, cfg) {
|
|
524
|
+
if (typeof actionNameOrServiceProvider === 'string') {
|
|
525
|
+
// no provider
|
|
526
|
+
const finalCfg = typeof cfgOrActionName === 'object' ? cfgOrActionName : cfg;
|
|
527
|
+
return new ActionDescriptorInst(actionNameOrServiceProvider, {
|
|
528
|
+
model: new ModelDescriptor(type, finalCfg?.idProperty, finalCfg?.titleProperty, finalCfg?.i18nBaseKey),
|
|
529
|
+
...(typeof cfgOrActionName === 'object' ? cfgOrActionName : {}),
|
|
530
|
+
...cfg
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
return new ActionDescriptorInst(typeof cfgOrActionName === 'string' ? cfgOrActionName : 'default', {
|
|
535
|
+
model: new ModelDescriptor(type, cfg?.idProperty, cfg?.titleProperty, cfg?.i18nBaseKey),
|
|
536
|
+
...actionGetProviderCfgObj(actionNameOrServiceProvider),
|
|
537
|
+
...cfg
|
|
538
|
+
});
|
|
490
539
|
}
|
|
491
540
|
}
|
|
492
541
|
class ActionDeleteDescriptor {
|
|
493
542
|
static create(model) {
|
|
494
|
-
return
|
|
543
|
+
return actionDelete(model);
|
|
495
544
|
}
|
|
496
545
|
static createWithProvider(model, serviceProvider) {
|
|
497
|
-
return
|
|
498
|
-
...actionGetProviderCfgObj(serviceProvider)
|
|
499
|
-
});
|
|
546
|
+
return actionDelete(model, serviceProvider);
|
|
500
547
|
}
|
|
501
548
|
}
|
|
549
|
+
function actionDelete(model, serviceProvider) {
|
|
550
|
+
return new ActionDeleteDescriptorInst(model, {
|
|
551
|
+
...(serviceProvider ? actionGetProviderCfgObj(serviceProvider) : {})
|
|
552
|
+
});
|
|
553
|
+
}
|
|
502
554
|
|
|
503
555
|
class EditorDataProviderInst extends DataProviderInst {
|
|
504
556
|
constructor(type, serviceType) {
|
|
@@ -571,50 +623,7 @@ class EditorDataProviderInst extends DataProviderInst {
|
|
|
571
623
|
return this;
|
|
572
624
|
}
|
|
573
625
|
}
|
|
574
|
-
class EditorDataProvider extends EditorDataProviderInst {
|
|
575
|
-
constructor() {
|
|
576
|
-
super(undefined, undefined);
|
|
577
|
-
}
|
|
578
|
-
static create() {
|
|
579
|
-
return new EditorDataProviderInst(undefined, undefined);
|
|
580
|
-
}
|
|
581
|
-
static fromClass(type) {
|
|
582
|
-
return new EditorDataProviderInst(type, undefined);
|
|
583
|
-
}
|
|
584
|
-
static fromClassWithService(type, serviceType) {
|
|
585
|
-
return new EditorDataProviderInst(type, serviceType);
|
|
586
|
-
}
|
|
587
|
-
static fromService(serviceType) {
|
|
588
|
-
return new EditorDataProviderInst(undefined, serviceType);
|
|
589
|
-
}
|
|
590
|
-
static fromAnyParam(type, serviceType) {
|
|
591
|
-
if (typeof type !== 'undefined') {
|
|
592
|
-
return typeof serviceType !== 'undefined'
|
|
593
|
-
? EditorDataProvider.fromClassWithService(type, serviceType)
|
|
594
|
-
: EditorDataProvider.fromClass(type);
|
|
595
|
-
}
|
|
596
|
-
else if (typeof serviceType !== 'undefined') {
|
|
597
|
-
return EditorDataProvider.fromService(serviceType);
|
|
598
|
-
}
|
|
599
|
-
else {
|
|
600
|
-
return EditorDataProvider.create();
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
626
|
|
|
605
|
-
const actionEditorGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
606
|
-
const cfg = {};
|
|
607
|
-
if (serviceOrDataProvider) {
|
|
608
|
-
if (serviceOrDataProvider.isDataProvider) {
|
|
609
|
-
// type casting needed, cause there was no other way found to differentiate the types
|
|
610
|
-
cfg.dataProvider = serviceOrDataProvider;
|
|
611
|
-
}
|
|
612
|
-
else {
|
|
613
|
-
cfg.serviceType = serviceOrDataProvider;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
return cfg;
|
|
617
|
-
};
|
|
618
627
|
class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
619
628
|
constructor(editorDescriptor, actionName, cfg) {
|
|
620
629
|
super(actionName, {
|
|
@@ -630,14 +639,14 @@ class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
|
630
639
|
this._resubmitRefetch = true;
|
|
631
640
|
this._unsavedChangesConfirmation = false;
|
|
632
641
|
if (cfg?.serviceType) {
|
|
633
|
-
this._dataProvider =
|
|
642
|
+
this._dataProvider = new EditorDataProviderInst(this._model?.type, cfg.serviceType);
|
|
634
643
|
}
|
|
635
644
|
else if (cfg?.dataProvider) {
|
|
636
645
|
this._dataProvider = cfg.dataProvider;
|
|
637
646
|
}
|
|
638
647
|
this._type = ActionTypeEnum.Editor;
|
|
639
648
|
this._editorDescriptor = editorDescriptor;
|
|
640
|
-
this._editorActions.push(
|
|
649
|
+
this._editorActions.push(actionEditorSubmit(this), actionEditorCancel(this));
|
|
641
650
|
}
|
|
642
651
|
get editorTitle() {
|
|
643
652
|
return this._editorTitle;
|
|
@@ -741,6 +750,14 @@ class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
|
741
750
|
this._editorComponent = editorComponent;
|
|
742
751
|
return this;
|
|
743
752
|
}
|
|
753
|
+
/**
|
|
754
|
+
* Enables or disables resubmit resubmit - this means the form will not exit after successful submission, but will instead remain open.
|
|
755
|
+
*
|
|
756
|
+
* @param {boolean} [enabled=true] - Specifies whether resubmit is enabled or disabled. Defaults to true if not provided.
|
|
757
|
+
* @param {boolean} [refetch=true] - Specifies whether the data should be refetched after resubmit. If not, the data in the form stays as is. Defaults to true if not provided.
|
|
758
|
+
*
|
|
759
|
+
* @returns {this} - Returns the current instance with the resubmit configuration updated.
|
|
760
|
+
*/
|
|
744
761
|
withResubmit(enabled, refetch = true) {
|
|
745
762
|
this._resubmitEnabled = enabled;
|
|
746
763
|
this._resubmitRefetch = refetch;
|
|
@@ -751,21 +768,6 @@ class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
|
751
768
|
return this;
|
|
752
769
|
}
|
|
753
770
|
}
|
|
754
|
-
class ActionEditorDescriptor {
|
|
755
|
-
static create(editor, actionName, cfg) {
|
|
756
|
-
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
757
|
-
parentType: cfg?.parentType,
|
|
758
|
-
parentProperty: cfg?.parentProperty
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
static createWithProvider(editor, serviceProvider, actionName, cfg) {
|
|
762
|
-
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
763
|
-
...actionEditorGetProviderCfgObj(serviceProvider),
|
|
764
|
-
parentType: cfg?.parentType,
|
|
765
|
-
parentProperty: cfg?.parentProperty
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
771
|
class ActionEditorSubmitDescriptorInst extends ActionDescriptorInst {
|
|
770
772
|
constructor(editorAction, submitType = ActionEditorSubmitTypeEnum.Submit) {
|
|
771
773
|
super(submitType === ActionEditorSubmitTypeEnum.Submit ? `${editorAction.actionName}.submit` : `${editorAction.actionName}.cancel`, { model: editorAction.model });
|
|
@@ -778,23 +780,21 @@ class ActionEditorSubmitDescriptorInst extends ActionDescriptorInst {
|
|
|
778
780
|
return this._submitType;
|
|
779
781
|
}
|
|
780
782
|
}
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
return new ActionEditorSubmitDescriptorInst(editorAction, submitType).withButtonDescriptor(new ActionButtonDescriptor().withStyleClass(new ButtonStyleBuilder().withTextButton()));
|
|
797
|
-
}
|
|
783
|
+
/**
|
|
784
|
+
* creates primary action with primary button style
|
|
785
|
+
* @param editorAction
|
|
786
|
+
* @param submitType
|
|
787
|
+
*/
|
|
788
|
+
function actionEditorSubmit(editorAction, submitType = ActionEditorSubmitTypeEnum.Submit) {
|
|
789
|
+
return new ActionEditorSubmitDescriptorInst(editorAction, submitType).withButtonDescriptor(new ActionButtonDescriptor().withStyleClass(new ButtonStyleBuilder()));
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* creates secondary button with text button style
|
|
793
|
+
* @param editorAction
|
|
794
|
+
* @param submitType
|
|
795
|
+
*/
|
|
796
|
+
function actionEditorCancel(editorAction, submitType = ActionEditorSubmitTypeEnum.Cancel) {
|
|
797
|
+
return new ActionEditorSubmitDescriptorInst(editorAction, submitType).withButtonDescriptor(new ActionButtonDescriptor().withStyleClass(new ButtonStyleBuilder().withTextButton()));
|
|
798
798
|
}
|
|
799
799
|
class ActionEditorDetailsDescriptorInst extends ActionEditorDescriptorInst {
|
|
800
800
|
static { this.ACTION_NAME = 'details'; }
|
|
@@ -802,20 +802,10 @@ class ActionEditorDetailsDescriptorInst extends ActionEditorDescriptorInst {
|
|
|
802
802
|
super(editorDescriptor, ActionEditorDetailsDescriptorInst.ACTION_NAME, cfg);
|
|
803
803
|
this.withPosition(ActionPositionEnum.RowClick);
|
|
804
804
|
this.withRouteTrigger(':itemId');
|
|
805
|
-
this.withEditorActions([
|
|
805
|
+
this.withEditorActions([actionEditorCancel(this)]);
|
|
806
806
|
this.withTableviewCategory(TableviewActionDefaultCategories.DETAILS);
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
|
-
class ActionEditorDetailsDescriptor {
|
|
810
|
-
static create(editor) {
|
|
811
|
-
return new ActionEditorDetailsDescriptorInst(editor);
|
|
812
|
-
}
|
|
813
|
-
static createWithProvider(editor, serviceProvider) {
|
|
814
|
-
return new ActionEditorDetailsDescriptorInst(editor, {
|
|
815
|
-
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
809
|
class ActionEditorAddDescriptorInst extends ActionEditorDescriptorInst {
|
|
820
810
|
static { this.ACTION_NAME = 'add'; }
|
|
821
811
|
constructor(editorDescriptor, cfg) {
|
|
@@ -827,16 +817,6 @@ class ActionEditorAddDescriptorInst extends ActionEditorDescriptorInst {
|
|
|
827
817
|
this.withUnsavedChangesConfirmation();
|
|
828
818
|
}
|
|
829
819
|
}
|
|
830
|
-
class ActionEditorAddDescriptor {
|
|
831
|
-
static create(editor) {
|
|
832
|
-
return new ActionEditorAddDescriptorInst(editor);
|
|
833
|
-
}
|
|
834
|
-
static createWithProvider(editor, serviceProvider) {
|
|
835
|
-
return new ActionEditorAddDescriptorInst(editor, {
|
|
836
|
-
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
820
|
class ActionEditorEditDescriptorInst extends ActionEditorDescriptorInst {
|
|
841
821
|
static { this.ACTION_NAME = 'edit'; }
|
|
842
822
|
constructor(editorDescriptor, cfg) {
|
|
@@ -849,16 +829,82 @@ class ActionEditorEditDescriptorInst extends ActionEditorDescriptorInst {
|
|
|
849
829
|
this.withUnsavedChangesConfirmation();
|
|
850
830
|
}
|
|
851
831
|
}
|
|
832
|
+
|
|
833
|
+
const actionEditorGetProviderCfgObj = (serviceOrDataProvider) => {
|
|
834
|
+
const cfg = {};
|
|
835
|
+
if (serviceOrDataProvider) {
|
|
836
|
+
if (serviceOrDataProvider.isDataProvider) {
|
|
837
|
+
// type casting needed, cause there was no other way found to differentiate the types
|
|
838
|
+
cfg.dataProvider = serviceOrDataProvider;
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
cfg.serviceType = serviceOrDataProvider;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
return cfg;
|
|
845
|
+
};
|
|
846
|
+
class ActionEditorDescriptor {
|
|
847
|
+
static create(editor, actionName, cfg) {
|
|
848
|
+
return actionEditor(editor, actionName, cfg);
|
|
849
|
+
}
|
|
850
|
+
static createWithProvider(editor, serviceProvider, actionName, cfg) {
|
|
851
|
+
return actionEditor(editor, serviceProvider, actionName, cfg);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
function actionEditor(editor, actionNameOrServiceProvider, cfgOrActionName, cfg) {
|
|
855
|
+
if (typeof actionNameOrServiceProvider === 'string') {
|
|
856
|
+
// no provider
|
|
857
|
+
return new ActionEditorDescriptorInst(editor, actionNameOrServiceProvider, {
|
|
858
|
+
...(typeof cfgOrActionName === 'object' ? cfgOrActionName : {}),
|
|
859
|
+
...cfg
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
else {
|
|
863
|
+
return new ActionEditorDescriptorInst(editor, typeof cfgOrActionName === 'string' ? cfgOrActionName : 'default', {
|
|
864
|
+
...actionEditorGetProviderCfgObj(actionNameOrServiceProvider),
|
|
865
|
+
...cfg
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
class ActionEditorDetailsDescriptor {
|
|
870
|
+
static create(editor) {
|
|
871
|
+
return actionEditorDetails(editor);
|
|
872
|
+
}
|
|
873
|
+
static createWithProvider(editor, serviceProvider) {
|
|
874
|
+
return actionEditorDetails(editor, serviceProvider);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
function actionEditorDetails(editor, serviceProvider) {
|
|
878
|
+
return new ActionEditorDetailsDescriptorInst(editor, {
|
|
879
|
+
...(serviceProvider ? actionEditorGetProviderCfgObj(serviceProvider) : {})
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
class ActionEditorAddDescriptor {
|
|
883
|
+
static create(editor) {
|
|
884
|
+
return actionEditorAdd(editor);
|
|
885
|
+
}
|
|
886
|
+
static createWithProvider(editor, serviceProvider) {
|
|
887
|
+
return actionEditorAdd(editor, serviceProvider);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
function actionEditorAdd(editor, serviceProvider) {
|
|
891
|
+
return new ActionEditorAddDescriptorInst(editor, {
|
|
892
|
+
...(serviceProvider ? actionEditorGetProviderCfgObj(serviceProvider) : {})
|
|
893
|
+
});
|
|
894
|
+
}
|
|
852
895
|
class ActionEditorEditDescriptor {
|
|
853
896
|
static create(editor) {
|
|
854
|
-
return
|
|
897
|
+
return actionEditorEdit(editor);
|
|
855
898
|
}
|
|
856
899
|
static createWithProvider(editor, serviceProvider) {
|
|
857
|
-
return
|
|
858
|
-
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
859
|
-
});
|
|
900
|
+
return actionEditorEdit(editor, serviceProvider);
|
|
860
901
|
}
|
|
861
902
|
}
|
|
903
|
+
function actionEditorEdit(editor, serviceProvider) {
|
|
904
|
+
return new ActionEditorEditDescriptorInst(editor, {
|
|
905
|
+
...(serviceProvider ? actionEditorGetProviderCfgObj(serviceProvider) : {})
|
|
906
|
+
});
|
|
907
|
+
}
|
|
862
908
|
|
|
863
909
|
class ActionLinkDescriptorInst extends ActionDescriptorInst {
|
|
864
910
|
constructor(actionName = 'link', cfg) {
|
|
@@ -916,36 +962,49 @@ class ActionLinkDescriptorInst extends ActionDescriptorInst {
|
|
|
916
962
|
return this;
|
|
917
963
|
}
|
|
918
964
|
}
|
|
965
|
+
|
|
919
966
|
class ActionLinkDescriptor {
|
|
920
967
|
static create(actionName, cfg) {
|
|
921
|
-
return
|
|
922
|
-
...cfg
|
|
923
|
-
});
|
|
968
|
+
return actionLink(actionName, cfg);
|
|
924
969
|
}
|
|
925
970
|
static fromModel(model, actionName, cfg) {
|
|
926
|
-
return
|
|
927
|
-
model,
|
|
928
|
-
...cfg
|
|
929
|
-
});
|
|
971
|
+
return actionLinkFromModel(model, actionName, cfg);
|
|
930
972
|
}
|
|
931
973
|
static fromClass(type, actionName, cfg) {
|
|
932
|
-
return
|
|
933
|
-
model: ModelDescriptor.fromClass(type, cfg?.idProperty, cfg?.titleProperty, cfg?.i18nBaseKey),
|
|
934
|
-
...cfg
|
|
935
|
-
});
|
|
974
|
+
return actionLinkFromClass(type, actionName, cfg);
|
|
936
975
|
}
|
|
937
976
|
static fromAction(action) {
|
|
938
|
-
|
|
939
|
-
action.copyTo(descriptor);
|
|
940
|
-
descriptor.withRunConfirmationDescriptor();
|
|
941
|
-
descriptor.withRunNotificationSuccess(undefined, undefined, false);
|
|
942
|
-
descriptor.withRunNotificationError(undefined, undefined, false);
|
|
943
|
-
descriptor.withAfterRunAction();
|
|
944
|
-
descriptor.withOnRunErrorAction();
|
|
945
|
-
descriptor.withSubactionsAsMenu(false);
|
|
946
|
-
return descriptor;
|
|
977
|
+
return actionLinkFromAction(action);
|
|
947
978
|
}
|
|
948
979
|
}
|
|
980
|
+
function actionLink(actionName, cfg) {
|
|
981
|
+
return new ActionLinkDescriptorInst(actionName, {
|
|
982
|
+
...cfg
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
function actionLinkFromModel(model, actionName, cfg) {
|
|
986
|
+
return new ActionLinkDescriptorInst(actionName, {
|
|
987
|
+
model,
|
|
988
|
+
...cfg
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
function actionLinkFromClass(type, actionName, cfg) {
|
|
992
|
+
return new ActionLinkDescriptorInst(actionName, {
|
|
993
|
+
model: ModelDescriptor.fromClass(type, cfg?.idProperty, cfg?.titleProperty, cfg?.i18nBaseKey),
|
|
994
|
+
...cfg
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
function actionLinkFromAction(action) {
|
|
998
|
+
const descriptor = new ActionLinkDescriptorInst(action.actionName, { model: action.model });
|
|
999
|
+
action.copyTo(descriptor);
|
|
1000
|
+
descriptor.withRunConfirmationDescriptor();
|
|
1001
|
+
descriptor.withRunNotificationSuccess(undefined, undefined, false);
|
|
1002
|
+
descriptor.withRunNotificationError(undefined, undefined, false);
|
|
1003
|
+
descriptor.withAfterRunAction();
|
|
1004
|
+
descriptor.withOnRunErrorAction();
|
|
1005
|
+
descriptor.withSubactionsAsMenu(false);
|
|
1006
|
+
return descriptor;
|
|
1007
|
+
}
|
|
949
1008
|
|
|
950
1009
|
class CommonsActionError extends ACommonsErrorBase {
|
|
951
1010
|
constructor(message, actionName, options) {
|
|
@@ -1098,6 +1157,47 @@ class DataProviderExecutor {
|
|
|
1098
1157
|
}
|
|
1099
1158
|
}
|
|
1100
1159
|
|
|
1160
|
+
class EditorDataProvider extends EditorDataProviderInst {
|
|
1161
|
+
constructor() {
|
|
1162
|
+
super(undefined, undefined);
|
|
1163
|
+
}
|
|
1164
|
+
static create() {
|
|
1165
|
+
return editorDataProvider();
|
|
1166
|
+
}
|
|
1167
|
+
static fromClass(type) {
|
|
1168
|
+
return editorDataProviderFromClass(type);
|
|
1169
|
+
}
|
|
1170
|
+
static fromClassWithService(type, serviceType) {
|
|
1171
|
+
return editorDataProviderFromClass(type, serviceType);
|
|
1172
|
+
}
|
|
1173
|
+
static fromService(serviceType) {
|
|
1174
|
+
return editorDataProviderWithService(serviceType);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
function editorDataProvider(type, serviceType) {
|
|
1178
|
+
return new EditorDataProviderInst(undefined, serviceType);
|
|
1179
|
+
}
|
|
1180
|
+
function editorDataProviderWithService(serviceType) {
|
|
1181
|
+
return new EditorDataProviderInst(undefined, serviceType);
|
|
1182
|
+
}
|
|
1183
|
+
function editorDataProviderFromClass(type, serviceType) {
|
|
1184
|
+
return new EditorDataProviderInst(type, serviceType);
|
|
1185
|
+
}
|
|
1186
|
+
function editorDataProviderFromModel(model, serviceType) {
|
|
1187
|
+
return typeof serviceType !== 'undefined'
|
|
1188
|
+
? new EditorDataProviderInst(model.type, serviceType)
|
|
1189
|
+
: new EditorDataProviderInst(model.type, undefined);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
var TableviewEditorTypeEnum;
|
|
1193
|
+
(function (TableviewEditorTypeEnum) {
|
|
1194
|
+
TableviewEditorTypeEnum[TableviewEditorTypeEnum["None"] = 0] = "None";
|
|
1195
|
+
TableviewEditorTypeEnum[TableviewEditorTypeEnum["Details"] = 1] = "Details";
|
|
1196
|
+
TableviewEditorTypeEnum[TableviewEditorTypeEnum["Edit"] = 2] = "Edit";
|
|
1197
|
+
TableviewEditorTypeEnum[TableviewEditorTypeEnum["Add"] = 3] = "Add";
|
|
1198
|
+
})(TableviewEditorTypeEnum || (TableviewEditorTypeEnum = {}));
|
|
1199
|
+
const EDITOR_DEFAULT_GROUP_NAME = '_default';
|
|
1200
|
+
|
|
1101
1201
|
var FieldSizeEnum;
|
|
1102
1202
|
(function (FieldSizeEnum) {
|
|
1103
1203
|
FieldSizeEnum[FieldSizeEnum["Small"] = 0] = "Small";
|
|
@@ -1154,97 +1254,6 @@ var FieldGroupTypeEnum;
|
|
|
1154
1254
|
FieldGroupTypeEnum[FieldGroupTypeEnum["Logical"] = 1] = "Logical";
|
|
1155
1255
|
})(FieldGroupTypeEnum || (FieldGroupTypeEnum = {}));
|
|
1156
1256
|
|
|
1157
|
-
/**
|
|
1158
|
-
* converts string type to type enum, default is text
|
|
1159
|
-
* @param attributeType
|
|
1160
|
-
*/
|
|
1161
|
-
function getFieldInputTypeFromClassAttributeDefType(attributeType) {
|
|
1162
|
-
switch (attributeType) {
|
|
1163
|
-
case 'hidden':
|
|
1164
|
-
return FieldInputTypeEnum.Hidden;
|
|
1165
|
-
case 'label':
|
|
1166
|
-
return FieldInputTypeEnum.Label;
|
|
1167
|
-
case 'textarea':
|
|
1168
|
-
return FieldInputTypeEnum.Textarea;
|
|
1169
|
-
case 'number':
|
|
1170
|
-
return FieldInputTypeEnum.Number;
|
|
1171
|
-
case 'currency':
|
|
1172
|
-
return FieldInputTypeEnum.Currency;
|
|
1173
|
-
case 'switch':
|
|
1174
|
-
case 'boolean':
|
|
1175
|
-
return FieldInputTypeEnum.Switch;
|
|
1176
|
-
case 'radio':
|
|
1177
|
-
return FieldInputTypeEnum.Radio;
|
|
1178
|
-
case 'datepicker':
|
|
1179
|
-
return FieldInputTypeEnum.Datepicker;
|
|
1180
|
-
case 'mask':
|
|
1181
|
-
return FieldInputTypeEnum.Mask;
|
|
1182
|
-
case 'file':
|
|
1183
|
-
return FieldInputTypeEnum.File;
|
|
1184
|
-
case 'custom':
|
|
1185
|
-
return FieldInputTypeEnum.Custom;
|
|
1186
|
-
case 'text':
|
|
1187
|
-
default:
|
|
1188
|
-
return FieldInputTypeEnum.Text;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
/**
|
|
1192
|
-
* convert column type to equivalent field input type
|
|
1193
|
-
* @param type column type
|
|
1194
|
-
* @param displayType column display type
|
|
1195
|
-
*/
|
|
1196
|
-
function getFieldInputTypeFromColumnType(type, displayType) {
|
|
1197
|
-
switch (type) {
|
|
1198
|
-
case ColumnTypeEnum.Number:
|
|
1199
|
-
return displayType === ColumnDisplayTypeEnum.Currency ? FieldInputTypeEnum.Currency : FieldInputTypeEnum.Number;
|
|
1200
|
-
case ColumnTypeEnum.Boolean:
|
|
1201
|
-
return FieldInputTypeEnum.Switch;
|
|
1202
|
-
case ColumnTypeEnum.Date:
|
|
1203
|
-
return FieldInputTypeEnum.Datepicker;
|
|
1204
|
-
case ColumnTypeEnum.Custom:
|
|
1205
|
-
return FieldInputTypeEnum.Custom;
|
|
1206
|
-
case ColumnTypeEnum.String:
|
|
1207
|
-
case ColumnTypeEnum.Enum:
|
|
1208
|
-
default:
|
|
1209
|
-
return FieldInputTypeEnum.Text;
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
function expandClassAttributeDefWithEditorDef(attributes) {
|
|
1213
|
-
if (!attributes) {
|
|
1214
|
-
throw new CommonsInternalError('Class attribute definition is null, problem with TypeRegistry::findAttributesDefinitionByClassType?', { name: 'TableviewUtilsError' });
|
|
1215
|
-
}
|
|
1216
|
-
const typeRegistry = TypeRegistry.get();
|
|
1217
|
-
const editorClassAttributeDef = [];
|
|
1218
|
-
for (const attribute of attributes) {
|
|
1219
|
-
editorClassAttributeDef.push({
|
|
1220
|
-
name: attribute.name,
|
|
1221
|
-
baseName: attribute.baseName,
|
|
1222
|
-
type: attribute.type,
|
|
1223
|
-
subtype: attribute.subtype,
|
|
1224
|
-
fieldType: getFieldInputTypeFromClassAttributeDefType(attribute.type),
|
|
1225
|
-
classType: typeRegistry.findType(attribute.type),
|
|
1226
|
-
enumType: typeRegistry.findEnum(attribute.type)
|
|
1227
|
-
});
|
|
1228
|
-
}
|
|
1229
|
-
return editorClassAttributeDef;
|
|
1230
|
-
}
|
|
1231
|
-
/**
|
|
1232
|
-
* returns attributes from class type and extends to typed def with column and field enum type
|
|
1233
|
-
* @param type class type
|
|
1234
|
-
*/
|
|
1235
|
-
function getEditorClassAttributeDef(type) {
|
|
1236
|
-
return expandClassAttributeDefWithEditorDef(TypeRegistry.get().findAttributesDefinitionByClassType(type));
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
var TableviewEditorTypeEnum;
|
|
1240
|
-
(function (TableviewEditorTypeEnum) {
|
|
1241
|
-
TableviewEditorTypeEnum[TableviewEditorTypeEnum["None"] = 0] = "None";
|
|
1242
|
-
TableviewEditorTypeEnum[TableviewEditorTypeEnum["Details"] = 1] = "Details";
|
|
1243
|
-
TableviewEditorTypeEnum[TableviewEditorTypeEnum["Edit"] = 2] = "Edit";
|
|
1244
|
-
TableviewEditorTypeEnum[TableviewEditorTypeEnum["Add"] = 3] = "Add";
|
|
1245
|
-
})(TableviewEditorTypeEnum || (TableviewEditorTypeEnum = {}));
|
|
1246
|
-
const EDITOR_DEFAULT_GROUP_NAME = '_default';
|
|
1247
|
-
|
|
1248
1257
|
class FieldValidationDescriptor {
|
|
1249
1258
|
constructor(name, validator, message, options) {
|
|
1250
1259
|
this._name = name;
|
|
@@ -1362,6 +1371,9 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1362
1371
|
get hiddenExpression() {
|
|
1363
1372
|
return this._hiddenExpression;
|
|
1364
1373
|
}
|
|
1374
|
+
get hiddenResetOnHide() {
|
|
1375
|
+
return this._hiddenResetOnHide;
|
|
1376
|
+
}
|
|
1365
1377
|
get updateOn() {
|
|
1366
1378
|
return this._updateOn;
|
|
1367
1379
|
}
|
|
@@ -1434,8 +1446,9 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1434
1446
|
}
|
|
1435
1447
|
return this;
|
|
1436
1448
|
}
|
|
1437
|
-
withHidden(hiddenExpression) {
|
|
1449
|
+
withHidden(hiddenExpression, resetOnHide) {
|
|
1438
1450
|
this._hiddenExpression = hiddenExpression;
|
|
1451
|
+
this._hiddenResetOnHide = resetOnHide;
|
|
1439
1452
|
return this;
|
|
1440
1453
|
}
|
|
1441
1454
|
withUpdateOn(updateOn) {
|
|
@@ -1516,11 +1529,14 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1516
1529
|
this._isLocalized = true;
|
|
1517
1530
|
return this;
|
|
1518
1531
|
}
|
|
1519
|
-
nextEvent(type,
|
|
1532
|
+
nextEvent(type, component, data) {
|
|
1520
1533
|
this._eventsSubject.next({
|
|
1521
1534
|
type: type,
|
|
1522
|
-
|
|
1523
|
-
|
|
1535
|
+
fieldComponent: component,
|
|
1536
|
+
formComponent: component.props.formEditorComponent,
|
|
1537
|
+
form: component?.form,
|
|
1538
|
+
fieldFormControl: component.formControl,
|
|
1539
|
+
fieldFormlyConfig: component.field,
|
|
1524
1540
|
data: data
|
|
1525
1541
|
});
|
|
1526
1542
|
}
|
|
@@ -1536,6 +1552,7 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1536
1552
|
obj._defaultValue = this._defaultValue;
|
|
1537
1553
|
obj._requiredExpression = this._requiredExpression;
|
|
1538
1554
|
obj._hiddenExpression = this._hiddenExpression;
|
|
1555
|
+
obj._hiddenResetOnHide = this._hiddenResetOnHide;
|
|
1539
1556
|
obj._updateOn = this._updateOn;
|
|
1540
1557
|
obj._onInit = this._onInit;
|
|
1541
1558
|
obj._onChanges = this._onChanges;
|
|
@@ -1631,8 +1648,8 @@ class AFieldGroupDescriptor extends AGenericFieldDescriptor {
|
|
|
1631
1648
|
this._title = title;
|
|
1632
1649
|
return this;
|
|
1633
1650
|
}
|
|
1634
|
-
withValidation(name, validator, message) {
|
|
1635
|
-
this._validations.push(new FieldValidationDescriptor(name, validator, message));
|
|
1651
|
+
withValidation(name, validator, message, opts) {
|
|
1652
|
+
this._validations.push(new FieldValidationDescriptor(name, validator, message, opts));
|
|
1636
1653
|
return this;
|
|
1637
1654
|
}
|
|
1638
1655
|
}
|
|
@@ -1716,7 +1733,7 @@ class FieldLookupDescriptor extends AFieldDescriptor {
|
|
|
1716
1733
|
this._dataProvider = cfg.dataProvider;
|
|
1717
1734
|
}
|
|
1718
1735
|
else {
|
|
1719
|
-
this._dataProvider =
|
|
1736
|
+
this._dataProvider = new LookupDataProviderInst(cfg?.type, cfg?.serviceType);
|
|
1720
1737
|
}
|
|
1721
1738
|
this._optionsValueProperty = cfg?.optionsValueProperty;
|
|
1722
1739
|
trySetLookupItemsProperties(this);
|
|
@@ -1845,7 +1862,7 @@ class FieldLookupDescriptor extends AFieldDescriptor {
|
|
|
1845
1862
|
class FieldLookupEnumDescriptor extends FieldLookupDescriptor {
|
|
1846
1863
|
constructor(editor, property, enumModel, options) {
|
|
1847
1864
|
super(editor, property, {
|
|
1848
|
-
dataProvider:
|
|
1865
|
+
dataProvider: new LookupDataProviderInst(undefined, undefined),
|
|
1849
1866
|
optionsValueProperty: 'value'
|
|
1850
1867
|
});
|
|
1851
1868
|
this._enumModel = enumModel;
|
|
@@ -1928,7 +1945,7 @@ class FieldManyToManyEditorDescriptor extends AFieldDescriptor {
|
|
|
1928
1945
|
this._lookupTableDataProvider = cfg.lookupDataProvider;
|
|
1929
1946
|
}
|
|
1930
1947
|
else {
|
|
1931
|
-
this._lookupTableDataProvider =
|
|
1948
|
+
this._lookupTableDataProvider = new TableDataProviderInst(lookupTableDescriptor.model.type, cfg?.lookupServiceType);
|
|
1932
1949
|
}
|
|
1933
1950
|
}
|
|
1934
1951
|
get fieldType() {
|
|
@@ -2050,36 +2067,25 @@ class FieldManyEditorDescriptor extends AFieldDescriptor {
|
|
|
2050
2067
|
}
|
|
2051
2068
|
}
|
|
2052
2069
|
|
|
2070
|
+
const minDateValidationName = 'minDate';
|
|
2053
2071
|
const minDateValidator = (min) => {
|
|
2054
|
-
return (
|
|
2055
|
-
const date =
|
|
2056
|
-
|
|
2057
|
-
if (!valid) {
|
|
2058
|
-
const newErrors = { ...c.errors, minDate: true };
|
|
2059
|
-
c?.markAsDirty();
|
|
2060
|
-
c.setErrors(newErrors);
|
|
2061
|
-
return newErrors;
|
|
2062
|
-
}
|
|
2063
|
-
if (c?.hasError('minDate')) {
|
|
2064
|
-
c.setErrors({ ...c.errors, minDate: null });
|
|
2065
|
-
}
|
|
2066
|
-
return null;
|
|
2072
|
+
return ({ fieldFormControl }) => {
|
|
2073
|
+
const date = fieldFormControl?.value == null ? undefined : new Date(fieldFormControl.value);
|
|
2074
|
+
return !date || date >= min;
|
|
2067
2075
|
};
|
|
2068
2076
|
};
|
|
2077
|
+
const maxDateValidationName = 'maxDate';
|
|
2069
2078
|
const maxDateValidator = (max) => {
|
|
2070
|
-
return (
|
|
2071
|
-
const date =
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
c.setErrors({ ...c.errors, maxDate: null });
|
|
2081
|
-
}
|
|
2082
|
-
return null;
|
|
2079
|
+
return ({ fieldFormControl }) => {
|
|
2080
|
+
const date = fieldFormControl?.value == null ? undefined : new Date(fieldFormControl.value);
|
|
2081
|
+
return !date || date <= max;
|
|
2082
|
+
};
|
|
2083
|
+
};
|
|
2084
|
+
const emailValidationName = 'email';
|
|
2085
|
+
const emailValidator = () => {
|
|
2086
|
+
return ({ fieldFormControl }) => {
|
|
2087
|
+
const error = fieldFormControl ? Validators.email(fieldFormControl) : null;
|
|
2088
|
+
return error === null;
|
|
2083
2089
|
};
|
|
2084
2090
|
};
|
|
2085
2091
|
|
|
@@ -2174,6 +2180,18 @@ class FieldInputDescriptor extends AFieldDescriptor {
|
|
|
2174
2180
|
get datePickerShowSeconds() {
|
|
2175
2181
|
return this._datePickerShowSeconds;
|
|
2176
2182
|
}
|
|
2183
|
+
get datePickerValueUtc() {
|
|
2184
|
+
return this._datePickerValueUtc;
|
|
2185
|
+
}
|
|
2186
|
+
get datePickerValueNoTimezone() {
|
|
2187
|
+
return this._datePickerValueNoTimezone;
|
|
2188
|
+
}
|
|
2189
|
+
get datePickerValueNoTime() {
|
|
2190
|
+
return this._datePickerValueNoTime;
|
|
2191
|
+
}
|
|
2192
|
+
get datePickerValueAsDateObj() {
|
|
2193
|
+
return this._datePickerValueAsDateObj;
|
|
2194
|
+
}
|
|
2177
2195
|
get maxLength() {
|
|
2178
2196
|
return this._maxLength;
|
|
2179
2197
|
}
|
|
@@ -2297,11 +2315,18 @@ class FieldInputDescriptor extends AFieldDescriptor {
|
|
|
2297
2315
|
this._datePickerMax = opts?.max;
|
|
2298
2316
|
this._datePickerShowTime = opts?.showTime;
|
|
2299
2317
|
this._datePickerShowSeconds = opts?.showSeconds;
|
|
2318
|
+
this._datePickerValueAsDateObj = opts?.asDateObj;
|
|
2319
|
+
this.withDateValue({
|
|
2320
|
+
asDateObj: opts?.asDateObj,
|
|
2321
|
+
utc: opts?.utc,
|
|
2322
|
+
noTimeZone: opts?.noTimeZone,
|
|
2323
|
+
noTime: opts?.noTime
|
|
2324
|
+
});
|
|
2300
2325
|
if (opts?.min != undefined) {
|
|
2301
|
-
this.withValidation(
|
|
2326
|
+
this.withValidation(minDateValidationName, minDateValidator(opts.min));
|
|
2302
2327
|
}
|
|
2303
2328
|
if (opts?.max !== undefined) {
|
|
2304
|
-
this.withValidation(
|
|
2329
|
+
this.withValidation(maxDateValidationName, maxDateValidator(opts.max));
|
|
2305
2330
|
}
|
|
2306
2331
|
return this;
|
|
2307
2332
|
}
|
|
@@ -2367,12 +2392,19 @@ class FieldInputDescriptor extends AFieldDescriptor {
|
|
|
2367
2392
|
this._inputTrim = trimOption;
|
|
2368
2393
|
return this;
|
|
2369
2394
|
}
|
|
2395
|
+
withDateValue(opts) {
|
|
2396
|
+
this._datePickerValueAsDateObj = opts?.asDateObj;
|
|
2397
|
+
this._datePickerValueUtc = opts?.utc;
|
|
2398
|
+
this._datePickerValueNoTimezone = opts?.noTimeZone;
|
|
2399
|
+
this._datePickerValueNoTime = opts?.noTime;
|
|
2400
|
+
return this;
|
|
2401
|
+
}
|
|
2370
2402
|
withTextValidationEmail(email = true) {
|
|
2371
2403
|
if (this.fieldType === FieldInputTypeEnum.Text && email) {
|
|
2372
|
-
this.withValidation(
|
|
2404
|
+
this.withValidation(emailValidationName, emailValidator());
|
|
2373
2405
|
}
|
|
2374
2406
|
else if (!email) {
|
|
2375
|
-
this.removeValidation(
|
|
2407
|
+
this.removeValidation(emailValidationName);
|
|
2376
2408
|
}
|
|
2377
2409
|
return this;
|
|
2378
2410
|
}
|
|
@@ -2398,6 +2430,10 @@ class FieldInputDescriptor extends AFieldDescriptor {
|
|
|
2398
2430
|
field._datePickerMax = this._datePickerMax;
|
|
2399
2431
|
field._datePickerShowTime = this._datePickerShowTime;
|
|
2400
2432
|
field._datePickerShowSeconds = this._datePickerShowSeconds;
|
|
2433
|
+
field._datePickerValueUtc = this._datePickerValueUtc;
|
|
2434
|
+
field._datePickerValueNoTimezone = this._datePickerValueNoTimezone;
|
|
2435
|
+
field._datePickerValueNoTime = this._datePickerValueNoTime;
|
|
2436
|
+
field._datePickerValueAsDateObj = this._datePickerValueAsDateObj;
|
|
2401
2437
|
field._maxLength = this._maxLength;
|
|
2402
2438
|
field._minLength = this._minLength;
|
|
2403
2439
|
field._pattern = this._pattern;
|
|
@@ -2646,8 +2682,9 @@ class EditorDescriptorInst {
|
|
|
2646
2682
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
2647
2683
|
* @typeparam LookupValueProperty - The property of lookup model type.
|
|
2648
2684
|
* @typeparam FieldValue - The value type of field on editor.
|
|
2685
|
+
* @typeparam ParentEditorModel - The value type of parent form.
|
|
2649
2686
|
*
|
|
2650
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, undefined, FieldValue>} - The field lookup descriptor.
|
|
2687
|
+
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, undefined, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
2651
2688
|
*/
|
|
2652
2689
|
addFieldLookupWithOptionsValuePropertyUnsafe(property, type, lookupOptionsValueProperty) {
|
|
2653
2690
|
const field = new FieldLookupDescriptor(this, property, {
|
|
@@ -2769,30 +2806,10 @@ class EditorDescriptorInst {
|
|
|
2769
2806
|
this.addFieldDescriptor(field);
|
|
2770
2807
|
return field;
|
|
2771
2808
|
}
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
* @param property Model's property name.
|
|
2775
|
-
* @param mainTableDescriptor Main table descriptor for displaying items added to main model's property.
|
|
2776
|
-
* @param lookupTableDescriptor Lookup table descriptor for displaying items to be added to main model's property.
|
|
2777
|
-
*/
|
|
2778
|
-
addFieldManyToManyEditor(property, mainTableDescriptor, lookupTableDescriptor) {
|
|
2779
|
-
return this.addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor);
|
|
2780
|
-
}
|
|
2781
|
-
/**
|
|
2782
|
-
* Adds tables for many-to-many (m:n) relations (UNSAFE).
|
|
2783
|
-
* @param property Model's property name.
|
|
2784
|
-
* @param mainTableDescriptor Main table descriptor for displaying items added to main model's property.
|
|
2785
|
-
* @param lookupTableDescriptor Lookup table descriptor for displaying items to be added to main model's property.
|
|
2786
|
-
*/
|
|
2787
|
-
addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor) {
|
|
2788
|
-
const field = new FieldManyToManyEditorDescriptor(this, property, mainTableDescriptor, lookupTableDescriptor);
|
|
2789
|
-
this.addFieldDescriptor(field);
|
|
2790
|
-
return field;
|
|
2791
|
-
}
|
|
2792
|
-
addFieldManyToManyEditorWithProvider(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
2793
|
-
return this.addFieldManyToManyEditorWithProviderUnsafe(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider);
|
|
2809
|
+
addFieldManyToManyEditor(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
2810
|
+
return this.addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider);
|
|
2794
2811
|
}
|
|
2795
|
-
|
|
2812
|
+
addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
2796
2813
|
const cfg = fieldManyToManyGetProviderCfgObj(lookupDataProvider);
|
|
2797
2814
|
const field = new FieldManyToManyEditorDescriptor(this, property, mainTableDescriptor, lookupTableDescriptor, {
|
|
2798
2815
|
...cfg
|
|
@@ -2813,11 +2830,23 @@ class EditorDescriptorInst {
|
|
|
2813
2830
|
* @param name Name of the validation.
|
|
2814
2831
|
* @param validator Field validator function.
|
|
2815
2832
|
* @param message Field validation message.
|
|
2833
|
+
* @param opts Additional configuration for validation.
|
|
2834
|
+
*/
|
|
2835
|
+
withValidation(name, validator, message, opts) {
|
|
2836
|
+
return this.withValidationUnsafe(name, validator, message, opts);
|
|
2837
|
+
}
|
|
2838
|
+
/**
|
|
2839
|
+
* Adds group validator to editor.
|
|
2840
|
+
* @param name Name of the validation.
|
|
2841
|
+
* @param validator Field validator function.
|
|
2842
|
+
* @param message Field validation message.
|
|
2843
|
+
* @param opts Additional configuration for validation.
|
|
2816
2844
|
*/
|
|
2817
|
-
|
|
2845
|
+
withValidationUnsafe(name, validator, message, opts) {
|
|
2818
2846
|
if (this._currentGroup) {
|
|
2819
|
-
this._currentGroup.withValidation(name, validator, message);
|
|
2847
|
+
this._currentGroup.withValidation(name, validator, message, opts);
|
|
2820
2848
|
}
|
|
2849
|
+
return this;
|
|
2821
2850
|
}
|
|
2822
2851
|
/**
|
|
2823
2852
|
* Creates a copy of editor descriptor object.
|
|
@@ -2879,66 +2908,6 @@ class EditorDescriptorInst {
|
|
|
2879
2908
|
this.createTabGroup(EditorDescriptorInst.defaultGroupName, 'general.general');
|
|
2880
2909
|
}
|
|
2881
2910
|
}
|
|
2882
|
-
/**
|
|
2883
|
-
* Modifies selected field by field property. For enums use {withFieldModifiedEnum} instead.
|
|
2884
|
-
* @param property Model's property name.
|
|
2885
|
-
* @param fieldType new field type for selected field
|
|
2886
|
-
* @param args additional parameters for field
|
|
2887
|
-
*/
|
|
2888
|
-
withFieldModifiedType(property, fieldType, ...args) {
|
|
2889
|
-
return this.withFieldModifiedTypeUnsafe(property, fieldType, ...args);
|
|
2890
|
-
}
|
|
2891
|
-
withFieldModifiedTypeUnsafe(property, fieldType, ...args) {
|
|
2892
|
-
if (!this.model.type) {
|
|
2893
|
-
throw new CommonsInternalError(`withFieldModifiedType cannot be executed for property ${property}: Model type is not defined.`);
|
|
2894
|
-
}
|
|
2895
|
-
const attribute = getEditorClassAttributeDef(this.model.type).find(attribute => attribute.name === property);
|
|
2896
|
-
if (attribute) {
|
|
2897
|
-
attribute.fieldType = fieldType;
|
|
2898
|
-
EditorDescriptorInst.upsertFieldFromAttributeDef(this, attribute, this.fields.find(fi => fi.property === property), ...args);
|
|
2899
|
-
}
|
|
2900
|
-
return this;
|
|
2901
|
-
}
|
|
2902
|
-
/**
|
|
2903
|
-
* Modifies selected field with enum type.
|
|
2904
|
-
* @param property Model's property name.
|
|
2905
|
-
* @param enumModel Enum descriptor.
|
|
2906
|
-
* @param values
|
|
2907
|
-
*/
|
|
2908
|
-
withFieldModifiedEnum(property, enumModel, values) {
|
|
2909
|
-
return this.withFieldModifiedEnumUnsafe(property, enumModel, values);
|
|
2910
|
-
}
|
|
2911
|
-
withFieldModifiedEnumUnsafe(property, enumDesc, values) {
|
|
2912
|
-
if (!this.model.type) {
|
|
2913
|
-
throw new CommonsInternalError(`withFieldModifiedEnum cannot be executed for property ${property}: Model type is not defined.`);
|
|
2914
|
-
}
|
|
2915
|
-
const attribute = getEditorClassAttributeDef(this.model.type).find(a => a.name === property);
|
|
2916
|
-
if (attribute) {
|
|
2917
|
-
attribute.fieldType = FieldInputTypeEnum.Radio;
|
|
2918
|
-
const field = this.fields.find(f => f.property === property);
|
|
2919
|
-
if (field && field instanceof FieldInputDescriptor) {
|
|
2920
|
-
field.asRadioFromEnum(enumDesc ?? enumModelGeneric(TypeRegistry.get().findEnum(attribute.type)), values);
|
|
2921
|
-
}
|
|
2922
|
-
}
|
|
2923
|
-
return this;
|
|
2924
|
-
}
|
|
2925
|
-
/**
|
|
2926
|
-
* Modifies selected field with lookup field.
|
|
2927
|
-
* @param property Model's property name.
|
|
2928
|
-
* @param lookupProvider provider to be added to field
|
|
2929
|
-
* @param titleProperty
|
|
2930
|
-
*/
|
|
2931
|
-
withFieldModifiedLookupWithProvider(property, lookupProvider, titleProperty) {
|
|
2932
|
-
return this.withFieldModifiedLookupWithProviderUnsafe(property, lookupProvider, titleProperty);
|
|
2933
|
-
}
|
|
2934
|
-
withFieldModifiedLookupWithProviderUnsafe(property, lookupProvider, titleProperty) {
|
|
2935
|
-
this.removeFieldUnsafe(property);
|
|
2936
|
-
const field = this.addFieldLookupWithProviderUnsafe(property, lookupProvider).asAutocomplete();
|
|
2937
|
-
if (titleProperty) {
|
|
2938
|
-
field.withOptionsLabelProperty(titleProperty);
|
|
2939
|
-
}
|
|
2940
|
-
return this;
|
|
2941
|
-
}
|
|
2942
2911
|
/**
|
|
2943
2912
|
* This method takes care of displaying correct/localized data in the editor
|
|
2944
2913
|
* @param property property that tells us where on the model are localizations accessible
|
|
@@ -2955,57 +2924,207 @@ class EditorDescriptorInst {
|
|
|
2955
2924
|
this._isLocalized = true;
|
|
2956
2925
|
return this;
|
|
2957
2926
|
}
|
|
2958
|
-
nextEvent(type,
|
|
2927
|
+
nextEvent(type, component, data) {
|
|
2959
2928
|
this._eventsSubject.next({
|
|
2960
2929
|
type: type,
|
|
2961
|
-
|
|
2962
|
-
|
|
2930
|
+
formComponent: component,
|
|
2931
|
+
form: component.form,
|
|
2963
2932
|
data: data
|
|
2964
2933
|
});
|
|
2965
2934
|
}
|
|
2966
|
-
completeEvents() {
|
|
2967
|
-
this._eventsSubject.complete();
|
|
2968
|
-
}
|
|
2969
2935
|
get events$() {
|
|
2970
2936
|
return this._eventsSubject.asObservable();
|
|
2971
2937
|
}
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
/**
|
|
2941
|
+
* converts string type to type enum, default is text
|
|
2942
|
+
* @param attributeType
|
|
2943
|
+
*/
|
|
2944
|
+
function getFieldInputTypeFromClassAttributeDefType(attributeType) {
|
|
2945
|
+
switch (attributeType) {
|
|
2946
|
+
case 'hidden':
|
|
2947
|
+
return FieldInputTypeEnum.Hidden;
|
|
2948
|
+
case 'label':
|
|
2949
|
+
return FieldInputTypeEnum.Label;
|
|
2950
|
+
case 'textarea':
|
|
2951
|
+
return FieldInputTypeEnum.Textarea;
|
|
2952
|
+
case 'number':
|
|
2953
|
+
return FieldInputTypeEnum.Number;
|
|
2954
|
+
case 'currency':
|
|
2955
|
+
return FieldInputTypeEnum.Currency;
|
|
2956
|
+
case 'switch':
|
|
2957
|
+
case 'boolean':
|
|
2958
|
+
return FieldInputTypeEnum.Switch;
|
|
2959
|
+
case 'radio':
|
|
2960
|
+
return FieldInputTypeEnum.Radio;
|
|
2961
|
+
case 'datepicker':
|
|
2962
|
+
return FieldInputTypeEnum.Datepicker;
|
|
2963
|
+
case 'mask':
|
|
2964
|
+
return FieldInputTypeEnum.Mask;
|
|
2965
|
+
case 'file':
|
|
2966
|
+
return FieldInputTypeEnum.File;
|
|
2967
|
+
case 'custom':
|
|
2968
|
+
return FieldInputTypeEnum.Custom;
|
|
2969
|
+
case 'text':
|
|
2970
|
+
default:
|
|
2971
|
+
return FieldInputTypeEnum.Text;
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* convert column type to equivalent field input type
|
|
2976
|
+
* @param type column type
|
|
2977
|
+
* @param displayType column display type
|
|
2978
|
+
*/
|
|
2979
|
+
function getFieldInputTypeFromColumnType(type, displayType) {
|
|
2980
|
+
switch (type) {
|
|
2981
|
+
case ColumnTypeEnum.Number:
|
|
2982
|
+
return displayType === ColumnDisplayTypeEnum.Currency ? FieldInputTypeEnum.Currency : FieldInputTypeEnum.Number;
|
|
2983
|
+
case ColumnTypeEnum.Boolean:
|
|
2984
|
+
return FieldInputTypeEnum.Switch;
|
|
2985
|
+
case ColumnTypeEnum.Date:
|
|
2986
|
+
return FieldInputTypeEnum.Datepicker;
|
|
2987
|
+
case ColumnTypeEnum.Custom:
|
|
2988
|
+
return FieldInputTypeEnum.Custom;
|
|
2989
|
+
case ColumnTypeEnum.String:
|
|
2990
|
+
case ColumnTypeEnum.Enum:
|
|
2991
|
+
default:
|
|
2992
|
+
return FieldInputTypeEnum.Text;
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
function expandClassAttributeDefWithEditorDef(attributes) {
|
|
2996
|
+
if (!attributes) {
|
|
2997
|
+
throw new CommonsInternalError('Class attribute definition is null, problem with TypeRegistry::findAttributesDefinitionByClassType?', { name: 'TableviewUtilsError' });
|
|
2998
|
+
}
|
|
2999
|
+
const typeRegistry = TypeRegistry.get();
|
|
3000
|
+
const editorClassAttributeDef = [];
|
|
3001
|
+
for (const attribute of attributes) {
|
|
3002
|
+
editorClassAttributeDef.push({
|
|
3003
|
+
name: attribute.name,
|
|
3004
|
+
baseName: attribute.baseName,
|
|
3005
|
+
type: attribute.type,
|
|
3006
|
+
subtype: attribute.subtype,
|
|
3007
|
+
fieldType: getFieldInputTypeFromClassAttributeDefType(attribute.type),
|
|
3008
|
+
classType: typeRegistry.findType(attribute.type),
|
|
3009
|
+
enumType: typeRegistry.findEnum(attribute.type)
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
return editorClassAttributeDef;
|
|
3013
|
+
}
|
|
3014
|
+
/**
|
|
3015
|
+
* returns attributes from class type and extends to typed def with column and field enum type
|
|
3016
|
+
* @param type class type
|
|
3017
|
+
*/
|
|
3018
|
+
function getEditorClassAttributeDef(type) {
|
|
3019
|
+
return expandClassAttributeDefWithEditorDef(TypeRegistry.get().findAttributesDefinitionByClassType(type));
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
/**
|
|
3023
|
+
* Generates field based on attribute definition, used for auto model
|
|
3024
|
+
* @param descriptor Editor descriptor instance.
|
|
3025
|
+
* @param attribute Attribute definition.
|
|
3026
|
+
* @param field Optional, if defined will be replaced, otherwise new will be generated.
|
|
3027
|
+
* @param args Optional additional arguments mapped to filed type. Arguments depend on possible arguments on fields.
|
|
3028
|
+
* @internal
|
|
3029
|
+
*/
|
|
3030
|
+
function upsertEditorFieldFromAttributeDef(descriptor, attribute, field, ...args) {
|
|
3031
|
+
if (field == null) {
|
|
3032
|
+
field = descriptor.addFieldUnsafe(attribute.name);
|
|
3033
|
+
}
|
|
3034
|
+
if (field instanceof FieldInputDescriptor) {
|
|
3035
|
+
if (attribute.enumType) {
|
|
3036
|
+
return field.asRadioFromEnum(enumModelGeneric(attribute.enumType));
|
|
2983
3037
|
}
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
else {
|
|
2989
|
-
const tableColumnType = getColumnTypeFromClassAttributeDefType(attribute.type);
|
|
2990
|
-
const tableColumnDisplayType = getColumnDisplayTypeFromColumnType(tableColumnType, attribute.type);
|
|
2991
|
-
return field.asType(attribute.fieldType ?? getFieldInputTypeFromColumnType(tableColumnType, tableColumnDisplayType), ...args);
|
|
2992
|
-
}
|
|
3038
|
+
else {
|
|
3039
|
+
const tableColumnType = getColumnTypeFromClassAttributeDefType(attribute.type);
|
|
3040
|
+
const tableColumnDisplayType = getColumnDisplayTypeFromColumnType(tableColumnType, attribute.type);
|
|
3041
|
+
return field.asType(attribute.fieldType ?? getFieldInputTypeFromColumnType(tableColumnType, tableColumnDisplayType), ...args);
|
|
2993
3042
|
}
|
|
2994
|
-
return field;
|
|
2995
3043
|
}
|
|
3044
|
+
return field;
|
|
3045
|
+
}
|
|
3046
|
+
/**
|
|
3047
|
+
* Modifies selected field by field property. For enums use {withFieldModifiedEnum} instead.
|
|
3048
|
+
* @param descriptor Editor descriptor.
|
|
3049
|
+
* @param property Model's property name.
|
|
3050
|
+
* @param fieldType new field type for selected field
|
|
3051
|
+
* @param args additional parameters for field
|
|
3052
|
+
*/
|
|
3053
|
+
function modifyEditorClassAttributeFieldType(descriptor, property, fieldType, ...args) {
|
|
3054
|
+
return modifyEditorClassAttributeFieldTypeUnsafe(descriptor, property, fieldType, ...args);
|
|
3055
|
+
}
|
|
3056
|
+
function modifyEditorClassAttributeFieldTypeUnsafe(descriptor, property, fieldType, ...args) {
|
|
3057
|
+
if (!descriptor.model.type) {
|
|
3058
|
+
throw new CommonsInternalError(`withFieldModifiedType cannot be executed for property ${property}: Model type is not defined.`);
|
|
3059
|
+
}
|
|
3060
|
+
const attribute = getEditorClassAttributeDef(descriptor.model.type).find(attribute => attribute.name === property);
|
|
3061
|
+
if (attribute) {
|
|
3062
|
+
attribute.fieldType = fieldType;
|
|
3063
|
+
return upsertEditorFieldFromAttributeDef(descriptor, attribute, descriptor.fields.find(fi => fi.property === property), ...args);
|
|
3064
|
+
}
|
|
3065
|
+
return null;
|
|
3066
|
+
}
|
|
3067
|
+
/**
|
|
3068
|
+
* Modifies selected field with enum type.
|
|
3069
|
+
* @param descriptor Editor descriptor.
|
|
3070
|
+
* @param property Model's property name.
|
|
3071
|
+
* @param enumModel Enum descriptor.
|
|
3072
|
+
* @param values
|
|
3073
|
+
*/
|
|
3074
|
+
function modifyEditorClassAttributeFieldEnum(descriptor, property, enumModel, values) {
|
|
3075
|
+
return modifyEditorClassAttributeFieldEnumUnsafe(descriptor, property, enumModel, values);
|
|
3076
|
+
}
|
|
3077
|
+
function modifyEditorClassAttributeFieldEnumUnsafe(descriptor, property, enumDesc, values) {
|
|
3078
|
+
if (!descriptor.model.type) {
|
|
3079
|
+
throw new CommonsInternalError(`withFieldModifiedEnum cannot be executed for property ${property}: Model type is not defined.`);
|
|
3080
|
+
}
|
|
3081
|
+
const attribute = getEditorClassAttributeDef(descriptor.model.type).find(a => a.name === property);
|
|
3082
|
+
if (attribute) {
|
|
3083
|
+
attribute.fieldType = FieldInputTypeEnum.Radio;
|
|
3084
|
+
const field = descriptor.fields.find(f => f.property === property);
|
|
3085
|
+
if (field && field instanceof FieldInputDescriptor) {
|
|
3086
|
+
field.asRadioFromEnum(enumDesc ?? enumModelGeneric(TypeRegistry.get().findEnum(attribute.type)), values);
|
|
3087
|
+
}
|
|
3088
|
+
return field ?? null;
|
|
3089
|
+
}
|
|
3090
|
+
return null;
|
|
3091
|
+
}
|
|
3092
|
+
/**
|
|
3093
|
+
* Modifies selected field with lookup field.
|
|
3094
|
+
* @param descriptor Editor descriptor.
|
|
3095
|
+
* @param property Model's property name.
|
|
3096
|
+
* @param lookupProvider provider to be added to field
|
|
3097
|
+
* @param titleProperty
|
|
3098
|
+
*/
|
|
3099
|
+
function modifyEditorFieldLookup(descriptor, property, lookupProvider, titleProperty) {
|
|
3100
|
+
return modifyEditorFieldLookupUnsafe(descriptor, property, lookupProvider, titleProperty);
|
|
3101
|
+
}
|
|
3102
|
+
function modifyEditorFieldLookupUnsafe(descriptor, property, lookupProvider, titleProperty) {
|
|
3103
|
+
descriptor.removeFieldUnsafe(property);
|
|
3104
|
+
const field = descriptor.addFieldLookupWithProviderUnsafe(property, lookupProvider).asAutocomplete();
|
|
3105
|
+
if (titleProperty) {
|
|
3106
|
+
field.withOptionsLabelPropertyUnsafe(titleProperty);
|
|
3107
|
+
}
|
|
3108
|
+
return field;
|
|
2996
3109
|
}
|
|
3110
|
+
|
|
2997
3111
|
class EditorDescriptor extends EditorDescriptorInst {
|
|
2998
3112
|
constructor() {
|
|
2999
3113
|
super(ModelDescriptor.create());
|
|
3000
3114
|
}
|
|
3001
3115
|
static create(idProperty, titleProperty, i18nBaseKey, tableviewEditorType = TableviewEditorTypeEnum.None) {
|
|
3002
|
-
return
|
|
3116
|
+
return editorDescriptor({ id: idProperty, title: titleProperty, i18nBase: i18nBaseKey, tableviewEditorType: tableviewEditorType });
|
|
3003
3117
|
}
|
|
3004
3118
|
static fromClass(type, idProperty, titleProperty, i18nBaseKey, tableviewEditorType = TableviewEditorTypeEnum.None) {
|
|
3005
|
-
return
|
|
3119
|
+
return editorDescriptorFromClass(type, {
|
|
3120
|
+
id: idProperty,
|
|
3121
|
+
title: titleProperty,
|
|
3122
|
+
i18nBase: i18nBaseKey,
|
|
3123
|
+
tableviewEditorType: tableviewEditorType
|
|
3124
|
+
});
|
|
3006
3125
|
}
|
|
3007
3126
|
static fromModel(model, tableviewEditorType = TableviewEditorTypeEnum.None) {
|
|
3008
|
-
return
|
|
3127
|
+
return editorDescriptor(model, { tableviewEditorType: tableviewEditorType });
|
|
3009
3128
|
}
|
|
3010
3129
|
/**
|
|
3011
3130
|
* Creates editor descriptor automatically based on openapi model's attributes definition which is automatically extracted. All fields will be included.
|
|
@@ -3023,16 +3142,47 @@ class EditorDescriptor extends EditorDescriptorInst {
|
|
|
3023
3142
|
* @param attributes List of attribute definitions from which fields should be created.
|
|
3024
3143
|
* @param idProperty Id property representing model (optional).
|
|
3025
3144
|
* @param titleProperty Title property representing model (optional). If not provided, it will be automatically chosen.
|
|
3026
|
-
* @param
|
|
3145
|
+
* @param tableviewEditorType Type of editor in tableview (add, edit, view or none).
|
|
3027
3146
|
*/
|
|
3028
|
-
static fromClassWithCustomAttrsDef(type, attributes, idProperty, titleProperty,
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3147
|
+
static fromClassWithCustomAttrsDef(type, attributes, idProperty, titleProperty, tableviewEditorType = TableviewEditorTypeEnum.None) {
|
|
3148
|
+
return editorDescriptorFromClassAttrsDef(type, attributes, {
|
|
3149
|
+
id: idProperty,
|
|
3150
|
+
title: titleProperty,
|
|
3151
|
+
tableviewEditorType: tableviewEditorType
|
|
3152
|
+
});
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
function editorDescriptor(typeOrModelOrClassOrOpts, opts) {
|
|
3156
|
+
if (typeOrModelOrClassOrOpts == null) {
|
|
3157
|
+
return new EditorDescriptorInst(model(), opts?.tableviewEditorType);
|
|
3158
|
+
}
|
|
3159
|
+
else if (typeOrModelOrClassOrOpts instanceof TypeDescriptor) {
|
|
3160
|
+
return new EditorDescriptorInst(model(opts ?? {}), opts?.tableviewEditorType);
|
|
3161
|
+
}
|
|
3162
|
+
else if (typeOrModelOrClassOrOpts instanceof ModelDescriptor) {
|
|
3163
|
+
return new EditorDescriptorInst(typeOrModelOrClassOrOpts, opts?.tableviewEditorType);
|
|
3164
|
+
}
|
|
3165
|
+
else {
|
|
3166
|
+
// this could have autoGenerated if model descriptor is class
|
|
3167
|
+
return new EditorDescriptorInst(model(typeOrModelOrClassOrOpts), typeOrModelOrClassOrOpts?.tableviewEditorType);
|
|
3034
3168
|
}
|
|
3035
3169
|
}
|
|
3170
|
+
function editorDescriptorFromClass(type, opts) {
|
|
3171
|
+
return new EditorDescriptorInst(model(type, opts), opts?.tableviewEditorType);
|
|
3172
|
+
}
|
|
3173
|
+
/**
|
|
3174
|
+
* Generates descriptor based on type attribute definition
|
|
3175
|
+
* @param type class type
|
|
3176
|
+
* @param attributes
|
|
3177
|
+
* @param opts
|
|
3178
|
+
*/
|
|
3179
|
+
function editorDescriptorFromClassAttrsDef(type, attributes, opts) {
|
|
3180
|
+
const descriptor = new EditorDescriptorInst(model(type, opts), opts?.tableviewEditorType);
|
|
3181
|
+
(attributes ?? getEditorClassAttributeDef(type))
|
|
3182
|
+
.filter(attr => !attr.type.includes('Set') && !attr.type.includes('Array'))
|
|
3183
|
+
.forEach(attr => upsertEditorFieldFromAttributeDef(descriptor, attr));
|
|
3184
|
+
return descriptor;
|
|
3185
|
+
}
|
|
3036
3186
|
|
|
3037
3187
|
var FormFieldEventTypeEnum;
|
|
3038
3188
|
(function (FormFieldEventTypeEnum) {
|
|
@@ -3089,10 +3239,10 @@ class AFormlyCustomFieldComponent extends FieldType {
|
|
|
3089
3239
|
get formState() {
|
|
3090
3240
|
return this._formState;
|
|
3091
3241
|
}
|
|
3092
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.
|
|
3093
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.
|
|
3242
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: AFormlyCustomFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
3243
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.3.4", type: AFormlyCustomFieldComponent, inputs: { field: "field", _model: ["model", "_model"], _form: ["form", "_form"], _options: ["options", "_options"], _key: ["key", "_key"], _formControl: ["formControl", "_formControl"], _props: ["props", "_props"], _showError: ["showError", "_showError"], _id: ["id", "_id"], _formState: ["formState", "_formState"] }, usesInheritance: true, ngImport: i0 }); }
|
|
3094
3244
|
}
|
|
3095
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.
|
|
3245
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: AFormlyCustomFieldComponent, decorators: [{
|
|
3096
3246
|
type: Directive
|
|
3097
3247
|
}], propDecorators: { field: [{
|
|
3098
3248
|
type: Input,
|
|
@@ -3129,8 +3279,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImpor
|
|
|
3129
3279
|
class TableviewDataProviderInst extends DataProviderInst {
|
|
3130
3280
|
constructor(type, serviceType) {
|
|
3131
3281
|
super(type, serviceType);
|
|
3132
|
-
this.editorDataProvider =
|
|
3133
|
-
this.tableDataProvider =
|
|
3282
|
+
this.editorDataProvider = new EditorDataProviderInst(type, serviceType);
|
|
3283
|
+
this.tableDataProvider = new TableDataProviderInst(type, serviceType);
|
|
3134
3284
|
}
|
|
3135
3285
|
get isLazy() {
|
|
3136
3286
|
return this.tableDataProvider.isLazy;
|
|
@@ -3181,94 +3331,68 @@ class TableviewDataProviderInst extends DataProviderInst {
|
|
|
3181
3331
|
return this;
|
|
3182
3332
|
}
|
|
3183
3333
|
}
|
|
3334
|
+
class DynamicTableviewDataProviderInst extends TableviewDataProviderInst {
|
|
3335
|
+
constructor(serviceType) {
|
|
3336
|
+
super(undefined, serviceType);
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
|
|
3184
3340
|
class TableviewDataProvider extends TableviewDataProviderInst {
|
|
3185
3341
|
constructor() {
|
|
3186
3342
|
super(undefined, undefined);
|
|
3187
3343
|
}
|
|
3188
3344
|
static create() {
|
|
3189
|
-
return
|
|
3345
|
+
return tableviewDataProvider();
|
|
3190
3346
|
}
|
|
3191
3347
|
static fromClass(type) {
|
|
3192
|
-
return
|
|
3348
|
+
return tableviewDataProviderFromClass(type);
|
|
3193
3349
|
}
|
|
3194
3350
|
static fromClassWithService(type, serviceType) {
|
|
3195
|
-
return
|
|
3351
|
+
return tableviewDataProviderFromClass(type, serviceType);
|
|
3196
3352
|
}
|
|
3197
3353
|
static fromService(serviceType) {
|
|
3198
|
-
return
|
|
3199
|
-
}
|
|
3200
|
-
static fromAnyParam(type, serviceType) {
|
|
3201
|
-
if (typeof type !== 'undefined') {
|
|
3202
|
-
return typeof serviceType !== 'undefined'
|
|
3203
|
-
? TableviewDataProvider.fromClassWithService(type, serviceType)
|
|
3204
|
-
: TableviewDataProvider.fromClass(type);
|
|
3205
|
-
}
|
|
3206
|
-
else if (typeof serviceType !== 'undefined') {
|
|
3207
|
-
return TableviewDataProvider.fromService(serviceType);
|
|
3208
|
-
}
|
|
3209
|
-
else {
|
|
3210
|
-
return TableviewDataProvider.create();
|
|
3211
|
-
}
|
|
3354
|
+
return tableviewDataProviderWithService(serviceType);
|
|
3212
3355
|
}
|
|
3213
3356
|
}
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3357
|
+
function tableviewDataProvider(type, serviceType) {
|
|
3358
|
+
return new TableviewDataProviderInst(undefined, serviceType);
|
|
3359
|
+
}
|
|
3360
|
+
function tableviewDataProviderWithService(serviceType) {
|
|
3361
|
+
return new TableviewDataProviderInst(undefined, serviceType);
|
|
3362
|
+
}
|
|
3363
|
+
function tableviewDataProviderFromClass(type, serviceType) {
|
|
3364
|
+
return new TableviewDataProviderInst(type, serviceType);
|
|
3365
|
+
}
|
|
3366
|
+
function tableviewDataProviderFromModel(model, serviceType) {
|
|
3367
|
+
return typeof serviceType !== 'undefined'
|
|
3368
|
+
? new TableviewDataProviderInst(model.type, serviceType)
|
|
3369
|
+
: new TableviewDataProviderInst(model.type, undefined);
|
|
3218
3370
|
}
|
|
3219
3371
|
class DynamicTableviewDataProvider extends DynamicTableviewDataProviderInst {
|
|
3220
3372
|
constructor() {
|
|
3221
3373
|
super(undefined);
|
|
3222
3374
|
}
|
|
3223
3375
|
static create() {
|
|
3224
|
-
return
|
|
3376
|
+
return tableviewDynamicDataProvider();
|
|
3225
3377
|
}
|
|
3226
3378
|
static fromService(serviceType) {
|
|
3227
|
-
return
|
|
3228
|
-
}
|
|
3229
|
-
}
|
|
3230
|
-
|
|
3231
|
-
function expandClassAttributeDefWithTableviewDef(attributes) {
|
|
3232
|
-
if (!attributes) {
|
|
3233
|
-
throw new CommonsInternalError('Class attribute definition is null, problem with TypeRegistry::findAttributesDefinitionByClassType?', { name: 'TableviewUtilsError' });
|
|
3234
|
-
}
|
|
3235
|
-
const typeRegistry = TypeRegistry.get();
|
|
3236
|
-
const tableClassAttributeDef = [];
|
|
3237
|
-
for (const attribute of attributes) {
|
|
3238
|
-
const enumType = typeRegistry.findEnum(attribute.type);
|
|
3239
|
-
const columnType = enumType ? ColumnTypeEnum.Enum : getColumnTypeFromClassAttributeDefType(attribute.type);
|
|
3240
|
-
tableClassAttributeDef.push({
|
|
3241
|
-
name: attribute.name,
|
|
3242
|
-
baseName: attribute.baseName,
|
|
3243
|
-
type: attribute.type,
|
|
3244
|
-
subtype: attribute.subtype,
|
|
3245
|
-
columnType: enumType ? ColumnTypeEnum.Enum : getColumnTypeFromClassAttributeDefType(attribute.type),
|
|
3246
|
-
columnDisplayType: getColumnDisplayTypeFromColumnType(columnType, attribute.type),
|
|
3247
|
-
fieldType: getFieldInputTypeFromClassAttributeDefType(attribute.type),
|
|
3248
|
-
enumType: typeRegistry.findEnum(attribute.type),
|
|
3249
|
-
classType: typeRegistry.findType(attribute.type)
|
|
3250
|
-
});
|
|
3379
|
+
return tableviewDynamicDataProvider(serviceType);
|
|
3251
3380
|
}
|
|
3252
|
-
return tableClassAttributeDef;
|
|
3253
3381
|
}
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
* @param type class type
|
|
3257
|
-
*/
|
|
3258
|
-
function getTableviewClassAttributeDef(type) {
|
|
3259
|
-
return expandClassAttributeDefWithTableviewDef(TypeRegistry.get().findAttributesDefinitionByClassType(type));
|
|
3382
|
+
function tableviewDynamicDataProvider(serviceType) {
|
|
3383
|
+
return new DynamicTableviewDataProviderInst(serviceType);
|
|
3260
3384
|
}
|
|
3261
3385
|
|
|
3262
3386
|
class TableviewDescriptorInst {
|
|
3263
3387
|
constructor(model) {
|
|
3264
3388
|
this._isLocalized = false;
|
|
3265
3389
|
this._model = model;
|
|
3266
|
-
this._table =
|
|
3390
|
+
this._table = new TableDescriptorInst(model);
|
|
3267
3391
|
this._tableTitle = `${this._model.i18nBaseKey}.name`;
|
|
3268
|
-
this._detailsEditor =
|
|
3392
|
+
this._detailsEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Details);
|
|
3269
3393
|
this._detailsEditor.withDisabled();
|
|
3270
|
-
this._addEditor =
|
|
3271
|
-
this._editEditor =
|
|
3394
|
+
this._addEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Add);
|
|
3395
|
+
this._editEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Edit);
|
|
3272
3396
|
}
|
|
3273
3397
|
get table() {
|
|
3274
3398
|
return this._table;
|
|
@@ -3334,10 +3458,13 @@ class TableviewDescriptorInst {
|
|
|
3334
3458
|
this._tableTitle = title;
|
|
3335
3459
|
return this;
|
|
3336
3460
|
}
|
|
3337
|
-
|
|
3338
|
-
this.
|
|
3339
|
-
|
|
3340
|
-
|
|
3461
|
+
withValidation(name, expression, message, opts) {
|
|
3462
|
+
return this.withValidationUnsafe(name, expression, message, opts);
|
|
3463
|
+
}
|
|
3464
|
+
withValidationUnsafe(name, expression, message, opts) {
|
|
3465
|
+
this._detailsEditor.withValidationUnsafe(name, expression, message, opts);
|
|
3466
|
+
this._addEditor.withValidationUnsafe(name, expression, message, opts);
|
|
3467
|
+
this._editEditor.withValidationUnsafe(name, expression, message, opts);
|
|
3341
3468
|
return this;
|
|
3342
3469
|
}
|
|
3343
3470
|
getColumn(property) {
|
|
@@ -3506,6 +3633,11 @@ class TableviewDescriptorInst {
|
|
|
3506
3633
|
properties.forEach(p => this.addField(p));
|
|
3507
3634
|
return this;
|
|
3508
3635
|
}
|
|
3636
|
+
addFieldAction(actionName) {
|
|
3637
|
+
const field = this._detailsEditor.addFieldAction(actionName);
|
|
3638
|
+
this.addFieldToEditAndAdd(field);
|
|
3639
|
+
return field;
|
|
3640
|
+
}
|
|
3509
3641
|
addFieldToEditAndAdd(field) {
|
|
3510
3642
|
this._addEditor.addFieldDescriptor(field);
|
|
3511
3643
|
this._editEditor.addFieldDescriptor(field);
|
|
@@ -3519,7 +3651,7 @@ class TableviewDescriptorInst {
|
|
|
3519
3651
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3520
3652
|
* @typeparam FieldValue - The value type of field on editor.
|
|
3521
3653
|
*
|
|
3522
|
-
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, undefined, FieldValue>} - The field lookup descriptor.
|
|
3654
|
+
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, undefined, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
3523
3655
|
*/
|
|
3524
3656
|
addFieldLookup(property, type) {
|
|
3525
3657
|
const field = this._detailsEditor.addFieldLookup(property, type);
|
|
@@ -3535,7 +3667,7 @@ class TableviewDescriptorInst {
|
|
|
3535
3667
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3536
3668
|
* @typeparam FieldValue - The value type of field on editor.
|
|
3537
3669
|
*
|
|
3538
|
-
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, undefined, FieldValue>} - The field lookup descriptor.
|
|
3670
|
+
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, undefined, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
3539
3671
|
*/
|
|
3540
3672
|
addFieldLookupUnsafe(property, type) {
|
|
3541
3673
|
const field = this._detailsEditor.addFieldLookupUnsafe(property, type);
|
|
@@ -3674,23 +3806,13 @@ class TableviewDescriptorInst {
|
|
|
3674
3806
|
this.addFieldToEditAndAdd(field);
|
|
3675
3807
|
return field;
|
|
3676
3808
|
}
|
|
3677
|
-
addFieldManyToManyEditor(property, mainTableDescriptor, lookupTableDescriptor) {
|
|
3678
|
-
const field = this._detailsEditor.addFieldManyToManyEditor(property, mainTableDescriptor, lookupTableDescriptor);
|
|
3679
|
-
this.addFieldToEditAndAdd(field);
|
|
3680
|
-
return field;
|
|
3681
|
-
}
|
|
3682
|
-
addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor) {
|
|
3683
|
-
const field = this._detailsEditor.addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor);
|
|
3684
|
-
this.addFieldToEditAndAdd(field);
|
|
3685
|
-
return field;
|
|
3686
|
-
}
|
|
3687
|
-
addFieldManyToManyEditorWithProvider(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
3688
|
-
const field = this._detailsEditor.addFieldManyToManyEditorWithProvider(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider);
|
|
3809
|
+
addFieldManyToManyEditor(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
3810
|
+
const field = this._detailsEditor.addFieldManyToManyEditor(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider);
|
|
3689
3811
|
this.addFieldToEditAndAdd(field);
|
|
3690
3812
|
return field;
|
|
3691
3813
|
}
|
|
3692
|
-
|
|
3693
|
-
const field = this._detailsEditor.
|
|
3814
|
+
addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider) {
|
|
3815
|
+
const field = this._detailsEditor.addFieldManyToManyEditorUnsafe(property, mainTableDescriptor, lookupTableDescriptor, lookupDataProvider);
|
|
3694
3816
|
this.addFieldToEditAndAdd(field);
|
|
3695
3817
|
return field;
|
|
3696
3818
|
}
|
|
@@ -3716,113 +3838,60 @@ class TableviewDescriptorInst {
|
|
|
3716
3838
|
tableview._isLocalized = this._isLocalized;
|
|
3717
3839
|
return tableview;
|
|
3718
3840
|
}
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
* if field exists, it is replaced
|
|
3722
|
-
* DO NOT USE WITH TYPES WHERE ARGS ARE REQUIRED - ERROR WILL BE THROWN
|
|
3723
|
-
* for enum use withEnumType
|
|
3724
|
-
* for custom class use withClassType
|
|
3725
|
-
* @param property name of field
|
|
3726
|
-
* @param columnType required column type
|
|
3727
|
-
* @param fieldType optional, if not provided it is converted from column type
|
|
3728
|
-
* @param columnDisplayType optional
|
|
3729
|
-
*/
|
|
3730
|
-
withModifiedType(property, columnType, fieldType, columnDisplayType) {
|
|
3731
|
-
return this.withModifiedTypeUnsafe(property, columnType, fieldType, columnDisplayType);
|
|
3841
|
+
localized(property, model, localeProperty) {
|
|
3842
|
+
return this.localizedUnsafe(property, model, localeProperty);
|
|
3732
3843
|
}
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
}
|
|
3740
|
-
const attributeDef = getTableviewClassAttributeDef(this.model.type).find(attr => attr.name === property);
|
|
3741
|
-
if (attributeDef != null) {
|
|
3742
|
-
fieldType ??= getFieldInputTypeFromColumnType(columnType, columnDisplayType);
|
|
3743
|
-
attributeDef.fieldType = fieldType;
|
|
3744
|
-
this._table.withColumnModifiedTypeUnsafe(property, columnType, columnDisplayType);
|
|
3745
|
-
this._editEditor.withFieldModifiedTypeUnsafe(property, fieldType);
|
|
3746
|
-
this._addEditor.withFieldModifiedTypeUnsafe(property, fieldType);
|
|
3747
|
-
this._detailsEditor.withFieldModifiedTypeUnsafe(property, fieldType);
|
|
3748
|
-
}
|
|
3844
|
+
localizedUnsafe(property, model, localeProperty) {
|
|
3845
|
+
this._isLocalized = true;
|
|
3846
|
+
this._table.withLocalizationLocaleProperty(localeProperty);
|
|
3847
|
+
this.detailsEditor.localizedUnsafe(property, model, localeProperty);
|
|
3848
|
+
this.addEditor.localizedUnsafe(property, model, localeProperty);
|
|
3849
|
+
this.editEditor.localizedUnsafe(property, model, localeProperty);
|
|
3749
3850
|
return this;
|
|
3750
3851
|
}
|
|
3852
|
+
}
|
|
3853
|
+
class TableviewDynamicDescriptorInt extends TableviewDescriptorInst {
|
|
3854
|
+
constructor(model) {
|
|
3855
|
+
super(model);
|
|
3856
|
+
this._table = new TableDynamicDescriptorInst(this.model);
|
|
3857
|
+
this._tableTitle = undefined;
|
|
3858
|
+
}
|
|
3859
|
+
get table() {
|
|
3860
|
+
return this._table;
|
|
3861
|
+
}
|
|
3751
3862
|
/**
|
|
3752
|
-
*
|
|
3753
|
-
*
|
|
3754
|
-
* @param property property name
|
|
3755
|
-
* @param enumDesc type of enum
|
|
3756
|
-
* @param fieldType type of field, optional, default is Text
|
|
3863
|
+
* sets custom table descriptor
|
|
3864
|
+
* @param descriptor
|
|
3757
3865
|
*/
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
}
|
|
3761
|
-
withModifiedEnumUnsafe(property, enumDesc, fieldType) {
|
|
3762
|
-
if (!this.model.type) {
|
|
3763
|
-
throw new CommonsInternalError(`withModifiedEnum cannot be executed for property ${property}: Model type is not defined.`);
|
|
3764
|
-
}
|
|
3765
|
-
const attributeDef = getTableviewClassAttributeDef(this.model.type).find(attr => attr.name === property);
|
|
3766
|
-
if (attributeDef != null) {
|
|
3767
|
-
attributeDef.fieldType = fieldType ?? FieldInputTypeEnum.Text;
|
|
3768
|
-
this._table.withColumnModifiedEnumUnsafe(property, enumDesc);
|
|
3769
|
-
this._editEditor.withFieldModifiedEnumUnsafe(property, enumDesc);
|
|
3770
|
-
this._detailsEditor.withFieldModifiedEnumUnsafe(property, enumDesc);
|
|
3771
|
-
this._addEditor.withFieldModifiedEnumUnsafe(property, enumDesc);
|
|
3772
|
-
}
|
|
3866
|
+
withTableDescriptor(descriptor) {
|
|
3867
|
+
this._table = descriptor;
|
|
3773
3868
|
return this;
|
|
3774
3869
|
}
|
|
3775
3870
|
/**
|
|
3776
|
-
*
|
|
3777
|
-
*
|
|
3778
|
-
* @param property property
|
|
3779
|
-
* @param type class type of object
|
|
3780
|
-
* @param titleProperty
|
|
3781
|
-
* @param lookupProvider
|
|
3782
|
-
* @param optionsLabelProperty
|
|
3783
|
-
* @param filterProperty
|
|
3871
|
+
* sets visibility hidden state to column with given property
|
|
3872
|
+
* equals to be removing in auto and base tableview descriptor
|
|
3873
|
+
* * @param property column's property
|
|
3784
3874
|
*/
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
}
|
|
3788
|
-
withModifiedLookupUnsafe(property, type, lookupProvider, titleProperty, optionsLabelProperty, filterProperty) {
|
|
3789
|
-
if (!this.model.type) {
|
|
3790
|
-
throw new CommonsInternalError(`withModifiedLookup cannot be executed for property ${property}: Model type is not defined.`);
|
|
3791
|
-
}
|
|
3792
|
-
const attributeDef = getTableviewClassAttributeDef(this.model.type).find(attr => attr.name === property);
|
|
3793
|
-
if (attributeDef != null) {
|
|
3794
|
-
type ??= attributeDef.classType ?? TypeRegistry.get().findType(attributeDef.type);
|
|
3795
|
-
titleProperty ??= type ? findClassTitleAttribute(type) ?? undefined : undefined;
|
|
3796
|
-
optionsLabelProperty ??= titleProperty;
|
|
3797
|
-
attributeDef.columnType = ColumnTypeEnum.String;
|
|
3798
|
-
attributeDef.fieldType = FieldInputTypeEnum.Text;
|
|
3799
|
-
if (lookupProvider != null) {
|
|
3800
|
-
this._table.withColumnModifiedLookupUnsafe(property, lookupProvider, optionsLabelProperty, filterProperty);
|
|
3801
|
-
this._addEditor.withFieldModifiedLookupWithProviderUnsafe(property, lookupProvider, optionsLabelProperty);
|
|
3802
|
-
this._detailsEditor.withFieldModifiedLookupWithProviderUnsafe(property, lookupProvider, optionsLabelProperty);
|
|
3803
|
-
this._editEditor.withFieldModifiedLookupWithProviderUnsafe(property, lookupProvider, optionsLabelProperty);
|
|
3804
|
-
}
|
|
3805
|
-
else {
|
|
3806
|
-
const column = this._table.getColumnUnsafe(property) ?? this.addColumnUnsafe(property);
|
|
3807
|
-
if (titleProperty) {
|
|
3808
|
-
column.withGetter(value => value?.[titleProperty]);
|
|
3809
|
-
}
|
|
3810
|
-
}
|
|
3811
|
-
}
|
|
3875
|
+
removeColumn(property) {
|
|
3876
|
+
this._table.removeColumn(property);
|
|
3812
3877
|
return this;
|
|
3813
3878
|
}
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
localizedUnsafe(property, model, localeProperty) {
|
|
3818
|
-
this._isLocalized = true;
|
|
3819
|
-
this._table.withLocalizationLocaleProperty(localeProperty);
|
|
3820
|
-
this.detailsEditor.localizedUnsafe(property, model, localeProperty);
|
|
3821
|
-
this.addEditor.localizedUnsafe(property, model, localeProperty);
|
|
3822
|
-
this.editEditor.localizedUnsafe(property, model, localeProperty);
|
|
3879
|
+
withEntityForTranslations(i18nBaseKey) {
|
|
3880
|
+
this._table.model.withI18nBase(i18nBaseKey);
|
|
3881
|
+
this._detailsEditor.model.withI18nBase(i18nBaseKey);
|
|
3823
3882
|
return this;
|
|
3824
3883
|
}
|
|
3884
|
+
/**
|
|
3885
|
+
* creates deep copy of tableview object and its children
|
|
3886
|
+
*/
|
|
3887
|
+
copy() {
|
|
3888
|
+
const descriptor = new TableviewDynamicDescriptorInt(this.model.copy());
|
|
3889
|
+
descriptor._table = this._table.copy();
|
|
3890
|
+
descriptor._tableTitle = this._tableTitle;
|
|
3891
|
+
return descriptor;
|
|
3892
|
+
}
|
|
3825
3893
|
}
|
|
3894
|
+
|
|
3826
3895
|
class TableviewDescriptor extends TableviewDescriptorInst {
|
|
3827
3896
|
constructor() {
|
|
3828
3897
|
super(ModelDescriptor.create());
|
|
@@ -3843,12 +3912,12 @@ class TableviewDescriptor extends TableviewDescriptorInst {
|
|
|
3843
3912
|
* @param titleProperty
|
|
3844
3913
|
*/
|
|
3845
3914
|
static fromClassWithAutoAttrsDef(type, idProperty, titleProperty) {
|
|
3846
|
-
const
|
|
3847
|
-
const
|
|
3848
|
-
descriptor.withTableDescriptor(
|
|
3849
|
-
descriptor.withEditDescriptor(
|
|
3850
|
-
descriptor.withDetailsDescriptor(
|
|
3851
|
-
descriptor.withAddDescriptor(
|
|
3915
|
+
const descriptor = tableviewDescriptor(model(type, { id: idProperty, title: titleProperty }));
|
|
3916
|
+
const optsBase = { id: idProperty, title: titleProperty };
|
|
3917
|
+
descriptor.withTableDescriptor(tableDescriptorFromClassAttrsDef(type, undefined, optsBase));
|
|
3918
|
+
descriptor.withEditDescriptor(editorDescriptorFromClassAttrsDef(type, undefined, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Edit }));
|
|
3919
|
+
descriptor.withDetailsDescriptor(editorDescriptorFromClassAttrsDef(type, undefined, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Details }).withDisabled());
|
|
3920
|
+
descriptor.withAddDescriptor(editorDescriptorFromClassAttrsDef(type, undefined, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Add }));
|
|
3852
3921
|
return descriptor;
|
|
3853
3922
|
}
|
|
3854
3923
|
/**
|
|
@@ -3860,74 +3929,111 @@ class TableviewDescriptor extends TableviewDescriptorInst {
|
|
|
3860
3929
|
* @param titleProperty
|
|
3861
3930
|
*/
|
|
3862
3931
|
static fromClassWithCustomAttrsDef(type, columnAttributes, fieldAttributes, idProperty, titleProperty) {
|
|
3863
|
-
const
|
|
3864
|
-
descriptor
|
|
3932
|
+
const optsBase = { id: idProperty, title: titleProperty };
|
|
3933
|
+
const descriptor = tableviewDescriptor(model(type, optsBase));
|
|
3934
|
+
descriptor.withTableDescriptor(tableDescriptorFromClassAttrsDef(type, columnAttributes, optsBase));
|
|
3865
3935
|
if (fieldAttributes !== null) {
|
|
3866
|
-
descriptor.withEditDescriptor(
|
|
3867
|
-
descriptor.withDetailsDescriptor(
|
|
3868
|
-
descriptor.withAddDescriptor(
|
|
3936
|
+
descriptor.withEditDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Edit }));
|
|
3937
|
+
descriptor.withDetailsDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Details }));
|
|
3938
|
+
descriptor.withAddDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...optsBase, tableviewEditorType: TableviewEditorTypeEnum.Add }));
|
|
3869
3939
|
}
|
|
3870
3940
|
return descriptor;
|
|
3871
3941
|
}
|
|
3872
3942
|
}
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
this._table = TableDynamicDescriptor.fromModel(this.model);
|
|
3877
|
-
this._tableTitle = undefined;
|
|
3878
|
-
}
|
|
3879
|
-
get table() {
|
|
3880
|
-
return this._table;
|
|
3881
|
-
}
|
|
3882
|
-
/**
|
|
3883
|
-
* sets custom table descriptor
|
|
3884
|
-
* @param descriptor
|
|
3885
|
-
*/
|
|
3886
|
-
withTableDescriptor(descriptor) {
|
|
3887
|
-
this._table = descriptor;
|
|
3888
|
-
return this;
|
|
3943
|
+
function tableviewDescriptor(typeOrModelOrClassOrOpts, opts) {
|
|
3944
|
+
if (typeOrModelOrClassOrOpts == null) {
|
|
3945
|
+
return new TableviewDescriptorInst(model());
|
|
3889
3946
|
}
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
* equals to be removing in auto and base tableview descriptor
|
|
3893
|
-
* * @param property column's property
|
|
3894
|
-
*/
|
|
3895
|
-
removeColumn(property) {
|
|
3896
|
-
this._table.removeColumn(property);
|
|
3897
|
-
return this;
|
|
3947
|
+
else if (typeOrModelOrClassOrOpts instanceof TypeDescriptor) {
|
|
3948
|
+
return new TableviewDescriptorInst(model(opts ?? {}));
|
|
3898
3949
|
}
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
this._detailsEditor.model.withI18nBase(i18nBaseKey);
|
|
3902
|
-
return this;
|
|
3950
|
+
else if (typeOrModelOrClassOrOpts instanceof ModelDescriptor) {
|
|
3951
|
+
return new TableviewDescriptorInst(typeOrModelOrClassOrOpts);
|
|
3903
3952
|
}
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
copy() {
|
|
3908
|
-
const descriptor = new TableviewDynamicDescriptorInt(this.model.copy());
|
|
3909
|
-
descriptor._table = this._table.copy();
|
|
3910
|
-
descriptor._tableTitle = this._tableTitle;
|
|
3911
|
-
return descriptor;
|
|
3953
|
+
else {
|
|
3954
|
+
// this could have autoGenerated if model descriptor is class
|
|
3955
|
+
return new TableviewDescriptorInst(model(typeOrModelOrClassOrOpts));
|
|
3912
3956
|
}
|
|
3913
3957
|
}
|
|
3958
|
+
function tableviewDescriptorFromClass(type, opts) {
|
|
3959
|
+
return new TableviewDescriptorInst(model(type, opts));
|
|
3960
|
+
}
|
|
3961
|
+
/**
|
|
3962
|
+
* generates descriptor based on type attribute definition
|
|
3963
|
+
* @param type class type
|
|
3964
|
+
* @param columnAttributes
|
|
3965
|
+
* @param fieldAttributes
|
|
3966
|
+
* @param opts
|
|
3967
|
+
*/
|
|
3968
|
+
function tableviewDescriptorFromClassAttrsDef(type, columnAttributes, fieldAttributes, opts) {
|
|
3969
|
+
const model = new ModelDescriptor(type, opts?.id, opts?.title, opts?.i18nBase);
|
|
3970
|
+
const descriptor = new TableviewDescriptorInst(model);
|
|
3971
|
+
descriptor.withTableDescriptor(tableDescriptorFromClassAttrsDef(type, columnAttributes, opts));
|
|
3972
|
+
if (fieldAttributes !== null) {
|
|
3973
|
+
descriptor.withEditDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...opts, tableviewEditorType: TableviewEditorTypeEnum.Edit }));
|
|
3974
|
+
descriptor.withDetailsDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...opts, tableviewEditorType: TableviewEditorTypeEnum.Details }).withDisabled());
|
|
3975
|
+
descriptor.withAddDescriptor(editorDescriptorFromClassAttrsDef(type, fieldAttributes ?? columnAttributes, { ...opts, tableviewEditorType: TableviewEditorTypeEnum.Add }));
|
|
3976
|
+
}
|
|
3977
|
+
return descriptor;
|
|
3978
|
+
}
|
|
3979
|
+
function tableviewDescriptorFromParent(descriptor, classOrType, idProperty, titleProperty, i18nBaseKey) {
|
|
3980
|
+
return classOrType instanceof ModelDescriptor
|
|
3981
|
+
? new TableviewDescriptorInst(classOrType)
|
|
3982
|
+
: new TableviewDescriptorInst(model(classOrType, { id: idProperty, title: titleProperty, i18nBase: i18nBaseKey }));
|
|
3983
|
+
}
|
|
3914
3984
|
class TableviewDynamicDescriptor extends TableviewDynamicDescriptorInt {
|
|
3915
3985
|
constructor() {
|
|
3916
3986
|
super(ModelDescriptor.create());
|
|
3917
3987
|
}
|
|
3918
3988
|
static create(idProperty, titleProperty, i18nBaseKey) {
|
|
3919
|
-
return
|
|
3989
|
+
return tableviewDynamicDescriptor({ id: idProperty, title: titleProperty, i18nBase: i18nBaseKey });
|
|
3920
3990
|
}
|
|
3921
3991
|
static fromModel(model) {
|
|
3922
|
-
return
|
|
3992
|
+
return tableviewDynamicDescriptor(model);
|
|
3993
|
+
}
|
|
3994
|
+
}
|
|
3995
|
+
function tableviewDynamicDescriptor(modelOrOpts) {
|
|
3996
|
+
return modelOrOpts instanceof ModelDescriptor
|
|
3997
|
+
? new TableviewDynamicDescriptorInt(modelOrOpts)
|
|
3998
|
+
: new TableviewDynamicDescriptorInt(new ModelDescriptor(undefined, modelOrOpts?.id, modelOrOpts?.title, modelOrOpts?.i18nBase));
|
|
3999
|
+
}
|
|
4000
|
+
|
|
4001
|
+
function expandClassAttributeDefWithTableviewDef(attributes) {
|
|
4002
|
+
if (!attributes) {
|
|
4003
|
+
throw new CommonsInternalError('Class attribute definition is null, problem with TypeRegistry::findAttributesDefinitionByClassType?', { name: 'TableviewUtilsError' });
|
|
4004
|
+
}
|
|
4005
|
+
const typeRegistry = TypeRegistry.get();
|
|
4006
|
+
const tableClassAttributeDef = [];
|
|
4007
|
+
for (const attribute of attributes) {
|
|
4008
|
+
const enumType = typeRegistry.findEnum(attribute.type);
|
|
4009
|
+
const columnType = enumType ? ColumnTypeEnum.Enum : getColumnTypeFromClassAttributeDefType(attribute.type);
|
|
4010
|
+
tableClassAttributeDef.push({
|
|
4011
|
+
name: attribute.name,
|
|
4012
|
+
baseName: attribute.baseName,
|
|
4013
|
+
type: attribute.type,
|
|
4014
|
+
subtype: attribute.subtype,
|
|
4015
|
+
columnType: enumType ? ColumnTypeEnum.Enum : getColumnTypeFromClassAttributeDefType(attribute.type),
|
|
4016
|
+
columnDisplayType: getColumnDisplayTypeFromColumnType(columnType, attribute.type),
|
|
4017
|
+
fieldType: getFieldInputTypeFromClassAttributeDefType(attribute.type),
|
|
4018
|
+
enumType: typeRegistry.findEnum(attribute.type),
|
|
4019
|
+
classType: typeRegistry.findType(attribute.type)
|
|
4020
|
+
});
|
|
3923
4021
|
}
|
|
4022
|
+
return tableClassAttributeDef;
|
|
4023
|
+
}
|
|
4024
|
+
/**
|
|
4025
|
+
* returns attributes from class type and extends to typed def with column and field enum type
|
|
4026
|
+
* @param type class type
|
|
4027
|
+
*/
|
|
4028
|
+
function getTableviewClassAttributeDef(type) {
|
|
4029
|
+
return expandClassAttributeDefWithTableviewDef(TypeRegistry.get().findAttributesDefinitionByClassType(type));
|
|
3924
4030
|
}
|
|
3925
4031
|
|
|
3926
4032
|
function convertDataToStringWithDelimiter(data, delimiter, descriptor, translate) {
|
|
3927
4033
|
const replaceNullValue = (key, value) => (value === null ? '' : value);
|
|
3928
4034
|
const getterPipe = new GetterPipe();
|
|
3929
4035
|
return [
|
|
3930
|
-
descriptor.table.columns.map(col => translate.instant(descriptor.model.
|
|
4036
|
+
descriptor.table.columns.map(col => translate.instant(descriptor.model.i18nBaseKey + '.properties.' + col.property)).join(delimiter),
|
|
3931
4037
|
...data.map((row) => descriptor.table.columns
|
|
3932
4038
|
.map(column => {
|
|
3933
4039
|
if (typeof column.getter === 'function') {
|
|
@@ -4037,34 +4143,50 @@ function getRouteData(injector) {
|
|
|
4037
4143
|
}
|
|
4038
4144
|
function tableviewDetailsAction(descriptor, injector) {
|
|
4039
4145
|
const routeData = getRouteData(injector);
|
|
4040
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasDetails ?
|
|
4146
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasDetails ? new ActionEditorDetailsDescriptorInst(descriptor) : null;
|
|
4041
4147
|
}
|
|
4042
4148
|
function tableviewDetailsActionWithProvider(descriptor, serviceProvider, injector) {
|
|
4043
4149
|
const routeData = getRouteData(injector);
|
|
4044
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasDetails
|
|
4150
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasDetails
|
|
4151
|
+
? new ActionEditorDetailsDescriptorInst(descriptor, {
|
|
4152
|
+
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
4153
|
+
})
|
|
4154
|
+
: null;
|
|
4045
4155
|
}
|
|
4046
4156
|
function tableviewAddAction(descriptor, injector) {
|
|
4047
4157
|
const routeData = getRouteData(injector);
|
|
4048
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasAdd ?
|
|
4158
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasAdd ? new ActionEditorAddDescriptorInst(descriptor) : null;
|
|
4049
4159
|
}
|
|
4050
4160
|
function tableviewAddActionWithProvider(descriptor, serviceProvider, injector) {
|
|
4051
4161
|
const routeData = getRouteData(injector);
|
|
4052
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasAdd
|
|
4162
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasAdd
|
|
4163
|
+
? new ActionEditorAddDescriptorInst(descriptor, {
|
|
4164
|
+
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
4165
|
+
})
|
|
4166
|
+
: null;
|
|
4053
4167
|
}
|
|
4054
4168
|
function tableviewEditAction(descriptor, injector) {
|
|
4055
4169
|
const routeData = getRouteData(injector);
|
|
4056
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasEdit ?
|
|
4170
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasEdit ? new ActionEditorEditDescriptorInst(descriptor) : null;
|
|
4057
4171
|
}
|
|
4058
4172
|
function tableviewEditActionWithProvider(descriptor, serviceProvider, injector) {
|
|
4059
4173
|
const routeData = getRouteData(injector);
|
|
4060
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasEdit
|
|
4174
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasEdit
|
|
4175
|
+
? new ActionEditorEditDescriptorInst(descriptor, {
|
|
4176
|
+
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
4177
|
+
})
|
|
4178
|
+
: null;
|
|
4061
4179
|
}
|
|
4062
4180
|
function tableviewEditOnDetailsAction(descriptor, editDescriptor, injector) {
|
|
4063
4181
|
const routeData = getRouteData(injector);
|
|
4064
4182
|
if (routeData?.tableviewActions && !routeData.tableviewActions.hasEdit) {
|
|
4065
4183
|
return null;
|
|
4066
4184
|
}
|
|
4067
|
-
const action = editDescriptor
|
|
4185
|
+
const action = editDescriptor
|
|
4186
|
+
? actionLinkFromAction(editDescriptor)
|
|
4187
|
+
: new ActionLinkDescriptorInst(ActionEditorEditDescriptorInst.ACTION_NAME, {
|
|
4188
|
+
model: descriptor
|
|
4189
|
+
});
|
|
4068
4190
|
action
|
|
4069
4191
|
.withTableviewCategory(TableviewActionDefaultCategories.EDIT)
|
|
4070
4192
|
.withPositionTableviewCategories([TableviewActionDefaultCategories.DETAILS])
|
|
@@ -4080,11 +4202,15 @@ function tableviewEditOnDetailsAction(descriptor, editDescriptor, injector) {
|
|
|
4080
4202
|
}
|
|
4081
4203
|
function tableviewDeleteAction(descriptor, injector) {
|
|
4082
4204
|
const routeData = getRouteData(injector);
|
|
4083
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasDelete ?
|
|
4205
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasDelete ? new ActionDeleteDescriptorInst(descriptor) : null;
|
|
4084
4206
|
}
|
|
4085
4207
|
function tableviewDeleteActionWithProvider(descriptor, serviceProvider, injector) {
|
|
4086
4208
|
const routeData = getRouteData(injector);
|
|
4087
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasDelete
|
|
4209
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasDelete
|
|
4210
|
+
? new ActionDeleteDescriptorInst(descriptor, {
|
|
4211
|
+
...actionGetProviderCfgObj(serviceProvider)
|
|
4212
|
+
})
|
|
4213
|
+
: null;
|
|
4088
4214
|
}
|
|
4089
4215
|
function tableviewDeleteOnDetailsAction(model, injector) {
|
|
4090
4216
|
const action = tableviewDeleteAction(model, injector);
|
|
@@ -4107,7 +4233,9 @@ function tableviewDeleteOnDetailsAction(model, injector) {
|
|
|
4107
4233
|
return null;
|
|
4108
4234
|
}
|
|
4109
4235
|
function tableviewExportAction(descriptor, injector, defaultActions) {
|
|
4110
|
-
const exportAction =
|
|
4236
|
+
const exportAction = new ActionDescriptorInst('export', {
|
|
4237
|
+
model: descriptor.model
|
|
4238
|
+
})
|
|
4111
4239
|
.withButtonDescriptor(new ActionButtonDescriptor().withIcon('pi pi-download'))
|
|
4112
4240
|
.withSubactionsAsMenu();
|
|
4113
4241
|
const subactions = [];
|
|
@@ -4120,7 +4248,9 @@ function tableviewExportAction(descriptor, injector, defaultActions) {
|
|
|
4120
4248
|
}
|
|
4121
4249
|
function tableviewExportJsonAction(descriptor, injector) {
|
|
4122
4250
|
const dataProviderExecutor = getInjector(injector)?.get(DataProviderExecutor);
|
|
4123
|
-
return
|
|
4251
|
+
return new ActionDescriptorInst('exportJson', {
|
|
4252
|
+
model: descriptor.model
|
|
4253
|
+
})
|
|
4124
4254
|
.withRunFunction(ctx => {
|
|
4125
4255
|
const params = ctx.parameters.dataListParams ? copyDataListParams(ctx.parameters.dataListParams) : {};
|
|
4126
4256
|
params.offset = 0;
|
|
@@ -4140,7 +4270,9 @@ function tableviewExportJsonAction(descriptor, injector) {
|
|
|
4140
4270
|
}
|
|
4141
4271
|
function tableviewExportCsvAction(descriptor, injector) {
|
|
4142
4272
|
const dataProviderExecutor = getInjector(injector)?.get(DataProviderExecutor);
|
|
4143
|
-
return
|
|
4273
|
+
return new ActionDescriptorInst('exportCsv', {
|
|
4274
|
+
model: descriptor.model
|
|
4275
|
+
})
|
|
4144
4276
|
.withRunFunction(ctx => {
|
|
4145
4277
|
const params = ctx.parameters.dataListParams ? copyDataListParams(ctx.parameters.dataListParams) : {};
|
|
4146
4278
|
params.offset = 0;
|
|
@@ -4164,7 +4296,9 @@ function tableviewExportCsvAction(descriptor, injector) {
|
|
|
4164
4296
|
.withPosition(ActionPositionEnum.ToolbarRight);
|
|
4165
4297
|
}
|
|
4166
4298
|
function tableviewRefreshAction(descriptor) {
|
|
4167
|
-
const action =
|
|
4299
|
+
const action = new ActionDescriptorInst('refresh', {
|
|
4300
|
+
model: descriptor
|
|
4301
|
+
})
|
|
4168
4302
|
.withPosition(ActionPositionEnum.ToolbarRight)
|
|
4169
4303
|
.withTableviewCategory(TableviewActionDefaultCategories.READ)
|
|
4170
4304
|
.withRunNotificationSuccess(undefined, undefined, false)
|
|
@@ -4177,7 +4311,11 @@ function tableviewRefreshAction(descriptor) {
|
|
|
4177
4311
|
}
|
|
4178
4312
|
function tableviewLocalizationLanguageSelectAction(descriptor) {
|
|
4179
4313
|
return descriptor.isLocalized()
|
|
4180
|
-
?
|
|
4314
|
+
? new ActionDescriptorInst('translator', {
|
|
4315
|
+
model: descriptor.model
|
|
4316
|
+
})
|
|
4317
|
+
.withPosition(ActionPositionEnum.ToolbarLeft)
|
|
4318
|
+
.withComponentFromDi(DATA_LANGUAGE_DROPDOWN_COMPONENT_IT)
|
|
4181
4319
|
: null;
|
|
4182
4320
|
}
|
|
4183
4321
|
|
|
@@ -4326,7 +4464,7 @@ class TableviewInputBuilder {
|
|
|
4326
4464
|
* Builds and returns an instance of ITableview.
|
|
4327
4465
|
* DO NOT CALL this within tableview create callback function!
|
|
4328
4466
|
*
|
|
4329
|
-
* @return {
|
|
4467
|
+
* @return {TableviewInput<Model, Service, Sorts, Filters, Descriptor, DataProvider>} - The built ITableview instance.
|
|
4330
4468
|
*/
|
|
4331
4469
|
build() {
|
|
4332
4470
|
return {
|
|
@@ -4352,21 +4490,124 @@ class TableviewInputBuilder {
|
|
|
4352
4490
|
* @returns A tableview instance with descriptor, data provider and actions.
|
|
4353
4491
|
*/
|
|
4354
4492
|
function tableview(model, service, buildFn) {
|
|
4355
|
-
const builder = new TableviewInputBuilder(
|
|
4493
|
+
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model), new TableviewDataProviderInst(undefined, service), inject(Injector));
|
|
4356
4494
|
buildFn?.(builder);
|
|
4357
4495
|
return builder.build();
|
|
4358
4496
|
}
|
|
4359
4497
|
function tableviewWithSortAndFilter(model, service, sorts, filters, buildFn) {
|
|
4360
|
-
const builder = new TableviewInputBuilder(
|
|
4498
|
+
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model), new TableviewDataProviderInst(undefined, service), inject(Injector));
|
|
4361
4499
|
buildFn?.(builder);
|
|
4362
4500
|
return builder.build();
|
|
4363
4501
|
}
|
|
4364
4502
|
|
|
4503
|
+
/**
|
|
4504
|
+
* creates column and field with custom type, for example currency
|
|
4505
|
+
* if field exists, it is replaced
|
|
4506
|
+
* DO NOT USE WITH TYPES WHERE ARGS ARE REQUIRED - ERROR WILL BE THROWN
|
|
4507
|
+
* for enum use withEnumType
|
|
4508
|
+
* for custom class use withClassType
|
|
4509
|
+
* @param descriptor Tableview descriptor
|
|
4510
|
+
* @param property name of field
|
|
4511
|
+
* @param columnType required column type
|
|
4512
|
+
* @param fieldType optional, if not provided it is converted from column type
|
|
4513
|
+
* @param columnDisplayType optional
|
|
4514
|
+
*/
|
|
4515
|
+
function modifyTableviewClassAttributeType(descriptor, property, columnType, fieldType, columnDisplayType) {
|
|
4516
|
+
return modifyTableviewClassAttributeTypeUnsafe(descriptor, property, columnType, fieldType, columnDisplayType);
|
|
4517
|
+
}
|
|
4518
|
+
function modifyTableviewClassAttributeTypeUnsafe(descriptor, property, columnType, fieldType, columnDisplayType) {
|
|
4519
|
+
if (!descriptor.model.type) {
|
|
4520
|
+
throw new CommonsInternalError(`withModifiedType cannot be executed for property ${property}: Model type is not defined.`);
|
|
4521
|
+
}
|
|
4522
|
+
if (columnType === ColumnTypeEnum.Enum) {
|
|
4523
|
+
throw new CommonsInternalError('Do not use with types where args are required', { name: 'TableviewDescriptorError' });
|
|
4524
|
+
}
|
|
4525
|
+
const attributeDef = getTableviewClassAttributeDef(descriptor.model.type).find(attr => attr.name === property);
|
|
4526
|
+
if (attributeDef != null) {
|
|
4527
|
+
fieldType ??= getFieldInputTypeFromColumnType(columnType, columnDisplayType);
|
|
4528
|
+
attributeDef.fieldType = fieldType;
|
|
4529
|
+
modifyTableClassAttributeColumnTypeUnsafe(descriptor.table, property, columnType, columnDisplayType);
|
|
4530
|
+
modifyEditorClassAttributeFieldTypeUnsafe(descriptor.editEditor, property, fieldType);
|
|
4531
|
+
modifyEditorClassAttributeFieldTypeUnsafe(descriptor.addEditor, property, fieldType);
|
|
4532
|
+
modifyEditorClassAttributeFieldTypeUnsafe(descriptor.detailsEditor, property, fieldType);
|
|
4533
|
+
return true;
|
|
4534
|
+
}
|
|
4535
|
+
return false;
|
|
4536
|
+
}
|
|
4537
|
+
/**
|
|
4538
|
+
* creates column with enum type
|
|
4539
|
+
* if fields exists, it is replaced
|
|
4540
|
+
* @param descriptor Tableview descriptor
|
|
4541
|
+
* @param property property name
|
|
4542
|
+
* @param enumDesc type of enum
|
|
4543
|
+
* @param fieldType type of field, optional, default is Text
|
|
4544
|
+
*/
|
|
4545
|
+
function modifyTableviewClassAttributeEnum(descriptor, property, enumDesc, fieldType) {
|
|
4546
|
+
return modifyTableviewClassAttributeEnumUnsafe(descriptor, property, enumDesc, fieldType);
|
|
4547
|
+
}
|
|
4548
|
+
function modifyTableviewClassAttributeEnumUnsafe(descriptor, property, enumDesc, fieldType) {
|
|
4549
|
+
if (!descriptor.model.type) {
|
|
4550
|
+
throw new CommonsInternalError(`withModifiedEnum cannot be executed for property ${property}: Model type is not defined.`);
|
|
4551
|
+
}
|
|
4552
|
+
const attributeDef = getTableviewClassAttributeDef(descriptor.model.type).find(attr => attr.name === property);
|
|
4553
|
+
if (attributeDef != null) {
|
|
4554
|
+
attributeDef.fieldType = fieldType ?? FieldInputTypeEnum.Text;
|
|
4555
|
+
tableDescriptorModifyEnumColumnUnsafe(descriptor.table, property, enumDesc);
|
|
4556
|
+
modifyEditorClassAttributeFieldEnumUnsafe(descriptor.editEditor, property, enumDesc);
|
|
4557
|
+
modifyEditorClassAttributeFieldEnumUnsafe(descriptor.addEditor, property, enumDesc);
|
|
4558
|
+
modifyEditorClassAttributeFieldEnumUnsafe(descriptor.detailsEditor, property, enumDesc);
|
|
4559
|
+
return true;
|
|
4560
|
+
}
|
|
4561
|
+
return false;
|
|
4562
|
+
}
|
|
4563
|
+
/**
|
|
4564
|
+
* generates column with custom class type
|
|
4565
|
+
* field is generated only if lookupProvider is provided
|
|
4566
|
+
* @param descriptor Tableview descriptor
|
|
4567
|
+
* @param property property name
|
|
4568
|
+
* @param type class type of object
|
|
4569
|
+
* @param titleProperty
|
|
4570
|
+
* @param lookupProvider
|
|
4571
|
+
* @param optionsLabelProperty
|
|
4572
|
+
* @param filterProperty
|
|
4573
|
+
*/
|
|
4574
|
+
function modifyTableviewLookup(descriptor, property, type, lookupProvider, titleProperty, optionsLabelProperty, filterProperty) {
|
|
4575
|
+
return modifyTableviewLookupUnsafe(descriptor, property, type, lookupProvider, titleProperty, optionsLabelProperty, filterProperty);
|
|
4576
|
+
}
|
|
4577
|
+
function modifyTableviewLookupUnsafe(descriptor, property, type, lookupProvider, titleProperty, optionsLabelProperty, filterProperty) {
|
|
4578
|
+
if (!descriptor.model.type) {
|
|
4579
|
+
throw new CommonsInternalError(`withModifiedLookup cannot be executed for property ${property}: Model type is not defined.`);
|
|
4580
|
+
}
|
|
4581
|
+
const attributeDef = getTableviewClassAttributeDef(descriptor.model.type).find(attr => attr.name === property);
|
|
4582
|
+
if (attributeDef != null) {
|
|
4583
|
+
type ??= attributeDef.classType ?? TypeRegistry.get().findType(attributeDef.type);
|
|
4584
|
+
titleProperty ??= type ? findClassTitleAttribute(type) ?? undefined : undefined;
|
|
4585
|
+
optionsLabelProperty ??= titleProperty;
|
|
4586
|
+
attributeDef.columnType = ColumnTypeEnum.String;
|
|
4587
|
+
attributeDef.fieldType = FieldInputTypeEnum.Text;
|
|
4588
|
+
if (lookupProvider != null) {
|
|
4589
|
+
modifyTableColumnFilterLookupUnsafe(descriptor.table, property, lookupProvider, optionsLabelProperty, filterProperty);
|
|
4590
|
+
modifyEditorFieldLookupUnsafe(descriptor.addEditor, property, lookupProvider, optionsLabelProperty);
|
|
4591
|
+
modifyEditorFieldLookupUnsafe(descriptor.detailsEditor, property, lookupProvider, optionsLabelProperty);
|
|
4592
|
+
modifyEditorFieldLookupUnsafe(descriptor.editEditor, property, lookupProvider, optionsLabelProperty);
|
|
4593
|
+
return true;
|
|
4594
|
+
}
|
|
4595
|
+
else {
|
|
4596
|
+
const column = descriptor.table.getColumnUnsafe(property) ?? descriptor.addColumnUnsafe(property);
|
|
4597
|
+
if (titleProperty) {
|
|
4598
|
+
column.withGetter(value => value?.[titleProperty]);
|
|
4599
|
+
}
|
|
4600
|
+
return true;
|
|
4601
|
+
}
|
|
4602
|
+
}
|
|
4603
|
+
return false;
|
|
4604
|
+
}
|
|
4605
|
+
|
|
4365
4606
|
// action descriptors
|
|
4366
4607
|
|
|
4367
4608
|
/**
|
|
4368
4609
|
* Generated bundle index. Do not edit.
|
|
4369
4610
|
*/
|
|
4370
4611
|
|
|
4371
|
-
export { AFieldDescriptor, AFieldGroupDescriptor, AFormlyCustomFieldComponent, AGenericFieldDescriptor, ActionActivationTriggerEnum, ActionConfirmationDescriptor, ActionDeleteDescriptor, ActionDeleteDescriptorInst, ActionDescriptor, ActionDescriptorInst, ActionEditorAddDescriptor, ActionEditorAddDescriptorInst, ActionEditorDescriptor, ActionEditorDescriptorInst, ActionEditorDetailsDescriptor, ActionEditorDetailsDescriptorInst, ActionEditorEditDescriptor, ActionEditorEditDescriptorInst,
|
|
4612
|
+
export { AFieldDescriptor, AFieldGroupDescriptor, AFormlyCustomFieldComponent, AGenericFieldDescriptor, ActionActivationTriggerEnum, ActionConfirmationDescriptor, ActionDeleteDescriptor, ActionDeleteDescriptorInst, ActionDescriptor, ActionDescriptorInst, ActionEditorAddDescriptor, ActionEditorAddDescriptorInst, ActionEditorDescriptor, ActionEditorDescriptorInst, ActionEditorDetailsDescriptor, ActionEditorDetailsDescriptorInst, ActionEditorEditDescriptor, ActionEditorEditDescriptorInst, ActionEditorSubmitDescriptorInst, ActionEditorSubmitTypeEnum, ActionInstanceStateEnum, ActionLinkDescriptor, ActionLinkDescriptorInst, ActionPositionEnum, ActionTypeEnum, CommonsActionError, DATA_LANGUAGE_DROPDOWN_COMPONENT_IT, DataProviderExecutor, DynamicTableviewDataProvider, DynamicTableviewDataProviderInst, EDITOR_DEFAULT_GROUP_NAME, EditorDataProvider, EditorDataProviderInst, EditorDescriptor, EditorDescriptorInst, FieldActionDescriptor, FieldGroupDescriptor, FieldGroupTypeEnum, FieldInputDescriptor, FieldInputTypeEnum, FieldLookupDescriptor, FieldLookupEnumDescriptor, FieldLookupTypeEnum, FieldManyEditorActionEnum, FieldManyEditorDescriptor, FieldManyEditorTypeEnum, FieldManyToManyEditorActionEnum, FieldManyToManyEditorDescriptor, FieldManyToManyEditorTypeEnum, FieldSizeEnum, FieldTabGroupDescriptor, FieldValidationDescriptor, FormEventTypeEnum, FormFieldEventComponentSubtype, FormFieldEventDialogSubtype, FormFieldEventTypeEnum, TableviewActionDefaultCategories, TableviewDataProvider, TableviewDataProviderInst, TableviewDefaultActionsEnum, TableviewDescriptor, TableviewDescriptorInst, TableviewDynamicDescriptor, TableviewDynamicDescriptorInt, TableviewEditorTypeEnum, TableviewInputBuilder, action, actionDelete, actionEditor, actionEditorAdd, actionEditorCancel, actionEditorDetails, actionEditorEdit, actionEditorGetProviderCfgObj, actionEditorSubmit, actionFromClass, actionFromModel, actionGetProviderCfgObj, actionLink, actionLinkFromAction, actionLinkFromClass, actionLinkFromModel, actionWithProvider, convertDataToStringWithDelimiter, createTableviewAction, createTableviewActions, editorDataProvider, editorDataProviderFromClass, editorDataProviderFromModel, editorDataProviderWithService, editorDescriptor, editorDescriptorFromClass, editorDescriptorFromClassAttrsDef, emailValidationName, emailValidator, expandClassAttributeDefWithEditorDef, expandClassAttributeDefWithTableviewDef, fieldLookupGetProviderCfgObj, fieldManyToManyGetProviderCfgObj, getDataProviderService, getEditorClassAttributeDef, getFieldInputTypeFromClassAttributeDefType, getFieldInputTypeFromColumnType, getTableviewClassAttributeDef, getTableviewDefaultActions, maxDateValidationName, maxDateValidator, minDateValidationName, minDateValidator, modifyEditorClassAttributeFieldEnum, modifyEditorClassAttributeFieldEnumUnsafe, modifyEditorClassAttributeFieldType, modifyEditorClassAttributeFieldTypeUnsafe, modifyEditorFieldLookup, modifyEditorFieldLookupUnsafe, modifyTableviewClassAttributeEnum, modifyTableviewClassAttributeEnumUnsafe, modifyTableviewClassAttributeType, modifyTableviewClassAttributeTypeUnsafe, modifyTableviewLookup, modifyTableviewLookupUnsafe, runCreateFromDataProvider, runDeleteFromDataProvider, runFetchFromDataProvider, runFnFromDataProviderOrFail, runFnFromDataProviderOrFallback, runGetAllFromDataProvider, runUpdateFromDataProvider, saveFileAs, tableview, tableviewAddAction, tableviewAddActionWithProvider, tableviewDataProvider, tableviewDataProviderFromClass, tableviewDataProviderFromModel, tableviewDataProviderWithService, tableviewDeleteAction, tableviewDeleteActionWithProvider, tableviewDeleteOnDetailsAction, tableviewDescriptor, tableviewDescriptorFromClass, tableviewDescriptorFromClassAttrsDef, tableviewDescriptorFromParent, tableviewDetailsAction, tableviewDetailsActionWithProvider, tableviewDynamicDataProvider, tableviewDynamicDescriptor, tableviewEditAction, tableviewEditActionWithProvider, tableviewEditOnDetailsAction, tableviewExportAction, tableviewExportCsvAction, tableviewExportJsonAction, tableviewLocalizationLanguageSelectAction, tableviewRefreshAction, tableviewWithSortAndFilter, upsertEditorFieldFromAttributeDef };
|
|
4372
4613
|
//# sourceMappingURL=mediusinc-mng-commons-tableview-api.mjs.map
|