Files
zitadel/console/src/app/modules/edit-text/edit-text.component.ts
T
2e684684de feat(console): message and login texts, privacy policy (#2016)
* message texts wrapper components

* message-text sub, i18n, grid

* fix routing

* pack

* pack

* update material

* audit

* fix mgmt service for labelplcy

* map conv

* edit text from map

* request map

* fetch data, mgmt admin service

* warn box, i18n

* resetbtn

* login texts

* login text requests

* reset, default, i18n

* disabled, features, message text setter, service

* locale switcher

* policy grid

* password reset, domain claimed i18n

* lint files

* fix admin service, i18n, lang setter

* fix scss duplicate

* privacy policy, cleanup grid, fix message, login texts (#2031)

* policy grid everywhere 🦒

* cleanup home

* log login text request

* patch all data

* refresh toggle

* fix: add dialog for unsaved changes (#2057)

* logintexts dialog

* check for dialog on pairwise operation

* fix: patch value to local state after save

* fix: i18n and custom login texts (#2060)

* fix: i18n and custom login texts

* fix: tos and privacy texts

* fix frontend

* fix: tos and privacy texts and tests

* fix: i18n, tos and privacy texts and tests

* fix frontend maps

* i18n

* add ResetCustomLoginTextToDefault in admin api and fix template remove in handlers

* resetlogintexttodefault

Co-authored-by: Livio Amstutz <[email protected]>
2021-07-26 12:44:45 +02:00

55 lines
1.8 KiB
TypeScript

import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { Observable, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Component({
selector: 'cnsl-edit-text',
templateUrl: './edit-text.component.html',
styleUrls: ['./edit-text.component.scss'],
})
export class EditTextComponent implements OnInit, OnDestroy {
@Input() label: string = '';
@Input() current$!: Observable<{ [key: string]: any | string; }>;
@Input() default$!: Observable<{ [key: string]: any | string; }>;
@Input() currentlyDragged: string = '';
@Output() changedValues: EventEmitter<{ [key: string]: string; }> = new EventEmitter();
public currentMap: { [key: string]: string; } = {};
private destroy$: Subject<void> = new Subject();
public form!: FormGroup;
public warnText: { [key: string]: string | undefined; } = {};
@Input() public chips: any[] = [];
@Input() public disabled: boolean = true;
public copied: string = '';
public ngOnInit(): void {
this.current$.pipe(takeUntil(this.destroy$)).subscribe(value => {
this.currentMap = value;
this.form = new FormGroup({});
Object.keys(value).map(key => {
const control = new FormControl({ value: value[key], disabled: this.disabled });
this.form.addControl(key, control);
});
this.form.valueChanges.pipe(takeUntil(this.destroy$)).subscribe(values => this.changedValues.emit(values));
});
}
public ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
public setWarnText(key: string, text: string | undefined): void {
this.warnText[key] = text;
}
public addChip(key: string, value: string): void {
const c = this.form.get(key)?.value;
this.form.get(key)?.setValue(`${c} ${value}`);
}
}