wt-front-shared 19.0.16 → 19.0.17
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/fesm2022/wt-front-shared.mjs +75 -23
- package/fesm2022/wt-front-shared.mjs.map +1 -1
- package/lib/core/components/auto-form/components/form-field-select/form-field-select.component.d.ts +1 -0
- package/lib/core/components/auto-form/interfaces/form-field-others.d.ts +5 -0
- package/package.json +3 -2
|
@@ -7,7 +7,7 @@ import * as i2 from '@angular/router';
|
|
|
7
7
|
import { RouterModule, NavigationEnd } from '@angular/router';
|
|
8
8
|
import * as i1$2 from '@ngrx/effects';
|
|
9
9
|
import { createEffect, ofType } from '@ngrx/effects';
|
|
10
|
-
import { map, catchError, tap, filter as filter$1, switchMap, flatMap, first, take, mergeMap, takeUntil,
|
|
10
|
+
import { map, catchError, tap, filter as filter$1, switchMap, flatMap, first, take, distinctUntilChanged, mergeMap, takeUntil, startWith } from 'rxjs/operators';
|
|
11
11
|
import * as i1 from '@ngrx/store';
|
|
12
12
|
import { createAction, props, createReducer, on, createFeatureSelector, createSelector, select } from '@ngrx/store';
|
|
13
13
|
import { get } from 'lodash';
|
|
@@ -29,6 +29,7 @@ import * as i3 from '@angular/forms';
|
|
|
29
29
|
import { Validators, FormControl, UntypedFormControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
30
30
|
import { switchMap as switchMap$2 } from 'rxjs/internal/operators/switchMap';
|
|
31
31
|
import * as i3$2 from 'ngx-cookie-service';
|
|
32
|
+
import objectHash from 'object-hash';
|
|
32
33
|
import * as i1$5 from '@angular/platform-browser';
|
|
33
34
|
import * as i2$4 from '@angular/material/form-field';
|
|
34
35
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
@@ -6868,6 +6869,8 @@ const getStaticDataRevisionsList = (contentTypes) => createSelector(getStaticDat
|
|
|
6868
6869
|
return result;
|
|
6869
6870
|
});
|
|
6870
6871
|
const getStaticData = (contentType, subSection, where) => createSelector(getDataByType(contentType, subSection), getLoaded$1(contentType, subSection), (listDataModels, isLoaded) => {
|
|
6872
|
+
console.log('listDataModels', listDataModels);
|
|
6873
|
+
console.log('listDataModels.isLoaded', isLoaded);
|
|
6871
6874
|
let list = isLoaded ? listDataModels : null;
|
|
6872
6875
|
if (where && list?.length) {
|
|
6873
6876
|
list = list.filter(item => {
|
|
@@ -6934,7 +6937,7 @@ class StaticDataFacade {
|
|
|
6934
6937
|
return this.store.pipe(select(staticDataQuery.getStaticDataMeta(contentType, subSection)));
|
|
6935
6938
|
}
|
|
6936
6939
|
getStaticData$(contentType, subSection = 'list', options, where) {
|
|
6937
|
-
return this.store.pipe(select(staticDataQuery.getStaticData(contentType, subSection, where)));
|
|
6940
|
+
return this.store.pipe(select(staticDataQuery.getStaticData(contentType, subSection, where)), distinctUntilChanged((a, b) => objectHash(a) === objectHash(b)));
|
|
6938
6941
|
}
|
|
6939
6942
|
getOrLoadStaticData$(contentType, subSection = 'list', options, where, loadParams) {
|
|
6940
6943
|
const defaultParams = {
|
|
@@ -8059,8 +8062,9 @@ const getStore = (storeKey) => {
|
|
|
8059
8062
|
nestedStore = params[1] !== 'list' ? params[1] : params[2];
|
|
8060
8063
|
}
|
|
8061
8064
|
const getCoreState = createFeatureSelector(rootStore);
|
|
8065
|
+
console.log('getCoreState', getCoreState);
|
|
8062
8066
|
return createSelector(getCoreState, (state) => {
|
|
8063
|
-
if (state
|
|
8067
|
+
if (state?.list) {
|
|
8064
8068
|
if (nestedStore) {
|
|
8065
8069
|
return state.list[nestedStore];
|
|
8066
8070
|
}
|
|
@@ -8335,6 +8339,7 @@ class FormFieldSelectComponent {
|
|
|
8335
8339
|
this.isLoading = true;
|
|
8336
8340
|
this.hasRelatedData = false;
|
|
8337
8341
|
this.destroy$ = new Subject();
|
|
8342
|
+
this.searchValue = '';
|
|
8338
8343
|
}
|
|
8339
8344
|
ngOnInit() {
|
|
8340
8345
|
const { subscribeToFormChanges } = this.fieldData.options;
|
|
@@ -8361,6 +8366,9 @@ class FormFieldSelectComponent {
|
|
|
8361
8366
|
}
|
|
8362
8367
|
}
|
|
8363
8368
|
this.subscribeToSearchChange();
|
|
8369
|
+
if (this.fieldData.options?.loadOptionFromStore) {
|
|
8370
|
+
this.loadOptionsFromStore(this.fieldData.options.loadOptionFromStore);
|
|
8371
|
+
}
|
|
8364
8372
|
}
|
|
8365
8373
|
ngOnDestroy() {
|
|
8366
8374
|
this.destroy$.next();
|
|
@@ -8373,7 +8381,7 @@ class FormFieldSelectComponent {
|
|
|
8373
8381
|
this.options = selectOptions;
|
|
8374
8382
|
}
|
|
8375
8383
|
if (loadOptionFromStore) {
|
|
8376
|
-
this.loadOptionsFromStore(loadOptionFromStore);
|
|
8384
|
+
// this.loadOptionsFromStore(loadOptionFromStore);
|
|
8377
8385
|
}
|
|
8378
8386
|
else {
|
|
8379
8387
|
this.loaded = true;
|
|
@@ -8385,18 +8393,30 @@ class FormFieldSelectComponent {
|
|
|
8385
8393
|
this.searchCtrl.valueChanges
|
|
8386
8394
|
.pipe(takeUntil(this.destroy$))
|
|
8387
8395
|
.subscribe((searchValue) => {
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8396
|
+
this.searchValue = searchValue;
|
|
8397
|
+
if (this.fieldData.options?.innerSearchOptions?.lazyLoading) {
|
|
8398
|
+
const innerSearchOptions = this.fieldData.options?.innerSearchOptions;
|
|
8399
|
+
if (searchValue.length > innerSearchOptions.minValueLengthForRequest) {
|
|
8400
|
+
const parameters = {
|
|
8401
|
+
search: searchValue,
|
|
8402
|
+
};
|
|
8403
|
+
this.staticDataFacade.loadStaticData(innerSearchOptions?.entityType, parameters);
|
|
8391
8404
|
}
|
|
8392
|
-
this.options = this.allOptions.filter(item => {
|
|
8393
|
-
return item.name.toLowerCase().indexOf(searchValue.toLowerCase()) !== -1;
|
|
8394
|
-
});
|
|
8395
8405
|
}
|
|
8396
8406
|
else {
|
|
8397
|
-
if (
|
|
8398
|
-
|
|
8399
|
-
|
|
8407
|
+
if (searchValue) {
|
|
8408
|
+
if (!this.tempOptions.length) {
|
|
8409
|
+
this.tempOptions = [...this.options];
|
|
8410
|
+
}
|
|
8411
|
+
this.options = this.allOptions.filter(item => {
|
|
8412
|
+
return item.name.toLowerCase().indexOf(searchValue.toLowerCase()) !== -1;
|
|
8413
|
+
});
|
|
8414
|
+
}
|
|
8415
|
+
else {
|
|
8416
|
+
if (this.tempOptions.length) {
|
|
8417
|
+
this.options = [...this.tempOptions];
|
|
8418
|
+
this.tempOptions = [];
|
|
8419
|
+
}
|
|
8400
8420
|
}
|
|
8401
8421
|
}
|
|
8402
8422
|
});
|
|
@@ -8434,15 +8454,35 @@ class FormFieldSelectComponent {
|
|
|
8434
8454
|
}
|
|
8435
8455
|
loadOptionsFromStore(loadOptionFromStore) {
|
|
8436
8456
|
const listKeys = loadOptionFromStore.split('.');
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
.pipe(
|
|
8457
|
+
// @TODO Need to rework, for a selector in specific store
|
|
8458
|
+
// store: 'staticData.list.site-tours-steps'
|
|
8459
|
+
let storeSelector;
|
|
8460
|
+
console.log('listKeys', listKeys, listKeys[0]);
|
|
8461
|
+
if (listKeys[0] === 'staticData') {
|
|
8462
|
+
console.log('staticDataQuery.getStaticData');
|
|
8463
|
+
storeSelector = this.staticDataFacade.getStaticData$(listKeys[2], 'list');
|
|
8464
|
+
// storeSelector = this.store.pipe(select(staticDataQuery.getStaticData(listKeys[2], 'list')))
|
|
8465
|
+
}
|
|
8466
|
+
else {
|
|
8467
|
+
storeSelector = this.store.pipe(select(coreQuery.getStore(loadOptionFromStore)));
|
|
8468
|
+
}
|
|
8469
|
+
/*this.store.select(state => {
|
|
8470
|
+
let selectedStore = state;
|
|
8471
|
+
listKeys.forEach(key => {
|
|
8472
|
+
selectedStore = selectedStore[key];
|
|
8473
|
+
});
|
|
8474
|
+
|
|
8475
|
+
return selectedStore;
|
|
8476
|
+
})*/
|
|
8477
|
+
storeSelector?.pipe(filter((listItems) => !!listItems), tap((listItems) => { console.log('listItems.tap', this.fieldData, listItems); }),
|
|
8478
|
+
/*distinctUntilChanged((a, b) => {
|
|
8479
|
+
console.log('a,b ', a, b, a?.list?.length, b?.list?.length);
|
|
8480
|
+
return a?.list?.length === b?.list?.length;// && a[0]?.id === b[0]?.id;
|
|
8481
|
+
// return a.length === b.length && a[0]?.id === b[0]?.id;
|
|
8482
|
+
}),*/
|
|
8483
|
+
takeUntil(this.destroy$))
|
|
8445
8484
|
.subscribe((listItems) => {
|
|
8485
|
+
console.log('listItems.subscribe', listItems);
|
|
8446
8486
|
let newOptions = [];
|
|
8447
8487
|
if (listItems && listItems?.items) {
|
|
8448
8488
|
newOptions = listItems.items;
|
|
@@ -8453,10 +8493,21 @@ class FormFieldSelectComponent {
|
|
|
8453
8493
|
else if (Array.isArray(listItems)) {
|
|
8454
8494
|
newOptions = listItems;
|
|
8455
8495
|
}
|
|
8496
|
+
console.log('newOptions.1', newOptions);
|
|
8497
|
+
if (this.searchValue) {
|
|
8498
|
+
newOptions = newOptions.filter(item => item.name.indexOf(this.searchValue) === 0);
|
|
8499
|
+
}
|
|
8500
|
+
/*
|
|
8501
|
+
if (!this.searchValue && this.fieldData.options?.innerSearchOptions?.lazyLoading) {
|
|
8502
|
+
newOptions = [];
|
|
8503
|
+
}
|
|
8504
|
+
*/
|
|
8505
|
+
console.log('newOptions.2', newOptions);
|
|
8456
8506
|
newOptions = this.sortOptionItemsByName(newOptions);
|
|
8457
8507
|
if (this.fieldData.options?.nestedByField) {
|
|
8458
8508
|
newOptions = this.groupItemsByNestedField(newOptions);
|
|
8459
8509
|
}
|
|
8510
|
+
console.log('newOptions.3', newOptions);
|
|
8460
8511
|
this.allOptions = newOptions;
|
|
8461
8512
|
this.isLoading = false;
|
|
8462
8513
|
if (!this.fieldData.options?.subscribeToFormChanges) {
|
|
@@ -8465,6 +8516,7 @@ class FormFieldSelectComponent {
|
|
|
8465
8516
|
else {
|
|
8466
8517
|
this.filterOptionsByRelatedFieldValue(this.form.value);
|
|
8467
8518
|
}
|
|
8519
|
+
console.log('this.options', this.options);
|
|
8468
8520
|
this.cd.markForCheck();
|
|
8469
8521
|
});
|
|
8470
8522
|
}
|
|
@@ -8528,11 +8580,11 @@ class FormFieldSelectComponent {
|
|
|
8528
8580
|
});
|
|
8529
8581
|
}
|
|
8530
8582
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: FormFieldSelectComponent, deps: [{ token: i1.Store }, { token: StaticDataFacade }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
8531
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: FormFieldSelectComponent, isStandalone: false, selector: "shared-form-field-select", inputs: { config: "config", fieldData: "fieldData", form: "form", autoCompleteFields: "autoCompleteFields" }, usesOnChanges: true, ngImport: i0, template: "<div [formGroup]=\"form\" [ngClass]=\"{'small-form-width-form-field': config?.smallFormWidth}\">\n <mat-form-field appearance=\"outline\"\n class=\"width100\">\n <mat-label>{{ fieldData.title }}</mat-label>\n <mat-select [required]=\"fieldData.validators?.includes('required')\"\n [multiple]=\"fieldData.options?.multiple\"\n [formControlName]=\"fieldData.field\">\n <mat-option *ngIf=\"fieldData.options?.innerSearch\">\n <ngx-mat-select-search\n placeholderLabel=\"\u041F\u043E\u0438\u0441\u043A...\"\n [formControl]=\"searchCtrl\"></ngx-mat-select-search>\n </mat-option>\n <mat-option *ngIf=\"!fieldData.validators?.includes('required')\" value=\"0\">\n -----\n </mat-option>\n @if (options.length) {\n <mat-option *ngFor=\"let item of options\" [value]=\"item.id\">\n {{ item.name || item['title'] }}\n </mat-option>\n }\n\n
|
|
8583
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: FormFieldSelectComponent, isStandalone: false, selector: "shared-form-field-select", inputs: { config: "config", fieldData: "fieldData", form: "form", autoCompleteFields: "autoCompleteFields" }, usesOnChanges: true, ngImport: i0, template: "<div [formGroup]=\"form\" [ngClass]=\"{'small-form-width-form-field': config?.smallFormWidth}\">\n <mat-form-field appearance=\"outline\"\n class=\"width100\">\n <mat-label>{{ fieldData.title }}</mat-label>\n <mat-select [required]=\"fieldData.validators?.includes('required')\"\n [multiple]=\"fieldData.options?.multiple\"\n [formControlName]=\"fieldData.field\">\n <mat-option *ngIf=\"fieldData.options?.innerSearch\">\n <ngx-mat-select-search\n placeholderLabel=\"\u041F\u043E\u0438\u0441\u043A...\"\n [formControl]=\"searchCtrl\"></ngx-mat-select-search>\n </mat-option>\n <mat-option *ngIf=\"!fieldData.validators?.includes('required')\" value=\"0\">\n -----\n </mat-option>\n @if (options.length) {\n <mat-option *ngFor=\"let item of options\" [value]=\"item.id\">\n {{ item.name || item['title'] }}\n </mat-option>\n }\n\n <!--@if (!options.length) {\n <mat-option>\n \u0421\u043F\u0438\u0441\u043E\u043A \u043F\u0443\u0441\u0442\n </mat-option>\n }-->\n\n <ng-container *ngIf=\"isLoading\">\n <mat-option>\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430....</mat-option>\n </ng-container>\n </mat-select>\n <ng-container *ngIf=\"!hasRelatedData && placeholder\">\n <div @appearOpacity class=\"form-select-placeholder\">{{ placeholder }}</div>\n </ng-container>\n </mat-form-field>\n</div>\n<shared-form-field-spinner *ngIf=\"isLoading\"></shared-form-field-spinner>\n", styles: [".form-select-placeholder{position:absolute;margin-right:25px;margin-top:-22px;opacity:.8;right:0;color:#e53935}\n"], dependencies: [{ kind: "directive", type: i1$3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2$4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i2$4.MatLabel, selector: "mat-label" }, { kind: "component", type: i5$1.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth", "canSelectNullableOptions"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "component", type: i5$1.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i7.MatSelectSearchComponent, selector: "ngx-mat-select-search", inputs: ["placeholderLabel", "type", "closeIcon", "closeSvgIcon", "noEntriesFoundLabel", "clearSearchInput", "searching", "disableInitialFocus", "enableClearOnEscapePressed", "preventHomeEndKeyPropagation", "disableScrollToActiveOnOptionsChanged", "ariaLabel", "showToggleAllCheckbox", "toggleAllCheckboxChecked", "toggleAllCheckboxIndeterminate", "toggleAllCheckboxTooltipMessage", "toggleAllCheckboxTooltipPosition", "hideClearSearchButton", "alwaysRestoreSelectedOptionsMulti", "recreateValuesArray"], outputs: ["toggleAll"] }, { kind: "component", type: FormFieldSpinnerComponent, selector: "shared-form-field-spinner" }], animations: [appearOpacity], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
8532
8584
|
}
|
|
8533
8585
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: FormFieldSelectComponent, decorators: [{
|
|
8534
8586
|
type: Component,
|
|
8535
|
-
args: [{ selector: 'shared-form-field-select', changeDetection: ChangeDetectionStrategy.OnPush, animations: [appearOpacity], standalone: false, template: "<div [formGroup]=\"form\" [ngClass]=\"{'small-form-width-form-field': config?.smallFormWidth}\">\n <mat-form-field appearance=\"outline\"\n class=\"width100\">\n <mat-label>{{ fieldData.title }}</mat-label>\n <mat-select [required]=\"fieldData.validators?.includes('required')\"\n [multiple]=\"fieldData.options?.multiple\"\n [formControlName]=\"fieldData.field\">\n <mat-option *ngIf=\"fieldData.options?.innerSearch\">\n <ngx-mat-select-search\n placeholderLabel=\"\u041F\u043E\u0438\u0441\u043A...\"\n [formControl]=\"searchCtrl\"></ngx-mat-select-search>\n </mat-option>\n <mat-option *ngIf=\"!fieldData.validators?.includes('required')\" value=\"0\">\n -----\n </mat-option>\n @if (options.length) {\n <mat-option *ngFor=\"let item of options\" [value]=\"item.id\">\n {{ item.name || item['title'] }}\n </mat-option>\n }\n\n
|
|
8587
|
+
args: [{ selector: 'shared-form-field-select', changeDetection: ChangeDetectionStrategy.OnPush, animations: [appearOpacity], standalone: false, template: "<div [formGroup]=\"form\" [ngClass]=\"{'small-form-width-form-field': config?.smallFormWidth}\">\n <mat-form-field appearance=\"outline\"\n class=\"width100\">\n <mat-label>{{ fieldData.title }}</mat-label>\n <mat-select [required]=\"fieldData.validators?.includes('required')\"\n [multiple]=\"fieldData.options?.multiple\"\n [formControlName]=\"fieldData.field\">\n <mat-option *ngIf=\"fieldData.options?.innerSearch\">\n <ngx-mat-select-search\n placeholderLabel=\"\u041F\u043E\u0438\u0441\u043A...\"\n [formControl]=\"searchCtrl\"></ngx-mat-select-search>\n </mat-option>\n <mat-option *ngIf=\"!fieldData.validators?.includes('required')\" value=\"0\">\n -----\n </mat-option>\n @if (options.length) {\n <mat-option *ngFor=\"let item of options\" [value]=\"item.id\">\n {{ item.name || item['title'] }}\n </mat-option>\n }\n\n <!--@if (!options.length) {\n <mat-option>\n \u0421\u043F\u0438\u0441\u043E\u043A \u043F\u0443\u0441\u0442\n </mat-option>\n }-->\n\n <ng-container *ngIf=\"isLoading\">\n <mat-option>\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430....</mat-option>\n </ng-container>\n </mat-select>\n <ng-container *ngIf=\"!hasRelatedData && placeholder\">\n <div @appearOpacity class=\"form-select-placeholder\">{{ placeholder }}</div>\n </ng-container>\n </mat-form-field>\n</div>\n<shared-form-field-spinner *ngIf=\"isLoading\"></shared-form-field-spinner>\n", styles: [".form-select-placeholder{position:absolute;margin-right:25px;margin-top:-22px;opacity:.8;right:0;color:#e53935}\n"] }]
|
|
8536
8588
|
}], ctorParameters: () => [{ type: i1.Store }, { type: StaticDataFacade }, { type: i0.ChangeDetectorRef }], propDecorators: { config: [{
|
|
8537
8589
|
type: Input
|
|
8538
8590
|
}], fieldData: [{
|