Skip to content

Commit 02bf7f2

Browse files
committed
[DSC-1236] add language support to metadata group handling
1 parent 2cc3cca commit 02bf7f2

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/modal/dynamic-relation-group-modal.components.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ export class DsDynamicRelationGroupModalComponent extends DynamicFormControlComp
143143
if (this.item) {
144144
this.formModel.forEach((row) => {
145145
const modelRow = row as DynamicFormGroupModel;
146-
modelRow.group.forEach((model: DynamicInputModel) => {
146+
modelRow.group.forEach((model: DsDynamicInputModel) => {
147+
console.log(model);
147148
const value = (this.item[model.name] === PLACEHOLDER_PARENT_METADATA
148149
|| this.item[model.name].value === PLACEHOLDER_PARENT_METADATA)
149150
? null
@@ -152,6 +153,9 @@ export class DsDynamicRelationGroupModalComponent extends DynamicFormControlComp
152153
value.value : value;
153154
if (isNotEmpty(nextValue)) {
154155
model.value = nextValue;
156+
if (isNotEmpty(nextValue?.language)) {
157+
model.language = nextValue.language;
158+
}
155159
}
156160

157161
this.initSecurityLevelConfig(model, modelRow);
@@ -258,6 +262,7 @@ export class DsDynamicRelationGroupModalComponent extends DynamicFormControlComp
258262
const model = this.getMandatoryFieldModel();
259263
const currentValue: string = (model.value instanceof FormFieldMetadataValueObject
260264
|| model.value instanceof VocabularyEntry) ? model.value.value : model.value;
265+
const currentLang: string = (model.value instanceof FormFieldMetadataValueObject) ? model.value.language : model.language;
261266
let security = null;
262267
if (this.model.value instanceof VocabularyEntry) {
263268
security = this.model.value.securityLevel;
@@ -266,7 +271,7 @@ export class DsDynamicRelationGroupModalComponent extends DynamicFormControlComp
266271
security = this.model.metadataValue.securityLevel;
267272
}
268273
}
269-
const valueWithAuthority: any = new FormFieldMetadataValueObject(currentValue, null, security, authority);
274+
const valueWithAuthority: any = new FormFieldMetadataValueObject(currentValue, currentLang, security, authority);
270275
model.value = valueWithAuthority;
271276
this.modifyChip();
272277
setTimeout(() => {
@@ -346,14 +351,16 @@ export class DsDynamicRelationGroupModalComponent extends DynamicFormControlComp
346351

347352
item[control.name] =
348353
new FormFieldMetadataValueObject(
349-
controlValue, (control as any)?.language,
354+
controlValue,
355+
mainModel?.language,
350356
controlValue === PLACEHOLDER_PARENT_METADATA ? null : mainModel.securityLevel,
351357
controlAuthority,
352358
null, 0, null,
353359
(control?.value as any)?.otherInformation || null,
354360
);
355361
});
356362
});
363+
console.log(item);
357364
return item;
358365
}
359366

src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-inline-group/dynamic-relation-inline-group.components.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export class DsDynamicRelationInlineGroupComponent extends DynamicFormControlCom
216216
}
217217

218218
model.securityLevel = mainSecurityLevel;
219+
model.language = (mainRow as any).language ?? null;
219220

220221
modelGroup.group.forEach((item: any) => {
221222
if (item.name !== this.model.name) {
@@ -236,29 +237,30 @@ export class DsDynamicRelationInlineGroupComponent extends DynamicFormControlCom
236237

237238
private getRowValue(formGroup: DynamicFormGroupModel, securityLevel?: number) {
238239
let mainSecurityLevel;
240+
const mainRow = formGroup.group.find(itemModel => itemModel.name === this.model.name);
239241
if (isNotEmpty(securityLevel)) {
240242
mainSecurityLevel = securityLevel;
241243
} else {
242-
const mainRow = formGroup.group.find(itemModel => itemModel.name === this.model.name);
243244
mainSecurityLevel = (mainRow as any).securityLevel;
244245
}
246+
const mainLanguage = (mainRow as any).language ?? null;
245247
const groupValue = Object.create({});
246248
formGroup.group.forEach((model: any) => {
247249
if (model.name !== this.model.mandatoryField) {
248250
if (isEmpty(model.value)) {
249251
groupValue[model.name] = PLACEHOLDER_PARENT_METADATA;
250252
} else {
251253
if (typeof model.value === 'string') {
252-
groupValue[model.name] = new FormFieldMetadataValueObject(model.value, null, mainSecurityLevel);
254+
groupValue[model.name] = new FormFieldMetadataValueObject(model.value, mainLanguage, mainSecurityLevel);
253255
} else {
254-
groupValue[model.name] = Object.assign(new FormFieldMetadataValueObject(), model.value, { securityLevel: mainSecurityLevel || null });
256+
groupValue[model.name] = Object.assign(new FormFieldMetadataValueObject(), model.value, { language: mainLanguage, securityLevel: mainSecurityLevel || null });
255257
}
256258
}
257259
} else {
258260
if (typeof model.value === 'string') {
259-
groupValue[model.name] = new FormFieldMetadataValueObject(model.value, null, mainSecurityLevel);
261+
groupValue[model.name] = new FormFieldMetadataValueObject(model.value, mainLanguage, mainSecurityLevel);
260262
} else {
261-
groupValue[model.name] = Object.assign(new FormFieldMetadataValueObject(), model.value, { securityLevel: mainSecurityLevel || null });
263+
groupValue[model.name] = Object.assign(new FormFieldMetadataValueObject(), model.value, { language: mainLanguage, securityLevel: mainSecurityLevel || null });
262264
}
263265
}
264266
});

0 commit comments

Comments
 (0)