Added persistence to generators scope
This commit was merged in pull request #13.
This commit is contained in:
@@ -5,12 +5,12 @@
|
||||
@if (showControls) {
|
||||
<div class="controls">
|
||||
<mat-button-toggle-group vertical multiple class="generator-toggles">
|
||||
<mat-button-toggle [checked]="showRegon" (change)="showRegon = $event.source.checked">REGON</mat-button-toggle>
|
||||
<mat-button-toggle [checked]="showNip" (change)="showNip = $event.source.checked">NIP</mat-button-toggle>
|
||||
<mat-button-toggle [checked]="showPesel" (change)="showPesel = $event.source.checked">PESEL</mat-button-toggle>
|
||||
<mat-button-toggle [checked]="showIdentityCard" (change)="showIdentityCard = $event.source.checked">DOWÓD</mat-button-toggle>
|
||||
<mat-button-toggle [checked]="showMobile" (change)="showMobile = $event.source.checked">KOMÓRA</mat-button-toggle>
|
||||
<mat-button-toggle [checked]="showIban" (change)="showIban = $event.source.checked">IBAN</mat-button-toggle>
|
||||
<mat-button-toggle [checked]="showRegon" (change)="showRegon = $event.source.checked; saveGeneratorSettings()">REGON</mat-button-toggle>
|
||||
<mat-button-toggle [checked]="showNip" (change)="showNip = $event.source.checked; saveGeneratorSettings()">NIP</mat-button-toggle>
|
||||
<mat-button-toggle [checked]="showPesel" (change)="showPesel = $event.source.checked; saveGeneratorSettings()">PESEL</mat-button-toggle>
|
||||
<mat-button-toggle [checked]="showIdentityCard" (change)="showIdentityCard = $event.source.checked; saveGeneratorSettings()">DOWÓD</mat-button-toggle>
|
||||
<mat-button-toggle [checked]="showMobile" (change)="showMobile = $event.source.checked; saveGeneratorSettings()">KOMÓRA</mat-button-toggle>
|
||||
<mat-button-toggle [checked]="showIban" (change)="showIban = $event.source.checked; saveGeneratorSettings()">IBAN</mat-button-toggle>
|
||||
</mat-button-toggle-group>
|
||||
|
||||
<mat-button-toggle-group vertical class="theme-toggles">
|
||||
|
||||
@@ -36,6 +36,18 @@ export class AppComponent implements OnInit {
|
||||
this.selectedTheme = savedTheme;
|
||||
this.applyTheme(savedTheme);
|
||||
}
|
||||
|
||||
const savedGenerators = localStorage.getItem('generatorSettings');
|
||||
if (savedGenerators) {
|
||||
const settings = JSON.parse(savedGenerators);
|
||||
this.showRegon = settings.showRegon ?? true;
|
||||
this.showNip = settings.showNip ?? true;
|
||||
this.showPesel = settings.showPesel ?? true;
|
||||
this.showIdentityCard = settings.showIdentityCard ?? true;
|
||||
this.showIban = settings.showIban ?? true;
|
||||
this.showMobile = settings.showMobile ?? true;
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.isInitialVisible = false;
|
||||
this.cdr.detectChanges();
|
||||
@@ -48,6 +60,18 @@ export class AppComponent implements OnInit {
|
||||
this.applyTheme(theme);
|
||||
}
|
||||
|
||||
saveGeneratorSettings() {
|
||||
const settings = {
|
||||
showRegon: this.showRegon,
|
||||
showNip: this.showNip,
|
||||
showPesel: this.showPesel,
|
||||
showIdentityCard: this.showIdentityCard,
|
||||
showIban: this.showIban,
|
||||
showMobile: this.showMobile
|
||||
};
|
||||
localStorage.setItem('generatorSettings', JSON.stringify(settings));
|
||||
}
|
||||
|
||||
private applyTheme(theme: string) {
|
||||
const body = document.body;
|
||||
this.themes.forEach(t => {
|
||||
|
||||
Reference in New Issue
Block a user