Skip to content

Commit

Permalink
Merge pull request #1893 from ProgrammeVitam/bug_12792_dashes_on_comp…
Browse files Browse the repository at this point in the history
…lementary_fields

bug #12792 : dashes on complementary fields
  • Loading branch information
hazco75 authored Jun 4, 2024
2 parents 7e726ef + a7a7dc4 commit 755813b
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 @@ -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 {
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
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 755813b

Please sign in to comment.