Skip to content
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 @@ -26,8 +26,11 @@ import {
and,
Categorization,
categorizationHasCategory,
Category,
defaultJsonFormsI18nState,
deriveLabelForUISchemaElement,
getAjv,
isVisible,
JsonFormsState,
Labelable,
mapStateToLayoutProps,
Expand All @@ -47,7 +50,7 @@ import { Subscription } from 'rxjs';
template: `
<mat-tab-group dynamicHeight="true" [fxHide]="hidden">
<mat-tab
*ngFor="let category of uischema.elements; let i = index"
*ngFor="let category of visibleCategories; let i = index"
[label]="categoryLabels[i]"
>
<div *ngFor="let element of category.elements">
Expand All @@ -61,6 +64,7 @@ export class CategorizationTabLayoutRenderer
extends JsonFormsBaseRenderer<Categorization>
implements OnInit, OnDestroy {
hidden: boolean;
visibleCategories: (Category | Categorization)[];
private subscription: Subscription;
categoryLabels: string[];

Expand All @@ -73,7 +77,9 @@ export class CategorizationTabLayoutRenderer
next: (state: JsonFormsState) => {
const props = mapStateToLayoutProps(state, this.getOwnProps());
this.hidden = !props.visible;
this.categoryLabels = this.uischema.elements.map(
this.visibleCategories = this.uischema.elements.filter((category: Category | Categorization) =>
isVisible(category, props.data, undefined, getAjv(state)));
this.categoryLabels = this.visibleCategories.map(
element => deriveLabelForUISchemaElement(element as Labelable<boolean>,
state.jsonforms.i18n?.translate ?? defaultJsonFormsI18nState.translate));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ describe('Categorization tab layout', () => {
}
]
};
getJsonFormsService(component).setUiSchema(newUischema);
component.uischema = newUischema;
fixture.detectChanges();
getJsonFormsService(component).setUiSchema(newUischema);

fixture.whenRenderingDone().then(() => {
fixture.detectChanges();
Expand All @@ -284,8 +284,7 @@ describe('Categorization tab layout', () => {
expect(tabGroup2._tabs.length).toBe(3);
const lastTab: MatTab = tabGroup2._tabs.last;
expect(lastTab.isActive).toBeFalsy();
// there are update issues within the tests so that the new ui schema is not assigned to `this.uischema` within the renderer
// expect(lastTab.textLabel).toBe('quux');
expect(lastTab.textLabel).toBe('quux');
});
});
}));
Expand Down