diff options
Diffstat (limited to 'src/components/Action.vue')
-rw-r--r-- | src/components/Action.vue | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/components/Action.vue b/src/components/Action.vue new file mode 100644 index 0000000..2cf8766 --- /dev/null +++ b/src/components/Action.vue @@ -0,0 +1,62 @@ +<template> + <button class="action-button pull-right" + :data-type="type" :data-href="link" @click="onClickActionButton"> + <iron-icon icon="undo"></iron-icon> {{ label }} + </button> +</template> + +<script> +import axios from 'nextcloud-axios' +import '@polymer/iron-icon/iron-icon.js'; +import '@polymer/iron-icons/iron-icons.js'; + +export default { + name: 'Action', + + props: { + label: { + type: String, + default: '', + required: true + }, + link: { + type: String, + default: '', + required: true + }, + type: { + type: String, + default: '', + required: true + }, + data: { + type: Object, + default: {}, + required: false + } + }, + + methods: { + onClickActionButton: function() { + axios({ + method: this.type || 'GET', + url: this.link + }) + .then(() => { + this.$parent._$el.fadeOut(OC.menuSpeed) + this.$parent.$emit('remove') + $('body').trigger(new $.Event('OCA.Notification.Action', { + notification: this.$parent, + action: { + url: this.link, + type: this.type || 'GET' + } + })) + }) + .catch(() => { + OC.Notification.showTemporary(t('notifications', 'Failed to perform action')) + }); + } + } +} +</script>
\ No newline at end of file |