* at the root of the template (see ConfirmDialogComponent).
*/
+export interface DialogRejectionResponse {
+ // Did the user simply close the dialog without performing an action.
+ dismissed?: boolean;
+ // Relays error, etc. messages from the dialog handler to the caller.
+ message?: string;
+}
+
@Component({
selector: 'eg-dialog',
template: '<ng-template></ng-template>'
resolve(result);
this.modalRef = null;
},
+
(result) => {
+ // NgbModal creates some result values for us, which
+ // are outside of our control. Other dismissal
+ // reasons are agreed upon by implementing subclasses.
console.debug('dialog closed with ' + result);
- reject(result);
+
+ const dismissed = (
+ result === 0 // body click
+ || result === 1 // Esc key
+ || result === 'canceled' // Cancel button
+ || result === 'cross_click' // modal top-right X
+ );
+
+ const rejection: DialogRejectionResponse = {
+ dismissed: dismissed,
+ message: result
+ };
+
+ reject(rejection);
this.modalRef = null;
}
);
.then(str => this.toast.success(str));
this.grid.reload();
},
- err => {
- this.createErrString.current()
- .then(str => this.toast.danger(str));
+ rejection => {
+ if (!rejection.dismissed) {
+ this.createErrString.current()
+ .then(str => this.toast.danger(str));
+ }
}
);
};
.then(str => this.toast.success(str));
this.grid.reload();
},
- err => {
- this.updateFailedString.current()
- .then(str => this.toast.danger(str));
+ rejection => {
+ if (!rejection.dismissed) {
+ this.updateFailedString.current()
+ .then(str => this.toast.danger(str));
+ }
}
);
}