@snabcentr/client-ui 0.17.0 → 0.17.1
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.
Potentially problematic release.
This version of @snabcentr/client-ui might be problematic. Click here for more details.
- package/esm2020/form-fields/suggestion-field/sc-suggestion-field.component.mjs +25 -20
- package/fesm2015/snabcentr-client-ui.mjs +23 -18
- package/fesm2015/snabcentr-client-ui.mjs.map +1 -1
- package/fesm2020/snabcentr-client-ui.mjs +22 -17
- package/fesm2020/snabcentr-client-ui.mjs.map +1 -1
- package/package.json +1 -1
@@ -35,6 +35,7 @@ import { LineChart } from 'echarts/charts';
|
|
35
35
|
import { TitleComponent, TooltipComponent, GridComponent } from 'echarts/components';
|
36
36
|
import * as echarts from 'echarts/core';
|
37
37
|
import { SVGRenderer } from 'echarts/renderers';
|
38
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
38
39
|
import * as i3$1 from '@taiga-ui/layout';
|
39
40
|
import { TuiBlockStatusModule } from '@taiga-ui/layout';
|
40
41
|
|
@@ -2359,16 +2360,18 @@ class ScSuggestionFieldComponent {
|
|
2359
2360
|
/** @inheritDoc */
|
2360
2361
|
ngOnInit() {
|
2361
2362
|
const request$ = tuiControlValue(this.control).pipe(debounceTime(300), filter(tuiIsPresent), map((term) => term.trim()), filter((term) => term.length >= 3), switchMap((term) => this.suggestionService.getData(term, this.type).pipe(startWith(null))), catchError((error) => {
|
2362
|
-
|
2363
|
-
|
2364
|
-
|
2365
|
-
|
2366
|
-
|
2367
|
-
|
2363
|
+
if (error instanceof HttpErrorResponse) {
|
2364
|
+
const errorResponse = error.error;
|
2365
|
+
if (this.control.control) {
|
2366
|
+
tuiMarkControlAsTouchedAndValidate(this.control.control);
|
2367
|
+
this.control.control.setErrors({
|
2368
|
+
serverResponse: [errorResponse.message || 'Ошибка сервера: пожалуйста, перезагрузите страницу и/или выполните запрос позже.'],
|
2369
|
+
});
|
2370
|
+
}
|
2368
2371
|
}
|
2369
2372
|
return throwError(() => of([]));
|
2370
2373
|
}), share());
|
2371
|
-
this.suggestions$ = request
|
2374
|
+
this.suggestions$ = request$.pipe(filter(tuiIsPresent), startWith(null));
|
2372
2375
|
this.loading$ = request$.pipe(map(tuiIsFalsy));
|
2373
2376
|
}
|
2374
2377
|
/**
|
@@ -2385,21 +2388,21 @@ class ScSuggestionFieldComponent {
|
|
2385
2388
|
break;
|
2386
2389
|
case ScISuggestionType.address:
|
2387
2390
|
if ('addressString' in suggestion) {
|
2388
|
-
this.control.control?.patchValue(suggestion.addressString
|
2391
|
+
this.control.control?.patchValue(suggestion.addressString);
|
2389
2392
|
}
|
2390
2393
|
break;
|
2391
2394
|
case ScISuggestionType.bank:
|
2392
2395
|
if ('inn' in suggestion && 'bic' in suggestion) {
|
2393
|
-
this.control.control?.parent
|
2396
|
+
(this.control.control?.parent).patchValue({
|
2394
2397
|
bankName: suggestion.name,
|
2395
2398
|
bic: suggestion.bic,
|
2396
|
-
correspondentAccount: suggestion.correspondentAccount
|
2397
|
-
}
|
2399
|
+
correspondentAccount: suggestion.correspondentAccount,
|
2400
|
+
});
|
2398
2401
|
}
|
2399
2402
|
break;
|
2400
2403
|
case ScISuggestionType.organization:
|
2401
2404
|
if ('inn' in suggestion && !('bic' in suggestion)) {
|
2402
|
-
this.control.control?.parent
|
2405
|
+
(this.control.control?.parent).patchValue({
|
2403
2406
|
name: suggestion.name,
|
2404
2407
|
inn: suggestion.inn,
|
2405
2408
|
kpp: suggestion.kpp,
|
@@ -2408,23 +2411,25 @@ class ScSuggestionFieldComponent {
|
|
2408
2411
|
directorPosition: suggestion.directorPosition,
|
2409
2412
|
legalAddress: suggestion.legalAddress,
|
2410
2413
|
postalAddress: suggestion.postalAddress,
|
2411
|
-
actualAddress: suggestion.actualAddress
|
2412
|
-
}
|
2414
|
+
actualAddress: suggestion.actualAddress,
|
2415
|
+
});
|
2413
2416
|
}
|
2414
2417
|
break;
|
2415
2418
|
case ScISuggestionType.email:
|
2416
2419
|
if ('email' in suggestion) {
|
2417
|
-
this.control.control?.patchValue(suggestion.email
|
2420
|
+
this.control.control?.patchValue(suggestion.email);
|
2418
2421
|
}
|
2419
2422
|
break;
|
2423
|
+
default:
|
2424
|
+
break;
|
2420
2425
|
}
|
2421
2426
|
}
|
2422
2427
|
}
|
2423
2428
|
ScSuggestionFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScSuggestionFieldComponent, deps: [{ token: NgControl, skipSelf: true }, { token: i1.ScSuggestionService }], target: i0.ɵɵFactoryTarget.Component });
|
2424
|
-
ScSuggestionFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ScSuggestionFieldComponent, selector: "sc-suggestion-field", inputs: { type: "type" }, ngImport: i0, template: "<tui-loader
|
2429
|
+
ScSuggestionFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: ScSuggestionFieldComponent, selector: "sc-suggestion-field", inputs: { type: "type" }, ngImport: i0, template: "<tui-loader\n size=\"m\"\n [overlay]=\"true\"\n [showLoader]=\"!!(loading$ | async)\"\n>\n <tui-data-list *tuiLet=\"suggestions$ | async as options\">\n <button\n *ngFor=\"let option of options\"\n tuiOption\n (click)=\"onSelected(option)\"\n class=\"flex-col !items-start\"\n >\n <ng-container *tuiLet=\"$any(option) as option\">\n <ng-container [ngSwitch]=\"type\">\n <ng-container *ngSwitchCase=\"suggestionType.fio\">\n <span class=\"text-tui-link\">{{ option.fio }}</span>\n </ng-container>\n <ng-container *ngSwitchCase=\"suggestionType.organization\">\n <span class=\"text-tui-link\">\n {{ option.name }}\n <span class=\"ml-2 text-tui-text-02\">\u0438\u043D\u043D: {{ option.inn }}</span>\n </span>\n <span class=\"text-tui-text-02\">{{ option?.legalAddress }}</span>\n </ng-container>\n <ng-container *ngSwitchCase=\"suggestionType.bank\">\n <span class=\"text-tui-link\">{{ option.name }}</span>\n <span class=\"text-tui-text-02\">{{ option.bic }}</span>\n </ng-container>\n <ng-container *ngSwitchCase=\"suggestionType.email\">\n <span class=\"text-tui-link\">{{ option.email }}</span>\n </ng-container>\n <ng-container *ngSwitchCase=\"suggestionType.address\">\n <span class=\"text-tui-link\">{{ option.addressString }}</span>\n </ng-container>\n </ng-container>\n </ng-container>\n </button>\n </tui-data-list>\n</tui-loader>\n", dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i5.TuiLetDirective, selector: "[tuiLet]", inputs: ["tuiLet"] }, { kind: "component", type: i4.TuiDataListComponent, selector: "tui-data-list", inputs: ["role", "emptyContent", "size"] }, { kind: "component", type: i4.TuiOptionComponent, selector: "button[tuiOption], a[tuiOption]", inputs: ["size", "role", "disabled", "value"] }, { kind: "component", type: i4.TuiLoaderComponent, selector: "tui-loader", inputs: ["size", "inheritColor", "overlay", "textContent", "showLoader"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
2425
2430
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ScSuggestionFieldComponent, decorators: [{
|
2426
2431
|
type: Component,
|
2427
|
-
args: [{ selector: 'sc-suggestion-field', template: "<tui-loader
|
2432
|
+
args: [{ selector: 'sc-suggestion-field', changeDetection: ChangeDetectionStrategy.OnPush, template: "<tui-loader\n size=\"m\"\n [overlay]=\"true\"\n [showLoader]=\"!!(loading$ | async)\"\n>\n <tui-data-list *tuiLet=\"suggestions$ | async as options\">\n <button\n *ngFor=\"let option of options\"\n tuiOption\n (click)=\"onSelected(option)\"\n class=\"flex-col !items-start\"\n >\n <ng-container *tuiLet=\"$any(option) as option\">\n <ng-container [ngSwitch]=\"type\">\n <ng-container *ngSwitchCase=\"suggestionType.fio\">\n <span class=\"text-tui-link\">{{ option.fio }}</span>\n </ng-container>\n <ng-container *ngSwitchCase=\"suggestionType.organization\">\n <span class=\"text-tui-link\">\n {{ option.name }}\n <span class=\"ml-2 text-tui-text-02\">\u0438\u043D\u043D: {{ option.inn }}</span>\n </span>\n <span class=\"text-tui-text-02\">{{ option?.legalAddress }}</span>\n </ng-container>\n <ng-container *ngSwitchCase=\"suggestionType.bank\">\n <span class=\"text-tui-link\">{{ option.name }}</span>\n <span class=\"text-tui-text-02\">{{ option.bic }}</span>\n </ng-container>\n <ng-container *ngSwitchCase=\"suggestionType.email\">\n <span class=\"text-tui-link\">{{ option.email }}</span>\n </ng-container>\n <ng-container *ngSwitchCase=\"suggestionType.address\">\n <span class=\"text-tui-link\">{{ option.addressString }}</span>\n </ng-container>\n </ng-container>\n </ng-container>\n </button>\n </tui-data-list>\n</tui-loader>\n" }]
|
2428
2433
|
}], ctorParameters: function () { return [{ type: i3.NgControl, decorators: [{
|
2429
2434
|
type: SkipSelf
|
2430
2435
|
}, {
|