Skip to content

Commit

Permalink
[#58524] fixed empty state rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Kharonus committed Nov 8, 2024
1 parent 414e225 commit 0857271
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,22 @@ import { renderHierarchyItem } from 'core-app/shared/components/fields/display/f

export class HierarchyItemDisplayField extends ResourceDisplayField {
public render(element:HTMLElement, _displayText:string) {
const item = this.attribute as HalResource;
if (item === null || item.name === this.texts.placeholder) {
this.renderEmpty(element);
return;
}

element.innerHTML = '';
element.classList.add('hierarchy-items');

this.branch().subscribe((path) => {
this.branch(item).subscribe((path) => {
element.appendChild(path);
});
}

private branch():Observable<HTMLDivElement> {
const attribute = this.attribute as HalResource;
const itemLink = attribute.$link as HalLink;
private branch(item:HalResource):Observable<HTMLDivElement> {
const itemLink = item.$link as HalLink;

return from(itemLink.$fetch())
.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ import { renderHierarchyItem } from 'core-app/shared/components/fields/display/f

export class MultipleLinesHierarchyItemDisplayField extends ResourcesDisplayField {
public render(element:HTMLElement, _displayText:string) {
const items = this.attribute as HalResource[];
if (items.length === 0) {
this.renderEmpty(element);
return;
}

element.innerHTML = '';
element.classList.add('hierarchy-items');

this.branches().subscribe((elements) => {
this.branches(items).subscribe((elements) => {
elements.forEach((el) => {
element.appendChild(el);
});
Expand All @@ -52,10 +57,8 @@ export class MultipleLinesHierarchyItemDisplayField extends ResourcesDisplayFiel
return this.stringValue.join(', ');
}

private branches():Observable<HTMLDivElement[]> {
const attribute = this.attribute as HalResource[];

return combineLatest(attribute.map((value:HalResource) => {
private branches(items:HalResource[]):Observable<HTMLDivElement[]> {
return combineLatest(items.map((value:HalResource) => {
const itemLink = value.$link as HalLink;

return from(itemLink.$fetch())
Expand Down

0 comments on commit 0857271

Please sign in to comment.