Compare commits
No commits in common. "380b2efa0d0bad876e1ab3406fa724dbe1a7279c" and "a86e88e08775f5faba3d66fc60b2c667b69bce76" have entirely different histories.
380b2efa0d
...
a86e88e087
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "1.0.0-b7",
|
||||
"version": "1.0.0-b6",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "frontend",
|
||||
"version": "1.0.0-b7",
|
||||
"version": "1.0.0-b6",
|
||||
"dependencies": {
|
||||
"@angular/animations": "^18.2.6",
|
||||
"@angular/cdk": "~18.2.6",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "1.0.0-b7",
|
||||
"version": "1.0.0-b6",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
|
@ -1,7 +1,7 @@
|
||||
@if (loading) {
|
||||
<app-data-spinner/>
|
||||
} @else {
|
||||
<button mat-fab color="primary" (click)="retryLoad()">
|
||||
<button mat-fab color="primary" (click)="retryFunction.emit()">
|
||||
<mat-icon>refresh</mat-icon>
|
||||
</button>
|
||||
}
|
||||
|
@ -18,9 +18,4 @@ import {MatButton, MatFabButton} from "@angular/material/button";
|
||||
export class LoadingIndicatorComponent {
|
||||
@Input() loading: boolean = true;
|
||||
@Output() retryFunction: EventEmitter<void> = new EventEmitter<void>();
|
||||
|
||||
protected retryLoad() {
|
||||
this.loading = true;
|
||||
this.retryFunction.emit();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component, EventEmitter, ViewChild} from '@angular/core';
|
||||
import {Component, EventEmitter, Output, ViewChild} from '@angular/core';
|
||||
import {MatExpansionModule, MatExpansionPanel} from "@angular/material/expansion";
|
||||
import {MatChipListbox, MatChipsModule} from '@angular/material/chips';
|
||||
import {FormControl, FormsModule, ReactiveFormsModule} from "@angular/forms";
|
||||
@ -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, TabStorageService} from "@service/tab-storage.service";
|
||||
|
||||
enum Enclosure {
|
||||
faculty, course, group
|
||||
}
|
||||
import {TabSelect, TabSelectData, TabSelectType, TabStorageService} from "@service/tab-storage.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-group',
|
||||
@ -29,6 +25,7 @@ enum Enclosure {
|
||||
styleUrl: './group.component.css',
|
||||
providers: [FacultyService, GroupService]
|
||||
})
|
||||
|
||||
export class GroupComponent implements IScheduleTab {
|
||||
protected faculties: FacultyResponse[] | null = null;
|
||||
protected courseNumbers: number[] | null = null;
|
||||
@ -54,50 +51,13 @@ export class GroupComponent implements IScheduleTab {
|
||||
@ViewChild('courseIndicator') courseIndicator!: LoadingIndicatorComponent;
|
||||
@ViewChild('groupIndicator') groupIndicator!: LoadingIndicatorComponent;
|
||||
|
||||
private resetCourse() {
|
||||
this.courseNumber = null;
|
||||
this.groups = [];
|
||||
this.formChipCourse.reset();
|
||||
this.courseChip.value = undefined;
|
||||
@Output() eventResult = new EventEmitter<number>();
|
||||
|
||||
constructor(private facultyApi: FacultyService, private groupApi: GroupService, private tabStorage: TabStorageService) {
|
||||
}
|
||||
|
||||
private resetGroup() {
|
||||
this.filteredGroupsBehaviour = [];
|
||||
this.filteredGroupsMagistracy = [];
|
||||
this.filteredGroupsSpecialist = [];
|
||||
this.formChipGroup.reset();
|
||||
this.groupChip.value = undefined;
|
||||
}
|
||||
|
||||
public eventResult = new EventEmitter<number>();
|
||||
public selectChangeEvent = new EventEmitter<TabSelect[]>();
|
||||
|
||||
constructor(private facultyApi: FacultyService, private groupApi: GroupService) {
|
||||
}
|
||||
|
||||
private getSelectedTabs(): TabSelect[] {
|
||||
const faculty = this.facultyChip.value;
|
||||
const course = this.courseChip.value;
|
||||
const group = this.groupChip.value;
|
||||
|
||||
const result: TabSelect[] = [];
|
||||
|
||||
if (faculty)
|
||||
result.push(new TabSelect(faculty, this.faculties!.find(x => x.id === faculty)?.name ?? ''));
|
||||
|
||||
if (course)
|
||||
result.push(new TabSelect(course, course.toString()));
|
||||
|
||||
if (group)
|
||||
result.push(new TabSelect(group, this.groups!.find(x => x.id == group)?.name ?? ''));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public getEnclosureList(): string[] {
|
||||
return Object.keys(Enclosure).filter((item) => {
|
||||
return isNaN(Number(item));
|
||||
});
|
||||
existParams(data: TabSelectData): boolean {
|
||||
return data.selected['group'] !== undefined || data.selected['course'] !== undefined || data.selected['faculty'] !== undefined;
|
||||
}
|
||||
|
||||
protected loadFaculties() {
|
||||
@ -109,8 +69,7 @@ export class GroupComponent implements IScheduleTab {
|
||||
.subscribe(data => {
|
||||
this.faculties = data;
|
||||
|
||||
let selected = TabStorageService.selected?.selected[this.getEnclosureList()[Enclosure.faculty]];
|
||||
|
||||
let selected = TabStorageService.selected?.selected['faculty'];
|
||||
if (selected) {
|
||||
let selectedFaculty = data.find(x => x.id === selected.index);
|
||||
|
||||
@ -119,7 +78,7 @@ export class GroupComponent implements IScheduleTab {
|
||||
|
||||
if (selectedFaculty !== undefined) {
|
||||
TabStorageService.trySelectChip(selectedFaculty.id, this.facultyChip);
|
||||
this.onFacultySelected(selectedFaculty.id, true);
|
||||
this.onFacultySelected(selectedFaculty.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -145,7 +104,7 @@ export class GroupComponent implements IScheduleTab {
|
||||
.sort((a, b) => a - b))
|
||||
);
|
||||
|
||||
let selected = TabStorageService.selected?.selected[this.getEnclosureList()[Enclosure.course]];
|
||||
let selected = TabStorageService.selected?.selected['course'];
|
||||
if (selected) {
|
||||
let selectedCourse = this.courseNumbers.find(x => x === selected.index);
|
||||
|
||||
@ -154,11 +113,11 @@ export class GroupComponent implements IScheduleTab {
|
||||
|
||||
if (selectedCourse !== undefined) {
|
||||
TabStorageService.trySelectChip(selectedCourse, this.courseChip);
|
||||
this.onCourseSelected(selectedCourse, true);
|
||||
this.onCourseSelected(selectedCourse);
|
||||
}
|
||||
}
|
||||
|
||||
let selectedGroupStorage = TabStorageService.selected?.selected[this.getEnclosureList()[Enclosure.group]];
|
||||
let selectedGroupStorage = TabStorageService.selected?.selected['group'];
|
||||
if (selectedGroupStorage) {
|
||||
let selectedGroup = data.find(x => x.id === selectedGroupStorage.index);
|
||||
|
||||
@ -167,7 +126,7 @@ export class GroupComponent implements IScheduleTab {
|
||||
|
||||
if (selectedGroup !== undefined) {
|
||||
TabStorageService.trySelectChip(selectedGroup.id, this.groupChip);
|
||||
this.onGroupSelected(selectedGroup.id, true);
|
||||
this.onGroupSelected(selectedGroup.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -188,19 +147,18 @@ export class GroupComponent implements IScheduleTab {
|
||||
}
|
||||
}
|
||||
|
||||
protected onFacultySelected(index: number, loadMode: boolean = false) {
|
||||
this.resetCourse();
|
||||
this.resetGroup();
|
||||
protected onFacultySelected(index: number) {
|
||||
this.courseNumber = null;
|
||||
this.groups = [];
|
||||
this.formChipGroup.reset();
|
||||
this.formChipCourse.reset();
|
||||
|
||||
if (index === undefined) {
|
||||
this.facultyId = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (loadMode)
|
||||
this.facultyChip.value = index;
|
||||
else
|
||||
this.selectChangeEvent.emit(this.getSelectedTabs());
|
||||
this.tabStorage.select(new TabSelect(index, this.faculties!.find(x => x.id === index)?.name ?? ''), TabSelectType.group, 'faculty');
|
||||
|
||||
this.facultyId = index;
|
||||
this.courseNumberPanel.open();
|
||||
@ -208,32 +166,29 @@ export class GroupComponent implements IScheduleTab {
|
||||
this.loadCourseGroup();
|
||||
}
|
||||
|
||||
protected onCourseSelected(course: number, loadMode: boolean = false) {
|
||||
this.resetGroup();
|
||||
protected onCourseSelected(course: number) {
|
||||
this.filteredGroupsBehaviour = [];
|
||||
this.filteredGroupsMagistracy = [];
|
||||
this.filteredGroupsSpecialist = [];
|
||||
this.formChipGroup.reset();
|
||||
|
||||
if (course === undefined) {
|
||||
this.courseNumber = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (loadMode)
|
||||
this.courseChip.value = course;
|
||||
else
|
||||
this.selectChangeEvent.emit(this.getSelectedTabs());
|
||||
this.tabStorage.select(new TabSelect(course, course.toString()), TabSelectType.group, 'course');
|
||||
|
||||
this.courseNumber = course;
|
||||
this.groupPanel.open();
|
||||
this.loadCourseGroup();
|
||||
}
|
||||
|
||||
protected onGroupSelected(index: number, loadMode: boolean = false) {
|
||||
protected onGroupSelected(index: number) {
|
||||
if (index === undefined)
|
||||
return;
|
||||
|
||||
if (loadMode)
|
||||
this.groupChip.value = index;
|
||||
|
||||
this.selectChangeEvent.emit(this.getSelectedTabs());
|
||||
this.tabStorage.select(new TabSelect(index, this.groups!.find(x => x.id == index)?.name ?? ''), TabSelectType.group, 'group');
|
||||
|
||||
this.groupPanel.close();
|
||||
this.eventResult.emit(index);
|
||||
|
@ -1,12 +1,8 @@
|
||||
import {EventEmitter} from "@angular/core";
|
||||
import {TabSelect} from "@service/tab-storage.service";
|
||||
|
||||
import {TabSelectData} from "@service/tab-storage.service";
|
||||
|
||||
export interface IScheduleTab {
|
||||
load(): void;
|
||||
|
||||
getEnclosureList(): string[];
|
||||
|
||||
eventResult: EventEmitter<number>;
|
||||
selectChangeEvent: EventEmitter<TabSelect[]>;
|
||||
existParams(data: TabSelectData): boolean;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component, EventEmitter, ViewChild} from '@angular/core';
|
||||
import {Component, EventEmitter, Output, ViewChild} from '@angular/core';
|
||||
import {AsyncPipe} from "@angular/common";
|
||||
import {MatAccordion, MatExpansionModule, MatExpansionPanel} from "@angular/material/expansion";
|
||||
import {MatChipListbox, MatChipsModule} from "@angular/material/chips";
|
||||
@ -10,11 +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, TabStorageService} from "@service/tab-storage.service";
|
||||
|
||||
enum Enclosure {
|
||||
campus, lecture
|
||||
}
|
||||
import {TabSelect, TabSelectData, TabSelectType, TabStorageService} from "@service/tab-storage.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-lecture-hall',
|
||||
@ -31,6 +27,7 @@ enum Enclosure {
|
||||
styleUrl: './lecture-hall.component.css',
|
||||
providers: [CampusService, LectureHallService]
|
||||
})
|
||||
|
||||
export class LectureHallComponent implements IScheduleTab {
|
||||
protected campusId: number | null = null;
|
||||
protected formLectureHalls: FormControl = new FormControl();
|
||||
@ -38,6 +35,8 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
protected campuses: CampusBasicInfoResponse[] | null = null;
|
||||
protected lectureHallsFiltered: LectureHallResponse[] | null = null;
|
||||
|
||||
@Output() eventResult = new EventEmitter<number>();
|
||||
|
||||
@ViewChild('lecturePanel') lecturePanel!: MatExpansionPanel;
|
||||
@ViewChild('lectureIndicator') lectureIndicator!: LoadingIndicatorComponent;
|
||||
@ViewChild('campusIndicator') campusIndicator!: LoadingIndicatorComponent;
|
||||
@ -47,31 +46,11 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
|
||||
private lectureHalls: LectureHallResponse[] | null = null;
|
||||
|
||||
public eventResult = new EventEmitter<number>();
|
||||
public selectChangeEvent = new EventEmitter<TabSelect[]>();
|
||||
|
||||
constructor(private campusApi: CampusService, private lectureHallApi: LectureHallService) {
|
||||
constructor(private campusApi: CampusService, private lectureHallApi: LectureHallService, private tabStorage: TabStorageService) {
|
||||
}
|
||||
|
||||
private getSelectedTabs(): TabSelect[] {
|
||||
const campus = this.campusChip.value;
|
||||
const lecture = this.lectureChip.value;
|
||||
|
||||
const result: TabSelect[] = [];
|
||||
|
||||
if (campus)
|
||||
result.push(new TabSelect(campus, this.campuses!.find(x => x.id === campus)?.codeName ?? ''));
|
||||
|
||||
if (lecture)
|
||||
result.push(new TabSelect(lecture, this.lectureHallsFiltered!.find(x => x.id === lecture)?.name ?? ''));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
getEnclosureList(): string[] {
|
||||
return Object.keys(Enclosure).filter((item) => {
|
||||
return isNaN(Number(item));
|
||||
});
|
||||
existParams(data: TabSelectData): boolean {
|
||||
return data.selected['campus'] !== undefined || data.selected['lecture'] !== undefined;
|
||||
}
|
||||
|
||||
protected loadCampuses() {
|
||||
@ -83,7 +62,7 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
.subscribe(data => {
|
||||
this.campuses = data;
|
||||
|
||||
let selected = TabStorageService.selected?.selected[this.getEnclosureList()[Enclosure.campus]];
|
||||
let selected = TabStorageService.selected?.selected['campus'];
|
||||
if (selected) {
|
||||
let selectedCampus = data.find(x => x.id === selected.index);
|
||||
|
||||
@ -92,7 +71,7 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
|
||||
if (selectedCampus !== undefined) {
|
||||
TabStorageService.trySelectChip(selectedCampus.id, this.campusChip);
|
||||
this.onCampusSelected(selectedCampus.id, true);
|
||||
this.onCampusSelected(selectedCampus.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -102,14 +81,10 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
this.lectureHallsFiltered = this.lectureHalls?.filter(x => x.campusId === this.campusId) ?? null;
|
||||
}
|
||||
|
||||
protected onCampusSelected(index: number, loadMode: boolean = false) {
|
||||
protected onCampusSelected(index: number) {
|
||||
this.formLectureHalls.reset();
|
||||
this.lectureChip.value = undefined;
|
||||
|
||||
if (loadMode)
|
||||
this.campusChip.value = index;
|
||||
else
|
||||
this.selectChangeEvent.emit(this.getSelectedTabs());
|
||||
this.tabStorage.select(new TabSelect(index, this.campuses!.find(x => x.id === index)?.codeName ?? ''), TabSelectType.lecture, 'campus');
|
||||
|
||||
if (index === undefined) {
|
||||
this.campusId = null;
|
||||
@ -136,7 +111,7 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
this.lectureHalls = data;
|
||||
this.filteringLectureHalls();
|
||||
|
||||
let selected = TabStorageService.selected?.selected[this.getEnclosureList()[Enclosure.lecture]];
|
||||
let selected = TabStorageService.selected?.selected['lecture'];
|
||||
if (selected) {
|
||||
let selectedLecture = data.find(x => x.id === selected.index);
|
||||
|
||||
@ -145,20 +120,17 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
|
||||
if (selectedLecture !== undefined) {
|
||||
TabStorageService.trySelectChip(selectedLecture.id, this.lectureChip);
|
||||
this.onLectureHallSelected(selectedLecture.id, true);
|
||||
this.onLectureHallSelected(selectedLecture.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected onLectureHallSelected(index: number, loadMode: boolean = false) {
|
||||
protected onLectureHallSelected(index: number) {
|
||||
if (index === undefined)
|
||||
return;
|
||||
|
||||
if (loadMode)
|
||||
this.lectureChip.value = index;
|
||||
else
|
||||
this.selectChangeEvent.emit(this.getSelectedTabs());
|
||||
this.tabStorage.select(new TabSelect(index, this.lectureHallsFiltered!.find(x => x.id === index)?.name ?? ''), TabSelectType.lecture, 'lecture');
|
||||
|
||||
this.lecturePanel.close();
|
||||
this.eventResult.emit(index);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component, EventEmitter, OnInit, ViewChild} from "@angular/core";
|
||||
import {Component, EventEmitter, OnInit, Output, ViewChild} from "@angular/core";
|
||||
import {MatFormField, MatInput} from "@angular/material/input";
|
||||
import {FormControl, ReactiveFormsModule} from "@angular/forms";
|
||||
import {MatAutocompleteModule} from "@angular/material/autocomplete";
|
||||
@ -8,7 +8,7 @@ import {LoadingIndicatorComponent} from "@component/common/loading-indicator/loa
|
||||
import {ProfessorResponse} from "@api/v1/professorResponse";
|
||||
import {ProfessorService} from "@api/v1/professor.service";
|
||||
import {IScheduleTab} from "@component/schedule/tabs/ischedule-tab";
|
||||
import {TabSelect, TabStorageService} from "@service/tab-storage.service";
|
||||
import {TabSelect, TabSelectData, TabSelectType, TabStorageService} from "@service/tab-storage.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-professor',
|
||||
@ -33,14 +33,13 @@ export class ProfessorComponent implements OnInit, IScheduleTab {
|
||||
|
||||
@ViewChild('professorIndicator') professorIndicator!: LoadingIndicatorComponent;
|
||||
|
||||
public eventResult = new EventEmitter<number>();
|
||||
public selectChangeEvent = new EventEmitter<TabSelect[]>();
|
||||
@Output() eventResult = new EventEmitter<number>();
|
||||
|
||||
constructor(private api: ProfessorService) {
|
||||
constructor(private api: ProfessorService, private tabStorage: TabStorageService) {
|
||||
}
|
||||
|
||||
getEnclosureList(): string[] {
|
||||
return ['professor'];
|
||||
existParams(data: TabSelectData): boolean {
|
||||
return data.selected['professor'] !== undefined;
|
||||
}
|
||||
|
||||
protected loadProfessors() {
|
||||
@ -96,7 +95,7 @@ export class ProfessorComponent implements OnInit, IScheduleTab {
|
||||
this.professorControl.setValue(selectedOption.name);
|
||||
this.eventResult.emit(selectedOption.id);
|
||||
|
||||
this.selectChangeEvent.emit([new TabSelect(selectedOption.id, selectedOption.name)]);
|
||||
this.tabStorage.select(new TabSelect(selectedOption.id, selectedOption.name), TabSelectType.professor, 'professor');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,17 +3,17 @@
|
||||
(selectedTabChange)="chooseTabs($event.index)">
|
||||
<mat-tab label="Группа">
|
||||
<div>
|
||||
<app-group #groupTab/>
|
||||
<app-group #groupTab (eventResult)="groupSelected($event)"/>
|
||||
</div>
|
||||
</mat-tab>
|
||||
<mat-tab label="Преподаватель">
|
||||
<div>
|
||||
<app-professor #professorTab/>
|
||||
<app-professor #professorTab (eventResult)="professorSelected($event)"/>
|
||||
</div>
|
||||
</mat-tab>
|
||||
<mat-tab label="Кабинет">
|
||||
<div>
|
||||
<app-lecture-hall #lectureHallTab/>
|
||||
<app-lecture-hall #lectureHallTab (eventResult)="lectureHallSelected($event)"/>
|
||||
</div>
|
||||
</mat-tab>
|
||||
|
||||
|
@ -17,7 +17,7 @@ import {GroupService} from "@api/v1/group.service";
|
||||
import {ProfessorService} from "@api/v1/professor.service";
|
||||
import {AuthRoles} from "@model/AuthRoles";
|
||||
import {HasRoleDirective} from "@/directives/has-role.directive";
|
||||
import {TabSelectType, TabStorageService} from "@service/tab-storage.service";
|
||||
import {TabStorageService} from "@service/tab-storage.service";
|
||||
|
||||
export enum TabsSelect {
|
||||
Group,
|
||||
@ -49,91 +49,77 @@ export enum TabsSelect {
|
||||
|
||||
export class TabsComponent implements AfterViewInit {
|
||||
@Output() eventResult = new EventEmitter<[TabsSelect, number, Observable<ScheduleResponse[]>]>();
|
||||
private currentTab: number = -1;
|
||||
|
||||
constructor(private scheduleApi: ScheduleService,
|
||||
private disciplineApi: DisciplineService,
|
||||
private lectureApi: LectureHallService,
|
||||
private groupApi: GroupService,
|
||||
private professorApi: ProfessorService,
|
||||
private tabStorage: TabStorageService) {
|
||||
private professorApi: ProfessorService) {
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.groupTab.selectChangeEvent.subscribe(event => this.tabStorage.select(TabSelectType.group, event));
|
||||
this.professorTab.selectChangeEvent.subscribe(event => this.tabStorage.select(TabSelectType.professor, event));
|
||||
this.lectureHallTab.selectChangeEvent.subscribe(event => this.tabStorage.select(TabSelectType.lecture, event));
|
||||
|
||||
this.groupTab.eventResult.subscribe(event => this.eventResult.emit(
|
||||
[
|
||||
TabsSelect.Group,
|
||||
event,
|
||||
this.scheduleApi.getByGroup(event)
|
||||
]
|
||||
));
|
||||
|
||||
this.professorTab.eventResult.subscribe(event => this.eventResult.emit(
|
||||
[
|
||||
TabsSelect.Professor,
|
||||
event,
|
||||
this.scheduleApi.getByProfessor(event)
|
||||
]
|
||||
));
|
||||
|
||||
this.lectureHallTab.eventResult.subscribe(event => this.eventResult.emit(
|
||||
[
|
||||
TabsSelect.LectureHall,
|
||||
event,
|
||||
this.scheduleApi.getByLectureHall(event)
|
||||
]
|
||||
));
|
||||
|
||||
let selected = TabStorageService.selected;
|
||||
|
||||
let index = 0;
|
||||
|
||||
if (selected !== null) {
|
||||
const selectedKeys = Object.keys(selected?.selected);
|
||||
if (selected.type === null) {
|
||||
if (this.groupTab.getEnclosureList().every((value, index) => value === selectedKeys[index]))
|
||||
if (this.groupTab.existParams(selected))
|
||||
index = 0;
|
||||
else if (this.professorTab.getEnclosureList().every((value, index) => value === selectedKeys[index]))
|
||||
else if (this.professorTab.existParams(selected))
|
||||
index = 1;
|
||||
else if (this.lectureHallTab.getEnclosureList().every((value, index) => value === selectedKeys[index]))
|
||||
else if (this.lectureHallTab.existParams(selected))
|
||||
index = 2;
|
||||
} else
|
||||
index = selected.type;
|
||||
}
|
||||
|
||||
if (index === 0)
|
||||
if (index === null || index === 0)
|
||||
this.chooseTabs(0).then();
|
||||
else
|
||||
this.tabs.selectedIndex = index;
|
||||
}
|
||||
|
||||
protected async chooseTabs(index: number) {
|
||||
let needGetEnclosure = false;
|
||||
|
||||
if (this.currentTab !== index) {
|
||||
this.currentTab = index;
|
||||
needGetEnclosure = true;
|
||||
protected groupSelected(id: number) {
|
||||
this.eventResult.emit(
|
||||
[
|
||||
TabsSelect.Group,
|
||||
id,
|
||||
this.scheduleApi.getByGroup(id)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected professorSelected(id: number) {
|
||||
this.eventResult.emit(
|
||||
[
|
||||
TabsSelect.Professor,
|
||||
id,
|
||||
this.scheduleApi.getByProfessor(id)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected lectureHallSelected(id: number) {
|
||||
this.eventResult.emit(
|
||||
[
|
||||
TabsSelect.LectureHall,
|
||||
id,
|
||||
this.scheduleApi.getByLectureHall(id)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected async chooseTabs(index: number) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
this.groupTab.load();
|
||||
if (needGetEnclosure)
|
||||
this.tabStorage.enclosure = this.groupTab.getEnclosureList();
|
||||
break;
|
||||
case 1:
|
||||
this.professorTab.load();
|
||||
if (needGetEnclosure)
|
||||
this.tabStorage.enclosure = this.professorTab.getEnclosureList();
|
||||
break;
|
||||
case 2:
|
||||
this.lectureHallTab.load();
|
||||
if (needGetEnclosure)
|
||||
this.tabStorage.enclosure = this.lectureHallTab.getEnclosureList();
|
||||
break;
|
||||
case 3:
|
||||
await this.loadDisciplines();
|
||||
|
@ -30,7 +30,6 @@ export interface TabSelectData {
|
||||
})
|
||||
export class TabStorageService {
|
||||
private static dataName = 'tabSelectedData';
|
||||
private _enclosure: string[] = [];
|
||||
|
||||
constructor(private router: Router, private location: Location) {
|
||||
}
|
||||
@ -53,18 +52,27 @@ export class TabStorageService {
|
||||
}, 100);
|
||||
}
|
||||
|
||||
public set enclosure(data: string[]) {
|
||||
this._enclosure = data;
|
||||
private resetIfNeed(type: TabSelectType) {
|
||||
let selectedData = TabStorageService.selected;
|
||||
|
||||
if (selectedData === null || selectedData?.type === null)
|
||||
return;
|
||||
|
||||
if (selectedData.type !== type) {
|
||||
localStorage.removeItem(TabStorageService.dataName);
|
||||
const currentUrl = this.router.url.split('?')[0];
|
||||
this.location.replaceState(currentUrl);
|
||||
}
|
||||
}
|
||||
|
||||
public select(type: TabSelectType, tabSelected: TabSelect[]) {
|
||||
let selectedData = {selected: {}} as TabSelectData;
|
||||
public select(selected: TabSelect, type: TabSelectType, navigateName: string) {
|
||||
this.resetIfNeed(type);
|
||||
let selectedData = TabStorageService.selected;
|
||||
|
||||
for (let index = 0; index < this._enclosure.length; index++) {
|
||||
if (tabSelected[index])
|
||||
selectedData.selected[this._enclosure[index]] = tabSelected[index];
|
||||
}
|
||||
if (selectedData === null || !selectedData.selected)
|
||||
selectedData = {selected: {}} as TabSelectData;
|
||||
|
||||
selectedData.selected[navigateName] = selected;
|
||||
selectedData.type = type;
|
||||
|
||||
localStorage.setItem(TabStorageService.dataName, JSON.stringify(selectedData));
|
||||
|
Loading…
Reference in New Issue
Block a user