@mediusinc/mng-commons 3.0.0-rc.9 → 3.1.0-rc.0
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/dev-scripts/version-info.js +13 -6
- package/esm2022/lib/components/form/formly/fields/formly-field-action/formly-field-action.component.mjs +22 -4
- package/esm2022/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +4 -4
- package/esm2022/lib/components/form/models/field-action-context.model.mjs +1 -1
- package/esm2022/lib/components/form/models/index.mjs +2 -1
- package/esm2022/lib/components/tableview/table/table.component.mjs +47 -50
- package/esm2022/lib/descriptors/action/action.descriptor.mjs +1 -1
- package/esm2022/lib/descriptors/editor/field.descriptor.mjs +13 -4
- package/esm2022/lib/models/version.model.mjs +1 -1
- package/esm2022/lib/pipes/json-path.pipe.mjs +3 -62
- package/esm2022/lib/services/action-executor.service.mjs +26 -14
- package/esm2022/lib/services/configuration.service.mjs +1 -1
- package/esm2022/lib/services/logger.service.mjs +2 -2
- package/esm2022/lib/services/version.service.mjs +1 -1
- package/esm2022/lib/utils/editor-formly.util.mjs +2 -1
- package/esm2022/lib/utils/object.util.mjs +50 -1
- package/fesm2022/mediusinc-mng-commons.mjs +157 -132
- package/fesm2022/mediusinc-mng-commons.mjs.map +1 -1
- package/lib/components/form/formly/fields/formly-field-action/formly-field-action.component.d.ts +3 -0
- package/lib/components/form/models/field-action-context.model.d.ts +7 -0
- package/lib/components/form/models/index.d.ts +1 -0
- package/lib/components/tableview/table/table.component.d.ts +1 -0
- package/lib/descriptors/action/action.descriptor.d.ts +6 -6
- package/lib/descriptors/editor/field.descriptor.d.ts +7 -5
- package/lib/models/version.model.d.ts +1 -1
- package/lib/pipes/json-path.pipe.d.ts +0 -1
- package/lib/utils/object.util.d.ts +1 -0
- package/package.json +4 -1
- package/scss/common/theme/designer/_components.scss +1 -1
- package/scss/mng-overrides/_theme_dialog.scss +7 -0
- package/scss/mng-overrides/_theme_tableview.scss +3 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i2$1 from '@angular/common';
|
|
2
|
-
import { DatePipe, AsyncPipe, NgIf, NgForOf, NgSwitch, NgSwitchCase, NgSwitchDefault, DecimalPipe, CurrencyPipe, NgClass, NgStyle, NgTemplateOutlet, CommonModule } from '@angular/common';
|
|
2
|
+
import { DatePipe, AsyncPipe, NgIf, NgForOf, NgSwitch, NgSwitchCase, NgSwitchDefault, DecimalPipe, CurrencyPipe, NgClass, NgStyle, NgTemplateOutlet, JsonPipe, CommonModule } from '@angular/common';
|
|
3
3
|
import * as i1$1 from '@angular/common/http';
|
|
4
4
|
import { HttpErrorResponse, HttpClient, HttpClientModule, HttpParams } from '@angular/common/http';
|
|
5
5
|
import * as i0 from '@angular/core';
|
|
@@ -82,11 +82,14 @@ import { PrimeNGConfig, FilterService, FilterMatchMode, ConfirmationService, Mes
|
|
|
82
82
|
import * as i11 from 'primeng/menu';
|
|
83
83
|
import { MenuModule } from 'primeng/menu';
|
|
84
84
|
import { isObservable, throwError, BehaviorSubject, Subject, ReplaySubject, distinctUntilChanged, take, mergeMap, of, combineLatest, switchMap, from, timeout, tap, Observable, debounceTime, merge } from 'rxjs';
|
|
85
|
-
import { filter, map, catchError, first, mergeMap as mergeMap$1, take as take$1
|
|
85
|
+
import { filter, map, startWith, catchError, first, mergeMap as mergeMap$1, take as take$1 } from 'rxjs/operators';
|
|
86
|
+
import { logger } from 'nx/src/utils/logger';
|
|
86
87
|
import 'reflect-metadata';
|
|
87
88
|
import { Title, DomSanitizer } from '@angular/platform-browser';
|
|
88
89
|
import { ZIndexUtils } from 'primeng/utils';
|
|
89
90
|
import { TimesIcon } from 'primeng/icons/times';
|
|
91
|
+
import * as i5$2 from 'primeng/message';
|
|
92
|
+
import { MessageModule } from 'primeng/message';
|
|
90
93
|
import { trigger, state, style, transition, animate } from '@angular/animations';
|
|
91
94
|
|
|
92
95
|
/**
|
|
@@ -1214,67 +1217,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
1214
1217
|
* - Array notation (e.g.: [0])
|
|
1215
1218
|
*/
|
|
1216
1219
|
class JsonPathPipe {
|
|
1217
|
-
constructor() {
|
|
1218
|
-
this.logger = MngLoggerService.get().create('JsonPathPipe');
|
|
1219
|
-
}
|
|
1220
1220
|
transform(value, path = '') {
|
|
1221
|
-
|
|
1222
|
-
// only return the root
|
|
1223
|
-
return value;
|
|
1224
|
-
}
|
|
1225
|
-
// Check for leading root object notation
|
|
1226
|
-
if (path.startsWith('$')) {
|
|
1227
|
-
path = path.substring(1);
|
|
1228
|
-
}
|
|
1229
|
-
// Check for leading .
|
|
1230
|
-
if (path.startsWith('.')) {
|
|
1231
|
-
path = path.substring(1);
|
|
1232
|
-
}
|
|
1233
|
-
if (path.indexOf('.') >= 0) {
|
|
1234
|
-
const pathSplit = path.split('.');
|
|
1235
|
-
let currValue = value;
|
|
1236
|
-
for (const p of pathSplit) {
|
|
1237
|
-
if (typeof currValue === 'undefined' || currValue === null) {
|
|
1238
|
-
return currValue;
|
|
1239
|
-
}
|
|
1240
|
-
if (!p.length) {
|
|
1241
|
-
// empty path, return current value
|
|
1242
|
-
return currValue;
|
|
1243
|
-
}
|
|
1244
|
-
const leftBracketIdx = p.indexOf('[');
|
|
1245
|
-
if (leftBracketIdx >= 0 && p.endsWith(']')) {
|
|
1246
|
-
// should be reference to array
|
|
1247
|
-
const arrayPath = p.substring(0, leftBracketIdx);
|
|
1248
|
-
const arrayIdx = +p.substring(leftBracketIdx + 1, p.length - 1);
|
|
1249
|
-
const array = currValue[arrayPath];
|
|
1250
|
-
if (Array.isArray(array)) {
|
|
1251
|
-
if (arrayIdx >= 0 && arrayIdx < array.length) {
|
|
1252
|
-
// valid index, continue on the path
|
|
1253
|
-
currValue = array[arrayIdx];
|
|
1254
|
-
continue;
|
|
1255
|
-
}
|
|
1256
|
-
else {
|
|
1257
|
-
this.logger?.warn(`Path ${path} array index at ${p} is not within valid array range`, value);
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
else {
|
|
1261
|
-
this.logger?.warn(`Path ${path} array at ${p} is not a valid array`, value);
|
|
1262
|
-
}
|
|
1263
|
-
return undefined;
|
|
1264
|
-
}
|
|
1265
|
-
else if (typeof currValue === 'object') {
|
|
1266
|
-
currValue = currValue[p];
|
|
1267
|
-
}
|
|
1268
|
-
else {
|
|
1269
|
-
this.logger?.warn(`Path ${path} is not valid for object`, value);
|
|
1270
|
-
return currValue;
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
return currValue;
|
|
1274
|
-
}
|
|
1275
|
-
else {
|
|
1276
|
-
return value[path];
|
|
1277
|
-
}
|
|
1221
|
+
return ObjectUtil.getPropertyByPath(value, path);
|
|
1278
1222
|
}
|
|
1279
1223
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: JsonPathPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1280
1224
|
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.7", ngImport: i0, type: JsonPathPipe, isStandalone: true, name: "jsonPath" }); }
|
|
@@ -1666,7 +1610,7 @@ class MngLoggerService {
|
|
|
1666
1610
|
else if (data?.length && data[0] instanceof Error) {
|
|
1667
1611
|
// if first data is error, also consider as error
|
|
1668
1612
|
logEntry.error = data[0];
|
|
1669
|
-
data = data.splice(1);
|
|
1613
|
+
logEntry.data = data.splice(1);
|
|
1670
1614
|
}
|
|
1671
1615
|
this._log(logEntry);
|
|
1672
1616
|
}
|
|
@@ -2438,14 +2382,16 @@ class MngActionExecutorService {
|
|
|
2438
2382
|
if (ctx.instance.action.afterRunAction) {
|
|
2439
2383
|
// mark new state for next action start
|
|
2440
2384
|
ctx.instance.state = ActionInstanceStateEnum.NextActionStart;
|
|
2441
|
-
const
|
|
2385
|
+
const afterRunAction = typeof ctx.instance.action.afterRunAction === 'function' ? ctx.instance.action.afterRunAction(ctx) : ctx.instance.action.afterRunAction;
|
|
2386
|
+
const nextActionInstance = this.activateAction(afterRunAction, new ActionParameters(ctx.parameters.itemId, runResult)
|
|
2442
2387
|
.withActionData(ctx.parameters.actionData)
|
|
2443
2388
|
.withRoute(ctx.parameters.route)
|
|
2444
2389
|
.withSourceComponent(ctx.parameters.sourceComponent)
|
|
2445
|
-
.withViewContainer(ctx.parameters.viewContainer), undefined, ctx.instance);
|
|
2390
|
+
.withViewContainer(ctx.parameters.viewContainer), undefined, ctx.instance, true);
|
|
2446
2391
|
ctx.instance.nextActionInstance = nextActionInstance;
|
|
2447
2392
|
// finish current action when next action finishes
|
|
2448
|
-
return nextActionInstance.state$.pipe(
|
|
2393
|
+
return nextActionInstance.state$.pipe(startWith(nextActionInstance.state), // provide first state cause it might be finished already
|
|
2394
|
+
filter(state => state >= ActionInstanceStateEnum.FinishSuccessFinal), take(1), map(() => {
|
|
2449
2395
|
ctx.instance.state = ActionInstanceStateEnum.NextActionEnd;
|
|
2450
2396
|
return runResult;
|
|
2451
2397
|
}));
|
|
@@ -2470,25 +2416,25 @@ class MngActionExecutorService {
|
|
|
2470
2416
|
ctx.instance.state = isMainRunFn ? ActionInstanceStateEnum.RunError : ActionInstanceStateEnum.FetchError;
|
|
2471
2417
|
// mark execution error on context
|
|
2472
2418
|
ctx.executionError(actionError);
|
|
2419
|
+
if (ctx.instance.action.hasRunNotificationError) {
|
|
2420
|
+
NotificationUtil.actionNotificationError(this.translate, ctx.instance.action, actionError, 'fetch', ctx.parameters.viewContainer, ctx.parameters.item);
|
|
2421
|
+
}
|
|
2473
2422
|
let errorObs = of(void 0);
|
|
2474
2423
|
if (isMainRunFn) {
|
|
2475
2424
|
ctx.instance.error = err;
|
|
2476
2425
|
ctx.instance.isRunLoadingSubject.next(false);
|
|
2477
2426
|
// handle possible error action if run
|
|
2478
2427
|
if (isMainRunFn && ctx.instance.action.onRunErrorAction) {
|
|
2428
|
+
const onRunErrorAction = typeof ctx.instance.action.onRunErrorAction === 'function' ? ctx.instance.action.onRunErrorAction(ctx) : ctx.instance.action.onRunErrorAction;
|
|
2479
2429
|
// cannot start with trigger, because routing might be problematic (lousing previous results etc.)
|
|
2480
|
-
const errorActionInstance = this.activateAction(
|
|
2430
|
+
const errorActionInstance = this.activateAction(onRunErrorAction, new ActionParameters(ctx.parameters.itemId, ctx.parameters.item)
|
|
2481
2431
|
.withActionData(ctx.parameters.actionData)
|
|
2482
2432
|
.withRoute(ctx.parameters.route)
|
|
2483
2433
|
.withSourceComponent(ctx.parameters.sourceComponent)
|
|
2484
|
-
.withViewContainer(ctx.parameters.viewContainer));
|
|
2434
|
+
.withViewContainer(ctx.parameters.viewContainer), undefined, undefined, true);
|
|
2485
2435
|
ctx.instance.errorActionInstance = errorActionInstance;
|
|
2486
|
-
errorObs = errorActionInstance.state$.pipe(
|
|
2487
|
-
|
|
2488
|
-
}
|
|
2489
|
-
else {
|
|
2490
|
-
if (ctx.instance.action.hasRunNotificationError) {
|
|
2491
|
-
NotificationUtil.actionNotificationError(this.translate, ctx.instance.action, actionError, 'fetch', ctx.parameters.viewContainer, ctx.parameters.item);
|
|
2436
|
+
errorObs = errorActionInstance.state$.pipe(startWith(errorActionInstance.state), // provide first state cause it might be finished already
|
|
2437
|
+
filter(state => state >= ActionInstanceStateEnum.FinishSuccessFinal), take(1), map(() => void 0));
|
|
2492
2438
|
}
|
|
2493
2439
|
}
|
|
2494
2440
|
// list and map only to mark instance state as finished error state
|
|
@@ -2742,7 +2688,7 @@ class MngActionExecutorService {
|
|
|
2742
2688
|
finishAction(instance, onDestroy = false) {
|
|
2743
2689
|
instance = this.getOrCreateInstance(instance);
|
|
2744
2690
|
if (instance.state >= ActionInstanceStateEnum.FinishSuccessFinal) {
|
|
2745
|
-
this.logger.
|
|
2691
|
+
this.logger.trace(`ActionInstance ${instance.instanceLongName} already finished`);
|
|
2746
2692
|
return;
|
|
2747
2693
|
}
|
|
2748
2694
|
let finalState;
|
|
@@ -2789,6 +2735,15 @@ class MngActionExecutorService {
|
|
|
2789
2735
|
instance.context?.parameters.viewContainer?.setActionRouteTriggeredInstance?.(newInstance);
|
|
2790
2736
|
instance.reactivationInstance = newInstance;
|
|
2791
2737
|
}
|
|
2738
|
+
// finish related actions
|
|
2739
|
+
if (instance.nextActionInstance) {
|
|
2740
|
+
logger.debug(`Finishing instance ${instance.instanceLongName} related next action instance: ${instance.nextActionInstance.instanceLongName}`);
|
|
2741
|
+
this.finishAction(instance.nextActionInstance, onDestroy);
|
|
2742
|
+
}
|
|
2743
|
+
if (instance.errorActionInstance) {
|
|
2744
|
+
logger.debug(`Finishing instance ${instance.instanceLongName} related error action instance: ${instance.errorActionInstance.instanceLongName}`);
|
|
2745
|
+
this.finishAction(instance.errorActionInstance, onDestroy);
|
|
2746
|
+
}
|
|
2792
2747
|
}
|
|
2793
2748
|
/**
|
|
2794
2749
|
* Triggers action with parameters.
|
|
@@ -6903,7 +6858,7 @@ class FieldInputDescriptor extends AFieldDescriptor {
|
|
|
6903
6858
|
this._imageUrlInputHiddenOnDisabled = inputVisibleOnDisabled;
|
|
6904
6859
|
return this;
|
|
6905
6860
|
}
|
|
6906
|
-
asCustomComponent(customComponent,
|
|
6861
|
+
asCustomComponent(customComponent, wrappers = ['field'], componentInputs) {
|
|
6907
6862
|
this._fieldType = FieldInputTypeEnum.Custom;
|
|
6908
6863
|
if (typeof customComponent === 'string') {
|
|
6909
6864
|
this._customComponentName = customComponent;
|
|
@@ -6912,8 +6867,8 @@ class FieldInputDescriptor extends AFieldDescriptor {
|
|
|
6912
6867
|
this._customComponentType = customComponent;
|
|
6913
6868
|
this._customComponentInputs = componentInputs;
|
|
6914
6869
|
}
|
|
6915
|
-
if (
|
|
6916
|
-
this._customComponentWrappers =
|
|
6870
|
+
if (wrappers) {
|
|
6871
|
+
this._customComponentWrappers = wrappers;
|
|
6917
6872
|
}
|
|
6918
6873
|
return this;
|
|
6919
6874
|
}
|
|
@@ -6996,6 +6951,7 @@ class FieldActionDescriptor extends AFieldDescriptor {
|
|
|
6996
6951
|
constructor(editor, property) {
|
|
6997
6952
|
super(editor, property);
|
|
6998
6953
|
this._button = new ActionButtonDescriptor();
|
|
6954
|
+
this._wrappers = ['field'];
|
|
6999
6955
|
this._fieldActionName = property;
|
|
7000
6956
|
let displayName = property;
|
|
7001
6957
|
if (this._editor.model)
|
|
@@ -7008,6 +6964,9 @@ class FieldActionDescriptor extends AFieldDescriptor {
|
|
|
7008
6964
|
get runFunction() {
|
|
7009
6965
|
return this._runFunction;
|
|
7010
6966
|
}
|
|
6967
|
+
get wrappers() {
|
|
6968
|
+
return this._wrappers;
|
|
6969
|
+
}
|
|
7011
6970
|
withButtonDescriptor(button) {
|
|
7012
6971
|
this._button = button;
|
|
7013
6972
|
return this;
|
|
@@ -7020,11 +6979,16 @@ class FieldActionDescriptor extends AFieldDescriptor {
|
|
|
7020
6979
|
this._runFunction = fn;
|
|
7021
6980
|
return this;
|
|
7022
6981
|
}
|
|
6982
|
+
withWrappers(wrappers) {
|
|
6983
|
+
this._wrappers = wrappers;
|
|
6984
|
+
return this;
|
|
6985
|
+
}
|
|
7023
6986
|
copy() {
|
|
7024
6987
|
const field = new FieldActionDescriptor(this._editor, this._property);
|
|
7025
6988
|
this.copyFieldsTo(field);
|
|
7026
6989
|
field._button = this._button.copy();
|
|
7027
6990
|
field._runFunction = this._runFunction?.bind(field);
|
|
6991
|
+
field._wrappers = [...this._wrappers];
|
|
7028
6992
|
return field;
|
|
7029
6993
|
}
|
|
7030
6994
|
}
|
|
@@ -7928,6 +7892,7 @@ class EditorFormlyUtil {
|
|
|
7928
7892
|
}
|
|
7929
7893
|
else if (descriptor instanceof FieldActionDescriptor) {
|
|
7930
7894
|
field.type = 'action';
|
|
7895
|
+
field.wrappers = descriptor.wrappers;
|
|
7931
7896
|
delete field.key;
|
|
7932
7897
|
}
|
|
7933
7898
|
else if (descriptor instanceof FieldLookupEnumDescriptor) {
|
|
@@ -8215,6 +8180,55 @@ class ObjectUtil {
|
|
|
8215
8180
|
}
|
|
8216
8181
|
return Array.from(getterSet);
|
|
8217
8182
|
}
|
|
8183
|
+
static getPropertyByPath(value, path) {
|
|
8184
|
+
if (path === '$') {
|
|
8185
|
+
// only return the root
|
|
8186
|
+
return value;
|
|
8187
|
+
}
|
|
8188
|
+
// Check for leading root object notation
|
|
8189
|
+
if (path.startsWith('$')) {
|
|
8190
|
+
path = path.substring(1);
|
|
8191
|
+
}
|
|
8192
|
+
// Check for leading .
|
|
8193
|
+
if (path.startsWith('.')) {
|
|
8194
|
+
path = path.substring(1);
|
|
8195
|
+
}
|
|
8196
|
+
if (path.indexOf('.') >= 0) {
|
|
8197
|
+
const pathSplit = path.split('.');
|
|
8198
|
+
let currValue = value;
|
|
8199
|
+
for (const p of pathSplit) {
|
|
8200
|
+
if (typeof currValue === 'undefined' || currValue === null) {
|
|
8201
|
+
return currValue;
|
|
8202
|
+
}
|
|
8203
|
+
if (!p.length) {
|
|
8204
|
+
// empty path, return current value
|
|
8205
|
+
return currValue;
|
|
8206
|
+
}
|
|
8207
|
+
const leftBracketIdx = p.indexOf('[');
|
|
8208
|
+
if (leftBracketIdx >= 0 && p.endsWith(']')) {
|
|
8209
|
+
// should be reference to array
|
|
8210
|
+
const arrayPath = p.substring(0, leftBracketIdx);
|
|
8211
|
+
const arrayIdx = +p.substring(leftBracketIdx + 1, p.length - 1);
|
|
8212
|
+
const array = currValue[arrayPath];
|
|
8213
|
+
if (Array.isArray(array)) {
|
|
8214
|
+
if (arrayIdx >= 0 && arrayIdx < array.length) {
|
|
8215
|
+
// valid index, continue on the path
|
|
8216
|
+
currValue = array[arrayIdx];
|
|
8217
|
+
continue;
|
|
8218
|
+
}
|
|
8219
|
+
}
|
|
8220
|
+
return undefined;
|
|
8221
|
+
}
|
|
8222
|
+
else if (typeof currValue === 'object') {
|
|
8223
|
+
currValue = currValue[p];
|
|
8224
|
+
}
|
|
8225
|
+
}
|
|
8226
|
+
return currValue;
|
|
8227
|
+
}
|
|
8228
|
+
else {
|
|
8229
|
+
return value[path];
|
|
8230
|
+
}
|
|
8231
|
+
}
|
|
8218
8232
|
}
|
|
8219
8233
|
|
|
8220
8234
|
class StringUtil {
|
|
@@ -12537,52 +12551,11 @@ class MngTableComponent {
|
|
|
12537
12551
|
// Used for configs within this method and is not dynamically set by TableDynamicDescriptor
|
|
12538
12552
|
const baseConfigDescriptor = this.initialDescriptor;
|
|
12539
12553
|
if (!(this.initialDescriptor instanceof TableDynamicDescriptor)) {
|
|
12540
|
-
this.
|
|
12554
|
+
this.setMainAndRelatedDescriptors(this.initialDescriptor);
|
|
12541
12555
|
}
|
|
12542
12556
|
// map row settings
|
|
12543
|
-
this.filterDescriptors = this.descriptor?.columns.filter(c => typeof c.filterDescriptor !== 'undefined').map(c => c.filterDescriptor) ?? [];
|
|
12544
|
-
this.hasColumnFilters = this.filterDescriptors.length > 0;
|
|
12545
12557
|
this.rows = baseConfigDescriptor?.defaultNumRows ?? 25;
|
|
12546
12558
|
this.rowsPerPageOptions = baseConfigDescriptor?.rowsPerPageOptions ?? [25, 50, 100];
|
|
12547
|
-
// get layout preferences if they exist
|
|
12548
|
-
if (this.descriptor?.model.typeName) {
|
|
12549
|
-
this.localstorageKey = TableviewUtil.generateTableLayoutPrefsKey(this.descriptor?.model.typeName, this.router.url, this.descriptor?.dataKey);
|
|
12550
|
-
const preferences = this.localStorageService.getItem(this.cmpTypeName, this.localstorageKey);
|
|
12551
|
-
if (preferences && typeof preferences === 'object') {
|
|
12552
|
-
if (preferences.columnWidths) {
|
|
12553
|
-
this.layoutPreferences.columnWidths = preferences.columnWidths;
|
|
12554
|
-
}
|
|
12555
|
-
if (preferences.columnOrder && Array.isArray(preferences.columnOrder) && preferences.columnOrder.every((el) => typeof el === 'string')) {
|
|
12556
|
-
this.layoutPreferences.columnOrder = preferences.columnOrder;
|
|
12557
|
-
}
|
|
12558
|
-
if (preferences.columnVisibility && Array.isArray(preferences.columnVisibility) && preferences.columnVisibility.every((el) => typeof el === 'string')) {
|
|
12559
|
-
this.layoutPreferences.columnVisibility = preferences.columnVisibility;
|
|
12560
|
-
}
|
|
12561
|
-
}
|
|
12562
|
-
}
|
|
12563
|
-
// initialize columns with additional properties
|
|
12564
|
-
if (this.descriptor?.columns) {
|
|
12565
|
-
this.areColumnsReorderable = this.descriptor.columns.some(value => value.isReorderable);
|
|
12566
|
-
this.areColumnsToggleable = this.descriptor.columns.some(value => value.isToggleable);
|
|
12567
|
-
this.columns = this.descriptor.columns.map(col => ({
|
|
12568
|
-
descriptor: col,
|
|
12569
|
-
disabled: !col.isToggleable,
|
|
12570
|
-
isVisible: this.layoutPreferences.columnVisibility ? this.layoutPreferences.columnVisibility.includes(col.property) : col.isVisible,
|
|
12571
|
-
width: this.layoutPreferences.columnWidths?.[col.property]
|
|
12572
|
-
}));
|
|
12573
|
-
if (this.layoutPreferences.columnOrder) {
|
|
12574
|
-
const newColumnOrder = [];
|
|
12575
|
-
for (const colName of this.layoutPreferences.columnOrder) {
|
|
12576
|
-
const foundCol = this.columns.find(el => el.descriptor.property === colName);
|
|
12577
|
-
if (foundCol) {
|
|
12578
|
-
newColumnOrder.push(foundCol);
|
|
12579
|
-
}
|
|
12580
|
-
}
|
|
12581
|
-
if (newColumnOrder.length === this.columns.length)
|
|
12582
|
-
this.columns = newColumnOrder;
|
|
12583
|
-
}
|
|
12584
|
-
this.visibleColumns = this.columns.filter(el => el.isVisible);
|
|
12585
|
-
}
|
|
12586
12559
|
// process actions
|
|
12587
12560
|
for (const action of this.actions) {
|
|
12588
12561
|
switch (action.position) {
|
|
@@ -12845,13 +12818,7 @@ class MngTableComponent {
|
|
|
12845
12818
|
.subscribe({
|
|
12846
12819
|
next: res => {
|
|
12847
12820
|
if (this.initialDescriptor instanceof TableDynamicDescriptor) {
|
|
12848
|
-
this.
|
|
12849
|
-
this.filterDescriptors = this.descriptor.columns.filter(c => typeof c.filterDescriptor !== 'undefined').map(c => c.filterDescriptor);
|
|
12850
|
-
this.hasColumnFilters = this.filterDescriptors.length > 0;
|
|
12851
|
-
this.isPagination = this.descriptor.paginationMode === TablePaginationModeEnum.Pagination;
|
|
12852
|
-
this.infiniteScroll = this.descriptor.paginationMode === TablePaginationModeEnum.InfiniteScroll;
|
|
12853
|
-
this.rows = this.initialDescriptor.defaultNumRows;
|
|
12854
|
-
this.rowsPerPageOptions = this.initialDescriptor.rowsPerPageOptions;
|
|
12821
|
+
this.setMainAndRelatedDescriptors(this.initialDescriptor.toTableDescriptorFromData(res));
|
|
12855
12822
|
}
|
|
12856
12823
|
if (this.infiniteScroll) {
|
|
12857
12824
|
if (this.isFilterChanged || this.isSortChanged) {
|
|
@@ -12897,6 +12864,50 @@ class MngTableComponent {
|
|
|
12897
12864
|
this.useQueryParamsInitializedSubejct.next(true);
|
|
12898
12865
|
this.loadTableWithDataProvider(mediusQueryParam);
|
|
12899
12866
|
}
|
|
12867
|
+
setMainAndRelatedDescriptors(descriptor) {
|
|
12868
|
+
this.descriptor = descriptor;
|
|
12869
|
+
this.filterDescriptors = this.descriptor?.columns.filter(c => typeof c.filterDescriptor !== 'undefined').map(c => c.filterDescriptor) ?? [];
|
|
12870
|
+
this.hasColumnFilters = this.filterDescriptors.length > 0;
|
|
12871
|
+
// get layout preferences if they exist
|
|
12872
|
+
if (this.descriptor?.model.typeName) {
|
|
12873
|
+
this.localstorageKey = TableviewUtil.generateTableLayoutPrefsKey(this.descriptor?.model.typeName, this.router.url, this.descriptor?.dataKey);
|
|
12874
|
+
const preferences = this.localStorageService.getItem(this.cmpTypeName, this.localstorageKey);
|
|
12875
|
+
if (preferences && typeof preferences === 'object') {
|
|
12876
|
+
if (preferences.columnWidths) {
|
|
12877
|
+
this.layoutPreferences.columnWidths = preferences.columnWidths;
|
|
12878
|
+
}
|
|
12879
|
+
if (preferences.columnOrder && Array.isArray(preferences.columnOrder) && preferences.columnOrder.every((el) => typeof el === 'string')) {
|
|
12880
|
+
this.layoutPreferences.columnOrder = preferences.columnOrder;
|
|
12881
|
+
}
|
|
12882
|
+
if (preferences.columnVisibility && Array.isArray(preferences.columnVisibility) && preferences.columnVisibility.every((el) => typeof el === 'string')) {
|
|
12883
|
+
this.layoutPreferences.columnVisibility = preferences.columnVisibility;
|
|
12884
|
+
}
|
|
12885
|
+
}
|
|
12886
|
+
}
|
|
12887
|
+
// initialize columns with additional properties
|
|
12888
|
+
if (this.descriptor?.columns) {
|
|
12889
|
+
this.areColumnsReorderable = this.descriptor.columns.some(value => value.isReorderable);
|
|
12890
|
+
this.areColumnsToggleable = this.descriptor.columns.some(value => value.isToggleable);
|
|
12891
|
+
this.columns = this.descriptor.columns.map(col => ({
|
|
12892
|
+
descriptor: col,
|
|
12893
|
+
disabled: !col.isToggleable,
|
|
12894
|
+
isVisible: this.layoutPreferences.columnVisibility ? this.layoutPreferences.columnVisibility.includes(col.property) : col.isVisible,
|
|
12895
|
+
width: this.layoutPreferences.columnWidths?.[col.property]
|
|
12896
|
+
}));
|
|
12897
|
+
if (this.layoutPreferences.columnOrder) {
|
|
12898
|
+
const newColumnOrder = [];
|
|
12899
|
+
for (const colName of this.layoutPreferences.columnOrder) {
|
|
12900
|
+
const foundCol = this.columns.find(el => el.descriptor.property === colName);
|
|
12901
|
+
if (foundCol) {
|
|
12902
|
+
newColumnOrder.push(foundCol);
|
|
12903
|
+
}
|
|
12904
|
+
}
|
|
12905
|
+
if (newColumnOrder.length === this.columns.length)
|
|
12906
|
+
this.columns = newColumnOrder;
|
|
12907
|
+
}
|
|
12908
|
+
this.visibleColumns = this.columns.filter(el => el.isVisible);
|
|
12909
|
+
}
|
|
12910
|
+
}
|
|
12900
12911
|
updatePrimeSortAndFilter(mediusQueryParam) {
|
|
12901
12912
|
this.multiSortMeta = this.createSortMeta(mediusQueryParam);
|
|
12902
12913
|
this.filterMetadata = this.createFilterMeta(mediusQueryParam);
|
|
@@ -13944,7 +13955,7 @@ class MngFormlyFieldTableDialogMultiselectComponent extends FieldType {
|
|
|
13944
13955
|
this.descriptor.lookupTableDescriptor.defaultSortProperty.forEach((p, idx) => queryParamBuilder.withSort(p, this.descriptor.lookupTableDescriptor.defaultSortAsc[idx]));
|
|
13945
13956
|
}
|
|
13946
13957
|
if (this.descriptor.hasLookupExcludeValues) {
|
|
13947
|
-
const filterValues = this.formControl.value.map((i) => i
|
|
13958
|
+
const filterValues = this.formControl.value.map((i) => ObjectUtil.getPropertyByPath(i, this.descriptor.excludeValueProperty));
|
|
13948
13959
|
queryParamBuilder.withFilter(this.descriptor.excludeFilterProperty, filterValues, undefined, MediusFilterMatchType.NotIn);
|
|
13949
13960
|
}
|
|
13950
13961
|
this.lookupDataProviderSubscription = this.descriptor.lookupTableDataProvider?.getAll(queryParamBuilder.build(), this.dialogDataProviderService).subscribe({
|
|
@@ -14005,7 +14016,7 @@ class MngFormlyFieldTableDialogMultiselectComponent extends FieldType {
|
|
|
14005
14016
|
name: 'FormlyFieldTableDialogMultiselectComponentError'
|
|
14006
14017
|
});
|
|
14007
14018
|
}
|
|
14008
|
-
value = value.filter((i) => i
|
|
14019
|
+
value = value.filter((i) => ObjectUtil.getPropertyByPath(i, compareProperty) !== ObjectUtil.getPropertyByPath(item, compareProperty));
|
|
14009
14020
|
this.formControl.patchValue(value);
|
|
14010
14021
|
this.formControl.markAsTouched();
|
|
14011
14022
|
this.formControl.markAsDirty();
|
|
@@ -14064,7 +14075,8 @@ class MngFormlyFieldActionComponent extends FieldType {
|
|
|
14064
14075
|
this.buttonClass = this.descriptor.button.styleClass.build();
|
|
14065
14076
|
}
|
|
14066
14077
|
onClick() {
|
|
14067
|
-
this.
|
|
14078
|
+
this.actionMessage = undefined;
|
|
14079
|
+
const result = this.descriptor.runFunction?.({
|
|
14068
14080
|
descriptor: this.descriptor,
|
|
14069
14081
|
formEditorComponent: this.props.formEditorComponent,
|
|
14070
14082
|
formly: {
|
|
@@ -14076,13 +14088,26 @@ class MngFormlyFieldActionComponent extends FieldType {
|
|
|
14076
14088
|
props: this.props
|
|
14077
14089
|
}
|
|
14078
14090
|
});
|
|
14091
|
+
if (result) {
|
|
14092
|
+
if (isObservable(result)) {
|
|
14093
|
+
result.subscribe(res => this.processResult(res));
|
|
14094
|
+
}
|
|
14095
|
+
else {
|
|
14096
|
+
this.processResult(result);
|
|
14097
|
+
}
|
|
14098
|
+
}
|
|
14099
|
+
}
|
|
14100
|
+
processResult(res) {
|
|
14101
|
+
if (res.message) {
|
|
14102
|
+
this.actionMessage = res.message;
|
|
14103
|
+
}
|
|
14079
14104
|
}
|
|
14080
14105
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: MngFormlyFieldActionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
14081
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: MngFormlyFieldActionComponent, isStandalone: true, selector: "mng-formly-field-action", usesInheritance: true, ngImport: i0, template: "<button\n
|
|
14106
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: MngFormlyFieldActionComponent, isStandalone: true, selector: "mng-formly-field-action", usesInheritance: true, ngImport: i0, template: "<div class=\"flex\">\n <button\n type=\"button\"\n pButton\n pRipple\n [icon]=\"$any(descriptor.button.icon)\"\n [label]=\"$any(descriptor.button.label === null ? null : descriptor.button.label ?? props!.label) | translate\"\n [pTooltip]=\"$any(descriptor.button.tooltip) | translate\"\n [disabled]=\"formControl.disabled\"\n (click)=\"onClick()\"\n [class]=\"buttonClass + (actionMessage ? ' mr-2' : '')\"></button>\n <p-message *ngIf=\"actionMessage\" [text]=\"actionMessage.content\" [severity]=\"actionMessage.severity ?? 'success'\"></p-message>\n</div>\n", dependencies: [{ kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i6.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { kind: "ngmodule", type: RippleModule }, { kind: "directive", type: i6$1.Ripple, selector: "[pRipple]" }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i4$1.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions"] }, { kind: "ngmodule", type: MessageModule }, { kind: "component", type: i5$2.UIMessage, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
14082
14107
|
}
|
|
14083
14108
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: MngFormlyFieldActionComponent, decorators: [{
|
|
14084
14109
|
type: Component,
|
|
14085
|
-
args: [{ standalone: true, selector: 'mng-formly-field-action', imports: [ButtonModule, RippleModule, TranslateModule, TooltipModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<button\n
|
|
14110
|
+
args: [{ standalone: true, selector: 'mng-formly-field-action', imports: [ButtonModule, RippleModule, TranslateModule, TooltipModule, JsonPipe, MessageModule, NgIf], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"flex\">\n <button\n type=\"button\"\n pButton\n pRipple\n [icon]=\"$any(descriptor.button.icon)\"\n [label]=\"$any(descriptor.button.label === null ? null : descriptor.button.label ?? props!.label) | translate\"\n [pTooltip]=\"$any(descriptor.button.tooltip) | translate\"\n [disabled]=\"formControl.disabled\"\n (click)=\"onClick()\"\n [class]=\"buttonClass + (actionMessage ? ' mr-2' : '')\"></button>\n <p-message *ngIf=\"actionMessage\" [text]=\"actionMessage.content\" [severity]=\"actionMessage.severity ?? 'success'\"></p-message>\n</div>\n" }]
|
|
14086
14111
|
}] });
|
|
14087
14112
|
|
|
14088
14113
|
class MngFormlyFieldCustomComponent extends FieldType {
|