@mediusinc/mng-commons 5.0.0-rc.2 → 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/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 +3 -3
- package/esm2022/core/components/pages/error/error.page.component.mjs +3 -3
- package/esm2022/core/components/pages/not-found/not-found.page.component.mjs +3 -3
- package/esm2022/core/data-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 +10 -7
- package/esm2022/core/index.mjs +2 -1
- package/esm2022/core/security/permission.service.mjs +4 -2
- package/esm2022/core/services/commons-init.service.mjs +2 -2
- package/esm2022/core/services/commons-router.service.mjs +16 -15
- package/esm2022/core/services/commons.service.mjs +109 -166
- 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 +92 -83
- package/esm2022/form/components/dropdown/dropdown.component.mjs +145 -87
- 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 +6 -7
- package/esm2022/table/components/column-value/column-value.component.mjs +2 -2
- package/esm2022/table/components/table/table.component.mjs +5 -5
- package/esm2022/table/pipes/locale-default-row-class.pipe.mjs +2 -2
- package/esm2022/table/services/data-list.service.mjs +1 -1
- package/esm2022/tableview/action/components/action/action.component.mjs +140 -188
- package/esm2022/tableview/action/components/editor/action-editor.component.mjs +56 -66
- package/esm2022/tableview/action/components/editor/injector-context/action-editor-injector-context.component.mjs +119 -141
- package/esm2022/tableview/action/components/localization/data-language-dropdown.component.mjs +21 -39
- package/esm2022/tableview/action/components/route/action-route.component.mjs +17 -23
- package/esm2022/tableview/action/components/table/action-table.component.mjs +1 -1
- package/esm2022/tableview/action/services/action-executor.service.mjs +9 -9
- package/esm2022/tableview/action/services/navigation.service.mjs +3 -2
- package/esm2022/tableview/action/services/view-container.service.mjs +5 -21
- 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 +20 -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/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 +7 -133
- 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 +1 -1
- 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 +1 -1
- package/esm2022/tableview/api/editor/helpers/editor-descriptor-helpers.mjs +95 -0
- package/esm2022/tableview/api/editor/helpers/field-validators.mjs +7 -7
- 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-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 +15 -168
- 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 +16 -11
- package/esm2022/tableview/editor/components/formly/fields/formly-field-action/formly-field-action.component.mjs +6 -2
- package/esm2022/tableview/editor/components/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.mjs +10 -11
- package/esm2022/tableview/editor/components/formly/fields/formly-field-custom/formly-field-custom.component.mjs +1 -1
- package/esm2022/tableview/editor/components/formly/fields/formly-field-datepicker/formly-field-datepicker.component.mjs +4 -4
- package/esm2022/tableview/editor/components/formly/fields/formly-field-dropdown/formly-field-dropdown.component.mjs +9 -11
- package/esm2022/tableview/editor/components/formly/fields/formly-field-input/formly-field-input.component.mjs +4 -4
- package/esm2022/tableview/editor/components/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.mjs +16 -18
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +20 -22
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +18 -20
- package/esm2022/tableview/editor/helpers/editor-formly.mjs +27 -6
- package/esm2022/tableview/editor/services/form-editor.service.mjs +96 -0
- package/esm2022/tableview/index.mjs +2 -1
- package/esm2022/tableview/tableview/components/tableview/tableview.component.mjs +3 -3
- package/fesm2022/mediusinc-mng-commons-core.mjs +155 -210
- 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 +236 -169
- 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 +11 -12
- package/fesm2022/mediusinc-mng-commons-table.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs +822 -590
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview.mjs +564 -571
- 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 +31 -23
- 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 +23 -23
- package/tableview/action/components/localization/data-language-dropdown.component.d.ts +11 -14
- package/tableview/action/components/route/action-route.component.d.ts +6 -11
- package/tableview/action/components/table/action-table.component.d.ts +3 -3
- 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 +17 -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/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 +34 -90
- package/tableview/api/editor/descriptors/field-action.descriptor.d.ts +3 -3
- package/tableview/api/editor/descriptors/field-base.descriptor.d.ts +15 -13
- package/tableview/api/editor/descriptors/field-group.descriptor.d.ts +7 -6
- 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 +6 -6
- package/tableview/api/editor/descriptors/field.descriptor.d.ts +1 -1
- package/tableview/api/editor/helpers/editor-descriptor-helpers.d.ts +43 -0
- package/tableview/api/editor/helpers/field-validators.d.ts +1 -1
- package/tableview/api/editor/models/editor-fields.model.d.ts +24 -22
- 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 -19
- package/tableview/api/editor/models/form-editor.event.d.ts +24 -16
- package/tableview/api/editor/models/form-editor.interface.d.ts +2 -1
- package/tableview/api/editor/models/formly-custom-field.model.d.ts +1 -1
- package/tableview/api/editor/models/formly-field.model.d.ts +4 -4
- 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 +40 -100
- 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 +6 -4
- 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-dropdown/formly-field-dropdown.component.d.ts +1 -1
- 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 -4
- package/tableview/editor/helpers/editor-formly.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 +1 -1
- package/tableview/tableview/components/tableview/tableview.component.d.ts +1 -1
- package/version-info.json +4 -4
|
@@ -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;
|
|
@@ -759,21 +768,6 @@ class ActionEditorDescriptorInst extends ActionDescriptorInst {
|
|
|
759
768
|
return this;
|
|
760
769
|
}
|
|
761
770
|
}
|
|
762
|
-
class ActionEditorDescriptor {
|
|
763
|
-
static create(editor, actionName, cfg) {
|
|
764
|
-
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
765
|
-
parentType: cfg?.parentType,
|
|
766
|
-
parentProperty: cfg?.parentProperty
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
static createWithProvider(editor, serviceProvider, actionName, cfg) {
|
|
770
|
-
return new ActionEditorDescriptorInst(editor, actionName, {
|
|
771
|
-
...actionEditorGetProviderCfgObj(serviceProvider),
|
|
772
|
-
parentType: cfg?.parentType,
|
|
773
|
-
parentProperty: cfg?.parentProperty
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
771
|
class ActionEditorSubmitDescriptorInst extends ActionDescriptorInst {
|
|
778
772
|
constructor(editorAction, submitType = ActionEditorSubmitTypeEnum.Submit) {
|
|
779
773
|
super(submitType === ActionEditorSubmitTypeEnum.Submit ? `${editorAction.actionName}.submit` : `${editorAction.actionName}.cancel`, { model: editorAction.model });
|
|
@@ -786,23 +780,21 @@ class ActionEditorSubmitDescriptorInst extends ActionDescriptorInst {
|
|
|
786
780
|
return this._submitType;
|
|
787
781
|
}
|
|
788
782
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
return new ActionEditorSubmitDescriptorInst(editorAction, submitType).withButtonDescriptor(new ActionButtonDescriptor().withStyleClass(new ButtonStyleBuilder().withTextButton()));
|
|
805
|
-
}
|
|
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()));
|
|
806
798
|
}
|
|
807
799
|
class ActionEditorDetailsDescriptorInst extends ActionEditorDescriptorInst {
|
|
808
800
|
static { this.ACTION_NAME = 'details'; }
|
|
@@ -810,20 +802,10 @@ class ActionEditorDetailsDescriptorInst extends ActionEditorDescriptorInst {
|
|
|
810
802
|
super(editorDescriptor, ActionEditorDetailsDescriptorInst.ACTION_NAME, cfg);
|
|
811
803
|
this.withPosition(ActionPositionEnum.RowClick);
|
|
812
804
|
this.withRouteTrigger(':itemId');
|
|
813
|
-
this.withEditorActions([
|
|
805
|
+
this.withEditorActions([actionEditorCancel(this)]);
|
|
814
806
|
this.withTableviewCategory(TableviewActionDefaultCategories.DETAILS);
|
|
815
807
|
}
|
|
816
808
|
}
|
|
817
|
-
class ActionEditorDetailsDescriptor {
|
|
818
|
-
static create(editor) {
|
|
819
|
-
return new ActionEditorDetailsDescriptorInst(editor);
|
|
820
|
-
}
|
|
821
|
-
static createWithProvider(editor, serviceProvider) {
|
|
822
|
-
return new ActionEditorDetailsDescriptorInst(editor, {
|
|
823
|
-
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
824
|
-
});
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
809
|
class ActionEditorAddDescriptorInst extends ActionEditorDescriptorInst {
|
|
828
810
|
static { this.ACTION_NAME = 'add'; }
|
|
829
811
|
constructor(editorDescriptor, cfg) {
|
|
@@ -835,16 +817,6 @@ class ActionEditorAddDescriptorInst extends ActionEditorDescriptorInst {
|
|
|
835
817
|
this.withUnsavedChangesConfirmation();
|
|
836
818
|
}
|
|
837
819
|
}
|
|
838
|
-
class ActionEditorAddDescriptor {
|
|
839
|
-
static create(editor) {
|
|
840
|
-
return new ActionEditorAddDescriptorInst(editor);
|
|
841
|
-
}
|
|
842
|
-
static createWithProvider(editor, serviceProvider) {
|
|
843
|
-
return new ActionEditorAddDescriptorInst(editor, {
|
|
844
|
-
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
820
|
class ActionEditorEditDescriptorInst extends ActionEditorDescriptorInst {
|
|
849
821
|
static { this.ACTION_NAME = 'edit'; }
|
|
850
822
|
constructor(editorDescriptor, cfg) {
|
|
@@ -857,16 +829,82 @@ class ActionEditorEditDescriptorInst extends ActionEditorDescriptorInst {
|
|
|
857
829
|
this.withUnsavedChangesConfirmation();
|
|
858
830
|
}
|
|
859
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
|
+
}
|
|
860
895
|
class ActionEditorEditDescriptor {
|
|
861
896
|
static create(editor) {
|
|
862
|
-
return
|
|
897
|
+
return actionEditorEdit(editor);
|
|
863
898
|
}
|
|
864
899
|
static createWithProvider(editor, serviceProvider) {
|
|
865
|
-
return
|
|
866
|
-
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
867
|
-
});
|
|
900
|
+
return actionEditorEdit(editor, serviceProvider);
|
|
868
901
|
}
|
|
869
902
|
}
|
|
903
|
+
function actionEditorEdit(editor, serviceProvider) {
|
|
904
|
+
return new ActionEditorEditDescriptorInst(editor, {
|
|
905
|
+
...(serviceProvider ? actionEditorGetProviderCfgObj(serviceProvider) : {})
|
|
906
|
+
});
|
|
907
|
+
}
|
|
870
908
|
|
|
871
909
|
class ActionLinkDescriptorInst extends ActionDescriptorInst {
|
|
872
910
|
constructor(actionName = 'link', cfg) {
|
|
@@ -924,36 +962,49 @@ class ActionLinkDescriptorInst extends ActionDescriptorInst {
|
|
|
924
962
|
return this;
|
|
925
963
|
}
|
|
926
964
|
}
|
|
965
|
+
|
|
927
966
|
class ActionLinkDescriptor {
|
|
928
967
|
static create(actionName, cfg) {
|
|
929
|
-
return
|
|
930
|
-
...cfg
|
|
931
|
-
});
|
|
968
|
+
return actionLink(actionName, cfg);
|
|
932
969
|
}
|
|
933
970
|
static fromModel(model, actionName, cfg) {
|
|
934
|
-
return
|
|
935
|
-
model,
|
|
936
|
-
...cfg
|
|
937
|
-
});
|
|
971
|
+
return actionLinkFromModel(model, actionName, cfg);
|
|
938
972
|
}
|
|
939
973
|
static fromClass(type, actionName, cfg) {
|
|
940
|
-
return
|
|
941
|
-
model: ModelDescriptor.fromClass(type, cfg?.idProperty, cfg?.titleProperty, cfg?.i18nBaseKey),
|
|
942
|
-
...cfg
|
|
943
|
-
});
|
|
974
|
+
return actionLinkFromClass(type, actionName, cfg);
|
|
944
975
|
}
|
|
945
976
|
static fromAction(action) {
|
|
946
|
-
|
|
947
|
-
action.copyTo(descriptor);
|
|
948
|
-
descriptor.withRunConfirmationDescriptor();
|
|
949
|
-
descriptor.withRunNotificationSuccess(undefined, undefined, false);
|
|
950
|
-
descriptor.withRunNotificationError(undefined, undefined, false);
|
|
951
|
-
descriptor.withAfterRunAction();
|
|
952
|
-
descriptor.withOnRunErrorAction();
|
|
953
|
-
descriptor.withSubactionsAsMenu(false);
|
|
954
|
-
return descriptor;
|
|
977
|
+
return actionLinkFromAction(action);
|
|
955
978
|
}
|
|
956
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
|
+
}
|
|
957
1008
|
|
|
958
1009
|
class CommonsActionError extends ACommonsErrorBase {
|
|
959
1010
|
constructor(message, actionName, options) {
|
|
@@ -1106,6 +1157,47 @@ class DataProviderExecutor {
|
|
|
1106
1157
|
}
|
|
1107
1158
|
}
|
|
1108
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
|
+
|
|
1109
1201
|
var FieldSizeEnum;
|
|
1110
1202
|
(function (FieldSizeEnum) {
|
|
1111
1203
|
FieldSizeEnum[FieldSizeEnum["Small"] = 0] = "Small";
|
|
@@ -1162,97 +1254,6 @@ var FieldGroupTypeEnum;
|
|
|
1162
1254
|
FieldGroupTypeEnum[FieldGroupTypeEnum["Logical"] = 1] = "Logical";
|
|
1163
1255
|
})(FieldGroupTypeEnum || (FieldGroupTypeEnum = {}));
|
|
1164
1256
|
|
|
1165
|
-
/**
|
|
1166
|
-
* converts string type to type enum, default is text
|
|
1167
|
-
* @param attributeType
|
|
1168
|
-
*/
|
|
1169
|
-
function getFieldInputTypeFromClassAttributeDefType(attributeType) {
|
|
1170
|
-
switch (attributeType) {
|
|
1171
|
-
case 'hidden':
|
|
1172
|
-
return FieldInputTypeEnum.Hidden;
|
|
1173
|
-
case 'label':
|
|
1174
|
-
return FieldInputTypeEnum.Label;
|
|
1175
|
-
case 'textarea':
|
|
1176
|
-
return FieldInputTypeEnum.Textarea;
|
|
1177
|
-
case 'number':
|
|
1178
|
-
return FieldInputTypeEnum.Number;
|
|
1179
|
-
case 'currency':
|
|
1180
|
-
return FieldInputTypeEnum.Currency;
|
|
1181
|
-
case 'switch':
|
|
1182
|
-
case 'boolean':
|
|
1183
|
-
return FieldInputTypeEnum.Switch;
|
|
1184
|
-
case 'radio':
|
|
1185
|
-
return FieldInputTypeEnum.Radio;
|
|
1186
|
-
case 'datepicker':
|
|
1187
|
-
return FieldInputTypeEnum.Datepicker;
|
|
1188
|
-
case 'mask':
|
|
1189
|
-
return FieldInputTypeEnum.Mask;
|
|
1190
|
-
case 'file':
|
|
1191
|
-
return FieldInputTypeEnum.File;
|
|
1192
|
-
case 'custom':
|
|
1193
|
-
return FieldInputTypeEnum.Custom;
|
|
1194
|
-
case 'text':
|
|
1195
|
-
default:
|
|
1196
|
-
return FieldInputTypeEnum.Text;
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
/**
|
|
1200
|
-
* convert column type to equivalent field input type
|
|
1201
|
-
* @param type column type
|
|
1202
|
-
* @param displayType column display type
|
|
1203
|
-
*/
|
|
1204
|
-
function getFieldInputTypeFromColumnType(type, displayType) {
|
|
1205
|
-
switch (type) {
|
|
1206
|
-
case ColumnTypeEnum.Number:
|
|
1207
|
-
return displayType === ColumnDisplayTypeEnum.Currency ? FieldInputTypeEnum.Currency : FieldInputTypeEnum.Number;
|
|
1208
|
-
case ColumnTypeEnum.Boolean:
|
|
1209
|
-
return FieldInputTypeEnum.Switch;
|
|
1210
|
-
case ColumnTypeEnum.Date:
|
|
1211
|
-
return FieldInputTypeEnum.Datepicker;
|
|
1212
|
-
case ColumnTypeEnum.Custom:
|
|
1213
|
-
return FieldInputTypeEnum.Custom;
|
|
1214
|
-
case ColumnTypeEnum.String:
|
|
1215
|
-
case ColumnTypeEnum.Enum:
|
|
1216
|
-
default:
|
|
1217
|
-
return FieldInputTypeEnum.Text;
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
function expandClassAttributeDefWithEditorDef(attributes) {
|
|
1221
|
-
if (!attributes) {
|
|
1222
|
-
throw new CommonsInternalError('Class attribute definition is null, problem with TypeRegistry::findAttributesDefinitionByClassType?', { name: 'TableviewUtilsError' });
|
|
1223
|
-
}
|
|
1224
|
-
const typeRegistry = TypeRegistry.get();
|
|
1225
|
-
const editorClassAttributeDef = [];
|
|
1226
|
-
for (const attribute of attributes) {
|
|
1227
|
-
editorClassAttributeDef.push({
|
|
1228
|
-
name: attribute.name,
|
|
1229
|
-
baseName: attribute.baseName,
|
|
1230
|
-
type: attribute.type,
|
|
1231
|
-
subtype: attribute.subtype,
|
|
1232
|
-
fieldType: getFieldInputTypeFromClassAttributeDefType(attribute.type),
|
|
1233
|
-
classType: typeRegistry.findType(attribute.type),
|
|
1234
|
-
enumType: typeRegistry.findEnum(attribute.type)
|
|
1235
|
-
});
|
|
1236
|
-
}
|
|
1237
|
-
return editorClassAttributeDef;
|
|
1238
|
-
}
|
|
1239
|
-
/**
|
|
1240
|
-
* returns attributes from class type and extends to typed def with column and field enum type
|
|
1241
|
-
* @param type class type
|
|
1242
|
-
*/
|
|
1243
|
-
function getEditorClassAttributeDef(type) {
|
|
1244
|
-
return expandClassAttributeDefWithEditorDef(TypeRegistry.get().findAttributesDefinitionByClassType(type));
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
var TableviewEditorTypeEnum;
|
|
1248
|
-
(function (TableviewEditorTypeEnum) {
|
|
1249
|
-
TableviewEditorTypeEnum[TableviewEditorTypeEnum["None"] = 0] = "None";
|
|
1250
|
-
TableviewEditorTypeEnum[TableviewEditorTypeEnum["Details"] = 1] = "Details";
|
|
1251
|
-
TableviewEditorTypeEnum[TableviewEditorTypeEnum["Edit"] = 2] = "Edit";
|
|
1252
|
-
TableviewEditorTypeEnum[TableviewEditorTypeEnum["Add"] = 3] = "Add";
|
|
1253
|
-
})(TableviewEditorTypeEnum || (TableviewEditorTypeEnum = {}));
|
|
1254
|
-
const EDITOR_DEFAULT_GROUP_NAME = '_default';
|
|
1255
|
-
|
|
1256
1257
|
class FieldValidationDescriptor {
|
|
1257
1258
|
constructor(name, validator, message, options) {
|
|
1258
1259
|
this._name = name;
|
|
@@ -1370,6 +1371,9 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1370
1371
|
get hiddenExpression() {
|
|
1371
1372
|
return this._hiddenExpression;
|
|
1372
1373
|
}
|
|
1374
|
+
get hiddenResetOnHide() {
|
|
1375
|
+
return this._hiddenResetOnHide;
|
|
1376
|
+
}
|
|
1373
1377
|
get updateOn() {
|
|
1374
1378
|
return this._updateOn;
|
|
1375
1379
|
}
|
|
@@ -1442,8 +1446,9 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1442
1446
|
}
|
|
1443
1447
|
return this;
|
|
1444
1448
|
}
|
|
1445
|
-
withHidden(hiddenExpression) {
|
|
1449
|
+
withHidden(hiddenExpression, resetOnHide) {
|
|
1446
1450
|
this._hiddenExpression = hiddenExpression;
|
|
1451
|
+
this._hiddenResetOnHide = resetOnHide;
|
|
1447
1452
|
return this;
|
|
1448
1453
|
}
|
|
1449
1454
|
withUpdateOn(updateOn) {
|
|
@@ -1524,11 +1529,14 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1524
1529
|
this._isLocalized = true;
|
|
1525
1530
|
return this;
|
|
1526
1531
|
}
|
|
1527
|
-
nextEvent(type,
|
|
1532
|
+
nextEvent(type, component, data) {
|
|
1528
1533
|
this._eventsSubject.next({
|
|
1529
1534
|
type: type,
|
|
1530
|
-
|
|
1531
|
-
|
|
1535
|
+
fieldComponent: component,
|
|
1536
|
+
formComponent: component.props.formEditorComponent,
|
|
1537
|
+
form: component?.form,
|
|
1538
|
+
fieldFormControl: component.formControl,
|
|
1539
|
+
fieldFormlyConfig: component.field,
|
|
1532
1540
|
data: data
|
|
1533
1541
|
});
|
|
1534
1542
|
}
|
|
@@ -1544,6 +1552,7 @@ class AFieldDescriptor extends AGenericFieldDescriptor {
|
|
|
1544
1552
|
obj._defaultValue = this._defaultValue;
|
|
1545
1553
|
obj._requiredExpression = this._requiredExpression;
|
|
1546
1554
|
obj._hiddenExpression = this._hiddenExpression;
|
|
1555
|
+
obj._hiddenResetOnHide = this._hiddenResetOnHide;
|
|
1547
1556
|
obj._updateOn = this._updateOn;
|
|
1548
1557
|
obj._onInit = this._onInit;
|
|
1549
1558
|
obj._onChanges = this._onChanges;
|
|
@@ -1724,7 +1733,7 @@ class FieldLookupDescriptor extends AFieldDescriptor {
|
|
|
1724
1733
|
this._dataProvider = cfg.dataProvider;
|
|
1725
1734
|
}
|
|
1726
1735
|
else {
|
|
1727
|
-
this._dataProvider =
|
|
1736
|
+
this._dataProvider = new LookupDataProviderInst(cfg?.type, cfg?.serviceType);
|
|
1728
1737
|
}
|
|
1729
1738
|
this._optionsValueProperty = cfg?.optionsValueProperty;
|
|
1730
1739
|
trySetLookupItemsProperties(this);
|
|
@@ -1853,7 +1862,7 @@ class FieldLookupDescriptor extends AFieldDescriptor {
|
|
|
1853
1862
|
class FieldLookupEnumDescriptor extends FieldLookupDescriptor {
|
|
1854
1863
|
constructor(editor, property, enumModel, options) {
|
|
1855
1864
|
super(editor, property, {
|
|
1856
|
-
dataProvider:
|
|
1865
|
+
dataProvider: new LookupDataProviderInst(undefined, undefined),
|
|
1857
1866
|
optionsValueProperty: 'value'
|
|
1858
1867
|
});
|
|
1859
1868
|
this._enumModel = enumModel;
|
|
@@ -1936,7 +1945,7 @@ class FieldManyToManyEditorDescriptor extends AFieldDescriptor {
|
|
|
1936
1945
|
this._lookupTableDataProvider = cfg.lookupDataProvider;
|
|
1937
1946
|
}
|
|
1938
1947
|
else {
|
|
1939
|
-
this._lookupTableDataProvider =
|
|
1948
|
+
this._lookupTableDataProvider = new TableDataProviderInst(lookupTableDescriptor.model.type, cfg?.lookupServiceType);
|
|
1940
1949
|
}
|
|
1941
1950
|
}
|
|
1942
1951
|
get fieldType() {
|
|
@@ -2060,22 +2069,22 @@ class FieldManyEditorDescriptor extends AFieldDescriptor {
|
|
|
2060
2069
|
|
|
2061
2070
|
const minDateValidationName = 'minDate';
|
|
2062
2071
|
const minDateValidator = (min) => {
|
|
2063
|
-
return (
|
|
2064
|
-
const date =
|
|
2072
|
+
return ({ fieldFormControl }) => {
|
|
2073
|
+
const date = fieldFormControl?.value == null ? undefined : new Date(fieldFormControl.value);
|
|
2065
2074
|
return !date || date >= min;
|
|
2066
2075
|
};
|
|
2067
2076
|
};
|
|
2068
2077
|
const maxDateValidationName = 'maxDate';
|
|
2069
2078
|
const maxDateValidator = (max) => {
|
|
2070
|
-
return (
|
|
2071
|
-
const date =
|
|
2079
|
+
return ({ fieldFormControl }) => {
|
|
2080
|
+
const date = fieldFormControl?.value == null ? undefined : new Date(fieldFormControl.value);
|
|
2072
2081
|
return !date || date <= max;
|
|
2073
2082
|
};
|
|
2074
2083
|
};
|
|
2075
2084
|
const emailValidationName = 'email';
|
|
2076
2085
|
const emailValidator = () => {
|
|
2077
|
-
return (
|
|
2078
|
-
const error = Validators.email(
|
|
2086
|
+
return ({ fieldFormControl }) => {
|
|
2087
|
+
const error = fieldFormControl ? Validators.email(fieldFormControl) : null;
|
|
2079
2088
|
return error === null;
|
|
2080
2089
|
};
|
|
2081
2090
|
};
|
|
@@ -2673,8 +2682,9 @@ class EditorDescriptorInst {
|
|
|
2673
2682
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
2674
2683
|
* @typeparam LookupValueProperty - The property of lookup model type.
|
|
2675
2684
|
* @typeparam FieldValue - The value type of field on editor.
|
|
2685
|
+
* @typeparam ParentEditorModel - The value type of parent form.
|
|
2676
2686
|
*
|
|
2677
|
-
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, undefined, FieldValue>} - The field lookup descriptor.
|
|
2687
|
+
* @returns {FieldLookupDescriptor<LookupModel, EditorModel, undefined, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
2678
2688
|
*/
|
|
2679
2689
|
addFieldLookupWithOptionsValuePropertyUnsafe(property, type, lookupOptionsValueProperty) {
|
|
2680
2690
|
const field = new FieldLookupDescriptor(this, property, {
|
|
@@ -2898,66 +2908,6 @@ class EditorDescriptorInst {
|
|
|
2898
2908
|
this.createTabGroup(EditorDescriptorInst.defaultGroupName, 'general.general');
|
|
2899
2909
|
}
|
|
2900
2910
|
}
|
|
2901
|
-
/**
|
|
2902
|
-
* Modifies selected field by field property. For enums use {withFieldModifiedEnum} instead.
|
|
2903
|
-
* @param property Model's property name.
|
|
2904
|
-
* @param fieldType new field type for selected field
|
|
2905
|
-
* @param args additional parameters for field
|
|
2906
|
-
*/
|
|
2907
|
-
withFieldModifiedType(property, fieldType, ...args) {
|
|
2908
|
-
return this.withFieldModifiedTypeUnsafe(property, fieldType, ...args);
|
|
2909
|
-
}
|
|
2910
|
-
withFieldModifiedTypeUnsafe(property, fieldType, ...args) {
|
|
2911
|
-
if (!this.model.type) {
|
|
2912
|
-
throw new CommonsInternalError(`withFieldModifiedType cannot be executed for property ${property}: Model type is not defined.`);
|
|
2913
|
-
}
|
|
2914
|
-
const attribute = getEditorClassAttributeDef(this.model.type).find(attribute => attribute.name === property);
|
|
2915
|
-
if (attribute) {
|
|
2916
|
-
attribute.fieldType = fieldType;
|
|
2917
|
-
EditorDescriptorInst.upsertFieldFromAttributeDef(this, attribute, this.fields.find(fi => fi.property === property), ...args);
|
|
2918
|
-
}
|
|
2919
|
-
return this;
|
|
2920
|
-
}
|
|
2921
|
-
/**
|
|
2922
|
-
* Modifies selected field with enum type.
|
|
2923
|
-
* @param property Model's property name.
|
|
2924
|
-
* @param enumModel Enum descriptor.
|
|
2925
|
-
* @param values
|
|
2926
|
-
*/
|
|
2927
|
-
withFieldModifiedEnum(property, enumModel, values) {
|
|
2928
|
-
return this.withFieldModifiedEnumUnsafe(property, enumModel, values);
|
|
2929
|
-
}
|
|
2930
|
-
withFieldModifiedEnumUnsafe(property, enumDesc, values) {
|
|
2931
|
-
if (!this.model.type) {
|
|
2932
|
-
throw new CommonsInternalError(`withFieldModifiedEnum cannot be executed for property ${property}: Model type is not defined.`);
|
|
2933
|
-
}
|
|
2934
|
-
const attribute = getEditorClassAttributeDef(this.model.type).find(a => a.name === property);
|
|
2935
|
-
if (attribute) {
|
|
2936
|
-
attribute.fieldType = FieldInputTypeEnum.Radio;
|
|
2937
|
-
const field = this.fields.find(f => f.property === property);
|
|
2938
|
-
if (field && field instanceof FieldInputDescriptor) {
|
|
2939
|
-
field.asRadioFromEnum(enumDesc ?? enumModelGeneric(TypeRegistry.get().findEnum(attribute.type)), values);
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
return this;
|
|
2943
|
-
}
|
|
2944
|
-
/**
|
|
2945
|
-
* Modifies selected field with lookup field.
|
|
2946
|
-
* @param property Model's property name.
|
|
2947
|
-
* @param lookupProvider provider to be added to field
|
|
2948
|
-
* @param titleProperty
|
|
2949
|
-
*/
|
|
2950
|
-
withFieldModifiedLookupWithProvider(property, lookupProvider, titleProperty) {
|
|
2951
|
-
return this.withFieldModifiedLookupWithProviderUnsafe(property, lookupProvider, titleProperty);
|
|
2952
|
-
}
|
|
2953
|
-
withFieldModifiedLookupWithProviderUnsafe(property, lookupProvider, titleProperty) {
|
|
2954
|
-
this.removeFieldUnsafe(property);
|
|
2955
|
-
const field = this.addFieldLookupWithProviderUnsafe(property, lookupProvider).asAutocomplete();
|
|
2956
|
-
if (titleProperty) {
|
|
2957
|
-
field.withOptionsLabelProperty(titleProperty);
|
|
2958
|
-
}
|
|
2959
|
-
return this;
|
|
2960
|
-
}
|
|
2961
2911
|
/**
|
|
2962
2912
|
* This method takes care of displaying correct/localized data in the editor
|
|
2963
2913
|
* @param property property that tells us where on the model are localizations accessible
|
|
@@ -2974,54 +2924,207 @@ class EditorDescriptorInst {
|
|
|
2974
2924
|
this._isLocalized = true;
|
|
2975
2925
|
return this;
|
|
2976
2926
|
}
|
|
2977
|
-
nextEvent(type,
|
|
2927
|
+
nextEvent(type, component, data) {
|
|
2978
2928
|
this._eventsSubject.next({
|
|
2979
2929
|
type: type,
|
|
2980
|
-
|
|
2981
|
-
|
|
2930
|
+
formComponent: component,
|
|
2931
|
+
form: component.form,
|
|
2982
2932
|
data: data
|
|
2983
2933
|
});
|
|
2984
2934
|
}
|
|
2985
2935
|
get events$() {
|
|
2986
2936
|
return this._eventsSubject.asObservable();
|
|
2987
2937
|
}
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
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));
|
|
2999
3037
|
}
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
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);
|
|
3042
|
+
}
|
|
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);
|
|
3009
3087
|
}
|
|
3010
|
-
return field;
|
|
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);
|
|
3011
3107
|
}
|
|
3108
|
+
return field;
|
|
3012
3109
|
}
|
|
3110
|
+
|
|
3013
3111
|
class EditorDescriptor extends EditorDescriptorInst {
|
|
3014
3112
|
constructor() {
|
|
3015
3113
|
super(ModelDescriptor.create());
|
|
3016
3114
|
}
|
|
3017
3115
|
static create(idProperty, titleProperty, i18nBaseKey, tableviewEditorType = TableviewEditorTypeEnum.None) {
|
|
3018
|
-
return
|
|
3116
|
+
return editorDescriptor({ id: idProperty, title: titleProperty, i18nBase: i18nBaseKey, tableviewEditorType: tableviewEditorType });
|
|
3019
3117
|
}
|
|
3020
3118
|
static fromClass(type, idProperty, titleProperty, i18nBaseKey, tableviewEditorType = TableviewEditorTypeEnum.None) {
|
|
3021
|
-
return
|
|
3119
|
+
return editorDescriptorFromClass(type, {
|
|
3120
|
+
id: idProperty,
|
|
3121
|
+
title: titleProperty,
|
|
3122
|
+
i18nBase: i18nBaseKey,
|
|
3123
|
+
tableviewEditorType: tableviewEditorType
|
|
3124
|
+
});
|
|
3022
3125
|
}
|
|
3023
3126
|
static fromModel(model, tableviewEditorType = TableviewEditorTypeEnum.None) {
|
|
3024
|
-
return
|
|
3127
|
+
return editorDescriptor(model, { tableviewEditorType: tableviewEditorType });
|
|
3025
3128
|
}
|
|
3026
3129
|
/**
|
|
3027
3130
|
* Creates editor descriptor automatically based on openapi model's attributes definition which is automatically extracted. All fields will be included.
|
|
@@ -3039,15 +3142,46 @@ class EditorDescriptor extends EditorDescriptorInst {
|
|
|
3039
3142
|
* @param attributes List of attribute definitions from which fields should be created.
|
|
3040
3143
|
* @param idProperty Id property representing model (optional).
|
|
3041
3144
|
* @param titleProperty Title property representing model (optional). If not provided, it will be automatically chosen.
|
|
3042
|
-
* @param
|
|
3145
|
+
* @param tableviewEditorType Type of editor in tableview (add, edit, view or none).
|
|
3043
3146
|
*/
|
|
3044
|
-
static fromClassWithCustomAttrsDef(type, attributes, idProperty, titleProperty,
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
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);
|
|
3050
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);
|
|
3168
|
+
}
|
|
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;
|
|
3051
3185
|
}
|
|
3052
3186
|
|
|
3053
3187
|
var FormFieldEventTypeEnum;
|
|
@@ -3145,8 +3279,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImpor
|
|
|
3145
3279
|
class TableviewDataProviderInst extends DataProviderInst {
|
|
3146
3280
|
constructor(type, serviceType) {
|
|
3147
3281
|
super(type, serviceType);
|
|
3148
|
-
this.editorDataProvider =
|
|
3149
|
-
this.tableDataProvider =
|
|
3282
|
+
this.editorDataProvider = new EditorDataProviderInst(type, serviceType);
|
|
3283
|
+
this.tableDataProvider = new TableDataProviderInst(type, serviceType);
|
|
3150
3284
|
}
|
|
3151
3285
|
get isLazy() {
|
|
3152
3286
|
return this.tableDataProvider.isLazy;
|
|
@@ -3197,94 +3331,68 @@ class TableviewDataProviderInst extends DataProviderInst {
|
|
|
3197
3331
|
return this;
|
|
3198
3332
|
}
|
|
3199
3333
|
}
|
|
3334
|
+
class DynamicTableviewDataProviderInst extends TableviewDataProviderInst {
|
|
3335
|
+
constructor(serviceType) {
|
|
3336
|
+
super(undefined, serviceType);
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
|
|
3200
3340
|
class TableviewDataProvider extends TableviewDataProviderInst {
|
|
3201
3341
|
constructor() {
|
|
3202
3342
|
super(undefined, undefined);
|
|
3203
3343
|
}
|
|
3204
3344
|
static create() {
|
|
3205
|
-
return
|
|
3345
|
+
return tableviewDataProvider();
|
|
3206
3346
|
}
|
|
3207
3347
|
static fromClass(type) {
|
|
3208
|
-
return
|
|
3348
|
+
return tableviewDataProviderFromClass(type);
|
|
3209
3349
|
}
|
|
3210
3350
|
static fromClassWithService(type, serviceType) {
|
|
3211
|
-
return
|
|
3351
|
+
return tableviewDataProviderFromClass(type, serviceType);
|
|
3212
3352
|
}
|
|
3213
3353
|
static fromService(serviceType) {
|
|
3214
|
-
return
|
|
3215
|
-
}
|
|
3216
|
-
static fromAnyParam(type, serviceType) {
|
|
3217
|
-
if (typeof type !== 'undefined') {
|
|
3218
|
-
return typeof serviceType !== 'undefined'
|
|
3219
|
-
? TableviewDataProvider.fromClassWithService(type, serviceType)
|
|
3220
|
-
: TableviewDataProvider.fromClass(type);
|
|
3221
|
-
}
|
|
3222
|
-
else if (typeof serviceType !== 'undefined') {
|
|
3223
|
-
return TableviewDataProvider.fromService(serviceType);
|
|
3224
|
-
}
|
|
3225
|
-
else {
|
|
3226
|
-
return TableviewDataProvider.create();
|
|
3227
|
-
}
|
|
3354
|
+
return tableviewDataProviderWithService(serviceType);
|
|
3228
3355
|
}
|
|
3229
3356
|
}
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
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);
|
|
3234
3370
|
}
|
|
3235
3371
|
class DynamicTableviewDataProvider extends DynamicTableviewDataProviderInst {
|
|
3236
3372
|
constructor() {
|
|
3237
3373
|
super(undefined);
|
|
3238
3374
|
}
|
|
3239
3375
|
static create() {
|
|
3240
|
-
return
|
|
3376
|
+
return tableviewDynamicDataProvider();
|
|
3241
3377
|
}
|
|
3242
3378
|
static fromService(serviceType) {
|
|
3243
|
-
return
|
|
3244
|
-
}
|
|
3245
|
-
}
|
|
3246
|
-
|
|
3247
|
-
function expandClassAttributeDefWithTableviewDef(attributes) {
|
|
3248
|
-
if (!attributes) {
|
|
3249
|
-
throw new CommonsInternalError('Class attribute definition is null, problem with TypeRegistry::findAttributesDefinitionByClassType?', { name: 'TableviewUtilsError' });
|
|
3250
|
-
}
|
|
3251
|
-
const typeRegistry = TypeRegistry.get();
|
|
3252
|
-
const tableClassAttributeDef = [];
|
|
3253
|
-
for (const attribute of attributes) {
|
|
3254
|
-
const enumType = typeRegistry.findEnum(attribute.type);
|
|
3255
|
-
const columnType = enumType ? ColumnTypeEnum.Enum : getColumnTypeFromClassAttributeDefType(attribute.type);
|
|
3256
|
-
tableClassAttributeDef.push({
|
|
3257
|
-
name: attribute.name,
|
|
3258
|
-
baseName: attribute.baseName,
|
|
3259
|
-
type: attribute.type,
|
|
3260
|
-
subtype: attribute.subtype,
|
|
3261
|
-
columnType: enumType ? ColumnTypeEnum.Enum : getColumnTypeFromClassAttributeDefType(attribute.type),
|
|
3262
|
-
columnDisplayType: getColumnDisplayTypeFromColumnType(columnType, attribute.type),
|
|
3263
|
-
fieldType: getFieldInputTypeFromClassAttributeDefType(attribute.type),
|
|
3264
|
-
enumType: typeRegistry.findEnum(attribute.type),
|
|
3265
|
-
classType: typeRegistry.findType(attribute.type)
|
|
3266
|
-
});
|
|
3379
|
+
return tableviewDynamicDataProvider(serviceType);
|
|
3267
3380
|
}
|
|
3268
|
-
return tableClassAttributeDef;
|
|
3269
3381
|
}
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
* @param type class type
|
|
3273
|
-
*/
|
|
3274
|
-
function getTableviewClassAttributeDef(type) {
|
|
3275
|
-
return expandClassAttributeDefWithTableviewDef(TypeRegistry.get().findAttributesDefinitionByClassType(type));
|
|
3382
|
+
function tableviewDynamicDataProvider(serviceType) {
|
|
3383
|
+
return new DynamicTableviewDataProviderInst(serviceType);
|
|
3276
3384
|
}
|
|
3277
3385
|
|
|
3278
3386
|
class TableviewDescriptorInst {
|
|
3279
3387
|
constructor(model) {
|
|
3280
3388
|
this._isLocalized = false;
|
|
3281
3389
|
this._model = model;
|
|
3282
|
-
this._table =
|
|
3390
|
+
this._table = new TableDescriptorInst(model);
|
|
3283
3391
|
this._tableTitle = `${this._model.i18nBaseKey}.name`;
|
|
3284
|
-
this._detailsEditor =
|
|
3392
|
+
this._detailsEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Details);
|
|
3285
3393
|
this._detailsEditor.withDisabled();
|
|
3286
|
-
this._addEditor =
|
|
3287
|
-
this._editEditor =
|
|
3394
|
+
this._addEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Add);
|
|
3395
|
+
this._editEditor = new EditorDescriptorInst(model, TableviewEditorTypeEnum.Edit);
|
|
3288
3396
|
}
|
|
3289
3397
|
get table() {
|
|
3290
3398
|
return this._table;
|
|
@@ -3525,6 +3633,11 @@ class TableviewDescriptorInst {
|
|
|
3525
3633
|
properties.forEach(p => this.addField(p));
|
|
3526
3634
|
return this;
|
|
3527
3635
|
}
|
|
3636
|
+
addFieldAction(actionName) {
|
|
3637
|
+
const field = this._detailsEditor.addFieldAction(actionName);
|
|
3638
|
+
this.addFieldToEditAndAdd(field);
|
|
3639
|
+
return field;
|
|
3640
|
+
}
|
|
3528
3641
|
addFieldToEditAndAdd(field) {
|
|
3529
3642
|
this._addEditor.addFieldDescriptor(field);
|
|
3530
3643
|
this._editEditor.addFieldDescriptor(field);
|
|
@@ -3538,7 +3651,7 @@ class TableviewDescriptorInst {
|
|
|
3538
3651
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3539
3652
|
* @typeparam FieldValue - The value type of field on editor.
|
|
3540
3653
|
*
|
|
3541
|
-
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, undefined, FieldValue>} - The field lookup descriptor.
|
|
3654
|
+
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, undefined, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
3542
3655
|
*/
|
|
3543
3656
|
addFieldLookup(property, type) {
|
|
3544
3657
|
const field = this._detailsEditor.addFieldLookup(property, type);
|
|
@@ -3554,7 +3667,7 @@ class TableviewDescriptorInst {
|
|
|
3554
3667
|
* @typeparam LookupModel - The field model type, defaults to the non-nullable type of the editor's property.
|
|
3555
3668
|
* @typeparam FieldValue - The value type of field on editor.
|
|
3556
3669
|
*
|
|
3557
|
-
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, undefined, FieldValue>} - The field lookup descriptor.
|
|
3670
|
+
* @returns {FieldLookupDescriptor<LookupModel, TableviewModel, undefined, FieldValue, ParentEditorModel>} - The field lookup descriptor.
|
|
3558
3671
|
*/
|
|
3559
3672
|
addFieldLookupUnsafe(property, type) {
|
|
3560
3673
|
const field = this._detailsEditor.addFieldLookupUnsafe(property, type);
|
|
@@ -3725,113 +3838,60 @@ class TableviewDescriptorInst {
|
|
|
3725
3838
|
tableview._isLocalized = this._isLocalized;
|
|
3726
3839
|
return tableview;
|
|
3727
3840
|
}
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
* if field exists, it is replaced
|
|
3731
|
-
* DO NOT USE WITH TYPES WHERE ARGS ARE REQUIRED - ERROR WILL BE THROWN
|
|
3732
|
-
* for enum use withEnumType
|
|
3733
|
-
* for custom class use withClassType
|
|
3734
|
-
* @param property name of field
|
|
3735
|
-
* @param columnType required column type
|
|
3736
|
-
* @param fieldType optional, if not provided it is converted from column type
|
|
3737
|
-
* @param columnDisplayType optional
|
|
3738
|
-
*/
|
|
3739
|
-
withModifiedType(property, columnType, fieldType, columnDisplayType) {
|
|
3740
|
-
return this.withModifiedTypeUnsafe(property, columnType, fieldType, columnDisplayType);
|
|
3841
|
+
localized(property, model, localeProperty) {
|
|
3842
|
+
return this.localizedUnsafe(property, model, localeProperty);
|
|
3741
3843
|
}
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
}
|
|
3749
|
-
const attributeDef = getTableviewClassAttributeDef(this.model.type).find(attr => attr.name === property);
|
|
3750
|
-
if (attributeDef != null) {
|
|
3751
|
-
fieldType ??= getFieldInputTypeFromColumnType(columnType, columnDisplayType);
|
|
3752
|
-
attributeDef.fieldType = fieldType;
|
|
3753
|
-
this._table.withColumnModifiedTypeUnsafe(property, columnType, columnDisplayType);
|
|
3754
|
-
this._editEditor.withFieldModifiedTypeUnsafe(property, fieldType);
|
|
3755
|
-
this._addEditor.withFieldModifiedTypeUnsafe(property, fieldType);
|
|
3756
|
-
this._detailsEditor.withFieldModifiedTypeUnsafe(property, fieldType);
|
|
3757
|
-
}
|
|
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);
|
|
3758
3850
|
return this;
|
|
3759
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
|
+
}
|
|
3760
3862
|
/**
|
|
3761
|
-
*
|
|
3762
|
-
*
|
|
3763
|
-
* @param property property name
|
|
3764
|
-
* @param enumDesc type of enum
|
|
3765
|
-
* @param fieldType type of field, optional, default is Text
|
|
3863
|
+
* sets custom table descriptor
|
|
3864
|
+
* @param descriptor
|
|
3766
3865
|
*/
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
}
|
|
3770
|
-
withModifiedEnumUnsafe(property, enumDesc, fieldType) {
|
|
3771
|
-
if (!this.model.type) {
|
|
3772
|
-
throw new CommonsInternalError(`withModifiedEnum cannot be executed for property ${property}: Model type is not defined.`);
|
|
3773
|
-
}
|
|
3774
|
-
const attributeDef = getTableviewClassAttributeDef(this.model.type).find(attr => attr.name === property);
|
|
3775
|
-
if (attributeDef != null) {
|
|
3776
|
-
attributeDef.fieldType = fieldType ?? FieldInputTypeEnum.Text;
|
|
3777
|
-
this._table.withColumnModifiedEnumUnsafe(property, enumDesc);
|
|
3778
|
-
this._editEditor.withFieldModifiedEnumUnsafe(property, enumDesc);
|
|
3779
|
-
this._detailsEditor.withFieldModifiedEnumUnsafe(property, enumDesc);
|
|
3780
|
-
this._addEditor.withFieldModifiedEnumUnsafe(property, enumDesc);
|
|
3781
|
-
}
|
|
3866
|
+
withTableDescriptor(descriptor) {
|
|
3867
|
+
this._table = descriptor;
|
|
3782
3868
|
return this;
|
|
3783
3869
|
}
|
|
3784
3870
|
/**
|
|
3785
|
-
*
|
|
3786
|
-
*
|
|
3787
|
-
* @param property property
|
|
3788
|
-
* @param type class type of object
|
|
3789
|
-
* @param titleProperty
|
|
3790
|
-
* @param lookupProvider
|
|
3791
|
-
* @param optionsLabelProperty
|
|
3792
|
-
* @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
|
|
3793
3874
|
*/
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
}
|
|
3797
|
-
withModifiedLookupUnsafe(property, type, lookupProvider, titleProperty, optionsLabelProperty, filterProperty) {
|
|
3798
|
-
if (!this.model.type) {
|
|
3799
|
-
throw new CommonsInternalError(`withModifiedLookup cannot be executed for property ${property}: Model type is not defined.`);
|
|
3800
|
-
}
|
|
3801
|
-
const attributeDef = getTableviewClassAttributeDef(this.model.type).find(attr => attr.name === property);
|
|
3802
|
-
if (attributeDef != null) {
|
|
3803
|
-
type ??= attributeDef.classType ?? TypeRegistry.get().findType(attributeDef.type);
|
|
3804
|
-
titleProperty ??= type ? findClassTitleAttribute(type) ?? undefined : undefined;
|
|
3805
|
-
optionsLabelProperty ??= titleProperty;
|
|
3806
|
-
attributeDef.columnType = ColumnTypeEnum.String;
|
|
3807
|
-
attributeDef.fieldType = FieldInputTypeEnum.Text;
|
|
3808
|
-
if (lookupProvider != null) {
|
|
3809
|
-
this._table.withColumnModifiedLookupUnsafe(property, lookupProvider, optionsLabelProperty, filterProperty);
|
|
3810
|
-
this._addEditor.withFieldModifiedLookupWithProviderUnsafe(property, lookupProvider, optionsLabelProperty);
|
|
3811
|
-
this._detailsEditor.withFieldModifiedLookupWithProviderUnsafe(property, lookupProvider, optionsLabelProperty);
|
|
3812
|
-
this._editEditor.withFieldModifiedLookupWithProviderUnsafe(property, lookupProvider, optionsLabelProperty);
|
|
3813
|
-
}
|
|
3814
|
-
else {
|
|
3815
|
-
const column = this._table.getColumnUnsafe(property) ?? this.addColumnUnsafe(property);
|
|
3816
|
-
if (titleProperty) {
|
|
3817
|
-
column.withGetter(value => value?.[titleProperty]);
|
|
3818
|
-
}
|
|
3819
|
-
}
|
|
3820
|
-
}
|
|
3875
|
+
removeColumn(property) {
|
|
3876
|
+
this._table.removeColumn(property);
|
|
3821
3877
|
return this;
|
|
3822
3878
|
}
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
localizedUnsafe(property, model, localeProperty) {
|
|
3827
|
-
this._isLocalized = true;
|
|
3828
|
-
this._table.withLocalizationLocaleProperty(localeProperty);
|
|
3829
|
-
this.detailsEditor.localizedUnsafe(property, model, localeProperty);
|
|
3830
|
-
this.addEditor.localizedUnsafe(property, model, localeProperty);
|
|
3831
|
-
this.editEditor.localizedUnsafe(property, model, localeProperty);
|
|
3879
|
+
withEntityForTranslations(i18nBaseKey) {
|
|
3880
|
+
this._table.model.withI18nBase(i18nBaseKey);
|
|
3881
|
+
this._detailsEditor.model.withI18nBase(i18nBaseKey);
|
|
3832
3882
|
return this;
|
|
3833
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
|
+
}
|
|
3834
3893
|
}
|
|
3894
|
+
|
|
3835
3895
|
class TableviewDescriptor extends TableviewDescriptorInst {
|
|
3836
3896
|
constructor() {
|
|
3837
3897
|
super(ModelDescriptor.create());
|
|
@@ -3852,12 +3912,12 @@ class TableviewDescriptor extends TableviewDescriptorInst {
|
|
|
3852
3912
|
* @param titleProperty
|
|
3853
3913
|
*/
|
|
3854
3914
|
static fromClassWithAutoAttrsDef(type, idProperty, titleProperty) {
|
|
3855
|
-
const
|
|
3856
|
-
const
|
|
3857
|
-
descriptor.withTableDescriptor(
|
|
3858
|
-
descriptor.withEditDescriptor(
|
|
3859
|
-
descriptor.withDetailsDescriptor(
|
|
3860
|
-
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 }));
|
|
3861
3921
|
return descriptor;
|
|
3862
3922
|
}
|
|
3863
3923
|
/**
|
|
@@ -3869,74 +3929,111 @@ class TableviewDescriptor extends TableviewDescriptorInst {
|
|
|
3869
3929
|
* @param titleProperty
|
|
3870
3930
|
*/
|
|
3871
3931
|
static fromClassWithCustomAttrsDef(type, columnAttributes, fieldAttributes, idProperty, titleProperty) {
|
|
3872
|
-
const
|
|
3873
|
-
descriptor
|
|
3932
|
+
const optsBase = { id: idProperty, title: titleProperty };
|
|
3933
|
+
const descriptor = tableviewDescriptor(model(type, optsBase));
|
|
3934
|
+
descriptor.withTableDescriptor(tableDescriptorFromClassAttrsDef(type, columnAttributes, optsBase));
|
|
3874
3935
|
if (fieldAttributes !== null) {
|
|
3875
|
-
descriptor.withEditDescriptor(
|
|
3876
|
-
descriptor.withDetailsDescriptor(
|
|
3877
|
-
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 }));
|
|
3878
3939
|
}
|
|
3879
3940
|
return descriptor;
|
|
3880
3941
|
}
|
|
3881
3942
|
}
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
this._table = TableDynamicDescriptor.fromModel(this.model);
|
|
3886
|
-
this._tableTitle = undefined;
|
|
3887
|
-
}
|
|
3888
|
-
get table() {
|
|
3889
|
-
return this._table;
|
|
3890
|
-
}
|
|
3891
|
-
/**
|
|
3892
|
-
* sets custom table descriptor
|
|
3893
|
-
* @param descriptor
|
|
3894
|
-
*/
|
|
3895
|
-
withTableDescriptor(descriptor) {
|
|
3896
|
-
this._table = descriptor;
|
|
3897
|
-
return this;
|
|
3943
|
+
function tableviewDescriptor(typeOrModelOrClassOrOpts, opts) {
|
|
3944
|
+
if (typeOrModelOrClassOrOpts == null) {
|
|
3945
|
+
return new TableviewDescriptorInst(model());
|
|
3898
3946
|
}
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
* equals to be removing in auto and base tableview descriptor
|
|
3902
|
-
* * @param property column's property
|
|
3903
|
-
*/
|
|
3904
|
-
removeColumn(property) {
|
|
3905
|
-
this._table.removeColumn(property);
|
|
3906
|
-
return this;
|
|
3947
|
+
else if (typeOrModelOrClassOrOpts instanceof TypeDescriptor) {
|
|
3948
|
+
return new TableviewDescriptorInst(model(opts ?? {}));
|
|
3907
3949
|
}
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
this._detailsEditor.model.withI18nBase(i18nBaseKey);
|
|
3911
|
-
return this;
|
|
3950
|
+
else if (typeOrModelOrClassOrOpts instanceof ModelDescriptor) {
|
|
3951
|
+
return new TableviewDescriptorInst(typeOrModelOrClassOrOpts);
|
|
3912
3952
|
}
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
copy() {
|
|
3917
|
-
const descriptor = new TableviewDynamicDescriptorInt(this.model.copy());
|
|
3918
|
-
descriptor._table = this._table.copy();
|
|
3919
|
-
descriptor._tableTitle = this._tableTitle;
|
|
3920
|
-
return descriptor;
|
|
3953
|
+
else {
|
|
3954
|
+
// this could have autoGenerated if model descriptor is class
|
|
3955
|
+
return new TableviewDescriptorInst(model(typeOrModelOrClassOrOpts));
|
|
3921
3956
|
}
|
|
3922
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
|
+
}
|
|
3923
3984
|
class TableviewDynamicDescriptor extends TableviewDynamicDescriptorInt {
|
|
3924
3985
|
constructor() {
|
|
3925
3986
|
super(ModelDescriptor.create());
|
|
3926
3987
|
}
|
|
3927
3988
|
static create(idProperty, titleProperty, i18nBaseKey) {
|
|
3928
|
-
return
|
|
3989
|
+
return tableviewDynamicDescriptor({ id: idProperty, title: titleProperty, i18nBase: i18nBaseKey });
|
|
3929
3990
|
}
|
|
3930
3991
|
static fromModel(model) {
|
|
3931
|
-
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
|
+
});
|
|
3932
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));
|
|
3933
4030
|
}
|
|
3934
4031
|
|
|
3935
4032
|
function convertDataToStringWithDelimiter(data, delimiter, descriptor, translate) {
|
|
3936
4033
|
const replaceNullValue = (key, value) => (value === null ? '' : value);
|
|
3937
4034
|
const getterPipe = new GetterPipe();
|
|
3938
4035
|
return [
|
|
3939
|
-
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),
|
|
3940
4037
|
...data.map((row) => descriptor.table.columns
|
|
3941
4038
|
.map(column => {
|
|
3942
4039
|
if (typeof column.getter === 'function') {
|
|
@@ -4046,34 +4143,50 @@ function getRouteData(injector) {
|
|
|
4046
4143
|
}
|
|
4047
4144
|
function tableviewDetailsAction(descriptor, injector) {
|
|
4048
4145
|
const routeData = getRouteData(injector);
|
|
4049
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasDetails ?
|
|
4146
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasDetails ? new ActionEditorDetailsDescriptorInst(descriptor) : null;
|
|
4050
4147
|
}
|
|
4051
4148
|
function tableviewDetailsActionWithProvider(descriptor, serviceProvider, injector) {
|
|
4052
4149
|
const routeData = getRouteData(injector);
|
|
4053
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasDetails
|
|
4150
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasDetails
|
|
4151
|
+
? new ActionEditorDetailsDescriptorInst(descriptor, {
|
|
4152
|
+
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
4153
|
+
})
|
|
4154
|
+
: null;
|
|
4054
4155
|
}
|
|
4055
4156
|
function tableviewAddAction(descriptor, injector) {
|
|
4056
4157
|
const routeData = getRouteData(injector);
|
|
4057
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasAdd ?
|
|
4158
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasAdd ? new ActionEditorAddDescriptorInst(descriptor) : null;
|
|
4058
4159
|
}
|
|
4059
4160
|
function tableviewAddActionWithProvider(descriptor, serviceProvider, injector) {
|
|
4060
4161
|
const routeData = getRouteData(injector);
|
|
4061
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasAdd
|
|
4162
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasAdd
|
|
4163
|
+
? new ActionEditorAddDescriptorInst(descriptor, {
|
|
4164
|
+
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
4165
|
+
})
|
|
4166
|
+
: null;
|
|
4062
4167
|
}
|
|
4063
4168
|
function tableviewEditAction(descriptor, injector) {
|
|
4064
4169
|
const routeData = getRouteData(injector);
|
|
4065
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasEdit ?
|
|
4170
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasEdit ? new ActionEditorEditDescriptorInst(descriptor) : null;
|
|
4066
4171
|
}
|
|
4067
4172
|
function tableviewEditActionWithProvider(descriptor, serviceProvider, injector) {
|
|
4068
4173
|
const routeData = getRouteData(injector);
|
|
4069
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasEdit
|
|
4174
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasEdit
|
|
4175
|
+
? new ActionEditorEditDescriptorInst(descriptor, {
|
|
4176
|
+
...actionEditorGetProviderCfgObj(serviceProvider)
|
|
4177
|
+
})
|
|
4178
|
+
: null;
|
|
4070
4179
|
}
|
|
4071
4180
|
function tableviewEditOnDetailsAction(descriptor, editDescriptor, injector) {
|
|
4072
4181
|
const routeData = getRouteData(injector);
|
|
4073
4182
|
if (routeData?.tableviewActions && !routeData.tableviewActions.hasEdit) {
|
|
4074
4183
|
return null;
|
|
4075
4184
|
}
|
|
4076
|
-
const action = editDescriptor
|
|
4185
|
+
const action = editDescriptor
|
|
4186
|
+
? actionLinkFromAction(editDescriptor)
|
|
4187
|
+
: new ActionLinkDescriptorInst(ActionEditorEditDescriptorInst.ACTION_NAME, {
|
|
4188
|
+
model: descriptor
|
|
4189
|
+
});
|
|
4077
4190
|
action
|
|
4078
4191
|
.withTableviewCategory(TableviewActionDefaultCategories.EDIT)
|
|
4079
4192
|
.withPositionTableviewCategories([TableviewActionDefaultCategories.DETAILS])
|
|
@@ -4089,11 +4202,15 @@ function tableviewEditOnDetailsAction(descriptor, editDescriptor, injector) {
|
|
|
4089
4202
|
}
|
|
4090
4203
|
function tableviewDeleteAction(descriptor, injector) {
|
|
4091
4204
|
const routeData = getRouteData(injector);
|
|
4092
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasDelete ?
|
|
4205
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasDelete ? new ActionDeleteDescriptorInst(descriptor) : null;
|
|
4093
4206
|
}
|
|
4094
4207
|
function tableviewDeleteActionWithProvider(descriptor, serviceProvider, injector) {
|
|
4095
4208
|
const routeData = getRouteData(injector);
|
|
4096
|
-
return !routeData?.tableviewActions || routeData.tableviewActions.hasDelete
|
|
4209
|
+
return !routeData?.tableviewActions || routeData.tableviewActions.hasDelete
|
|
4210
|
+
? new ActionDeleteDescriptorInst(descriptor, {
|
|
4211
|
+
...actionGetProviderCfgObj(serviceProvider)
|
|
4212
|
+
})
|
|
4213
|
+
: null;
|
|
4097
4214
|
}
|
|
4098
4215
|
function tableviewDeleteOnDetailsAction(model, injector) {
|
|
4099
4216
|
const action = tableviewDeleteAction(model, injector);
|
|
@@ -4116,7 +4233,9 @@ function tableviewDeleteOnDetailsAction(model, injector) {
|
|
|
4116
4233
|
return null;
|
|
4117
4234
|
}
|
|
4118
4235
|
function tableviewExportAction(descriptor, injector, defaultActions) {
|
|
4119
|
-
const exportAction =
|
|
4236
|
+
const exportAction = new ActionDescriptorInst('export', {
|
|
4237
|
+
model: descriptor.model
|
|
4238
|
+
})
|
|
4120
4239
|
.withButtonDescriptor(new ActionButtonDescriptor().withIcon('pi pi-download'))
|
|
4121
4240
|
.withSubactionsAsMenu();
|
|
4122
4241
|
const subactions = [];
|
|
@@ -4129,7 +4248,9 @@ function tableviewExportAction(descriptor, injector, defaultActions) {
|
|
|
4129
4248
|
}
|
|
4130
4249
|
function tableviewExportJsonAction(descriptor, injector) {
|
|
4131
4250
|
const dataProviderExecutor = getInjector(injector)?.get(DataProviderExecutor);
|
|
4132
|
-
return
|
|
4251
|
+
return new ActionDescriptorInst('exportJson', {
|
|
4252
|
+
model: descriptor.model
|
|
4253
|
+
})
|
|
4133
4254
|
.withRunFunction(ctx => {
|
|
4134
4255
|
const params = ctx.parameters.dataListParams ? copyDataListParams(ctx.parameters.dataListParams) : {};
|
|
4135
4256
|
params.offset = 0;
|
|
@@ -4149,7 +4270,9 @@ function tableviewExportJsonAction(descriptor, injector) {
|
|
|
4149
4270
|
}
|
|
4150
4271
|
function tableviewExportCsvAction(descriptor, injector) {
|
|
4151
4272
|
const dataProviderExecutor = getInjector(injector)?.get(DataProviderExecutor);
|
|
4152
|
-
return
|
|
4273
|
+
return new ActionDescriptorInst('exportCsv', {
|
|
4274
|
+
model: descriptor.model
|
|
4275
|
+
})
|
|
4153
4276
|
.withRunFunction(ctx => {
|
|
4154
4277
|
const params = ctx.parameters.dataListParams ? copyDataListParams(ctx.parameters.dataListParams) : {};
|
|
4155
4278
|
params.offset = 0;
|
|
@@ -4173,7 +4296,9 @@ function tableviewExportCsvAction(descriptor, injector) {
|
|
|
4173
4296
|
.withPosition(ActionPositionEnum.ToolbarRight);
|
|
4174
4297
|
}
|
|
4175
4298
|
function tableviewRefreshAction(descriptor) {
|
|
4176
|
-
const action =
|
|
4299
|
+
const action = new ActionDescriptorInst('refresh', {
|
|
4300
|
+
model: descriptor
|
|
4301
|
+
})
|
|
4177
4302
|
.withPosition(ActionPositionEnum.ToolbarRight)
|
|
4178
4303
|
.withTableviewCategory(TableviewActionDefaultCategories.READ)
|
|
4179
4304
|
.withRunNotificationSuccess(undefined, undefined, false)
|
|
@@ -4186,7 +4311,11 @@ function tableviewRefreshAction(descriptor) {
|
|
|
4186
4311
|
}
|
|
4187
4312
|
function tableviewLocalizationLanguageSelectAction(descriptor) {
|
|
4188
4313
|
return descriptor.isLocalized()
|
|
4189
|
-
?
|
|
4314
|
+
? new ActionDescriptorInst('translator', {
|
|
4315
|
+
model: descriptor.model
|
|
4316
|
+
})
|
|
4317
|
+
.withPosition(ActionPositionEnum.ToolbarLeft)
|
|
4318
|
+
.withComponentFromDi(DATA_LANGUAGE_DROPDOWN_COMPONENT_IT)
|
|
4190
4319
|
: null;
|
|
4191
4320
|
}
|
|
4192
4321
|
|
|
@@ -4335,7 +4464,7 @@ class TableviewInputBuilder {
|
|
|
4335
4464
|
* Builds and returns an instance of ITableview.
|
|
4336
4465
|
* DO NOT CALL this within tableview create callback function!
|
|
4337
4466
|
*
|
|
4338
|
-
* @return {
|
|
4467
|
+
* @return {TableviewInput<Model, Service, Sorts, Filters, Descriptor, DataProvider>} - The built ITableview instance.
|
|
4339
4468
|
*/
|
|
4340
4469
|
build() {
|
|
4341
4470
|
return {
|
|
@@ -4361,21 +4490,124 @@ class TableviewInputBuilder {
|
|
|
4361
4490
|
* @returns A tableview instance with descriptor, data provider and actions.
|
|
4362
4491
|
*/
|
|
4363
4492
|
function tableview(model, service, buildFn) {
|
|
4364
|
-
const builder = new TableviewInputBuilder(
|
|
4493
|
+
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model), new TableviewDataProviderInst(undefined, service), inject(Injector));
|
|
4365
4494
|
buildFn?.(builder);
|
|
4366
4495
|
return builder.build();
|
|
4367
4496
|
}
|
|
4368
4497
|
function tableviewWithSortAndFilter(model, service, sorts, filters, buildFn) {
|
|
4369
|
-
const builder = new TableviewInputBuilder(
|
|
4498
|
+
const builder = new TableviewInputBuilder(new TableviewDescriptorInst(model), new TableviewDataProviderInst(undefined, service), inject(Injector));
|
|
4370
4499
|
buildFn?.(builder);
|
|
4371
4500
|
return builder.build();
|
|
4372
4501
|
}
|
|
4373
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
|
+
|
|
4374
4606
|
// action descriptors
|
|
4375
4607
|
|
|
4376
4608
|
/**
|
|
4377
4609
|
* Generated bundle index. Do not edit.
|
|
4378
4610
|
*/
|
|
4379
4611
|
|
|
4380
|
-
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 };
|
|
4381
4613
|
//# sourceMappingURL=mediusinc-mng-commons-tableview-api.mjs.map
|