refactor: move TabStorage to service
This commit is contained in:
@ -10,7 +10,7 @@ import {LectureHallResponse} from "@api/v1/lectureHallResponse";
|
||||
import {CampusService} from "@api/v1/campus.service";
|
||||
import {LectureHallService} from "@api/v1/lectureHall.service";
|
||||
import {IScheduleTab} from "@component/schedule/tabs/ischedule-tab";
|
||||
import {TabSelect, TabSelectType, TabStorageComponent} from "@component/common/tab-storage/tab-storage.component";
|
||||
import {TabSelect, TabSelectType, TabStorageService} from "@service/tab-storage.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-lecture-hall',
|
||||
@ -48,7 +48,7 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
private readonly selected: TabSelect[] | null = null;
|
||||
|
||||
constructor(private campusApi: CampusService, private lectureHallApi: LectureHallService) {
|
||||
let selectedData = TabStorageComponent.selected;
|
||||
let selectedData = TabStorageService.selected;
|
||||
if (selectedData !== null && selectedData.selected !== null) {
|
||||
if (selectedData.type === TabSelectType.lecture)
|
||||
this.selected = selectedData.selected;
|
||||
@ -71,7 +71,7 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
selectedCampus = data.find(x => x.codeName === this.selected![0].name);
|
||||
|
||||
if (selectedCampus !== undefined) {
|
||||
TabStorageComponent.trySelectChip(selectedCampus.id, this.campusChip);
|
||||
TabStorageService.trySelectChip(selectedCampus.id, this.campusChip);
|
||||
this.onCampusSelected(selectedCampus.id);
|
||||
}
|
||||
}
|
||||
@ -85,7 +85,7 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
protected onCampusSelected(index: number) {
|
||||
this.formLectureHalls.reset();
|
||||
|
||||
TabStorageComponent.select(new TabSelect(index, this.campuses!.find(x => x.id === index)?.codeName ?? ''), TabSelectType.lecture, 0);
|
||||
TabStorageService.select(new TabSelect(index, this.campuses!.find(x => x.id === index)?.codeName ?? ''), TabSelectType.lecture, 0);
|
||||
|
||||
if (index === undefined) {
|
||||
this.campusId = null;
|
||||
@ -118,7 +118,7 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
selectedLecture = data.find(x => x.name === this.selected![1].name);
|
||||
|
||||
if (selectedLecture !== undefined) {
|
||||
TabStorageComponent.trySelectChip(selectedLecture.id, this.lectureChip);
|
||||
TabStorageService.trySelectChip(selectedLecture.id, this.lectureChip);
|
||||
this.onLectureHallSelected(selectedLecture.id);
|
||||
}
|
||||
}
|
||||
@ -129,7 +129,7 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
if (index === undefined)
|
||||
return;
|
||||
|
||||
TabStorageComponent.select(new TabSelect(index, this.lectureHallsFiltered!.find(x => x.id === index)?.name ?? ''), TabSelectType.lecture, 1);
|
||||
TabStorageService.select(new TabSelect(index, this.lectureHallsFiltered!.find(x => x.id === index)?.name ?? ''), TabSelectType.lecture, 1);
|
||||
|
||||
this.lecturePanel.close();
|
||||
this.eventResult.emit(index);
|
||||
|
Reference in New Issue
Block a user