reference field ui fix

This commit is contained in:
Sofia Papacharalampous 2024-06-04 18:08:12 +03:00
parent e665cbdfc6
commit d01180ab87
4 changed files with 7 additions and 3 deletions

View File

@ -110,6 +110,7 @@ export interface DescriptionTemplateBaseFieldDataPersist {
export interface DescriptionTemplateReferenceTypeFieldPersist extends DescriptionTemplateLabelAndMultiplicityDataPersist { export interface DescriptionTemplateReferenceTypeFieldPersist extends DescriptionTemplateLabelAndMultiplicityDataPersist {
referenceTypeId: Guid; referenceTypeId: Guid;
name: string;
} }
export interface DescriptionTemplateExternalDatasetDataPersist extends DescriptionTemplateLabelAndMultiplicityDataPersist { export interface DescriptionTemplateExternalDatasetDataPersist extends DescriptionTemplateLabelAndMultiplicityDataPersist {

View File

@ -238,7 +238,8 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
if (editorField.data.fieldType === DescriptionTemplateFieldType.REFERENCE_TYPES) { if (editorField.data.fieldType === DescriptionTemplateFieldType.REFERENCE_TYPES) {
convertedField.data = editorField.data; convertedField.data = editorField.data;
(convertedField.data as DescriptionTemplateReferenceTypeData).referenceType = { (convertedField.data as DescriptionTemplateReferenceTypeData).referenceType = {
id: (editorField.data as DescriptionTemplateReferenceTypeFieldPersist).referenceTypeId id: (editorField.data as DescriptionTemplateReferenceTypeFieldPersist).referenceTypeId,
name: (editorField.data as DescriptionTemplateReferenceTypeFieldPersist).name,
}; };
} else { } else {
convertedField.data = editorField.data; convertedField.data = editorField.data;

View File

@ -1246,6 +1246,7 @@ export class DescriptionTemplateExternalDatasetDataEditorModel extends Descripti
// //
export class DescriptionTemplateReferenceTypeDataEditorModel extends DescriptionTemplateLabelAndMultiplicityDataEditorModel implements DescriptionTemplateReferenceTypeFieldPersist { export class DescriptionTemplateReferenceTypeDataEditorModel extends DescriptionTemplateLabelAndMultiplicityDataEditorModel implements DescriptionTemplateReferenceTypeFieldPersist {
referenceTypeId: Guid; referenceTypeId: Guid;
name: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder(); protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor( constructor(
@ -1255,6 +1256,7 @@ export class DescriptionTemplateReferenceTypeDataEditorModel extends Description
fromModel(item: DescriptionTemplateReferenceTypeData): DescriptionTemplateReferenceTypeDataEditorModel { fromModel(item: DescriptionTemplateReferenceTypeData): DescriptionTemplateReferenceTypeDataEditorModel {
if (item) { if (item) {
super.fromModel(item); super.fromModel(item);
this.name = item.referenceType?.name;
this.referenceTypeId = item.referenceType?.id; this.referenceTypeId = item.referenceType?.id;
} }
return this; return this;
@ -1275,6 +1277,7 @@ export class DescriptionTemplateReferenceTypeDataEditorModel extends Description
const formGroup = super.buildForm({ context, disabled, rootPath }); const formGroup = super.buildForm({ context, disabled, rootPath });
formGroup.setControl('referenceTypeId', new FormControl({ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators)); formGroup.setControl('referenceTypeId', new FormControl({ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators));
formGroup.setControl('name', new FormControl({ value: this.name, disabled: disabled }));
return formGroup; return formGroup;
} }

View File

@ -129,13 +129,12 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit, On
} }
addReference() { addReference() {
const dialogRef = this.dialog.open(ReferenceDialogEditorComponent, { const dialogRef = this.dialog.open(ReferenceDialogEditorComponent, {
minWidth: '49%', minWidth: '49%',
restoreFocus: false, restoreFocus: false,
data: { data: {
referenceTypeId: this.referenceType.id, referenceTypeId: this.referenceType.id,
label: this.label ?? this.referenceType.name, label: this.label && this.label !== '' ? this.label : this.referenceType.name,
}, },
}); });
dialogRef.afterClosed() dialogRef.afterClosed()