Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs #12685: hide _sps field with one value #1904

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ export class ArchiveUnitEditObjectService {
displayObject.children.forEach((child) => this.hideLabellessDisplayObjects(child));
}

public hideSpsFieldWithOneValue(displayObject: DisplayObject): void {
const hasOneValue = displayObject.displayRule.ui.Path === '#originating_agencies' && displayObject.value.length === 1;

if (hasOneValue) {
displayObject.displayRule = { ...displayObject.displayRule, ui: { ...displayObject.displayRule.ui, display: false } };
}

displayObject.children.forEach((child) => this.hideSpsFieldWithOneValue(child));
}

public displayExternals(displayObject: DisplayObject, schemaByApiPath: SchemaElementByApiPath) {
if (displayObject.displayRule.Path) {
const dataPath = displayObject.displayRule.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class ArchiveUnitEditorService {
this.archiveUnitEditObject.collapseAll(editObject);
this.archiveUnitEditObject.expand('', editObject);
this.archiveUnitEditObject.expand('Generalities', editObject);
this.archiveUnitEditObject.hideSpsFieldWithOneValue(editObject);

return editObject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class ArchiveUnitViewerService implements DisplayObjectService {
this.archiveUnitEditObjectService.hideInconsistentDisplayObjects(displayObject);
// Attention display Other MetaData doit être après hideInconsistentDisplayObjects
this.archiveUnitEditObjectService.displayOtherMetadata(displayObject);
this.archiveUnitEditObjectService.hideSpsFieldWithOneValue(displayObject);

return displayObject;
}
Expand Down