diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/language/LanguageServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/language/LanguageServiceImpl.java index 8d602f861..0605dae11 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/language/LanguageServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/language/LanguageServiceImpl.java @@ -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()); diff --git a/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.html b/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.html index f6f4f6899..d63d0769c 100644 --- a/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.html @@ -64,6 +64,9 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}} + {{'LANGUAGE-EDITOR.FIELDS.OVERRIDE' | translate}} + + diff --git a/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts b/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts index 8fd096efd..8806ff43c 100644 --- a/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts @@ -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 { - 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 { - this.formGroup.get('payload').patchValue(language.payload); - }); - + 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); + } } } diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 079a2ec1b..98651e7a0 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -1191,7 +1191,8 @@ "FIELDS": { "CODE": "Code", "PAYLOAD": "Payload", - "ORDINAL": "Ordinal" + "ORDINAL": "Ordinal", + "OVERRIDE": "Override from file" }, "ACTIONS": { "SAVE": "Save",