Skip to content

Commit 383e37b

Browse files
CSimoesJrrafaellmarques
authored andcommitted
feat(table): implementa funcionalidade de ações em lote
Implementa a funcionalidade de ações em lote na tabela fixes DTHFUI-7317
1 parent b9f1c7c commit 383e37b

File tree

17 files changed

+610
-41
lines changed

17 files changed

+610
-41
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
[p-columns]="columns"
2323
[p-items]="items"
2424
[p-height]="height"
25+
[p-hide-batch-actions]="true"
2526
[p-infinite-scroll]="infiniteScroll"
2627
[p-show-more-disabled]="!hasNext"
2728
(p-show-more)="showMore()"

projects/ui/src/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
[p-loading]="isLoading"
6161
[p-show-more-disabled]="!hasNext"
6262
[p-infinite-scroll]="infiniteScroll"
63+
[p-hide-batch-actions]="true"
6364
(p-selected)="onSelect($event)"
6465
(p-unselected)="onUnselect($event)"
6566
(p-all-selected)="onAllSelected($event)"

projects/ui/src/lib/components/po-field/po-lookup/samples/sample-po-lookup-multiple/sample-po-lookup-multiple.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
[p-items]="heroes"
1717
[p-height]="220"
1818
[p-striped]="true"
19+
[p-hide-batch-actions]="true"
1920
[p-hide-columns-manager]="true"
2021
[p-loading]="loading"
2122
></po-table>

projects/ui/src/lib/components/po-table/interfaces/po-table-literals.interface.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ export interface PoTableLiterals {
1818
/** Texto exibido quando não existem itens para serem exibidos na tabela. */
1919
noData?: string;
2020

21+
/** Texto exibido quando nenhum item for selecionado no checkbox. */
22+
noItem?: string;
23+
24+
/** Texto exibido quando apenas 1 item for selecionado no checkbox. */
25+
oneItem?: string;
26+
27+
/** Texto exibido quando apenas 1 item for selecionado no checkbox. */
28+
multipleItems?: string;
29+
2130
/** Texto exibido quando não existem colunas visíveis para a tabela. */
2231
noVisibleColumn?: string;
2332

@@ -29,4 +38,19 @@ export interface PoTableLiterals {
2938

3039
/** Texto do botão **Ver legenda completa** que aparece quando o rodapé de legendas é maior que a tabela. */
3140
seeCompleteSubtitle?: string;
41+
42+
/** Texto no corpo do Modal de exclusão */
43+
bodyDelete?: string;
44+
45+
/** Texto no Modal para cancelar a exclusão */
46+
cancel?: string;
47+
48+
/** Texto no Modal para confirmar a exclusão */
49+
delete?: string;
50+
51+
/** Texto de notificação de remoção com sucesso */
52+
deleteSuccessful?: string;
53+
54+
/** Texto de notificação de erro na requisição Delete */
55+
deleteApiError?: string;
3256
}

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

Lines changed: 88 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,48 @@ describe('PoTableBaseComponent:', () => {
600600
});
601601
});
602602

603+
describe('setSelectedList: ', () => {
604+
const rows = [
605+
{
606+
id: 1,
607+
name: 'John',
608+
$selected: true
609+
},
610+
{
611+
id: 2,
612+
name: 'John'
613+
},
614+
{
615+
id: 3,
616+
name: 'John'
617+
}
618+
];
619+
620+
it('should call itemsSelected with 1 item in Array', () => {
621+
component.items = rows;
622+
623+
component.setSelectedList();
624+
625+
expect(component.itemsSelected).toEqual([rows[0]]);
626+
});
627+
628+
it('should call items with 2 items and itemsSelected empty', () => {
629+
component.items = [rows[1], rows[2]];
630+
631+
component.setSelectedList();
632+
633+
expect(component.itemsSelected).toEqual([]);
634+
});
635+
636+
it('should call items and itemsSelected empty', () => {
637+
component.items = [];
638+
639+
component.setSelectedList();
640+
641+
expect(component.itemsSelected).toEqual([]);
642+
});
643+
});
644+
603645
it('unselectOtherRows: should unselect rows that are different from the current row and call selectAllDetails', () => {
604646
const rows: any = [
605647
{
@@ -1139,31 +1181,48 @@ describe('PoTableBaseComponent:', () => {
11391181
});
11401182

11411183
describe('setService', () => {
1142-
it('should be called with string url and set service url', () => {
1184+
it('should be called with string url and set service url and method is GET', () => {
11431185
spyOn(component['poTableService'], 'setUrl');
11441186
const url = 'https://po-ui.io';
11451187

1146-
component['setService'](url);
1147-
expect(component['poTableService'].setUrl).toHaveBeenCalledWith(url);
1188+
component['setService'](url, 'GET');
1189+
expect(component['poTableService'].setUrl).toHaveBeenCalledWith(url, 'GET');
11481190
});
11491191

1150-
it("should be called with undefined and don't set url", () => {
1192+
it("should be called with undefined and don't set url and method is GET", () => {
11511193
spyOn(component['poTableService'], 'setUrl');
11521194
const url = undefined;
11531195

1154-
component['setService'](url);
1196+
component['setService'](url, 'GET');
11551197

11561198
expect(component['poTableService'].setUrl).not.toHaveBeenCalled();
11571199
});
11581200

1159-
it("should be called with empty string and don't set url", () => {
1201+
it("should be called with empty string and don't set url and method is GET", () => {
11601202
spyOn(component['poTableService'], 'setUrl');
11611203
const url = '';
11621204

1163-
component['setService'](url);
1205+
component['setService'](url, 'GET');
11641206
expect(component.hasService).toBeFalsy();
11651207
expect(component['poTableService'].setUrl).not.toHaveBeenCalled();
11661208
});
1209+
1210+
it('should be called with string url and set service url and method is DELETE', () => {
1211+
spyOn(component['poTableService'], 'setUrl');
1212+
const url = 'https://po-ui.io';
1213+
1214+
component['setService'](url, 'DELETE');
1215+
expect(component['poTableService'].setUrl).toHaveBeenCalledWith(url, 'DELETE');
1216+
});
1217+
1218+
it("should be called with undefined and don't set url and method is DELETE", () => {
1219+
spyOn(component['poTableService'], 'setUrl');
1220+
const url = undefined;
1221+
1222+
component['setService'](url, 'DELETE');
1223+
1224+
expect(component['poTableService'].setUrl).not.toHaveBeenCalled();
1225+
});
11671226
});
11681227

11691228
describe('getFilteredParams', () => {
@@ -1424,6 +1483,28 @@ describe('PoTableBaseComponent:', () => {
14241483
expectPropertiesValues(component, 'container', invalidValues, 'border');
14251484
});
14261485

1486+
it('p-param-delete-api: should update property with valid values', () => {
1487+
const validValue = 'value';
1488+
1489+
expectPropertiesValues(component, 'paramDeleteApi', validValue, validValue);
1490+
});
1491+
1492+
it('p-param-delete-api: should update property with `id` if values are invalid', () => {
1493+
const invalidValues = [undefined, null, true, false, 0, 1, [], {}];
1494+
1495+
expectPropertiesValues(component, 'paramDeleteApi', invalidValues, 'id');
1496+
});
1497+
1498+
it('p-param-delete-api: should update property with `id` if values are invalid', () => {
1499+
const invalidValues = [undefined, null, true, false, 0, 1, [], {}];
1500+
1501+
expectPropertiesValues(component, 'paramDeleteApi', invalidValues, 'id');
1502+
});
1503+
1504+
it('p-service-delete: should update property with valid values', () => {
1505+
expectPropertiesValues(component, 'serviceDeleteApi', 'https://po-ui.io', 'https://po-ui.io');
1506+
});
1507+
14271508
it('sortType: should return `ascending` if `sortedColumn.ascending` is `true`.', () => {
14281509
component.sortedColumn.ascending = true;
14291510

0 commit comments

Comments
 (0)