From 69e080033feb350010969f334343c7deafaf023d Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Tue, 11 Jun 2024 00:16:49 +0300 Subject: [PATCH] refactor: bind components to api --- .../schedule/tabs/tabs.component.html | 16 +++-- .../schedule/tabs/tabs.component.ts | 65 +------------------ 2 files changed, 13 insertions(+), 68 deletions(-) diff --git a/src/components/schedule/tabs/tabs.component.html b/src/components/schedule/tabs/tabs.component.html index 194d111..313fb45 100644 --- a/src/components/schedule/tabs/tabs.component.html +++ b/src/components/schedule/tabs/tabs.component.html @@ -15,15 +15,21 @@ + diff --git a/src/components/schedule/tabs/tabs.component.ts b/src/components/schedule/tabs/tabs.component.ts index ce3eeba..67c244e 100644 --- a/src/components/schedule/tabs/tabs.component.ts +++ b/src/components/schedule/tabs/tabs.component.ts @@ -43,9 +43,6 @@ export class TabsComponent { constructor(private scheduleApi: ScheduleService) { } - protected campuses: Observable = of([]); - protected lectureHalls: Observable = of([]); - private lectureHallsData: Observable = of([]); protected groupSelected(id: number) { this.eventResult.emit( [ @@ -153,68 +150,10 @@ export class TabsComponent { } } - protected async loadDisciplines() { - if (!this.disciplinesLoaded) { - this.disciplineApi.getDisciplines().pipe( - catchError((error) => { - this.disciplinesLoaded = null; - throw error; - })).subscribe(data => { - this.disciplineEx.Data = data.map(x => - ({ - id: x.id, - name: x.name, - selected: false - })); - this.disciplinesLoaded = true; - }); - } - } - - protected async loadGroups() { - if (!this.facultiesLoaded) - await this.facultyLoad(); - - if (!this.groupLoaded) { - this.groupsData = this.groupApi.getGroups(); - this.groupsData.pipe( - switchMap(groups => this.faculties.pipe( - map(campuses => { - return groups.map(x => { - const faculties = campuses.find(c => c.id === x.facultyId); - const name = faculties ? faculties.name : ''; - return { - id: x.id, - name: `${x.name} (${name})`, - selected: false - }; - }); - }) - )) - ).subscribe(data => { - this.groupEx.Data = data; - this.groupLoaded = true; - }); - } - } - - protected async extensionLoad() { - // Lecture Hall - await this.loadLectureHalls(); - - // Disciplines - await this.loadDisciplines(); - - // Groups - await this.loadGroups(); - - // Professors - if (this.professorsData.length === 0) - this.professorsLoad(); - } - + /* @ViewChild('discipline') disciplineEx!: OtherComponent; @ViewChild('lecture') lectureHallEx!: OtherComponent; @ViewChild('group') groupEx!: OtherComponent; @ViewChild('professor') professorEx!: OtherComponent; + */ }