feat: description script setup #1927

Merged
konrad merged 1 commits from dpschen/frontend:feature/feat-description-script-setup into main 2022-05-22 20:42:25 +00:00
1 changed files with 51 additions and 54 deletions

View File

@ -29,65 +29,62 @@
</div>
</template>
<script lang="ts">
import {defineComponent} from 'vue'
<script setup lang="ts">
import {ref,computed, watch} from 'vue'
import {useStore} from 'vuex'
import AsyncEditor from '@/components/input/AsyncEditor'
import Editor from '@/components/input/AsyncEditor'
import {LOADING} from '@/store/mutation-types'
import {mapState} from 'vuex'
import TaskModel from '@/models/task'
export default defineComponent({
name: 'description',
components: {
Editor: AsyncEditor,
},
data() {
return {
task: {description: ''},
saved: false,
saving: false, // Since loading is global state, this variable ensures we're only showing the saving icon when saving the description.
}
},
computed: mapState({
loading: LOADING,
}),
props: {
modelValue: {
required: true,
},
attachmentUpload: {
required: true,
},
canWrite: {
required: true,
},
},
emits: ['update:modelValue'],
watch: {
modelValue: {
handler(value) {
this.task = value
},
immediate: true,
},
},
methods: {
async save() {
this.saving = true
try {
this.task = await this.$store.dispatch('tasks/update', this.task)
this.$emit('update:modelValue', this.task)
this.saved = true
setTimeout(() => {
this.saved = false
}, 2000)
} finally {
this.saving = false
}
},
const props = defineProps({
modelValue: {
type: TaskModel,
required: true,
},
attachmentUpload: {
required: true,
},
canWrite: {
required: true,
},
})
const emit = defineEmits(['update:modelValue'])
const task = ref<TaskModel>({description: ''})
const saved = ref(false)
// Since loading is global state, this variable ensures we're only showing the saving icon when saving the description.
const saving = ref(false)
const store = useStore()
const loading = computed(() => store.state.loading)
watch(
() => props.modelValue,
(value) => {
task.value = value
},
{immediate: true},
)
async function save() {
saving.value = true
try {
// FIXME: don't update state from internal.

Is that the vuex state mutation error which appears when changing the description?

Is that the vuex state mutation error which appears when changing the description?

I'm not sure I can follow.
Might be that I fixed this when force pushing from 50489a8165 to c22f4ab788

I'm not sure I can follow. Might be that I fixed this when force pushing from 50489a8165 to c22f4ab788

Looks like this is fixed now.

Looks like this is fixed now.
task.value = await store.dispatch('tasks/update', task.value)
emit('update:modelValue', task.value)
saved.value = true
setTimeout(() => {
saved.value = false
}, 2000)
} finally {
saving.value = false
}
}
</script>