import Vue from 'vue'
import uniqueId from 'lodash'
import {i18n} from '../main'
import AuthorityFilter from '../commands/AuthorityFilter'
import DeletePeriodReportDialog from '@/components/DialogComponents/PeriodReportDialog/DeletePeriodReportDialog.vue'

Vue.component('DeletePeriodReportDialog', DeletePeriodReportDialog)

let CommandTypes = {
  DELETE_PERIOD_REPORT_CMD: {
    type: 'DeletePeriodReportDialog',
    executeComponent: 'DeletePeriodReportDialog',
    registerComponent: DeletePeriodReportDialog
  }
}

class PeriodReportCommands {
  static deletePeriodReportCommand (template1, commandContext) {
    let command = {
      id: uniqueId(CommandTypes.DELETE_PERIOD_REPORT_CMD.type),
      visible: true,
      disabled: false,
      target: template1,
      executeComponent: CommandTypes.DELETE_PERIOD_REPORT_CMD.executeComponent,
      execute: undefined,
      done: undefined,
      name: i18n.tc('ReportTemplateManagement.deleteReportTemplate')
    }
    command.execute = function () {
      Vue.set(commandContext, command.id, command)
    }
    command.done = function () {
      Vue.delete(commandContext, command.id)
    }
    return AuthorityFilter.periodReportAuthorityFilter(command)
  }
}

PeriodReportCommands.CommandTypes = CommandTypes

export default PeriodReportCommands
