<template>
  <el-dialog
    :visible.sync="isPreviewing"
    custom-class="c-dialog--preview"
    :before-close="onCloseScheduleDialog"
    :close-on-click-modal="false"
    append-to-body
    v-on="$attrs"
    @closed="onClosed"
  >
    <schedule
      v-if="scheduleId"
      class="l-flex__auto has-padding"
      :schedule="scheduleId"
    />
    <i
      class="l-flex__none c-dialog--preview__close el-icon-close u-bold u-pointer"
      @click="onCloseScheduleDialog"
    />
  </el-dialog>
</template>

<script>
export default {
  name: 'ScheduleDialog',
  data () {
    return {
      scheduleId: null,
      isPreviewing: false
    }
  },
  methods: {
    show (id) {
      this.scheduleId = id
      this.isPreviewing = true
    },
    onCloseScheduleDialog () {
      this.isPreviewing = false
    },
    onClosed () {
      this.scheduleId = null
    }
  }
}
</script>
