refactor: move TabStorage to service

This commit is contained in:
2024-08-28 02:01:39 +03:00
parent 42e454c4d6
commit 60218a73f2
5 changed files with 26 additions and 26 deletions

View File

@ -9,11 +9,7 @@ import {FacultyResponse} from "@api/v1/facultyResponse";
import {FacultyService} from "@api/v1/faculty.service";
import {GroupService} from "@api/v1/group.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-group',
@ -58,7 +54,7 @@ export class GroupComponent implements IScheduleTab {
@Output() eventResult = new EventEmitter<number>();
constructor(private facultyApi: FacultyService, private groupApi: GroupService) {
let selectedData = TabStorageComponent.selected;
let selectedData = TabStorageService.selected;
if (selectedData !== null && selectedData.selected !== null) {
if (selectedData.type === TabSelectType.group)
this.selected = selectedData.selected;
@ -81,7 +77,7 @@ export class GroupComponent implements IScheduleTab {
selectedFaculty = data.find(x => x.name === this.selected![0].name);
if (selectedFaculty !== undefined) {
TabStorageComponent.trySelectChip(selectedFaculty.id, this.facultyChip);
TabStorageService.trySelectChip(selectedFaculty.id, this.facultyChip);
this.onFacultySelected(selectedFaculty.id);
}
}
@ -112,7 +108,7 @@ export class GroupComponent implements IScheduleTab {
let selectedCourse = this.courseNumbers.find(x => x === this.selected![1].index);
if (selectedCourse !== undefined) {
TabStorageComponent.trySelectChip(selectedCourse, this.courseChip);
TabStorageService.trySelectChip(selectedCourse, this.courseChip);
this.onCourseSelected(selectedCourse);
}
}
@ -124,7 +120,7 @@ export class GroupComponent implements IScheduleTab {
selectedGroup = data.find(x => x.name === this.selected![2].name);
if (selectedGroup !== undefined) {
TabStorageComponent.trySelectChip(selectedGroup.id, this.groupChip);
TabStorageService.trySelectChip(selectedGroup.id, this.groupChip);
this.onGroupSelected(selectedGroup.id);
}
}
@ -148,7 +144,7 @@ export class GroupComponent implements IScheduleTab {
return;
}
TabStorageComponent.select(new TabSelect(index, this.faculties!.find(x => x.id === index)?.name ?? ''), TabSelectType.group, 0);
TabStorageService.select(new TabSelect(index, this.faculties!.find(x => x.id === index)?.name ?? ''), TabSelectType.group, 0);
this.facultyId = index;
this.courseNumberPanel.open();
@ -165,7 +161,7 @@ export class GroupComponent implements IScheduleTab {
return;
}
TabStorageComponent.select(new TabSelect(course, course.toString()), TabSelectType.group, 1);
TabStorageService.select(new TabSelect(course, course.toString()), TabSelectType.group, 1);
this.courseNumber = course;
this.groupPanel.open();
@ -176,7 +172,7 @@ export class GroupComponent implements IScheduleTab {
if (index === undefined)
return;
TabStorageComponent.select(new TabSelect(index, this.groups!.find(x => x.id == index)?.name ?? ''), TabSelectType.group, 2);
TabStorageService.select(new TabSelect(index, this.groups!.find(x => x.id == index)?.name ?? ''), TabSelectType.group, 2);
this.groupPanel.close();
this.eventResult.emit(index);