Skip to content

Commit 31919ab

Browse files
committed
fix: handle empty attr_zone_id
1 parent 3cbdb5f commit 31919ab

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/app/api/attrs/attrs.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export interface APIAttrUserValue {
8484
update_date: null | string;
8585
user_id: string;
8686
value: APIAttrAttributeValue | null;
87-
value_text: string;
87+
value_text: null | string;
8888
}
8989

9090
export interface APIAttrUserValueGetResponse {

src/app/cars/attrs-change-log/attrs-change-log.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class CarsAttrsChangeLogComponent implements OnInit, OnDestroy {
5656
user$: Observable<APIUser | null>;
5757
user_id: string;
5858
value: APIAttrAttributeValue | null;
59-
value_text: string;
59+
value_text: null | string;
6060
}[];
6161
paginator: APIPaginator;
6262
}> = combineLatest([this.userID$, this.itemID$, this.page$]).pipe(

src/app/cars/specifications-editor/spec/spec.component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
getUnitAbbrTranslation,
1313
getUnitNameTranslation,
1414
} from '@utils/translations';
15-
import {BehaviorSubject, combineLatest, EMPTY, forkJoin, Observable, of} from 'rxjs';
15+
import {BehaviorSubject, combineLatest, EMPTY, forkJoin, Observable, of, throwError} from 'rxjs';
1616
import {catchError, distinctUntilChanged, map, shareReplay, switchMap, tap} from 'rxjs/operators';
1717

1818
import {
@@ -58,7 +58,7 @@ interface AttrUserValueWithUser {
5858
user$: Observable<APIUser | null>;
5959
user_id: string;
6060
value: APIAttrAttributeValue | null;
61-
value_text: string;
61+
value_text: null | string;
6262
}
6363

6464
const booleanOptions: ListOption[] = [
@@ -109,7 +109,11 @@ export class CarsSpecificationsEditorSpecComponent {
109109
// fields: 'options,childs.options',
110110
protected readonly attributes$ = this.item$.pipe(
111111
distinctUntilChanged(),
112-
switchMap((item) => (item ? this.attrsService.getAttributes$(item.attr_zone_id + '', null) : EMPTY)),
112+
switchMap((item) =>
113+
item && item.attr_zone_id
114+
? this.attrsService.getAttributes$(item.attr_zone_id + '', null)
115+
: throwError(() => new Error('Failed to detect attr_zone_id')),
116+
),
113117
catchError((response: unknown) => {
114118
this.toastService.handleError(response);
115119
return EMPTY;
@@ -223,7 +227,7 @@ export class CarsSpecificationsEditorSpecComponent {
223227
}),
224228
);
225229

226-
protected readonly userValues$: Observable<Map<number, APIAttrUserValue[]>> = combineLatest([
230+
protected readonly userValues$: Observable<Map<number, AttrUserValueWithUser[]>> = combineLatest([
227231
this.item$,
228232
this.change$,
229233
]).pipe(

src/app/cars/specs-admin/specs-admin.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class CarsSpecsAdminComponent implements OnInit {
4747
user$: Observable<APIUser | null>;
4848
user_id: string;
4949
value: APIAttrAttributeValue | null;
50-
value_text: string;
50+
value_text: null | string;
5151
}[];
5252
paginator: APIPaginator;
5353
}> = combineLatest([this.itemID$, this.page$, this.move$]).pipe(

0 commit comments

Comments
 (0)