refactor: minor changes

This commit is contained in:
Polianin Nikita 2024-02-17 07:50:46 +03:00
parent d12abf0bee
commit 272c76cfa8

View File

@ -1,13 +1,7 @@
import {Component, EventEmitter, Input, OnInit, Output} from "@angular/core";
import {MatFormField, MatInput} from "@angular/material/input";
import {FormControl, FormsModule, ReactiveFormsModule} from "@angular/forms";
import {
MatAutocomplete,
MatAutocompleteSelectedEvent,
MatAutocompleteTrigger,
MatOptgroup,
MatOption
} from "@angular/material/autocomplete";
import {FormControl, ReactiveFormsModule} from "@angular/forms";
import {MatAutocompleteModule, MatAutocompleteSelectedEvent} from "@angular/material/autocomplete";
import {AsyncPipe} from "@angular/common";
import {DataSpinnerComponent} from "@component/data-spinner/data-spinner.component";
import {map, Observable, startWith} from "rxjs";
@ -22,16 +16,12 @@ export interface Professors {
selector: 'app-schedule-tabs-professor',
standalone: true,
imports: [
MatAutocompleteModule,
MatFormField,
MatInput,
FormsModule,
MatAutocompleteTrigger,
MatAutocomplete,
MatOptgroup,
ReactiveFormsModule,
MatOption,
DataSpinnerComponent,
AsyncPipe,
DataSpinnerComponent
ReactiveFormsModule,
MatInput
],
templateUrl: './schedule-tabs-professor.component.html',
styleUrl: './schedule-tabs-professor.component.css'
@ -41,7 +31,7 @@ export class ScheduleTabsProfessorComponent implements OnInit {
protected filteredTeachers!: Observable<Professors[]>;
@Input() teachers: Professors[] = [];
@Output() optionSelected = new EventEmitter<number>();
@Output() professorSelected = new EventEmitter<number>();
ngOnInit(): void {
this.filteredTeachers = this.teacherControl.valueChanges.pipe(
@ -65,7 +55,7 @@ export class ScheduleTabsProfessorComponent implements OnInit {
const selectedOption = this.teachers.find(teacher => teacher.id === event.option.value);
if (selectedOption) {
this.teacherControl.setValue(selectedOption.name);
this.optionSelected.emit(selectedOption.id);
this.professorSelected.emit(selectedOption.id);
}
}
}