diff --git a/dmp-frontend/src/app/core/pipes/field-value.pipe.ts b/dmp-frontend/src/app/core/pipes/field-value.pipe.ts index a4f7873c2..e90453e0c 100644 --- a/dmp-frontend/src/app/core/pipes/field-value.pipe.ts +++ b/dmp-frontend/src/app/core/pipes/field-value.pipe.ts @@ -13,7 +13,9 @@ export class FieldValuePipe implements PipeTransform { transform(controlValue: any): string | null { let value = controlValue.value; let renderStyle = controlValue.viewStyle?.renderStyle; - if (renderStyle && controlValue) { + if (renderStyle && value) { + console.log(renderStyle); + console.log(value); switch (renderStyle) { case DatasetProfileFieldViewStyle.Currency: if (value) { @@ -47,10 +49,39 @@ export class FieldValuePipe implements PipeTransform { break; case DatasetProfileFieldViewStyle.TextArea: return value; + case DatasetProfileFieldViewStyle.Registries: + case DatasetProfileFieldViewStyle.Services: + case DatasetProfileFieldViewStyle.Researchers: + case DatasetProfileFieldViewStyle.Organizations: + case DatasetProfileFieldViewStyle.ExternalDatasets: + case DatasetProfileFieldViewStyle.DataRepositories: + case DatasetProfileFieldViewStyle.PubRepositories: + case DatasetProfileFieldViewStyle.JournalRepositories: + case DatasetProfileFieldViewStyle.Taxonomies: + case DatasetProfileFieldViewStyle.Licenses: + case DatasetProfileFieldViewStyle.Publications: + case DatasetProfileFieldViewStyle.Tags: + return this.parseJson(value); + case DatasetProfileFieldViewStyle.InternalDmpEntities: + return this.parseJson(value, 'label'); + case DatasetProfileFieldViewStyle.DatasetIdentifier: + case DatasetProfileFieldViewStyle.Validation: + if(value && value.identifier) { + return value.identifier; + } + break; default: return null; } } return null; } + + public parseJson(value: any, field: string = 'name') { + if(Array.isArray(value)) { + return value.map(element => JSON.parse(element)[field]).join(','); + } else { + return JSON.parse(value)[field]; + } + } }