Skip to content

Commit

Permalink
Merge pull request #1929 from ProgrammeVitam/12792-dashes_on_compleme…
Browse files Browse the repository at this point in the history
…ntary_fields

CP 7.1 bugs #12792 : dashes on complementary fields
  • Loading branch information
hazco75 authored Jul 4, 2024
2 parents 6bed3e6 + 3bfd60e commit e1570d5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion ui/ui-frontend-common/src/app/modules/pipes/empty.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import { Pipe, PipeTransform } from '@angular/core';
})
export class EmptyPipe implements PipeTransform {
transform(value: any): any {
return value ? value : '— —';
return value ?? '— —';
}
}

0 comments on commit e1570d5

Please sign in to comment.