2015-12-10 09:40:54 -08:00
|
|
|
// #docregion
|
2016-05-02 16:53:25 -07:00
|
|
|
import { Injectable } from '@angular/core';
|
2015-12-10 09:40:54 -08:00
|
|
|
/**
|
|
|
|
* Async modal dialog service
|
|
|
|
* DialogService makes this app easier to test by faking this service.
|
2016-05-25 19:47:23 +05:30
|
|
|
* TODO: better modal implementation that doesn't use window.confirm
|
2015-12-10 09:40:54 -08:00
|
|
|
*/
|
|
|
|
@Injectable()
|
|
|
|
export class DialogService {
|
|
|
|
/**
|
|
|
|
* Ask user to confirm an action. `message` explains the action and choices.
|
|
|
|
* Returns promise resolving to `true`=confirm or `false`=cancel
|
|
|
|
*/
|
2016-05-02 16:53:25 -07:00
|
|
|
confirm(message?: string) {
|
2016-06-09 13:00:26 -05:00
|
|
|
return new Promise<boolean>(resolve => {
|
|
|
|
return resolve(window.confirm(message || 'Is it OK?'));
|
|
|
|
});
|
2015-12-10 09:40:54 -08:00
|
|
|
};
|
|
|
|
}
|