Files
jandl-taskmanager-app/app/src/plugins/tm@modal/master-task/z-complete-master-task-modal.vue
T

57 lines
1.6 KiB
Vue

<template>
<v-dialog v-model="visible" max-width="750" persistent :retain-focus="false">
<v-card>
<div class="d-flex justify-space-between align-center">
<h1>Ste si istý, že chcete {{ mastertask.is_finished ? 'znovu otvoriť' : 'dokončiť' }} <b>{{ mastertask?.name }}</b>?</h1>
<v-icon
@click.stop="visible = false"
icon="mdi-close"
size="large"
></v-icon>
</div>
<v-card-actions class="mt-10 d-flex justify-start align-center mobile-view">
<v-btn class="button primary half" variant="flat" @click="complete()">ÁNO</v-btn>
<v-btn class="button primary half outline" @click.stop="visible = false">ZRUŠIŤ</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script>
import modalMixin from '@/plugins/tm@modal/_mixins/modal.mixin'
export default {
mixins: [ modalMixin ],
emits: ['close', 'master-task-edited'],
data() {
return {
visible: false,
mastertask: null
}
},
methods: {
async showModal({ mastertask }) {
this.mastertask = mastertask
this.visible = true
},
async complete() {
try {
const tempMastertask = {...this.mastertask, is_finished: this.mastertask.is_finished ? 0 : 1 }
const { mastertask } = await this.$axios.put_auth(`v1/mastertasks/${tempMastertask.id}`, tempMastertask)
this.visible = false
this.$emit('master-task-edited', mastertask)
this.$events.emit('close-both-modals')
} catch (error) {
this.$toast.error(this.$parseError(error))
if (process.env.NODE_ENV === 'development')
console.log('[z-complete-master-task-modal.vue] Error: ', error)
}
}
}
}
</script>