2018-04-18 19:19:35 +00:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import { equal } from '@ember/object/computed';
|
2018-08-24 21:02:13 +00:00
|
|
|
import RSVP from 'rsvp';
|
2018-04-18 19:19:35 +00:00
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
classNames: ['two-step-button'],
|
|
|
|
|
|
|
|
idleText: '',
|
|
|
|
cancelText: '',
|
|
|
|
confirmText: '',
|
|
|
|
confirmationMessage: '',
|
2018-08-24 20:41:14 +00:00
|
|
|
awaitingConfirmation: false,
|
2018-04-18 19:19:35 +00:00
|
|
|
onConfirm() {},
|
|
|
|
onCancel() {},
|
|
|
|
|
|
|
|
state: 'idle',
|
|
|
|
isIdle: equal('state', 'idle'),
|
|
|
|
isPendingConfirmation: equal('state', 'prompt'),
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
setToIdle() {
|
|
|
|
this.set('state', 'idle');
|
|
|
|
},
|
|
|
|
promptForConfirmation() {
|
|
|
|
this.set('state', 'prompt');
|
|
|
|
},
|
2018-08-24 21:02:13 +00:00
|
|
|
confirm() {
|
|
|
|
RSVP.resolve(this.get('onConfirm')()).then(() => {
|
|
|
|
this.send('setToIdle');
|
|
|
|
});
|
|
|
|
},
|
2018-04-18 19:19:35 +00:00
|
|
|
},
|
|
|
|
});
|