Skip to content

Commit c2772ce

Browse files
jcorrea97rafaellmarques
authored andcommitted
feat(breadcrumb): implementa definições do AnimaliaDS
Implementa definições do AnimaliaDS no Breadcrumb fixes DTHFUI-7558
1 parent 2bc70bd commit c2772ce

17 files changed

+311
-375
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ describe('PoDisclaimerBaseComponent:', () => {
88

99
const items: Array<PoBreadcrumbItem> = [
1010
{ label: 'Teste nível 1', link: '/test/nivel/1' },
11-
{ label: 'Teste nível 2', link: '/test/nivel/2' },
12-
{ label: 'Teste nível 3', link: '/test/nivel/3' },
11+
{ label: 'Teste nível 2', link: '/test/nivel/2', action: () => {} },
12+
{ label: 'Teste nível 3', action: () => {} },
1313
{ label: 'Teste nível 4', link: '/test/nivel/4' }
1414
];
1515

@@ -30,4 +30,22 @@ describe('PoDisclaimerBaseComponent:', () => {
3030
expect(component.itemsView).toEqual(itemsEmpty);
3131
});
3232
});
33+
34+
describe('Methods:', () => {
35+
it('transformToArrayPopup: should remove first, penultimate and last item .', () => {
36+
component['transformToArrayPopup'](items);
37+
expect(component.itemsViewPopup.length).toEqual(1);
38+
});
39+
40+
it('transformArrayToActionPopUp: should edit property to `link` to `url` and remove action if exists `link`', () => {
41+
const newItem = component['transformArrayToActionPopUp'](items);
42+
const expectedOutputItems = [
43+
{ label: 'Teste nível 1', url: '/test/nivel/1' },
44+
{ label: 'Teste nível 2', url: '/test/nivel/2' },
45+
{ label: 'Teste nível 3', action: jasmine.any(Function) },
46+
{ label: 'Teste nível 4', url: '/test/nivel/4' }
47+
];
48+
expect(newItem).toEqual(expectedOutputItems);
49+
});
50+
});
3351
});

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export class PoBreadcrumbBaseComponent {
9292
@Input('p-params-service') paramsService?: object;
9393

9494
itemsView: Array<PoBreadcrumbItem> = [];
95+
itemsViewPopup: Array<any> = [];
9596

9697
protected clickoutListener: () => void;
9798
protected resizeListener: () => void;
@@ -111,9 +112,33 @@ export class PoBreadcrumbBaseComponent {
111112
@Input('p-items') set items(items: Array<PoBreadcrumbItem>) {
112113
this._items = items;
113114
this.itemsView = [].concat(items);
115+
if (this.itemsView.length >= 4) {
116+
this.transformToArrayPopup(items);
117+
}
114118
}
115119

116120
get items() {
117121
return this._items;
118122
}
123+
124+
private transformToArrayPopup(items: Array<PoBreadcrumbItem>) {
125+
const itemsCopy = items.map(obj => ({ ...obj }));
126+
itemsCopy.shift();
127+
itemsCopy.splice(-2, 1);
128+
itemsCopy.pop();
129+
this.itemsViewPopup = this.transformArrayToActionPopUp(itemsCopy);
130+
}
131+
132+
private transformArrayToActionPopUp(items: Array<PoBreadcrumbItem>) {
133+
return items.map(obj => {
134+
if (obj.hasOwnProperty('link')) {
135+
obj['url'] = obj.link;
136+
delete obj.link;
137+
if (obj.hasOwnProperty('action')) {
138+
delete obj.action;
139+
}
140+
}
141+
return obj;
142+
});
143+
}
119144
}

projects/ui/src/lib/components/po-breadcrumb/po-breadcrumb-dropdown/po-breadcrumb-dropdown.component.html

Lines changed: 0 additions & 5 deletions
This file was deleted.

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

Lines changed: 0 additions & 44 deletions
This file was deleted.

projects/ui/src/lib/components/po-breadcrumb/po-breadcrumb-dropdown/po-breadcrumb-dropdown.component.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
<div class="po-breadcrumb-favorite po-clickable" (click)="toggleFavoriteAction()">
1+
<div
2+
tabindex="0"
3+
role="button"
4+
class="po-breadcrumb-favorite po-clickable"
5+
(click)="toggleFavoriteAction()"
6+
(keyup.enter)="toggleFavoriteAction()"
7+
>
28
<span
39
class="po-icon po-icon-star po-breadcrumb-favorite-star po-clickable"
410
[class.po-breadcrumb-favorite-star-active]="favorite"
511
>
612
</span>
713

8-
<span class="po-hidden-sm po-breadcrumb-favorite-label" *ngIf="favorite">{{ literals?.unfavorite }}</span>
9-
<span class="po-hidden-sm po-breadcrumb-favorite-label" *ngIf="!favorite">{{ literals?.favorite }}</span>
14+
<span class="po-hidden-sm po-breadcrumb-favorite-label" *ngIf="favorite && !hiddenLiteral">{{
15+
literals?.unfavorite
16+
}}</span>
17+
<span class="po-hidden-sm po-breadcrumb-favorite-label" *ngIf="!favorite && !hiddenLiteral">{{
18+
literals?.favorite
19+
}}</span>
1020
</div>

projects/ui/src/lib/components/po-breadcrumb/po-breadcrumb-favorite/po-breadcrumb-favorite.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ export class PoBreadcrumbFavoriteComponent implements OnInit, OnDestroy {
4848
// Parâmetro que será enviado junto com o serviço de favoritar.
4949
@Input('p-params-service') paramsService: object;
5050

51+
// Esconde literal e mantém apenas icone
52+
@Input('p-hidden-literal') hiddenLiteral: boolean = false;
53+
5154
favorite: boolean = false;
5255
literals;
5356

projects/ui/src/lib/components/po-breadcrumb/po-breadcrumb-item/po-breadcrumb-item.component.html

Lines changed: 0 additions & 24 deletions
This file was deleted.

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

Lines changed: 0 additions & 93 deletions
This file was deleted.

projects/ui/src/lib/components/po-breadcrumb/po-breadcrumb-item/po-breadcrumb-item.component.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)