RED-7115, edit radio button type description.
This commit is contained in:
parent
b1b8ce2e49
commit
60b0d502ae
@ -1,14 +1,21 @@
|
|||||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
import { Component, EventEmitter, inject, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
|
||||||
import { DetailsRadioOption } from './details-radio-option';
|
import { DetailsRadioOption } from './details-radio-option';
|
||||||
import { FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, NG_VALIDATORS, NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { FormFieldComponent } from '../form-field/form-field-component.directive';
|
import { FormFieldComponent } from '../form-field/form-field-component.directive';
|
||||||
import { NgClass, NgForOf, NgIf } from '@angular/common';
|
import { NgClass, NgForOf, NgIf } from '@angular/common';
|
||||||
import { RoundCheckboxComponent } from '../round-checkbox/round-checkbox.component';
|
import { RoundCheckboxComponent } from '../round-checkbox/round-checkbox.component';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||||
import { ReplaceNbspPipe } from '../../pipes/replace-nbsp.pipe';
|
import { ReplaceNbspPipe } from '../../pipes/replace-nbsp.pipe';
|
||||||
|
import { removeActionDescriptorTranslations } from '../../../../../../apps/red-ui/src/app/translations/redact-text-translations';
|
||||||
|
import { List } from '../../utils';
|
||||||
|
|
||||||
|
export const removeActionDescriptorTranslationsPaths: List = [
|
||||||
|
removeActionDescriptorTranslations.redact,
|
||||||
|
removeActionDescriptorTranslations.recommend,
|
||||||
|
];
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'iqser-details-radio [options]',
|
selector: 'iqser-details-radio [options]',
|
||||||
@ -41,16 +48,32 @@ import { ReplaceNbspPipe } from '../../pipes/replace-nbsp.pipe';
|
|||||||
ReplaceNbspPipe,
|
ReplaceNbspPipe,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class DetailsRadioComponent<I> extends FormFieldComponent<DetailsRadioOption<I>> {
|
export class DetailsRadioComponent<I> extends FormFieldComponent<DetailsRadioOption<I>> implements OnChanges {
|
||||||
@Input() options: DetailsRadioOption<I>[] = [];
|
@Input() options: DetailsRadioOption<I>[] = [];
|
||||||
@Input() displayInRow = false;
|
@Input() displayInRow = false;
|
||||||
|
|
||||||
@Output() readonly extraOptionChanged: EventEmitter<DetailsRadioOption<I>> = new EventEmitter();
|
@Output() readonly extraOptionChanged: EventEmitter<DetailsRadioOption<I>> = new EventEmitter();
|
||||||
|
readonly #translateService = inject(TranslateService);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
|
if (!changes['options']) return;
|
||||||
|
this.options = this.options.map(option => {
|
||||||
|
const type = option.descriptionParams?.['type'];
|
||||||
|
if (!type) return option;
|
||||||
|
return {
|
||||||
|
...option,
|
||||||
|
descriptionParams: {
|
||||||
|
...option.descriptionParams,
|
||||||
|
type: removeActionDescriptorTranslationsPaths.includes(type) ? this.#translateService.instant(type) : type,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
toggleOption(option: DetailsRadioOption<I>): void {
|
toggleOption(option: DetailsRadioOption<I>): void {
|
||||||
if (option.value !== this._value?.value && !option.disabled) {
|
if (option.value !== this._value?.value && !option.disabled) {
|
||||||
this.markAsTouched();
|
this.markAsTouched();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user