@mediusinc/mng-commons 1.2.0 → 1.3.0-1c14fa2b
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/esm2020/lib/components/tableview/table/column-value/column-value.component.mjs +3 -3
- package/esm2020/lib/components/tableview/table/table.component.mjs +25 -24
- package/esm2020/lib/descriptors/column.descriptor.mjs +1 -1
- package/esm2020/lib/descriptors/filter.descriptor.mjs +50 -3
- package/esm2020/lib/services/commons.service.mjs +14 -1
- package/fesm2015/mediusinc-mng-commons.mjs +89 -27
- package/fesm2015/mediusinc-mng-commons.mjs.map +1 -1
- package/fesm2020/mediusinc-mng-commons.mjs +88 -27
- package/fesm2020/mediusinc-mng-commons.mjs.map +1 -1
- package/lib/descriptors/column.descriptor.d.ts +2 -2
- package/lib/descriptors/filter.descriptor.d.ts +11 -6
- package/lib/services/commons.service.d.ts +4 -0
- package/package.json +1 -1
- package/version-info.json +6 -6
|
@@ -2490,6 +2490,9 @@ class FilterLookupDescriptor extends FilterDescriptor {
|
|
|
2490
2490
|
this._defaultValue = filterValue;
|
|
2491
2491
|
this._defaultValueTo = filterValueTo;
|
|
2492
2492
|
this._defaultFilterMatchMode = filterMatchMode;
|
|
2493
|
+
if (Array.isArray(filterValue) && !this.multiselect) {
|
|
2494
|
+
throw new Error('Array default filter can only be used with a multiselect filter.');
|
|
2495
|
+
}
|
|
2493
2496
|
if (filterMatchMode && this._matchModes && this._matchModes.indexOf(filterMatchMode) < 0) {
|
|
2494
2497
|
this._defaultFilterMatchMode = undefined;
|
|
2495
2498
|
console.warn(`Default filter match mode '${filterMatchMode}' could not be assigned for property ${this._property}.`);
|
|
@@ -2526,14 +2529,16 @@ class FilterLookupDescriptor extends FilterDescriptor {
|
|
|
2526
2529
|
class FilterLookupEnumDescriptor extends FilterLookupDescriptor {
|
|
2527
2530
|
constructor(property, enumType, options, nameAsValue = false, optionsTitlePath) {
|
|
2528
2531
|
super(property, null);
|
|
2532
|
+
this._nameAsValue = false;
|
|
2529
2533
|
this._enumType = enumType;
|
|
2534
|
+
this._nameAsValue = nameAsValue;
|
|
2530
2535
|
if (typeof optionsTitlePath === 'undefined') {
|
|
2531
2536
|
optionsTitlePath = TypeUtil.findEnumName(enumType);
|
|
2532
2537
|
}
|
|
2533
|
-
|
|
2538
|
+
this._optionEnumValues = Array.isArray(options)
|
|
2534
2539
|
? EnumUtil.fromValuesAsEnumValueArray(enumType, options, nameAsValue, optionsTitlePath ?? undefined)
|
|
2535
2540
|
: EnumUtil.fromConstantsAsEnumValueArray(enumType, nameAsValue, optionsTitlePath ?? undefined);
|
|
2536
|
-
const dataProvider = new LookupDataProvider(null).withLookup(() => of(
|
|
2541
|
+
const dataProvider = new LookupDataProvider(null).withLookup(() => of(this._optionEnumValues));
|
|
2537
2542
|
this.withLookupDataProvider(dataProvider);
|
|
2538
2543
|
this.withItemsLabelProperty('title', optionsTitlePath !== null);
|
|
2539
2544
|
this.withItemsValueProperty('value');
|
|
@@ -2545,6 +2550,48 @@ class FilterLookupEnumDescriptor extends FilterLookupDescriptor {
|
|
|
2545
2550
|
super.asAutocomplete(openOnFocus, true);
|
|
2546
2551
|
return this;
|
|
2547
2552
|
}
|
|
2553
|
+
withMultiselectEnum(multiselect = true) {
|
|
2554
|
+
return super.withMultiselect(multiselect);
|
|
2555
|
+
}
|
|
2556
|
+
withDefaultFilter(filterValue, filterValueTo, filterMatchMode) {
|
|
2557
|
+
throw new Error(`withDefaultFilter on FilterLookupEnumDescriptor should not be used. Use withDefaultFilterEnum instead.`);
|
|
2558
|
+
}
|
|
2559
|
+
withDefaultFilterEnum(filterValue, filterValueTo, filterMatchMode) {
|
|
2560
|
+
let defaultOptionValue;
|
|
2561
|
+
if (Array.isArray(filterValue)) {
|
|
2562
|
+
defaultOptionValue = this._nameAsValue ? filterValue.map(value => EnumUtil.getConstantName(this._enumType, value)) : filterValue;
|
|
2563
|
+
}
|
|
2564
|
+
else {
|
|
2565
|
+
defaultOptionValue = this._nameAsValue ? EnumUtil.getConstantName(this._enumType, filterValue) : filterValue;
|
|
2566
|
+
}
|
|
2567
|
+
let defaultOptionValueTo;
|
|
2568
|
+
if (filterValueTo) {
|
|
2569
|
+
defaultOptionValueTo = this._nameAsValue ? EnumUtil.getConstantName(this._enumType, filterValueTo) : filterValueTo;
|
|
2570
|
+
}
|
|
2571
|
+
if (defaultOptionValue) {
|
|
2572
|
+
let option;
|
|
2573
|
+
if (Array.isArray(defaultOptionValue)) {
|
|
2574
|
+
option = defaultOptionValue.map(value => this._optionEnumValues.find(o => o.value === value));
|
|
2575
|
+
}
|
|
2576
|
+
else {
|
|
2577
|
+
option = this._optionEnumValues.find(o => o.value === defaultOptionValue);
|
|
2578
|
+
}
|
|
2579
|
+
const optionTo = defaultOptionValueTo ? this._optionEnumValues.find(o => o.value === defaultOptionValueTo) : undefined;
|
|
2580
|
+
let filterValueFromArrayTo = undefined;
|
|
2581
|
+
if (optionTo) {
|
|
2582
|
+
filterValueFromArrayTo = this._itemsValueProperty ? optionTo[this._itemsValueProperty] : optionTo;
|
|
2583
|
+
}
|
|
2584
|
+
let filterValueFromArray;
|
|
2585
|
+
if (Array.isArray(option)) {
|
|
2586
|
+
filterValueFromArray = this._itemsValueProperty ? option.map(value => value[this._itemsValueProperty]) : option;
|
|
2587
|
+
}
|
|
2588
|
+
else {
|
|
2589
|
+
filterValueFromArray = this._itemsValueProperty ? option[this._itemsValueProperty] : option;
|
|
2590
|
+
}
|
|
2591
|
+
super.withDefaultFilter(filterValueFromArray, filterValueFromArrayTo, filterMatchMode);
|
|
2592
|
+
}
|
|
2593
|
+
return this;
|
|
2594
|
+
}
|
|
2548
2595
|
copy() {
|
|
2549
2596
|
const field = new FilterLookupEnumDescriptor(this._property, this._enumType, []);
|
|
2550
2597
|
this.copyFieldsTo(field);
|
|
@@ -4424,6 +4471,9 @@ class MngCommonsService {
|
|
|
4424
4471
|
this.userSubject = new ReplaySubject(1);
|
|
4425
4472
|
this._userRoles = [];
|
|
4426
4473
|
this.userRolesSubject = new BehaviorSubject([]);
|
|
4474
|
+
// language
|
|
4475
|
+
this.languageSubject = new ReplaySubject(1);
|
|
4476
|
+
this.dataLanguageSubject = new ReplaySubject(1);
|
|
4427
4477
|
}
|
|
4428
4478
|
// APP section
|
|
4429
4479
|
get appName() {
|
|
@@ -4459,13 +4509,18 @@ class MngCommonsService {
|
|
|
4459
4509
|
set appLanguage(language) {
|
|
4460
4510
|
if (language === null) {
|
|
4461
4511
|
this.localStorage.removeItem('lang');
|
|
4512
|
+
this.languageSubject.next(language);
|
|
4462
4513
|
return;
|
|
4463
4514
|
}
|
|
4464
4515
|
if (this.appLanguages.some(l => l === language)) {
|
|
4465
4516
|
this.localStorage.setItem('lang', language);
|
|
4517
|
+
this.languageSubject.next(language);
|
|
4466
4518
|
this.translate.use(language);
|
|
4467
4519
|
}
|
|
4468
4520
|
}
|
|
4521
|
+
get appLanguage$() {
|
|
4522
|
+
return this.languageSubject.asObservable();
|
|
4523
|
+
}
|
|
4469
4524
|
initLanguage() {
|
|
4470
4525
|
const browserLang = this.translate.getBrowserLang();
|
|
4471
4526
|
if (browserLang && this.appLanguages.some(l => l === browserLang)) {
|
|
@@ -4495,12 +4550,17 @@ class MngCommonsService {
|
|
|
4495
4550
|
set appDataLanguage(dataLanguage) {
|
|
4496
4551
|
if (dataLanguage === null) {
|
|
4497
4552
|
this.localStorage.removeItem('dataLang');
|
|
4553
|
+
this.dataLanguageSubject.next(dataLanguage);
|
|
4498
4554
|
return;
|
|
4499
4555
|
}
|
|
4500
4556
|
if (this.appDataLanguages.some(dl => dl === dataLanguage)) {
|
|
4501
4557
|
this.localStorage.setItem('dataLang', dataLanguage);
|
|
4558
|
+
this.dataLanguageSubject.next(dataLanguage);
|
|
4502
4559
|
}
|
|
4503
4560
|
}
|
|
4561
|
+
get appDataLanguage$() {
|
|
4562
|
+
return this.dataLanguageSubject.asObservable();
|
|
4563
|
+
}
|
|
4504
4564
|
// We assume, that default data language is the first one from the array of all available data languages
|
|
4505
4565
|
get defaultDataLanguage() {
|
|
4506
4566
|
return this.appDataLanguages[0];
|
|
@@ -10089,10 +10149,10 @@ class MngTableColumnValueComponent {
|
|
|
10089
10149
|
}
|
|
10090
10150
|
}
|
|
10091
10151
|
MngTableColumnValueComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: MngTableColumnValueComponent, deps: [{ token: i0.ElementRef }, { token: i2$1.MessageService }, { token: i2.TranslateService }, { token: JsonPathPipe }, { token: MngGetterPipe }, { token: MngTemplatePipe }], target: i0.ɵɵFactoryTarget.Component });
|
|
10092
|
-
MngTableColumnValueComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0", type: MngTableColumnValueComponent, selector: "mng-table-column-value", inputs: { descriptor: "descriptor", item: "item" }, host: { properties: { "style.max-width.px": "this.styleMaxWidth", "class": "this.className" } }, ngImport: i0, template: "<ng-container [ngSwitch]=\"descriptor.columnDisplayType\">\n <i
|
|
10152
|
+
MngTableColumnValueComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0", type: MngTableColumnValueComponent, selector: "mng-table-column-value", inputs: { descriptor: "descriptor", item: "item" }, host: { properties: { "style.max-width.px": "this.styleMaxWidth", "class": "this.className" } }, ngImport: i0, template: "<ng-container [ngSwitch]=\"descriptor.columnDisplayType\">\n <i\n *ngIf=\"descriptor.localizationExistsProperty && !item[descriptor.localizationExistsProperty]\"\n class=\"pi pi-exclamation-circle\"\n [pTooltip]=\"'mngTable.translationMissing' | translate\"></i>\n <ng-container *ngSwitchCase=\"columnDisplayTypeString\">\n {{ value }}\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeHtml\">\n <span [innerHTML]=\"value\"></span>\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeNumber\">\n {{ value | number: descriptor.displayFormat:descriptor.locale }}\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeCurrency\">\n {{ value | currency: currency:descriptor.currencyDisplay:descriptor.displayFormat:descriptor.locale }}\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeDate\">\n {{ value | date: descriptor.displayFormat }}\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeBoolean\">\n <ng-container *ngIf=\"descriptor.booleanAsIcon; else booleanText\">\n <i [class]=\"value | boolean: descriptor.booleanYes:descriptor.booleanNo:true\"></i>\n </ng-container>\n <ng-template #booleanText>\n {{ value | boolean: descriptor.booleanYes:descriptor.booleanNo | translate }}\n </ng-template>\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeEnum\">\n {{ value | enum: descriptor.enumType:descriptor.enumTitlePath:descriptor.enumNameAsValue | translate }}\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeComponent\">\n <ng-container\n [mngComponent]=\"descriptor.customComponentType!\"\n [inputs]=\"{\n value: value,\n item: item,\n descriptor: descriptor\n }\"></ng-container>\n </ng-container>\n</ng-container>\n<div class=\"help-buttons\" *ngIf=\"descriptor.hasCopyToClipboard\">\n <button pButton pRipple type=\"button\" icon=\"pi pi-copy\" class=\"p-button-rounded p-button-info p-button-sm\" (click)=\"copyToClipboard($event)\"></button>\n</div>\n", styles: [":host{display:inline-block;overflow:hidden}:host.nowrap{white-space:nowrap;text-overflow:ellipsis}.help-buttons{display:none;position:absolute;right:0;top:50%;transform:translateY(-50%)}.help-buttons .p-button{height:1.9rem;width:1.9rem;padding:0}\n"], dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i4.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i7.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "fitContent", "pTooltip", "tooltipDisabled", "tooltipOptions"] }, { kind: "directive", type: i5.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { kind: "directive", type: i10.Ripple, selector: "[pRipple]" }, { kind: "directive", type: MngComponentDirective, selector: "[mngComponent]", inputs: ["mngComponent", "inputs"], outputs: ["instanceCreated"] }, { kind: "pipe", type: i4.DecimalPipe, name: "number" }, { kind: "pipe", type: i4.CurrencyPipe, name: "currency" }, { kind: "pipe", type: i4.DatePipe, name: "date" }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }, { kind: "pipe", type: MngEnumPipe, name: "enum" }, { kind: "pipe", type: MngBooleanPipe, name: "boolean" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
10093
10153
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: MngTableColumnValueComponent, decorators: [{
|
|
10094
10154
|
type: Component,
|
|
10095
|
-
args: [{ selector: 'mng-table-column-value', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container [ngSwitch]=\"descriptor.columnDisplayType\">\n <i
|
|
10155
|
+
args: [{ selector: 'mng-table-column-value', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container [ngSwitch]=\"descriptor.columnDisplayType\">\n <i\n *ngIf=\"descriptor.localizationExistsProperty && !item[descriptor.localizationExistsProperty]\"\n class=\"pi pi-exclamation-circle\"\n [pTooltip]=\"'mngTable.translationMissing' | translate\"></i>\n <ng-container *ngSwitchCase=\"columnDisplayTypeString\">\n {{ value }}\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeHtml\">\n <span [innerHTML]=\"value\"></span>\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeNumber\">\n {{ value | number: descriptor.displayFormat:descriptor.locale }}\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeCurrency\">\n {{ value | currency: currency:descriptor.currencyDisplay:descriptor.displayFormat:descriptor.locale }}\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeDate\">\n {{ value | date: descriptor.displayFormat }}\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeBoolean\">\n <ng-container *ngIf=\"descriptor.booleanAsIcon; else booleanText\">\n <i [class]=\"value | boolean: descriptor.booleanYes:descriptor.booleanNo:true\"></i>\n </ng-container>\n <ng-template #booleanText>\n {{ value | boolean: descriptor.booleanYes:descriptor.booleanNo | translate }}\n </ng-template>\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeEnum\">\n {{ value | enum: descriptor.enumType:descriptor.enumTitlePath:descriptor.enumNameAsValue | translate }}\n </ng-container>\n <ng-container *ngSwitchCase=\"columnDisplayTypeComponent\">\n <ng-container\n [mngComponent]=\"descriptor.customComponentType!\"\n [inputs]=\"{\n value: value,\n item: item,\n descriptor: descriptor\n }\"></ng-container>\n </ng-container>\n</ng-container>\n<div class=\"help-buttons\" *ngIf=\"descriptor.hasCopyToClipboard\">\n <button pButton pRipple type=\"button\" icon=\"pi pi-copy\" class=\"p-button-rounded p-button-info p-button-sm\" (click)=\"copyToClipboard($event)\"></button>\n</div>\n", styles: [":host{display:inline-block;overflow:hidden}:host.nowrap{white-space:nowrap;text-overflow:ellipsis}.help-buttons{display:none;position:absolute;right:0;top:50%;transform:translateY(-50%)}.help-buttons .p-button{height:1.9rem;width:1.9rem;padding:0}\n"] }]
|
|
10096
10156
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i2$1.MessageService }, { type: i2.TranslateService }, { type: JsonPathPipe }, { type: MngGetterPipe }, { type: MngTemplatePipe }]; }, propDecorators: { descriptor: [{
|
|
10097
10157
|
type: Input
|
|
10098
10158
|
}], item: [{
|
|
@@ -10586,32 +10646,33 @@ class MngTableComponent {
|
|
|
10586
10646
|
const applyDefaultFilters = (params.filterParams?.length ?? 0) === 0;
|
|
10587
10647
|
this.filterDescriptors.forEach(f => {
|
|
10588
10648
|
let matchMode;
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
case FilterTypeEnum.LookupEnum: {
|
|
10602
|
-
const lookupFilter = f;
|
|
10603
|
-
if (lookupFilter.multiselect) {
|
|
10604
|
-
matchMode = FilterMatchMode.IN;
|
|
10605
|
-
}
|
|
10606
|
-
else {
|
|
10607
|
-
matchMode = FilterMatchMode.EQUALS;
|
|
10608
|
-
}
|
|
10609
|
-
break;
|
|
10649
|
+
switch (f.filterType) {
|
|
10650
|
+
case FilterTypeEnum.String:
|
|
10651
|
+
matchMode = FilterMatchMode.CONTAINS;
|
|
10652
|
+
break;
|
|
10653
|
+
case FilterTypeEnum.Date:
|
|
10654
|
+
matchMode = FilterMatchMode.DATE_IS;
|
|
10655
|
+
break;
|
|
10656
|
+
case FilterTypeEnum.Lookup:
|
|
10657
|
+
case FilterTypeEnum.LookupEnum: {
|
|
10658
|
+
const lookupFilter = f;
|
|
10659
|
+
if (lookupFilter.multiselect) {
|
|
10660
|
+
matchMode = FilterMatchMode.IN;
|
|
10610
10661
|
}
|
|
10611
|
-
|
|
10662
|
+
else {
|
|
10612
10663
|
matchMode = FilterMatchMode.EQUALS;
|
|
10613
|
-
|
|
10664
|
+
}
|
|
10665
|
+
break;
|
|
10614
10666
|
}
|
|
10667
|
+
default:
|
|
10668
|
+
matchMode = FilterMatchMode.EQUALS;
|
|
10669
|
+
break;
|
|
10670
|
+
}
|
|
10671
|
+
if (f.defaultFilterMatchMode) {
|
|
10672
|
+
matchMode = f.defaultFilterMatchMode;
|
|
10673
|
+
}
|
|
10674
|
+
if (f.matchModes && !f.matchModes?.includes(matchMode)) {
|
|
10675
|
+
matchMode = f.matchModes[0];
|
|
10615
10676
|
}
|
|
10616
10677
|
let value = null;
|
|
10617
10678
|
if (applyDefaultFilters) {
|