feat: add parameters as navigation
Now there is automatic navigation on the inserted url and on localStorage
This commit is contained in:
src
components
schedule
tabs
pages
schedule
services
@ -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, TabStorageService} from "@service/tab-storage.service";
|
||||
import {TabSelect, TabSelectData, TabSelectType, TabStorageService} from "@service/tab-storage.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-lecture-hall',
|
||||
@ -45,14 +45,12 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
@ViewChild('lectureChip') lectureChip!: MatChipListbox;
|
||||
|
||||
private lectureHalls: LectureHallResponse[] | null = null;
|
||||
private readonly selected: TabSelect[] | null = null;
|
||||
|
||||
constructor(private campusApi: CampusService, private lectureHallApi: LectureHallService) {
|
||||
let selectedData = TabStorageService.selected;
|
||||
if (selectedData !== null && selectedData.selected !== null) {
|
||||
if (selectedData.type === TabSelectType.lecture)
|
||||
this.selected = selectedData.selected;
|
||||
}
|
||||
constructor(private campusApi: CampusService, private lectureHallApi: LectureHallService, private tabStorage: TabStorageService) {
|
||||
}
|
||||
|
||||
existParams(data: TabSelectData): boolean {
|
||||
return data.selected['campus'] !== undefined || data.selected['lecture'] !== undefined;
|
||||
}
|
||||
|
||||
protected loadCampuses() {
|
||||
@ -64,11 +62,12 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
.subscribe(data => {
|
||||
this.campuses = data;
|
||||
|
||||
if (this.selected !== null && this.selected.length >= 1) {
|
||||
let selectedCampus = data.find(x => x.id === this.selected![0].index);
|
||||
let selected = TabStorageService.selected?.selected['campus'];
|
||||
if (selected) {
|
||||
let selectedCampus = data.find(x => x.id === selected.index);
|
||||
|
||||
if (selectedCampus === undefined || selectedCampus.codeName !== this.selected![0].name)
|
||||
selectedCampus = data.find(x => x.codeName === this.selected![0].name);
|
||||
if (selectedCampus === undefined || selectedCampus.codeName !== selected.name)
|
||||
selectedCampus = data.find(x => x.codeName === selected.name);
|
||||
|
||||
if (selectedCampus !== undefined) {
|
||||
TabStorageService.trySelectChip(selectedCampus.id, this.campusChip);
|
||||
@ -85,7 +84,7 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
protected onCampusSelected(index: number) {
|
||||
this.formLectureHalls.reset();
|
||||
|
||||
TabStorageService.select(new TabSelect(index, this.campuses!.find(x => x.id === index)?.codeName ?? ''), TabSelectType.lecture, 0);
|
||||
this.tabStorage.select(new TabSelect(index, this.campuses!.find(x => x.id === index)?.codeName ?? ''), TabSelectType.lecture, 'campus');
|
||||
|
||||
if (index === undefined) {
|
||||
this.campusId = null;
|
||||
@ -111,11 +110,13 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
.subscribe(data => {
|
||||
this.lectureHalls = data;
|
||||
this.filteringLectureHalls();
|
||||
if (this.selected !== null && this.selected.length >= 2) {
|
||||
let selectedLecture = data.find(x => x.id === this.selected![1].index);
|
||||
|
||||
if (selectedLecture === undefined || selectedLecture.name !== this.selected![1].name)
|
||||
selectedLecture = data.find(x => x.name === this.selected![1].name);
|
||||
let selected = TabStorageService.selected?.selected['lecture'];
|
||||
if (selected) {
|
||||
let selectedLecture = data.find(x => x.id === selected.index);
|
||||
|
||||
if (selectedLecture === undefined || selectedLecture.name !== selected.name)
|
||||
selectedLecture = data.find(x => x.name === selected.name);
|
||||
|
||||
if (selectedLecture !== undefined) {
|
||||
TabStorageService.trySelectChip(selectedLecture.id, this.lectureChip);
|
||||
@ -129,7 +130,7 @@ export class LectureHallComponent implements IScheduleTab {
|
||||
if (index === undefined)
|
||||
return;
|
||||
|
||||
TabStorageService.select(new TabSelect(index, this.lectureHallsFiltered!.find(x => x.id === index)?.name ?? ''), TabSelectType.lecture, 1);
|
||||
this.tabStorage.select(new TabSelect(index, this.lectureHallsFiltered!.find(x => x.id === index)?.name ?? ''), TabSelectType.lecture, 'lecture');
|
||||
|
||||
this.lecturePanel.close();
|
||||
this.eventResult.emit(index);
|
||||
|
Reference in New Issue
Block a user