Skip to content

Commit

Permalink
Fixed #2186
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Mar 1, 2017
1 parent af4cfcb commit a590f27
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
1 change: 1 addition & 0 deletions components/common/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface TreeNode {

export interface Confirmation {
message: string;
key?: string;
icon?: string;
header?: string;
accept?: Function;
Expand Down
38 changes: 21 additions & 17 deletions components/confirmdialog/confirmdialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export class ConfirmDialog implements AfterViewInit,OnDestroy {
@Input() responsive: boolean = true;

@Input() appendTo: any;

@Input() key: string;

@ContentChild(Footer) footer;

Expand All @@ -99,24 +101,26 @@ export class ConfirmDialog implements AfterViewInit,OnDestroy {
constructor(public el: ElementRef, public domHandler: DomHandler,
public renderer: Renderer, private confirmationService: ConfirmationService) {
this.subscription = confirmationService.requireConfirmation$.subscribe(confirmation => {
this.confirmation = confirmation;
this.message = this.confirmation.message||this.message;
this.icon = this.confirmation.icon||this.icon;
this.header = this.confirmation.header||this.header;
this.rejectVisible = this.confirmation.rejectVisible == null ? this.rejectVisible : this.confirmation.rejectVisible;
this.acceptVisible = this.confirmation.acceptVisible == null ? this.acceptVisible : this.confirmation.acceptVisible;

if(this.confirmation.accept) {
this.confirmation.acceptEvent = new EventEmitter();
this.confirmation.acceptEvent.subscribe(this.confirmation.accept);
}

if(this.confirmation.reject) {
this.confirmation.rejectEvent = new EventEmitter();
this.confirmation.rejectEvent.subscribe(this.confirmation.reject);
}
if(confirmation.key === this.key) {
this.confirmation = confirmation;
this.message = this.confirmation.message||this.message;
this.icon = this.confirmation.icon||this.icon;
this.header = this.confirmation.header||this.header;
this.rejectVisible = this.confirmation.rejectVisible == null ? this.rejectVisible : this.confirmation.rejectVisible;
this.acceptVisible = this.confirmation.acceptVisible == null ? this.acceptVisible : this.confirmation.acceptVisible;

if(this.confirmation.accept) {
this.confirmation.acceptEvent = new EventEmitter();
this.confirmation.acceptEvent.subscribe(this.confirmation.accept);
}

if(this.confirmation.reject) {
this.confirmation.rejectEvent = new EventEmitter();
this.confirmation.rejectEvent.subscribe(this.confirmation.reject);
}

this.visible = true;
this.visible = true;
}
});
}

Expand Down
14 changes: 13 additions & 1 deletion showcase/demo/confirmdialog/confirmdialogdemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ <h3>Getting Started</h3>
<td>null</td>
<td>Message of the confirmation.</td>
</tr>
<tr>
<td>key</td>
<td>string</td>
<td>null</td>
<td>Optional key to match the key of the confirm dialog, necessary to use when component tree has multiple confirm dialogs.</td>
</tr>
<tr>
<td>header</td>
<td>string</td>
Expand Down Expand Up @@ -138,13 +144,19 @@ <h3>Attributes</h3>
<td>string</td>
<td>null</td>
<td>Title text of the dialog.</td>
</tr>
</tr>
<tr>
<td>message</td>
<td>string</td>
<td>null</td>
<td>Message of the confirmation.</td>
</tr>
<tr>
<td>key</td>
<td>string</td>
<td>null</td>
<td>Optional key to match the key of confirm object, necessary to use when component tree has multiple confirm dialogs.</td>
</tr>
<tr>
<td>icon</td>
<td>string</td>
Expand Down

0 comments on commit a590f27

Please sign in to comment.