Commit 7b941ce4 authored by Nicolas.Rod's avatar Nicolas.Rod
Browse files

refacto(ResearchDomainLabel): rename into ResearchDomainTranslation

parent 1aa20cb8
......@@ -15,7 +15,7 @@ import {
} from "@models";
import {SharedAbstractFormPresentational} from "@shared/components/presentationals/shared-abstract-form/shared-abstract-form.presentational";
import {BaseFormDefinition} from "@shared/models/base-form-definition.model";
import {ResearchDomainLabel} from "@shared/models/business/research-domain-label.model";
import {ResearchDomainTranslation} from "@shared/models/business/research-domain-translation.model";
import {
isNullOrUndefined,
PropertyName,
......@@ -38,11 +38,11 @@ export class AdminResearchDomainFormPresentational extends SharedAbstractFormPre
return;
}
this.languages.forEach(language => {
if (isNullOrUndefined(this.model) || isNullOrUndefined(this.model.labels)) {
if (isNullOrUndefined(this.model) || isNullOrUndefined(this.model.translations)) {
this.addControl(language.resId);
return;
}
const existingValue = (this.model.labels as ResearchDomainLabel[]).find(label => label.language.resId === language.resId);
const existingValue = (this.model.translations as ResearchDomainTranslation[]).find(label => label.language.resId === language.resId);
if (isNullOrUndefined(existingValue)) {
this.addControl(language.resId);
return;
......@@ -84,9 +84,9 @@ export class AdminResearchDomainFormPresentational extends SharedAbstractFormPre
}
protected treatmentBeforeSubmit(researchDomains: ResearchDomain): ResearchDomain {
const newLabels: ResearchDomainLabel[] = [];
const newTranslations: ResearchDomainTranslation[] = [];
this.languages.forEach(language => {
newLabels.push({
newTranslations.push({
description: researchDomains[language.resId],
language: language,
});
......@@ -95,7 +95,7 @@ export class AdminResearchDomainFormPresentational extends SharedAbstractFormPre
code: researchDomains.code,
name: researchDomains.name,
source: researchDomains.source,
labels: newLabels,
translations: newTranslations,
};
}
}
......
......@@ -253,7 +253,7 @@ export interface PreservationJobScheduling extends PreservationJobSchedulingPart
}
export interface ResearchDomain extends ResearchDomainPartial, BaseResource {
labels?: any[];
translations?: any[];
}
export interface Role extends RolePartial, BaseResource {
......
......@@ -6,7 +6,7 @@ import {
import {FormBuilder} from "@angular/forms";
import {ResearchDomain} from "@models";
import {SharedAbstractPresentational} from "@shared/components/presentationals/shared-abstract/shared-abstract.presentational";
import {ResearchDomainLabel} from "@shared/models/business/research-domain-label.model";
import {ResearchDomainTranslation} from "@shared/models/business/research-domain-translation.model";
import {isNullOrUndefined} from "solidify-frontend";
@Component({
......@@ -41,13 +41,13 @@ export class SharedAdminResearchDomainLabelPresentational extends SharedAbstract
return this._language;
}
value: ResearchDomainLabel | undefined;
value: ResearchDomainTranslation | undefined;
private computeLabel(): void {
if (isNullOrUndefined(this.language) || isNullOrUndefined(this.researchDomain)) {
return;
}
this.value = this.researchDomain.labels.find(label => label.language.resId === this.language);
this.value = this.researchDomain.translations.find(translation => translation.language.resId === this.language);
return;
}
......
import {Language} from "@models";
export interface ResearchDomainLabel {
export interface ResearchDomainTranslation {
description: string;
language: Language;
}
......@@ -21,8 +21,8 @@ export class MockTranslateService {
constructor() {
}
get(labels: string[]): Observable<String[]> {
return of(labels);
get(translations: string[]): Observable<String[]> {
return of(translations);
}
getTranslation(labels: string[]): Observable<any> {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment