Skip to content

Commit

Permalink
fix(stark-ui): table actions column is not displayed anymore if no ro…
Browse files Browse the repository at this point in the history
…w actions are defined

ISSUES CLOSED: #1462
  • Loading branch information
SuperITMan committed Dec 18, 2019
1 parent 080f13e commit b1ec04e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<ng-content select=".stark-table-columns"></ng-content>

<stark-table-column
*ngIf="tableRowActions && tableRowActions.actions"
*ngIf="tableRowActions && tableRowActions.actions && tableRowActions.actions.length"
[sortable]="false"
[name]="'STARK.TABLE.ACTIONS' | translate"
[stickyEnd]="tableRowActions.isFixed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,45 @@ describe("TableComponent", () => {
});
});

describe("column actions", () => {
const actionsColumnSelector = "table thead tr th.mat-column-STARK-TABLE-ACTIONS";

it("should display the 'actions' column when 'tableRowActions' contains some actions", () => {
hostComponent.tableRowActions = {
actions: [
{
id: "edit-item",
label: "STARK.ICONS.EDIT_ITEM",
icon: "pencil",
actionCall: (): void => undefined,
isEnabled: true
}
]
};
hostFixture.detectChanges();
component.ngAfterViewInit();

const actionsColumnElement = hostFixture.nativeElement.querySelector(actionsColumnSelector);
expect(actionsColumnElement).not.toBeNull();
});

it("should NOT display the 'actions' column when 'tableRowActions' input does NOT contain any action", () => {
hostComponent.tableRowActions = { actions: [] };
hostFixture.detectChanges();

const actionsColumnElement = hostFixture.nativeElement.querySelector(actionsColumnSelector);
expect(actionsColumnElement).toBeNull();
});

it("should NOT display the 'actions' column when 'tableRowActions' input is NOT defined", () => {
hostComponent.tableRowActions = undefined;
hostFixture.detectChanges();

const actionsColumnElement = hostFixture.nativeElement.querySelector(actionsColumnSelector);
expect(actionsColumnElement).toBeNull();
});
});

describe("column visibility", () => {
const columns: StarkTableColumnProperties[] = [{ name: "a" }, { name: "b", isVisible: false }, { name: "c", isVisible: true }];
const data: any = [{ a: 1, b: "b1", c: "c1" }, { a: 2, b: "b2", c: "c2" }, { a: 3, b: "b3", c: "c3" }];
Expand Down

0 comments on commit b1ec04e

Please sign in to comment.