Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 1x 14x 12x 18x 1x 3x 21x 9x 21x 58x 38x 58x 6x 4x 2x | import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; import { CustomTextDefs } from '../../interfaces/customtext.interfaces'; import { customTextDefaults } from '../../objects/customTextDefaults'; @Injectable({ providedIn: 'root' }) export class CustomtextService { private customTexts: { [key: string]: BehaviorSubject<string | null> } = {}; addCustomTexts(newTexts: { [key: string]: string }): void { Object.keys(newTexts).forEach(key => { this.addCustomText(key, newTexts[key]); }); } addCustomTextsFromDefs(newTexts: CustomTextDefs): void { Object.keys(newTexts).forEach(key => { this.addCustomText(key, newTexts[key].defaultvalue); }); } private addCustomText(key: string, value: string): void { if (typeof this.customTexts[key] === 'undefined') { this.customTexts[key] = new BehaviorSubject<string | null>(null); } this.customTexts[key].next(value); } getCustomText$(key: string): BehaviorSubject<string | null> { if (typeof this.customTexts[key] === 'undefined') { this.customTexts[key] = new BehaviorSubject<string | null>(null); } return this.customTexts[key]; } restoreDefault(all: boolean): void { Iif (typeof this.customTexts === 'undefined') { return; } Object.keys(this.customTexts).forEach(k => { Iif (this.customTexts[k] && customTextDefaults[k]) { this.customTexts[k].next(customTextDefaults[k].defaultvalue); } Iif (all) { Iif (!(k in customTextDefaults) && this.customTexts[k]) { this.customTexts[k] = new BehaviorSubject<string | null>(null); } } }); } getCustomText(key: string): string { if (typeof this.customTexts[key] === 'undefined') { return ''; } return this.customTexts[key].getValue() ?? ''; } } |