Skip to content

Commit 63771fc

Browse files
wsteixeirarafaellmarques
authored andcommitted
feat(table): utiliza po-tag para exibir o label
Altera o conteúdo do po-table-column-label para utilizar o componente po-tag Fixes #1421, DTHFUI-2583
1 parent 58a0638 commit 63771fc

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
<po-table-subtitle-circle [p-subtitle]="getSubtitleColumn(row, column)"></po-table-subtitle-circle>
293293
</span>
294294
<span *ngSwitchCase="'label'">
295-
<po-table-column-label [p-value]="getColumnLabel(row, column)"> </po-table-column-label>
295+
<po-tag [p-color]="getTagColor(row, column)" [p-value]="getTagValue(row, column)"> </po-tag>
296296
</span>
297297
<span *ngSwitchDefault>{{ getCellData(row, column) }}</span>
298298
</div>
@@ -574,7 +574,7 @@
574574
<po-table-subtitle-circle [p-subtitle]="getSubtitleColumn(row, column)"></po-table-subtitle-circle>
575575
</span>
576576
<span *ngSwitchCase="'label'">
577-
<po-table-column-label [p-value]="getColumnLabel(row, column)"> </po-table-column-label>
577+
<po-tag [p-color]="getTagColor(row, column)" [p-value]="getTagValue(row, column)"> </po-tag>
578578
</span>
579579
<span *ngSwitchDefault>{{ getCellData(row, column) }}</span>
580580
</div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ describe('PoTableComponent:', () => {
515515
component.columns.push(labels);
516516
fixture.detectChanges();
517517

518-
const labelColumn = tableElement.querySelector('.po-table-column-label');
518+
const labelColumn = tableElement.querySelector('.po-tag');
519519

520520
expect(labelColumn).toBeTruthy();
521521
});

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { PoPopupComponent } from '../po-popup/po-popup.component';
2727
import { PoTableAction } from './interfaces/po-table-action.interface';
2828
import { PoTableBaseComponent, QueryParamsType } from './po-table-base.component';
2929
import { PoTableColumn } from './interfaces/po-table-column.interface';
30-
import { PoTableColumnLabel } from './po-table-column-label/po-table-column-label.interface';
3130
import { PoTableRowTemplateDirective } from './po-table-row-template/po-table-row-template.directive';
3231
import { PoTableSubtitleColumn } from './po-table-subtitle-footer/po-table-subtitle-column.interface';
3332
import { PoTableCellTemplateDirective } from './po-table-cell-template/po-table-cell-template.directive';
@@ -119,6 +118,7 @@ export class PoTableComponent extends PoTableBaseComponent implements AfterViewI
119118
tooltipText: string;
120119
itemSize: number = 32;
121120
lastVisibleColumnsSelected: Array<PoTableColumn>;
121+
tagColor: string;
122122

123123
private _columnManagerTarget: ElementRef;
124124
private _columnManagerTargetFixed: ElementRef;
@@ -443,7 +443,15 @@ export class PoTableComponent extends PoTableBaseComponent implements AfterViewI
443443
return rowIcons;
444444
}
445445

446-
getColumnLabel(row: any, columnLabel: PoTableColumn): PoTableColumnLabel {
446+
getTagColor(row: any, columnLabel: PoTableColumn) {
447+
return columnLabel.labels.find(labelItem => this.getCellData(row, columnLabel) === labelItem.value)?.color;
448+
}
449+
450+
getTagValue(row: any, columnLabel: PoTableColumn) {
451+
return columnLabel.labels.find(labelItem => this.getCellData(row, columnLabel) === labelItem.value)?.label;
452+
}
453+
454+
getColumnLabel(row: any, columnLabel: PoTableColumn) {
447455
return columnLabel.labels.find(labelItem => this.getCellData(row, columnLabel) === labelItem.value);
448456
}
449457

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { PoLoadingModule } from '../po-loading/po-loading.module';
1111
import { PoModalModule } from '../po-modal/po-modal.module';
1212
import { PoPopoverModule } from '../po-popover/po-popover.module';
1313
import { PoPopupModule } from './../po-popup/po-popup.module';
14+
import { PoTagModule } from '../po-tag/po-tag.module';
1415
import { PoTimeModule } from '../../pipes/po-time/index';
1516
import { PoTooltipModule } from '../../directives/po-tooltip/index';
1617
import { PoIconModule } from './../po-icon/po-icon.module';
@@ -48,6 +49,7 @@ import { PoTableListManagerComponent } from './po-table-list-manager/po-table-li
4849
PoModalModule,
4950
PoPopoverModule,
5051
PoPopupModule,
52+
PoTagModule,
5153
PoTimeModule,
5254
PoTooltipModule,
5355
PoIconModule,

0 commit comments

Comments
 (0)