import Vue from 'vue/dist/vue'
import EventBus from "../util/EventBus";
import EventTypes from "../util/EventTypes";

Vue.component('brick-btn-duplicate', {
    delimiters: ['<<', '>>'],
    props: [
        'brick',
    ],
    data: function () {
        return {
            isLoading: false,
        };
    },
    methods: {
        beginLoading: function () {
            this.isLoading = true;
        },
        finishLoading: function () {
            this.isLoading = false;
        },
        emit() {
            EventBus.emitEvent(EventTypes.BRICK_DUPLICATE, this);
        }
    },
    template: `
      <button
          class="btn brick-action brick-duplicate"
          title="Dupliquer"
          v-on:click="emit"
      >
        <i :class="{
          'far fa-copy': !this.isLoading,
          'fas fa-circle-notch fa-spin': this.isLoading,
        }"></i>
      </button>
    `,
});