This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export abstract class TypeormCrudService<T> { | |
| readonly logger = new Logger(TypeormCrudService.name); | |
| protected constructor(private _repository: Repository<T>) {} | |
| async find(options?: FindManyOptions<T>): Promise<T[]> { | |
| return await this._repository.find(options); | |
| } | |
| async findOne(options: FindOneOptions<T>): Promise<T | null> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| selector: 'app-vehicle-edit', | |
| templateUrl: './vehicle-edit.component.html', | |
| styleUrls: ['./vehicle-edit.component.scss'] | |
| }) | |
| export class VehicleEditComponent implements OnInit { | |
| vehicleEditForm: VehicleEditForm = new VehicleEditForm(); | |
| constructor(private vehiclesService: VehiclesService) { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class VehicleEditForm extends FormGroup { | |
| get id(): string { | |
| return this.controls.id.value; | |
| } | |
| get brand(): string { | |
| return this.controls.brand.value; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class VehicleEditForm extends FormGroup { | |
| selectedFutureYear$: Observable<number> = this.controls.year.valueChanges.pipe( | |
| filter((value: number) => value > (new Date()).getFullYear()) | |
| ); | |
| constructor() { | |
| super({ | |
| id: new FormControl(null, Validators.compose([Validators.required])), | |
| brand: new FormControl(null, Validators.compose([Validators.required])), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ngOnInit(): void { | |
| this.vehiclesService.get().subscribe((data: Vehicle) => this.vehicleEditForm.setVehicle(data)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class VehicleEditForm extends FormGroup { | |
| constructor() { | |
| super({ | |
| id: new FormControl(null, Validators.compose([Validators.required])), | |
| brand: new FormControl(null, Validators.compose([Validators.required])), | |
| type: new FormControl(null, Validators.compose([Validators.required])), | |
| class: new FormControl(null, Validators.compose([Validators.required])), | |
| year: new FormControl(null, Validators.compose([Validators.required])), | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class VehicleEditForm extends FormGroup { | |
| constructor() { | |
| super({ | |
| id: new FormControl(null, Validators.compose([Validators.required])), | |
| brand: new FormControl(null, Validators.compose([Validators.required])), | |
| type: new FormControl(null, Validators.compose([Validators.required])), | |
| class: new FormControl(null, Validators.compose([Validators.required])), | |
| year: new FormControl(null, Validators.compose([Validators.required])), | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| selector: 'app-vehicle-edit', | |
| templateUrl: './vehicle-edit.component.html', | |
| styleUrls: ['./vehicle-edit.component.scss'] | |
| }) | |
| export class VehicleEditComponent implements OnInit { | |
| vehicleEditForm: FormGroup = new FormGroup({ | |
| id: new FormControl(null, Validators.compose([Validators.required])), | |
| brand: new FormControl(null, Validators.compose([Validators.required])), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class DevekeeComponent { | |
| devekeeForm: FormGroup = new FormGroup({ | |
| firstName: new FormControl(null), | |
| lastName: new FormControl(null) | |
| }); | |
| } |