From 95298278b633930b36962ba3883233a8eca1e654 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Mon, 19 Feb 2024 00:30:43 +0300 Subject: [PATCH] feat: add lecture hall tab --- .../schedule-tabs-lecture-hall.component.css | 0 .../schedule-tabs-lecture-hall.component.html | 35 +++++++++++ .../schedule-tabs-lecture-hall.component.ts | 59 +++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 src/components/schedule-tabs/schedule-tabs-lecture-hall/schedule-tabs-lecture-hall.component.css create mode 100644 src/components/schedule-tabs/schedule-tabs-lecture-hall/schedule-tabs-lecture-hall.component.html create mode 100644 src/components/schedule-tabs/schedule-tabs-lecture-hall/schedule-tabs-lecture-hall.component.ts diff --git a/src/components/schedule-tabs/schedule-tabs-lecture-hall/schedule-tabs-lecture-hall.component.css b/src/components/schedule-tabs/schedule-tabs-lecture-hall/schedule-tabs-lecture-hall.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/components/schedule-tabs/schedule-tabs-lecture-hall/schedule-tabs-lecture-hall.component.html b/src/components/schedule-tabs/schedule-tabs-lecture-hall/schedule-tabs-lecture-hall.component.html new file mode 100644 index 0000000..c4a98d3 --- /dev/null +++ b/src/components/schedule-tabs/schedule-tabs-lecture-hall/schedule-tabs-lecture-hall.component.html @@ -0,0 +1,35 @@ + + + + + Кампус + + + + @for (campus of campuses | async; track $index) { + + {{ campus.codeName }} + + } @empty { + + } + + + + + + + Кабинет + + + + @for (lectureHall of lectureHalls | async; track $index) { + + {{ lectureHall.name }} + + } @empty { + + } + + + diff --git a/src/components/schedule-tabs/schedule-tabs-lecture-hall/schedule-tabs-lecture-hall.component.ts b/src/components/schedule-tabs/schedule-tabs-lecture-hall/schedule-tabs-lecture-hall.component.ts new file mode 100644 index 0000000..29eed08 --- /dev/null +++ b/src/components/schedule-tabs/schedule-tabs-lecture-hall/schedule-tabs-lecture-hall.component.ts @@ -0,0 +1,59 @@ +import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; +import {AsyncPipe} from "@angular/common"; +import {DataSpinnerComponent} from "@component/data-spinner/data-spinner.component"; +import {MatAccordion, MatExpansionModule, MatExpansionPanel} from "@angular/material/expansion"; +import {MatChipListboxChange, MatChipsModule} from "@angular/material/chips"; +import {Observable, of} from "rxjs"; +import {CampusBasicInfoResponse} from "@model/campusBasicInfoResponse"; +import {FormControl, ReactiveFormsModule} from "@angular/forms"; +import {LectureHallResponse} from "@model/lectureHallResponse"; + +@Component({ + selector: 'app-schedule-tabs-lecture-hall', + standalone: true, + imports: [ + MatChipsModule, + DataSpinnerComponent, + MatExpansionModule, + AsyncPipe, + ReactiveFormsModule, + MatAccordion + ], + templateUrl: './schedule-tabs-lecture-hall.component.html', + styleUrl: './schedule-tabs-lecture-hall.component.css' +}) +export class ScheduleTabsLectureHallComponent { + protected campusId: number | null = null; + protected chipLecture: FormControl = new FormControl(); + + @ViewChild('lecturePanel') lecturePanel!: MatExpansionPanel; + + @Input() campuses: Observable = of([]); + @Input() lectureHalls: Observable = of([]); + + @Output() campusSelected = new EventEmitter(); + @Output() lectureHallSelected = new EventEmitter(); + + protected selectedCampus(event: MatChipListboxChange) { + this.chipLecture.reset(); + + if (event.value === undefined || event.value === null) { + this.campusId = null; + this.lectureHalls = of([]); + return; + } + + this.campusId = event.value; + this.lecturePanel.open(); + + this.campusSelected.emit(this.campusId!); + } + + protected selectedLectureHall(event: MatChipListboxChange) { + if (event.value === undefined || event.value === null) + return; + + this.lecturePanel.close(); + this.lectureHallSelected.emit(event.value); + } +}