summaryrefslogtreecommitdiff
path: root/assets/js/components/submit-cancel.js
blob: 061b11468923b60bd5a53c87e787e1ece82650ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Vue.component('submit-cancel', {
    props: ['labelButton', 'labelOr', 'labelCancel', 'callback'],
    template: '<div class="form-actions">' +
              '<button type="button" class="btn btn-blue" @click="onSubmit" :disabled="isLoading">' +
              '<span v-show="isLoading"><i class="fa fa-spinner fa-pulse"></i> </span>' +
              '{{ labelButton }}' +
              '</button> ' +
              '{{ labelOr }} <a href="#" v-on:click.prevent="onCancel">{{ labelCancel }}</a>' +
              '</div>'
    ,
    data: function () {
        return {
            loading: false
        };
    },
    computed: {
        isLoading: function () {
            return this.loading;
        }
    },
    methods: {
        onSubmit: function () {
            this.loading = true;
            this.callback();
        },
        onCancel: function () {
            _KB.get('Popover').close();
        }
    },
    events: {
        'submitCancelled': function() {
            this.loading = false;
        }
    }
});