diff --git a/ui/ui-frontend/projects/vitamui-library/src/app/modules/archive-unit/archive-unit-edit-object.service.ts b/ui/ui-frontend/projects/vitamui-library/src/app/modules/archive-unit/archive-unit-edit-object.service.ts index 8415d10ddf9..7762133ac06 100644 --- a/ui/ui-frontend/projects/vitamui-library/src/app/modules/archive-unit/archive-unit-edit-object.service.ts +++ b/ui/ui-frontend/projects/vitamui-library/src/app/modules/archive-unit/archive-unit-edit-object.service.ts @@ -147,11 +147,22 @@ export class ArchiveUnitEditObjectService { } public displayOtherMetadata(displayObject: DisplayObject, path = 'OtherMetadata') { - if (displayObject.path === path) { - displayObject.displayRule = { ...displayObject.displayRule, ui: { ...displayObject.displayRule.ui, display: true } }; + if (!displayObject.path.includes(path)) return; + + if (!displayObject.displayRule) { + return this.logger.warn(this, `Element '${displayObject.path}' has no displayRule`); } - displayObject.children.forEach((child) => this.displayOtherMetadata(child)); + const isConsistent = this.typeService.isConsistent(displayObject.value); + + displayObject.displayRule = { + ...displayObject.displayRule, + ui: { ...displayObject.displayRule.ui, display: isConsistent }, + }; + + if (isConsistent) { + displayObject.children.forEach((child) => this.displayOtherMetadata(child)); + } } public hideInconsistentDisplayObjects(displayObject: DisplayObject): void { diff --git a/ui/ui-frontend/projects/vitamui-library/src/app/modules/object-viewer/services/type.service.ts b/ui/ui-frontend/projects/vitamui-library/src/app/modules/object-viewer/services/type.service.ts index 97ae0b1ab36..6918c18ecd7 100644 --- a/ui/ui-frontend/projects/vitamui-library/src/app/modules/object-viewer/services/type.service.ts +++ b/ui/ui-frontend/projects/vitamui-library/src/app/modules/object-viewer/services/type.service.ts @@ -82,15 +82,9 @@ export class TypeService { } public isConsistent(value: any): boolean { - if (this.isPrimitive(value)) { - return Boolean(value) && value !== ''; - } - if (this.isList(value)) { - return value.some((item: any) => this.isConsistent(item)); - } - if (!value) { - return false; - } + if (value === null || value === undefined) return false; + if (this.isPrimitive(value)) return value !== ''; + if (this.isList(value)) return value.some((item: any) => this.isConsistent(item)); return Object.values(value).some((v: any) => this.isConsistent(v)); } diff --git a/ui/ui-frontend/projects/vitamui-library/src/app/modules/pipes/empty.pipe.ts b/ui/ui-frontend/projects/vitamui-library/src/app/modules/pipes/empty.pipe.ts index 65bbfe0de65..2768eb534a8 100644 --- a/ui/ui-frontend/projects/vitamui-library/src/app/modules/pipes/empty.pipe.ts +++ b/ui/ui-frontend/projects/vitamui-library/src/app/modules/pipes/empty.pipe.ts @@ -5,6 +5,6 @@ import { Pipe, PipeTransform } from '@angular/core'; }) export class EmptyPipe implements PipeTransform { transform(value: any): any { - return value ? value : '— —'; + return value ?? '— —'; } }