1
1
import type { InvalidParams } from '@utils/invalid-params.pipe' ;
2
2
3
3
import { AsyncPipe } from '@angular/common' ;
4
- import { ChangeDetectionStrategy , Component , ComponentRef , inject , input , output } from '@angular/core' ;
4
+ import {
5
+ ChangeDetectionStrategy ,
6
+ ChangeDetectorRef ,
7
+ Component ,
8
+ ComponentRef ,
9
+ inject ,
10
+ input ,
11
+ output ,
12
+ } from '@angular/core' ;
5
13
import { toObservable } from '@angular/core/rxjs-interop' ;
6
14
import {
7
15
AbstractControl ,
@@ -118,7 +126,7 @@ interface Form {
118
126
exactly : FormControl < boolean > ;
119
127
} > ;
120
128
spec_id ?: FormControl < specValue > ;
121
- vehicle_type_id ?: FormControl < null | string [ ] > ;
129
+ vehicle_type_id ?: FormControl < string [ ] > ;
122
130
}
123
131
124
132
interface ItemMetaFormAPISpec {
@@ -196,6 +204,7 @@ export class ItemMetaFormComponent {
196
204
readonly #picturesClient = inject ( PicturesClient ) ;
197
205
readonly #languageService = inject ( LanguageService ) ;
198
206
readonly #modalService = inject ( NgbModal ) ;
207
+ readonly #cdr = inject ( ChangeDetectorRef ) ;
199
208
200
209
readonly invalidParams = input . required < InvalidParams > ( ) ;
201
210
readonly submitted = output < ItemMetaFormResult > ( ) ;
@@ -403,7 +412,7 @@ export class ItemMetaFormComponent {
403
412
) ;
404
413
}
405
414
if ( [ ItemType . ITEM_TYPE_TWINS , ItemType . ITEM_TYPE_VEHICLE ] . includes ( item . itemTypeId ) ) {
406
- elements . vehicle_type_id = new FormControl ( vehicleTypeIDs ) ;
415
+ elements . vehicle_type_id = new FormControl ( vehicleTypeIDs , { nonNullable : true } ) ;
407
416
}
408
417
if ( item . itemTypeId !== ItemType . ITEM_TYPE_COPYRIGHT ) {
409
418
elements . begin = new FormGroup ( {
@@ -470,6 +479,7 @@ export class ItemMetaFormComponent {
470
479
471
480
modalRef . componentInstance . changed . subscribe ( ( value : string [ ] ) => {
472
481
vehicleTypeIDs . setValue ( value ) ;
482
+ this . #cdr. markForCheck ( ) ;
473
483
} ) ;
474
484
}
475
485
@@ -496,6 +506,7 @@ export class ItemMetaFormComponent {
496
506
i ++ ;
497
507
} ) ;
498
508
}
509
+ this . #cdr. markForCheck ( ) ;
499
510
}
500
511
501
512
protected onPictureClick ( e : PicturesListItem , ctrl : FormArray < FormControl < string > > ) {
@@ -512,5 +523,6 @@ export class ItemMetaFormComponent {
512
523
i ++ ;
513
524
} ) ;
514
525
}
526
+ this . #cdr. markForCheck ( ) ;
515
527
}
516
528
}
0 commit comments