<template>
  <div>
    <or-button @click="cancel">
      {{ modalMode === 'mergeFieldsReplacer' ? 'Cancel' : 'Back' }}
    </or-button>
    <or-button color="primary" :disabled="modalMode === 'mergeFieldsReplacer' && !allowSaveMergeFields" @click="save">
      Save
    </or-button>
  </div>
</template>

<script>
export default {
  name: 'ModalFooter',

  props: {
    modalMode: { type: String, default: 'mergeFieldsReplacer' },
    allowSaveMergeFields: { type: Boolean, default: false }
  },

  methods: {
    cancel () {
      if (this.modalMode === 'mergeFieldsReplacer') this.$EventBus.$emit('merge-fields::cancel');
      if (this.modalMode === 'replacedViewModal') this.$EventBus.$emit('replaced-string::cancel');
    },

    save () {
      if (this.modalMode === 'mergeFieldsReplacer') this.$EventBus.$emit('merge-fields::save');
      if (this.modalMode === 'replacedViewModal') this.$EventBus.$emit('replaced-string::save');
    }
  }
};
</script>

<style lang="scss" scoped></style>
