github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/app/components/two-step-button.js (about)

     1  import Component from '@ember/component';
     2  import { equal } from '@ember/object/computed';
     3  import RSVP from 'rsvp';
     4  
     5  export default Component.extend({
     6    classNames: ['two-step-button'],
     7  
     8    idleText: '',
     9    cancelText: '',
    10    confirmText: '',
    11    confirmationMessage: '',
    12    awaitingConfirmation: false,
    13    onConfirm() {},
    14    onCancel() {},
    15  
    16    state: 'idle',
    17    isIdle: equal('state', 'idle'),
    18    isPendingConfirmation: equal('state', 'prompt'),
    19  
    20    actions: {
    21      setToIdle() {
    22        this.set('state', 'idle');
    23      },
    24      promptForConfirmation() {
    25        this.set('state', 'prompt');
    26      },
    27      confirm() {
    28        RSVP.resolve(this.get('onConfirm')()).then(() => {
    29          this.send('setToIdle');
    30        });
    31      },
    32    },
    33  });