Skip to content

Commit 6caa4c1

Browse files
author
Giuseppe Pennisi
committed
fix: fixate regressioni
* mancato force per il metodo closeAllWinboxes * mancata gestione della close in caso di non definizione di una callBack
1 parent 1a711c5 commit 6caa4c1

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
<rbtech-sidebar [menu]="menu"></rbtech-sidebar>
2+
<button
3+
style="position: fixed; right: 0; top: 0"
4+
(click)="winboxService.closeAllWinBoxes()"
5+
>
6+
CHIUDI TUTTE LE SCHEDE
7+
</button>
28
<router-outlet></router-outlet>

apps/winbox-example-app/src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class AppComponent implements OnInit {
9393
};
9494

9595
constructor(
96-
private winboxService: WinboxService,
96+
protected winboxService: WinboxService,
9797
private modalService: NgbModal
9898
) {}
9999

packages/angular-winbox/src/lib/winbox.service.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ export class WinboxService {
5959
const optionsClose = options.onclose;
6060
winBox.onclose = (force) => {
6161
if (force) {
62-
return this.destroyComponent(componentRef, winBox);
62+
return this.destroyComponent<ComponentInstance>(componentRef, winBox);
6363
}
64-
6564
const isCloseConfirmed = optionsClose?.apply(winBox, [force]);
66-
if (isCloseConfirmed) {
67-
return this.destroyComponent(componentRef, winBox);
65+
if (isCloseConfirmed || !optionsClose) {
66+
return this.destroyComponent<ComponentInstance>(componentRef, winBox);
6867
}
6968
return true;
7069
};
@@ -80,7 +79,7 @@ export class WinboxService {
8079

8180
public closeAllWinBoxes() {
8281
for (const winBox of this.winBoxStack) {
83-
winBox.close();
82+
winBox.close(true);
8483
}
8584
this.winBoxStack = [];
8685
this.isThereAWinBox = false;
@@ -102,8 +101,8 @@ export class WinboxService {
102101
this.winBoxStack.find((winbox) => winbox.id === id)?.maximize(state);
103102
}
104103

105-
private destroyComponent(
106-
componentRef: ComponentRef<any>,
104+
private destroyComponent<ComponentInstance>(
105+
componentRef: ComponentRef<ComponentInstance>,
107106
winBox: WinBox
108107
): boolean {
109108
componentRef.destroy();

0 commit comments

Comments
 (0)