Skip to content

Commit f69fb34

Browse files
jhonyeduardojhosefmarks
authored andcommitted
feat(dynamic-table): esconde o botão new ao não informar actions.new
Não exibe o botão "Novo" caso não informar valor na propriedade actions.new. Fixes DTHFUI-4119
1 parent 8a7a4cf commit f69fb34

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

projects/templates/src/lib/components/po-page-dynamic-table/po-page-dynamic-table.component.spec.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,15 @@ describe('PoPageDynamicTableComponent:', () => {
16211621
expect(component.pageActions).toEqual([]);
16221622
});
16231623

1624+
it('setPageActions: shouldn`t set `new` page action if haven`t `actions.new`', () => {
1625+
component['_pageActions'] = [];
1626+
1627+
const actions = { new: '' };
1628+
component['setPageActions'](actions);
1629+
1630+
expect(component.pageActions).toEqual([]);
1631+
});
1632+
16241633
it('setPageActions: should set page actions if have `actions`', () => {
16251634
component['_pageActions'] = [];
16261635

@@ -1635,8 +1644,7 @@ describe('PoPageDynamicTableComponent:', () => {
16351644
const pageAction = [
16361645
{
16371646
label: component.literals.pageAction,
1638-
action: jasmine.any(Function),
1639-
disabled: !component.actions.new
1647+
action: jasmine.any(Function)
16401648
}
16411649
];
16421650

@@ -1655,7 +1663,6 @@ describe('PoPageDynamicTableComponent:', () => {
16551663
{
16561664
label: component.literals.pageAction,
16571665
action: jasmine.any(Function),
1658-
disabled: !component.actions.new
16591666
}
16601667
];
16611668

@@ -1677,7 +1684,6 @@ describe('PoPageDynamicTableComponent:', () => {
16771684
{
16781685
label: component.literals.pageAction,
16791686
action: jasmine.any(Function),
1680-
disabled: false
16811687
},
16821688
{
16831689
label: component.literals.pageActionRemoveAll,

projects/templates/src/lib/components/po-page-dynamic-table/po-page-dynamic-table.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,9 @@ export class PoPageDynamicTableComponent extends PoPageDynamicListBaseComponent
759759
}
760760

761761
private setPageActions(actions: PoPageDynamicTableActions) {
762-
if (actions) {
762+
if (actions?.new) {
763763
this._pageActions = [
764-
{ label: this.literals.pageAction, action: this.openNew.bind(this, actions.new), disabled: !this._actions.new }
764+
{ label: this.literals.pageAction, action: this.openNew.bind(this, actions.new) }
765765
];
766766
}
767767
}

0 commit comments

Comments
 (0)