Merge branch 'VM/DM-535' into 'master'

DM-535 - Components without references not displayed in Component View

Closes DM-535

See merge request redactmanager/red-ui!155
This commit is contained in:
Dan Percic 2023-10-23 22:57:15 +02:00
commit ea882511b5
4 changed files with 10 additions and 11 deletions

View File

@ -10,7 +10,7 @@
<div class="table-header">{{ 'component-log-dialog.table-header.annotation-references' | translate }}</div>
<ng-container *ngFor="let entry of componentLogEntries; let index = index">
<div class="bold">{{ entry.name.replaceAll('_', ' ').toLowerCase() }}</div>
<div class="bold">{{ entry.name }}</div>
<div [id]="getValueCellId(index)">
<iqser-editable-input
(save)="saveEdit($event, entry.name)"
@ -49,7 +49,7 @@
'component-log-dialog.annotations'
| translate
: {
type: entry.name,
type: parseType(reference.type),
page: reference.page,
ruleNumber: reference.entityRuleId
}

View File

@ -99,6 +99,10 @@ export class StructuredComponentManagementDialogComponent extends BaseDialogComp
return this.exportJSON();
}
parseType(type: string) {
return type.replaceAll('_', ' ').replace(/(^\w{1})|(\s+\w{1})/g, letter => letter.toUpperCase());
}
async toggleOpenScmDialogByDefault() {
await this.userPreferences.toggleOpenScmDialogByDefault();
await this.userPreferences.reload();

View File

@ -19,7 +19,7 @@ export class ComponentLogService extends GenericService<void> {
.pipe(
map(data => data.componentDetails),
catchError(() => of({} as ComponentDetails)),
map(componentDetails => this.#filterComponentDetails(componentDetails)),
map(componentDetails => this.#mapComponentDetails(componentDetails)),
mapEach(log => new ComponentLogEntry(log)),
);
}
@ -61,12 +61,7 @@ export class ComponentLogService extends GenericService<void> {
});
}
#filterComponentDetails(componentDetails: ComponentDetails): IComponentLogEntry[] {
return Object.keys(componentDetails)
.filter(function (key) {
const component = componentDetails[key];
return !!component.componentValues[0].entityReferences.length;
})
.reduce((res, key) => (res.push(componentDetails[key]), res), []);
#mapComponentDetails(componentDetails: ComponentDetails): IComponentLogEntry[] {
return Object.keys(componentDetails).reduce((res, key) => (res.push(componentDetails[key]), res), []);
}
}

View File

@ -12,7 +12,7 @@ export class ComponentLogEntry implements IComponentLogEntry {
readonly componentValues: ComponentValue[];
constructor(entry: IComponentLogEntry) {
this.name = entry.name;
this.name = entry.name.replaceAll('_', ' ');
this.componentValues = entry.componentValues;
}
}