From 3401dba3bee55103d656cf44fdefcef473a3f933 Mon Sep 17 00:00:00 2001 From: Wanderley Santos Teixeira Date: Mon, 18 Jul 2022 23:47:54 -0300 Subject: [PATCH] feat(table): coloca o columns-manager do mesmo lado do p-actions Colocando o columns-manager do mesmo lado do p-actions, melhorando a usabilidade do componente, principalmente do mobile. Fixes #1194 --- .../po-table-column-manager.component.spec.ts | 6 +- .../po-table-column-manager.component.ts | 4 +- .../po-table/po-table.component.html | 98 ++++++++++++++++--- .../po-table/po-table.component.spec.ts | 31 ++++-- .../components/po-table/po-table.component.ts | 27 +++-- 5 files changed, 129 insertions(+), 37 deletions(-) diff --git a/projects/ui/src/lib/components/po-table/po-table-column-manager/po-table-column-manager.component.spec.ts b/projects/ui/src/lib/components/po-table/po-table-column-manager/po-table-column-manager.component.spec.ts index d7e687834..1bab271b6 100644 --- a/projects/ui/src/lib/components/po-table/po-table-column-manager/po-table-column-manager.component.spec.ts +++ b/projects/ui/src/lib/components/po-table/po-table-column-manager/po-table-column-manager.component.spec.ts @@ -1024,7 +1024,7 @@ describe('PoTableColumnManagerComponent:', () => { describe(`onChangeColumns`, () => { it(`should set 'defaultColumns' with 'columns.currentValue' if 'defaultColumns' and ' currentValue' are different`, () => { component['defaultColumns'] = ['column 1']; - component['lastVisibleColumnsSelected'] = undefined; + component['isFirstUpdate'] = true; const columns = { firstChange: false, @@ -1038,9 +1038,9 @@ describe('PoTableColumnManagerComponent:', () => { expect(component['defaultColumns']).toEqual(columns.currentValue); }); - it(`should set 'defaultColumns' with 'columns.currentValue' if 'lastVisibleColumnsSelected' is true and 'currentValue' not is empty`, () => { + it(`should set 'defaultColumns' with 'columns.currentValue' if 'isFirstUpdate' is true and 'currentValue' not is empty`, () => { component['defaultColumns'] = []; - component['lastVisibleColumnsSelected'] = undefined; + component['isFirstUpdate'] = true; const columns = { firstChange: true, currentValue: ['column 1'] diff --git a/projects/ui/src/lib/components/po-table/po-table-column-manager/po-table-column-manager.component.ts b/projects/ui/src/lib/components/po-table/po-table-column-manager/po-table-column-manager.component.ts index b4c5fee4e..c53cde531 100644 --- a/projects/ui/src/lib/components/po-table/po-table-column-manager/po-table-column-manager.component.ts +++ b/projects/ui/src/lib/components/po-table/po-table-column-manager/po-table-column-manager.component.ts @@ -84,6 +84,7 @@ export class PoTableColumnManagerComponent implements OnChanges, OnDestroy { private restoreDefaultEvent: boolean; private lastEmittedValue: Array; private minColumns: number = 1; + private isFirstUpdate = true; @Input('p-max-columns') set maxColumns(value: number) { this._maxColumns = convertToInt(value, PoTableColumnManagerMaxColumnsDefault); @@ -356,7 +357,8 @@ export class PoTableColumnManagerComponent implements OnChanges, OnDestroy { this.columnUpdate = columns.currentValue; // atualizara o defaultColumns, quando for a primeira vez ou quando o defaultColumns for diferente do currentValue - if (!this.lastVisibleColumnsSelected && this.stringify(this.defaultColumns) !== this.stringify(currentValue)) { + if (this.isFirstUpdate && this.stringify(this.defaultColumns) !== this.stringify(currentValue)) { + this.isFirstUpdate = false; this.defaultColumns = [...currentValue]; } diff --git a/projects/ui/src/lib/components/po-table/po-table.component.html b/projects/ui/src/lib/components/po-table/po-table.component.html index 35fd1a997..2eeed4222 100644 --- a/projects/ui/src/lib/components/po-table/po-table.component.html +++ b/projects/ui/src/lib/components/po-table/po-table.component.html @@ -77,6 +77,30 @@ > + +
+ +
+ +
+
+ + @@ -424,19 +472,19 @@ >