@ecodev/natural 38.0.1 → 41.0.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/bundles/ecodev-natural.umd.js +81 -43
- package/bundles/ecodev-natural.umd.js.map +1 -1
- package/ecodev-natural.metadata.json +1 -1
- package/esm2015/lib/classes/abstract-list.js +14 -18
- package/esm2015/lib/classes/rxjs.js +13 -2
- package/esm2015/lib/classes/validators.js +15 -1
- package/esm2015/lib/modules/columns-picker/columns-picker.component.js +26 -8
- package/esm2015/lib/modules/hierarchic-selector/hierarchic-selector-dialog/hierarchic-selector-dialog.component.js +1 -1
- package/fesm2015/ecodev-natural.js +66 -27
- package/fesm2015/ecodev-natural.js.map +1 -1
- package/lib/classes/abstract-list.d.ts +6 -9
- package/lib/classes/rxjs.d.ts +6 -1
- package/lib/classes/validators.d.ts +7 -0
- package/lib/modules/columns-picker/columns-picker.component.d.ts +15 -5
- package/package.json +1 -1
- package/theming/_natural.theme.scss +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/localize/init'), require('@angular/core'), require('rxjs'), require('@angular/forms'), require('@angular/router'), require('lodash-es'), require('@angular/material/dialog'), require('@angular/material/snack-bar'), require('rxjs/operators'), require('@angular/material/table'), require('@angular/cdk/collections'), require('apollo-angular'), require('@apollo/client/core'), require('@angular/material/core'), require('@angular/cdk/platform'), require('@angular/common'), require('@angular/material/button'), require('@angular/material/checkbox'), require('@angular/material/menu'), require('@angular/material/icon'), require('@angular/platform-browser'), require('@angular/material/tooltip'), require('@angular/material/tabs'), require('@angular/material/form-field'), require('@angular/material/input'), require('@angular/material/select'), require('@angular/material/list'), require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/cdk/a11y'), require('@angular/animations'), require('@angular/material/datepicker'), require('@angular/cdk/tree'), require('@angular/material/chips'), require('@angular/material/progress-spinner'), require('@angular/material/tree'), require('@angular/material/autocomplete'), require('@angular/cdk/coercion'), require('@angular/flex-layout'), require('@angular/flex-layout/core'), require('@angular/material/paginator'), require('@angular/material/sidenav'), require('ts-md5')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define('@ecodev/natural', ['exports', '@angular/localize/init', '@angular/core', 'rxjs', '@angular/forms', '@angular/router', 'lodash-es', '@angular/material/dialog', '@angular/material/snack-bar', 'rxjs/operators', '@angular/material/table', '@angular/cdk/collections', 'apollo-angular', '@apollo/client/core', '@angular/material/core', '@angular/cdk/platform', '@angular/common', '@angular/material/button', '@angular/material/checkbox', '@angular/material/menu', '@angular/material/icon', '@angular/platform-browser', '@angular/material/tooltip', '@angular/material/tabs', '@angular/material/form-field', '@angular/material/input', '@angular/material/select', '@angular/material/list', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/cdk/a11y', '@angular/animations', '@angular/material/datepicker', '@angular/cdk/tree', '@angular/material/chips', '@angular/material/progress-spinner', '@angular/material/tree', '@angular/material/autocomplete', '@angular/cdk/coercion', '@angular/flex-layout', '@angular/flex-layout/core', '@angular/material/paginator', '@angular/material/sidenav', 'ts-md5'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ecodev = global.ecodev || {}, global.ecodev.natural = {}), global.ng.localize.init, global.ng.core, global.rxjs, global.ng.forms, global.ng.router, global["lodash-es"], global.ng.material.dialog, global.ng.material.snackBar, global.rxjs.operators, global.ng.material.table, global.ng.cdk.collections, global["apollo-angular"], global
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ecodev = global.ecodev || {}, global.ecodev.natural = {}), global.ng.localize.init, global.ng.core, global.rxjs, global.ng.forms, global.ng.router, global["lodash-es"], global.ng.material.dialog, global.ng.material.snackBar, global.rxjs.operators, global.ng.material.table, global.ng.cdk.collections, global["apollo-angular"], global["@apollo/client/core"], global.ng.material.core, global.ng.cdk.platform, global.ng.common, global.ng.material.button, global.ng.material.checkbox, global.ng.material.menu, global.ng.material.icon, global.ng.platformBrowser, global.ng.material.tooltip, global.ng.material.tabs, global.ng.material.formField, global.ng.material.input, global.ng.material.select, global.ng.material.list, global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.cdk.a11y, global.ng.animations, global.ng.material.datepicker, global.ng.cdk.tree, global.ng.material.chips, global.ng.material.progressSpinner, global.ng.material.tree, global.ng.material.autocomplete, global.ng.cdk.coercion, global.ng.flexLayout, global.ng.flexLayout.core, global.ng.material.paginator, global.ng.material.sidenav, global["ts-md5"]));
|
|
5
5
|
})(this, (function (exports, init, i0, rxjs, forms, i1$1, lodashEs, i1, i2, operators, table, collections, i1$2, core, i1$3, i2$1, i1$4, button, checkbox, menu, icon, i2$2, tooltip, tabs, formField, input, select, list, i1$5, portal, a11y, animations, datepicker, tree$1, chips, progressSpinner, tree, autocomplete, coercion, flexLayout, i4, paginator, sidenav, tsMd5) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespace(e) {
|
|
@@ -2384,6 +2384,21 @@
|
|
|
2384
2384
|
return rxjs.timer(500).pipe(operators.switchMap(function () { return modelService.count(qvm).pipe(operators.map(function (count) { return (count > 0 ? { duplicateValue: count } : null); })); }));
|
|
2385
2385
|
};
|
|
2386
2386
|
}
|
|
2387
|
+
/**
|
|
2388
|
+
* Returns an async validator function that checks that the form control value is available
|
|
2389
|
+
*
|
|
2390
|
+
* Similar to `unique` validator, but allows to use a custom query for when the client does
|
|
2391
|
+
* not have permissions for `modelService.count()`.
|
|
2392
|
+
*/
|
|
2393
|
+
function available(getAvailableQuery, excludedId) {
|
|
2394
|
+
if (excludedId === void 0) { excludedId = null; }
|
|
2395
|
+
return function (control) {
|
|
2396
|
+
if (!control.value || !control.dirty) {
|
|
2397
|
+
return rxjs.of(null);
|
|
2398
|
+
}
|
|
2399
|
+
return rxjs.timer(500).pipe(operators.switchMap(function () { return getAvailableQuery(control.value, excludedId).pipe(operators.map(function (isAvailable) { return (isAvailable ? null : { available: true }); })); }));
|
|
2400
|
+
};
|
|
2401
|
+
}
|
|
2387
2402
|
/**
|
|
2388
2403
|
* Return all errors recursively for the given Form or control
|
|
2389
2404
|
*/
|
|
@@ -3357,7 +3372,7 @@
|
|
|
3357
3372
|
* Components inheriting from this class can be used as standalone with input attributes.
|
|
3358
3373
|
*
|
|
3359
3374
|
* Usage :
|
|
3360
|
-
* <natural-my-listing [forcedVariables]="{filter:...}" [
|
|
3375
|
+
* <natural-my-listing [forcedVariables]="{filter:...}" [selectedColumns]="['col1']" [persistSearch]="false">
|
|
3361
3376
|
*/
|
|
3362
3377
|
// @dynamic
|
|
3363
3378
|
var NaturalAbstractList = /** @class */ (function (_super) {
|
|
@@ -3373,7 +3388,7 @@
|
|
|
3373
3388
|
/**
|
|
3374
3389
|
* Columns list after interaction with <natural-columns-picker>
|
|
3375
3390
|
*/
|
|
3376
|
-
_this.
|
|
3391
|
+
_this.columnsForTable = [];
|
|
3377
3392
|
/**
|
|
3378
3393
|
* The default column selection that automatically happened after <natural-columns-picker> initialization
|
|
3379
3394
|
*/
|
|
@@ -3624,7 +3639,7 @@
|
|
|
3624
3639
|
* Uses data provided by router such as:
|
|
3625
3640
|
*
|
|
3626
3641
|
* - `route.data.forcedVariables`
|
|
3627
|
-
* - `route.data.
|
|
3642
|
+
* - `route.data.selectedColumns`
|
|
3628
3643
|
*/
|
|
3629
3644
|
NaturalAbstractList.prototype.initFromRoute = function () {
|
|
3630
3645
|
// Variables
|
|
@@ -3632,8 +3647,8 @@
|
|
|
3632
3647
|
this.applyForcedVariables(this.route.snapshot.data.forcedVariables);
|
|
3633
3648
|
}
|
|
3634
3649
|
// Columns
|
|
3635
|
-
if (this.route.snapshot.data.
|
|
3636
|
-
this.
|
|
3650
|
+
if (this.route.snapshot.data.selectedColumns) {
|
|
3651
|
+
this.selectedColumns = this.route.snapshot.data.selectedColumns;
|
|
3637
3652
|
}
|
|
3638
3653
|
};
|
|
3639
3654
|
NaturalAbstractList.prototype.getDataObservable = function () {
|
|
@@ -3659,6 +3674,11 @@
|
|
|
3659
3674
|
if (sorting) {
|
|
3660
3675
|
this.variablesManager.set('sorting', { sorting: sorting });
|
|
3661
3676
|
}
|
|
3677
|
+
// Columns
|
|
3678
|
+
var persistedColumns = this.persistenceService.get('col', this.route, storageKey);
|
|
3679
|
+
if (typeof persistedColumns === 'string') {
|
|
3680
|
+
this.selectedColumns = persistedColumns.split(',');
|
|
3681
|
+
}
|
|
3662
3682
|
// Natural search : ns
|
|
3663
3683
|
this.naturalSearchSelections = fromUrl(this.persistenceService.get('ns', this.route, storageKey));
|
|
3664
3684
|
this.translateSearchAndRefreshList(this.naturalSearchSelections, true);
|
|
@@ -3716,34 +3736,21 @@
|
|
|
3716
3736
|
this.variablesManager.set('sorting', { sorting: variables.sorting });
|
|
3717
3737
|
}
|
|
3718
3738
|
};
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
if
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
if (typeof persistedColumns === 'string') {
|
|
3735
|
-
this.selectedColumns = persistedColumns.split(',');
|
|
3736
|
-
}
|
|
3737
|
-
}
|
|
3738
|
-
else {
|
|
3739
|
-
// Persist only if wanted columns are different from default selection
|
|
3740
|
-
var value = lodashEs.isEqual(this.defaultSelectedColumns, columns) ? null : columns.join(',');
|
|
3741
|
-
this.persistenceService.persist('col', value, this.route, this.getStorageKey());
|
|
3742
|
-
}
|
|
3743
|
-
},
|
|
3744
|
-
enumerable: false,
|
|
3745
|
-
configurable: true
|
|
3746
|
-
});
|
|
3739
|
+
NaturalAbstractList.prototype.selectColumns = function (columns) {
|
|
3740
|
+
this.columnsForTable = columns;
|
|
3741
|
+
if (!this.persistSearch || this.isPanel) {
|
|
3742
|
+
return;
|
|
3743
|
+
}
|
|
3744
|
+
// The first selection we receive is the default one made by <natural-columns-picker>
|
|
3745
|
+
if (!this.defaultSelectedColumns) {
|
|
3746
|
+
this.defaultSelectedColumns = columns;
|
|
3747
|
+
}
|
|
3748
|
+
else {
|
|
3749
|
+
// Persist only if wanted columns are different from default selection
|
|
3750
|
+
var value = lodashEs.isEqual(this.defaultSelectedColumns, columns) ? null : columns.join(',');
|
|
3751
|
+
this.persistenceService.persist('col', value, this.route, this.getStorageKey());
|
|
3752
|
+
}
|
|
3753
|
+
};
|
|
3747
3754
|
return NaturalAbstractList;
|
|
3748
3755
|
}(NaturalAbstractPanel));
|
|
3749
3756
|
NaturalAbstractList.decorators = [
|
|
@@ -3755,7 +3762,7 @@
|
|
|
3755
3762
|
]; };
|
|
3756
3763
|
NaturalAbstractList.propDecorators = {
|
|
3757
3764
|
persistSearch: [{ type: i0.Input }],
|
|
3758
|
-
|
|
3765
|
+
selectedColumns: [{ type: i0.Input }],
|
|
3759
3766
|
forcedVariables: [{ type: i0.Input }]
|
|
3760
3767
|
};
|
|
3761
3768
|
var templateObject_1$6, templateObject_2$1, templateObject_3$1, templateObject_4$1;
|
|
@@ -3953,6 +3960,17 @@
|
|
|
3953
3960
|
return;
|
|
3954
3961
|
}));
|
|
3955
3962
|
}
|
|
3963
|
+
/**
|
|
3964
|
+
* For debugging purpose only, will dump in console everything that happen to
|
|
3965
|
+
* the observable
|
|
3966
|
+
*/
|
|
3967
|
+
function debug(debugName) {
|
|
3968
|
+
return operators.tap({
|
|
3969
|
+
next: function (value) { return console.log('NEXT', debugName, value); },
|
|
3970
|
+
error: function (error) { return console.log('ERROR', debugName, error); },
|
|
3971
|
+
complete: function () { return console.log('COMPLETE', debugName); },
|
|
3972
|
+
});
|
|
3973
|
+
}
|
|
3956
3974
|
|
|
3957
3975
|
var NaturalAbstractModelService = /** @class */ (function () {
|
|
3958
3976
|
function NaturalAbstractModelService(apollo, name, oneQuery, allQuery, createMutation, updateMutation, deleteMutation) {
|
|
@@ -4844,20 +4862,38 @@
|
|
|
4844
4862
|
function NaturalColumnsPickerComponent(changeDetectorRef) {
|
|
4845
4863
|
this.changeDetectorRef = changeDetectorRef;
|
|
4846
4864
|
/**
|
|
4847
|
-
* Emit a list of column keys whenever the selection changes
|
|
4865
|
+
* Emit a list of valid and selected column keys whenever the selection changes
|
|
4848
4866
|
*/
|
|
4849
4867
|
this.selectionChange = new i0.EventEmitter();
|
|
4850
|
-
|
|
4868
|
+
/**
|
|
4869
|
+
* Available columns are defined by options in the template
|
|
4870
|
+
*/
|
|
4851
4871
|
this.availableColumns = null;
|
|
4872
|
+
/**
|
|
4873
|
+
* Displayed options in the dropdown menu
|
|
4874
|
+
*/
|
|
4852
4875
|
this.displayedColumns = [];
|
|
4853
4876
|
this.ngUnsubscribe = new rxjs.Subject();
|
|
4854
4877
|
}
|
|
4855
|
-
Object.defineProperty(NaturalColumnsPickerComponent.prototype, "
|
|
4878
|
+
Object.defineProperty(NaturalColumnsPickerComponent.prototype, "selections", {
|
|
4879
|
+
/**
|
|
4880
|
+
* Set the columns that are wanted but might be unavailable.
|
|
4881
|
+
*
|
|
4882
|
+
* If a column is unavailable it will be ignored silently. To know what columns were actually applied
|
|
4883
|
+
* you should use `selectionChange`.
|
|
4884
|
+
*
|
|
4885
|
+
* It is often set once on component initialization, but it can also be set again later in the lifespan of the component.
|
|
4886
|
+
*/
|
|
4856
4887
|
set: function (columns) {
|
|
4857
4888
|
var _a;
|
|
4889
|
+
this._selections = columns;
|
|
4890
|
+
if (!columns || !this.availableColumns) {
|
|
4891
|
+
return;
|
|
4892
|
+
}
|
|
4858
4893
|
(_a = this.availableColumns) === null || _a === void 0 ? void 0 : _a.forEach(function (col) {
|
|
4859
4894
|
col.checked = columns.includes(col.key);
|
|
4860
4895
|
});
|
|
4896
|
+
this.updateColumns();
|
|
4861
4897
|
},
|
|
4862
4898
|
enumerable: false,
|
|
4863
4899
|
configurable: true
|
|
@@ -4874,8 +4910,10 @@
|
|
|
4874
4910
|
var _this = this;
|
|
4875
4911
|
var _a, _b, _c;
|
|
4876
4912
|
(_a = this.availableColumns) === null || _a === void 0 ? void 0 : _a.forEach(function (col) {
|
|
4877
|
-
|
|
4913
|
+
var _a;
|
|
4914
|
+
col.checked = ((_a = _this._selections) === null || _a === void 0 ? void 0 : _a.length) ? _this._selections.includes(col.key) : col.checked;
|
|
4878
4915
|
});
|
|
4916
|
+
// Show options only for columns that are not hidden
|
|
4879
4917
|
this.displayedColumns = (_c = (_b = this.availableColumns) === null || _b === void 0 ? void 0 : _b.filter(function (col) { return !col.hidden; })) !== null && _c !== void 0 ? _c : [];
|
|
4880
4918
|
};
|
|
4881
4919
|
NaturalColumnsPickerComponent.prototype.updateColumns = function () {
|
|
@@ -4900,10 +4938,8 @@
|
|
|
4900
4938
|
{ type: i0.ChangeDetectorRef }
|
|
4901
4939
|
]; };
|
|
4902
4940
|
NaturalColumnsPickerComponent.propDecorators = {
|
|
4903
|
-
|
|
4941
|
+
selections: [{ type: i0.Input }],
|
|
4904
4942
|
selectionChange: [{ type: i0.Output }],
|
|
4905
|
-
defaultSelectionChange: [{ type: i0.Output }],
|
|
4906
|
-
initialSelection: [{ type: i0.Input }],
|
|
4907
4943
|
availableColumns: [{ type: i0.ContentChildren, args: [NaturalColumnsPickerColumnDirective,] }]
|
|
4908
4944
|
};
|
|
4909
4945
|
|
|
@@ -7178,7 +7214,7 @@
|
|
|
7178
7214
|
}());
|
|
7179
7215
|
NaturalHierarchicSelectorDialogComponent.decorators = [
|
|
7180
7216
|
{ type: i0.Component, args: [{
|
|
7181
|
-
template: "<h2 i18n mat-dialog-title>S\u00E9lection</h2>\n\n<mat-dialog-content>\n <natural-hierarchic-selector\n (selectionChange)=\"config.hierarchicSelection = $event\"\n [selected]=\"config.hierarchicSelection ?? {}\"\n [config]=\"config.hierarchicConfig\"\n [filters]=\"config.hierarchicFilters\"\n [multiple]=\"config.multiple ?? false\"\n [allowUnselect]=\"config.allowUnselect ?? true\"\n [searchFacets]=\"config.searchFacets ?? []\"\n [searchSelections]=\"config.searchSelections ?? []\"\n (searchSelectionChange)=\"searchSelectionsOutput = $event\"\n ></natural-hierarchic-selector>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button [mat-dialog-close]
|
|
7217
|
+
template: "<h2 i18n mat-dialog-title>S\u00E9lection</h2>\n\n<mat-dialog-content>\n <natural-hierarchic-selector\n (selectionChange)=\"config.hierarchicSelection = $event\"\n [selected]=\"config.hierarchicSelection ?? {}\"\n [config]=\"config.hierarchicConfig\"\n [filters]=\"config.hierarchicFilters\"\n [multiple]=\"config.multiple ?? false\"\n [allowUnselect]=\"config.allowUnselect ?? true\"\n [searchFacets]=\"config.searchFacets ?? []\"\n [searchSelections]=\"config.searchSelections ?? []\"\n (searchSelectionChange)=\"searchSelectionsOutput = $event\"\n ></natural-hierarchic-selector>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button [mat-dialog-close] mat-button i18n>Annuler</button>\n <button (click)=\"close(config.hierarchicSelection)\" color=\"primary\" mat-raised-button\n ><span i18n>Valider</span>\n </button>\n</mat-dialog-actions>\n",
|
|
7182
7218
|
styles: [":host mat-dialog-actions{display:flex;flex-direction:row;justify-content:flex-end}\n"]
|
|
7183
7219
|
},] }
|
|
7184
7220
|
];
|
|
@@ -11196,9 +11232,11 @@
|
|
|
11196
11232
|
exports.TypeNumberComponent = TypeNumberComponent;
|
|
11197
11233
|
exports.TypeSelectComponent = TypeSelectComponent;
|
|
11198
11234
|
exports.TypeTextComponent = TypeTextComponent;
|
|
11235
|
+
exports.available = available;
|
|
11199
11236
|
exports.cancellableTimeout = cancellableTimeout;
|
|
11200
11237
|
exports.cleanSameValues = cleanSameValues;
|
|
11201
11238
|
exports.collectErrors = collectErrors;
|
|
11239
|
+
exports.debug = debug;
|
|
11202
11240
|
exports.decimal = decimal;
|
|
11203
11241
|
exports.deliverableEmail = deliverableEmail;
|
|
11204
11242
|
exports.ensureHttpPrefix = ensureHttpPrefix;
|