add checkbox to language editor UI
This commit is contained in:
parent
40ae38e8d9
commit
4417532935
|
@ -90,7 +90,7 @@ public class LanguageServiceImpl implements LanguageService {
|
|||
}
|
||||
|
||||
data.setCode(model.getCode());
|
||||
data.setPayload(model.getPayload());
|
||||
data.setPayload(model.getPayload() != null && model.getPayload().length() > 0 ? model.getPayload() : null);
|
||||
data.setOrdinal(model.getOrdinal());
|
||||
data.setUpdatedAt(Instant.now());
|
||||
|
||||
|
|
|
@ -64,6 +64,9 @@
|
|||
<mat-error *ngIf="formGroup.get('payload').hasError('required')">
|
||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
<h9 class="col-12">{{'LANGUAGE-EDITOR.FIELDS.OVERRIDE' | translate}}
|
||||
<mat-checkbox (change)="overrideFromFile($event, formGroup.get('code').value)"></mat-checkbox>
|
||||
</h9>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
|
|
@ -28,6 +28,7 @@ import { LanguageEditorResolver } from './language-editor.resolver';
|
|||
import { LanguageEditorService } from './language-editor.service';
|
||||
import { LanguageEditorModel } from './language-editor.model';
|
||||
import { LanguageHttpService } from '@app/core/services/language/language.http.service';
|
||||
import { MatCheckboxChange } from '@angular/material/checkbox';
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -43,6 +44,7 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
|||
formGroup: UntypedFormGroup = null;
|
||||
showInactiveDetails = false;
|
||||
availableLanguageCodes: string[] = [];
|
||||
currentPayload: string = null;
|
||||
|
||||
protected get canDelete(): boolean {
|
||||
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeleteLanguage);
|
||||
|
@ -106,20 +108,12 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
|||
|
||||
prepareForm(data: Language) {
|
||||
try {
|
||||
if(data && data.payload == null){
|
||||
this.languageHttpService.getSingleWithCode(data.code, LanguageEditorResolver.lookupFields())
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(language => {
|
||||
data.payload = language.payload;
|
||||
this.editorModel = data ? new LanguageEditorModel().fromModel(data) : new LanguageEditorModel();
|
||||
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||
this.buildForm();
|
||||
});
|
||||
}else{
|
||||
this.editorModel = data ? new LanguageEditorModel().fromModel(data) : new LanguageEditorModel();
|
||||
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||
this.buildForm();
|
||||
if(data && data.payload){
|
||||
this.currentPayload = data.payload;
|
||||
}
|
||||
this.editorModel = data ? new LanguageEditorModel().fromModel(data) : new LanguageEditorModel();
|
||||
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||
this.buildForm();
|
||||
} catch (error) {
|
||||
this.logger.error('Could not parse Language item: ' + data + error);
|
||||
this.uiNotificationService.snackBarNotification(this.language.instant('COMMONS.ERRORS.DEFAULT'), SnackBarNotificationLevel.Error);
|
||||
|
@ -197,13 +191,16 @@ export class LanguageEditorComponent extends BaseEditor<LanguageEditorModel, Lan
|
|||
this.formService.validateAllFormFields(this.formGroup);
|
||||
}
|
||||
|
||||
public selectedCodeChanged(code: string){
|
||||
public overrideFromFile(matCheckBox: MatCheckboxChange, code: string){
|
||||
if(matCheckBox.checked == true){
|
||||
this.languageHttpService.getSingleWithCode(code, LanguageEditorResolver.lookupFields())
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(language => {
|
||||
this.formGroup.get('payload').patchValue(language.payload);
|
||||
});
|
||||
|
||||
}else{
|
||||
this.formGroup.get('payload').patchValue(this.currentPayload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1191,7 +1191,8 @@
|
|||
"FIELDS": {
|
||||
"CODE": "Code",
|
||||
"PAYLOAD": "Payload",
|
||||
"ORDINAL": "Ordinal"
|
||||
"ORDINAL": "Ordinal",
|
||||
"OVERRIDE": "Override from file"
|
||||
},
|
||||
"ACTIONS": {
|
||||
"SAVE": "Save",
|
||||
|
|
Loading…
Reference in New Issue