Skip to content

Commit 0ef53d7

Browse files
jhonyeduardojhosefmarks
authored andcommitted
fix(table): corrige colspan quando detail estiver aberto
Ao abrir o detail da tabela, o colspan da linha estava sendo contado de forma incorreta, já que quando há ações a coluna é reutilizada pelo column manager. Fixes DTHFUI-2499
1 parent a851fe2 commit 0ef53d7

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

projects/ui/src/lib/components/po-table/po-table.component.spec.ts

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -650,23 +650,6 @@ describe('PoTableComponent:', () => {
650650
expect(component['setTableOpacity']).toHaveBeenCalled();
651651
}));
652652

653-
it('should count columns for master detail', () => {
654-
const columnManager = 1;
655-
component.columns = [...columns];
656-
657-
const countColumns = columns.length + 1 + columnManager;
658-
659-
expect(component.columnCountForMasterDetail()).toBe(countColumns);
660-
661-
component.actions = [...actions];
662-
fixture.detectChanges();
663-
expect(component.columnCountForMasterDetail()).toBe(countColumns + 1);
664-
665-
component.checkbox = true;
666-
fixture.detectChanges();
667-
expect(component.columnCountForMasterDetail()).toBe(countColumns + 2);
668-
});
669-
670653
it('should calculate when height is a number in function calculateHeightTableContainer', () => {
671654
const fakeThis = {
672655
getHeightTableFooter: () => 0,
@@ -1561,6 +1544,41 @@ describe('PoTableComponent:', () => {
15611544
expect(spyDetectChanges).toHaveBeenCalled();
15621545
});
15631546

1547+
it('columnCountForMasterDetail: should return 7 columnCount if has actions and 5 columns', () => {
1548+
component.actions = [...singleAction];
1549+
component.columns = [...columns];
1550+
1551+
const columnCountAction = 1;
1552+
1553+
const countColumns = columns.length + 1 + columnCountAction;
1554+
1555+
expect(component.columnCountForMasterDetail()).toBe(countColumns);
1556+
});
1557+
1558+
it('columnCountForMasterDetail: should return 7 columnCount if actions is empty and has 5 columns', () => {
1559+
component.actions = [];
1560+
component.columns = [...columns];
1561+
1562+
const columnCountColumnManager = 1;
1563+
1564+
const countColumns = columns.length + 1 + columnCountColumnManager;
1565+
1566+
expect(component.columnCountForMasterDetail()).toBe(countColumns);
1567+
});
1568+
1569+
it('columnCountForMasterDetail: should return 8 columnCount if actions is empty, has 5 columns and has checkbox', () => {
1570+
component.actions = [];
1571+
component.columns = [...columns];
1572+
component.checkbox = true;
1573+
1574+
const columnCountColumnManager = 1;
1575+
const columnCountCheckbox = 1;
1576+
1577+
const countColumns = columns.length + 1 + columnCountColumnManager + columnCountCheckbox;
1578+
1579+
expect(component.columnCountForMasterDetail()).toBe(countColumns);
1580+
});
1581+
15641582
});
15651583

15661584
describe('Templates:', () => {

projects/ui/src/lib/components/po-table/po-table.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ export class PoTableComponent extends PoTableBaseComponent implements AfterViewI
215215
}
216216

217217
columnCountForMasterDetail() {
218-
const columnManager = 1;
218+
// caso tiver ações será utilizado a sua coluna para exibir o columnManager
219+
const columnManager = this.actions.length ? 0 : 1;
220+
219221
return (this.mainColumns.length + 1) + (this.actions.length > 0 ? 1 : 0) + (this.checkbox ? 1 : 0) + columnManager;
220222
}
221223

0 commit comments

Comments
 (0)