-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
105 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 6 additions & 15 deletions
21
...onents/einstellungen/globale-einstellungen/ui-naming-config/ui-naming-config.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,19 @@ | ||
import { Component } from "@angular/core"; | ||
import * as _ from "lodash"; | ||
import { ConfigApiService } from "src/app/services/api/config-api.service"; | ||
import { AppNamingService } from "src/app/services/config.service"; | ||
import { InfoService } from "src/app/services/info.service"; | ||
import { AppConfigService } from "src/app/services/app-config.service"; | ||
|
||
@Component({ | ||
selector: "app-ui-naming-config", | ||
templateUrl: "./ui-naming-config.component.html", | ||
styleUrls: ["./ui-naming-config.component.scss"], | ||
}) | ||
export class UiNamingConfigComponent { | ||
public readonly appNaming = _.cloneDeep(this.namingService.appNaming); | ||
public readonly editNaming = _.cloneDeep(this.namingService.appNaming); | ||
public readonly appNaming = _.cloneDeep(this.configService.appNaming); | ||
public readonly editNaming = _.cloneDeep(this.configService.appNaming); | ||
|
||
constructor( | ||
private namingService: AppNamingService, | ||
private configService: ConfigApiService, | ||
private infoService: InfoService | ||
) {} | ||
constructor(private configService: AppConfigService) {} | ||
|
||
public saveNaming(): void { | ||
this.configService.setUiNamingConfig(this.editNaming).subscribe({ | ||
next: (_) => this.infoService.success("Einstellungen gespeichert."), | ||
error: (err) => this.infoService.error(err), | ||
}); | ||
public updateNaming(): void { | ||
this.configService.updateAppNamingConfig(this.editNaming); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export interface UiConfigurations { | ||
uiNaming: UiNamingConfig; | ||
terminConfig: UiTerminConfig; | ||
} | ||
|
||
export interface UiNamingConfig { | ||
Termine: string; | ||
Noten: string; | ||
} | ||
|
||
export interface UiTerminConfig { | ||
terminKategorien: UiDropdownOption[]; | ||
} | ||
|
||
export interface UiDropdownOption { | ||
label: string; | ||
value: string; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { BehaviorSubject, Observable, map, tap } from "rxjs"; | ||
import { | ||
UiConfigurations, | ||
UiNamingConfig, | ||
UiTerminConfig, | ||
} from "../interfaces/UiConfigurations"; | ||
import { ConfigApiService } from "./api/config-api.service"; | ||
import { InfoService } from "./info.service"; | ||
|
||
@Injectable({ | ||
providedIn: "root", | ||
}) | ||
export class AppConfigService { | ||
private _appNaming = new BehaviorSubject<UiNamingConfig>(null); | ||
public get appNaming(): UiNamingConfig { | ||
return this._appNaming.value; | ||
} | ||
|
||
private _terminConfig = new BehaviorSubject<UiTerminConfig>(null); | ||
public get terminConfig(): UiTerminConfig { | ||
return this._terminConfig.value; | ||
} | ||
|
||
constructor( | ||
private configService: ConfigApiService, | ||
private infoService: InfoService | ||
) {} | ||
|
||
public initAppNamingConfig(): Observable<void> { | ||
return this.configService.getConfigs().pipe( | ||
tap((config) => this.setInternalConfigs(config)), | ||
map((config) => null) | ||
); | ||
} | ||
|
||
public updateAppNamingConfig(naming: UiNamingConfig) { | ||
const configurations: UiConfigurations = { | ||
uiNaming: naming, | ||
terminConfig: this.terminConfig, | ||
}; | ||
|
||
this.permitConfigs(configurations).subscribe({ | ||
next: (_) => this.infoService.success("Einstellungen gespeichert."), | ||
error: (err) => this.infoService.error(err), | ||
}); | ||
} | ||
|
||
private permitConfigs(configurations: UiConfigurations): Observable<void> { | ||
return this.configService.saveConfigs(configurations).pipe( | ||
tap((res) => { | ||
this.setInternalConfigs(res); | ||
}), | ||
map((_) => null) | ||
); | ||
} | ||
|
||
private setInternalConfigs(config: UiConfigurations): void { | ||
this._appNaming.next(config.uiNaming); | ||
this._terminConfig.next(config.terminConfig); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters