Saving week and other preferences in localstorage so they are persistent
All checks were successful
Jenkins Production Deployment
All checks were successful
Jenkins Production Deployment
This commit is contained in:
parent
d7c9fc9265
commit
7224a732e2
|
@ -28,6 +28,7 @@ export class DatepickerComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.fillDatePickers();
|
this.fillDatePickers();
|
||||||
|
this.getDetailsFromLocalStorage();
|
||||||
this.handleDateChange();
|
this.handleDateChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +129,7 @@ export class DatepickerComponent implements OnInit {
|
||||||
handleDateChange(): void {
|
handleDateChange(): void {
|
||||||
let mondayDate = this.findMondayInWeek(this.selectedYear, this.selectedMonth, this.selectedDay);
|
let mondayDate = this.findMondayInWeek(this.selectedYear, this.selectedMonth, this.selectedDay);
|
||||||
this.selectedMonday.emit(mondayDate);
|
this.selectedMonday.emit(mondayDate);
|
||||||
|
this.saveDetailsToLocalStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,5 +210,36 @@ export class DatepickerComponent implements OnInit {
|
||||||
this.switchDeletedBtnClass = 'show';
|
this.switchDeletedBtnClass = 'show';
|
||||||
this.showingDeletedBtnText = 'Showing deleted events';
|
this.showingDeletedBtnText = 'Showing deleted events';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.saveDetailsToLocalStorage();
|
||||||
|
}
|
||||||
|
|
||||||
|
saveDetailsToLocalStorage() {
|
||||||
|
localStorage.setItem('has_saved_details', 'true');
|
||||||
|
localStorage.setItem('selected_year', this.selectedYear);
|
||||||
|
localStorage.setItem('selected_month', this.selectedMonth);
|
||||||
|
localStorage.setItem('selected_day', this.selectedDay);
|
||||||
|
localStorage.setItem('show_deleted', this.internalShowDeletedEvents.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
getDetailsFromLocalStorage() {
|
||||||
|
if((localStorage.getItem('has_saved_details') ?? 'false') === 'true') {
|
||||||
|
this.selectedYear = localStorage.getItem('selected_year')!;
|
||||||
|
this.selectedMonth = localStorage.getItem('selected_month')!;
|
||||||
|
this.selectedDay = localStorage.getItem('selected_day')!;
|
||||||
|
this.internalShowDeletedEvents = localStorage.getItem('show_deleted')! === 'true';
|
||||||
|
this.showDeletedEvents.emit(this.internalShowDeletedEvents);
|
||||||
|
this.checkShowDeletedEventsBtn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkShowDeletedEventsBtn() {
|
||||||
|
if(this.internalShowDeletedEvents) {
|
||||||
|
this.switchDeletedBtnClass = 'show';
|
||||||
|
this.showingDeletedBtnText = 'Showing deleted events';
|
||||||
|
} else {
|
||||||
|
this.switchDeletedBtnClass = 'hide';
|
||||||
|
this.showingDeletedBtnText = 'Deleted events hidden';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user