theme persisted in the localstorage, reload config on page reload - issue #75

This commit is contained in:
tykayn 2020-04-11 16:59:46 +02:00
parent 6e6b812d2d
commit 936110846c
8 changed files with 1193 additions and 1149 deletions

View File

@ -1,6 +1,6 @@
<div
id='big_container'
class={{this.config.themeClass}}
class={{this.config.preferences.themeClass}}
>
<header class='big-header'>

View File

@ -21,7 +21,6 @@ export class AppComponent {
@Inject(DOCUMENT) private document,
private route: Router) {
this.detectCurrentTabOnRouteChange();
this.findLocalStoragePreferences();
this.isDevelopmentEnv = !environment.production
}
@ -56,13 +55,5 @@ export class AppComponent {
}
}
public findLocalStoragePreferences() {
const storage = window.localStorage;
if ( storage ){
const preferences = storage.getItem('FramadateConfig');
}
}
}

View File

@ -19,11 +19,14 @@ const baseConfigValues = {
};
/**
* configuration of the poll, add new fields at will
*/
export class PollConfig {
menuVisible = true;
expiracyDateDefaultInDays = 60;

View File

@ -74,10 +74,10 @@
{{"visibility.archiving_can_not"|translate}}
</option >
</select >
<span *ngIf="config.canModifyAnswers == 'false' || config.canModifyAnswers == false">
<span *ngIf=" config.canModifyAnswers == false">
{{"visibility.archiving_end_not"|translate}}
</span>
<span class="can_modify_votes" *ngIf="config.canModifyAnswers== 'true' || config.canModifyAnswers== true">
<span class="can_modify_votes" *ngIf="config.canModifyAnswers== true ">
<label for="modificationScope">
{{"visibility.archiving_end"|translate}}
</label>

View File

@ -20,12 +20,7 @@ export class VotingSummaryComponent implements OnInit {
ngOnInit() {
this.computePreferred();
console.log(' this.pollconfig.choices', this.pollconfig.choices)
console.log(' this.pollconfig.choices_count', this.pollconfig.choices_count.counts)
console.log('this.pollconfig.choices_count.counts[10]', this.pollconfig.choices_count.counts[10])
console.log('this.pollconfig.choices[2].id', this.pollconfig.choices[2].id)
console.log('this.pollconfig.choices_count.counts[]', this.pollconfig.choices_count.counts[this.pollconfig.choices[2].id].score)
}
}
getKeys(obj) {
return Object.keys(obj)

File diff suppressed because it is too large Load Diff

View File

@ -2,21 +2,21 @@
<h1 class='title' >Thème</h1 >
<span
class='choice btn'
[ngClass]="{ 'btn--primary' : config.themeClass ==='theme-light-watermelon' }"
[ngClass]="{ 'btn--primary' : config.preferences.themeClass ==='theme-light-watermelon' }"
(click)="selectTheme('light-watermelon')" >
<i class='fa fa-sun-o' ></i > light
</span >
<span
class='choice btn'
[ngClass]="{ 'btn--primary' : config.themeClass ==='theme-dark-crystal' }"
[ngClass]="{ 'btn--primary' : config.preferences.themeClass ==='theme-dark-crystal' }"
(click)="selectTheme('dark-crystal')" >
<i class='fa fa-moon-o' ></i > dark
</span >
<span
class='choice btn'
[ngClass]="{ 'btn--primary' : config.themeClass ==='theme-hot-covid' }"
[ngClass]="{ 'btn--primary' : config.preferences.themeClass ==='theme-hot-covid' }"
(click)="selectTheme('hot-covid')" >

View File

@ -1,5 +1,5 @@
import {Component, OnInit} from '@angular/core';
import {ConfigService} from "../../services/config.service";
import {ConfigService} from '../../services/config.service';
@Component({
selector: 'framadate-theme-selector',
@ -9,6 +9,7 @@ import {ConfigService} from "../../services/config.service";
export class ThemeSelectorComponent implements OnInit {
constructor(public config: ConfigService) {
// this.selectTheme('dark-crystal')
}
ngOnInit(): void {
@ -16,8 +17,8 @@ export class ThemeSelectorComponent implements OnInit {
selectTheme(themeName: string) {
if (this.config.themeChoices.includes(themeName)) {
this.config.themeSelected = this.config.themeChoices.indexOf(themeName);
this.config.themeClass = `theme-${themeName}`;
this.config.setPreference('themeName', themeName);
}
}