<template>
  <Dialog :show="tempData.show"
          :vue-name="dialogConfig.vueName"
          :height="dialogConfig.height"
          :width="dialogConfig.width"
          :header="dialogConfig.header"
          :dialog-type="dialogConfig.type"
          :position="dialogConfig.position">
    <template slot="default">
      <Weather ref="WeatherTemp"></Weather>
    </template>
  </Dialog>
</template>

<script lang="ts">
import {Component, Vue, Watch} from 'vue-property-decorator'
import Dialog from '@/components/dialog/index.vue'
import Weather from '@/views/on-map-view/Weather.vue'

@Component({
  components: {
    Dialog,
    Weather
  },
  props: {
    tempData: {
      type: Object,
      required: true,
      default: () => {
        return {}
      }
    }
  }
})
export default class WeatherTemp extends Vue {
  private dialogConfig = {
    width: '565px',
    height: '26.25rem',
    header: {
      title: '',
      hasIcon: false,
      iconSrc: '',
      hasMin: true,
      hasMax: false
    },
    position: {
      top: '20%',
      left: '30%'
    },
    vueName: ''
  }
  private menuGroup = 'menu'

  @Watch('tempData', {
    deep: true,
    immediate: true
  })
  dataChange(data: any) {
    const dialogData = data.dialogData
    this.dialogConfig.vueName = dialogData.vueName
    this.dialogConfig.header.title = `${this.$t('message.menu.WeatherTemp')}`
  }

  public mounted() {
    window.addEventListener("setItemEvent", (e: any) => {
      if (e.key === 'language') {
        this.dialogConfig.header.title = `${this.$t('message.menu.WeatherTemp')}`
      }
    });
  }
}
</script>

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