Browse Source

Bugfix: don't set empty value when loading page

pull/341/head
Hironsan 5 years ago
parent
commit
a54c70582a
1 changed files with 16 additions and 18 deletions
  1. 34
      frontend/pages/projects/_id/guideline/index.vue

34
frontend/pages/projects/_id/guideline/index.vue

@ -1,9 +1,9 @@
<template>
<editor
v-if="current"
v-model="editorText"
preview-style="vertical"
height="inherit"
@change="onEditorChange"
/>
</template>
@ -24,31 +24,29 @@ export default {
return /^\d+$/.test(params.id)
},
data() {
return {
editorText: ''
}
},
computed: {
...mapState('projects', ['current'])
...mapState('projects', ['current']),
editorText: {
get() {
return this.current.guideline
},
set(value) {
const data = {
projectId: this.$route.params.id,
guideline: value
}
this.updateCurrentProject(data)
}
}
},
async created() {
await this.setCurrentProject(this.$route.params.id)
this.editorText = this.current.guideline
},
methods: {
...mapActions('projects', ['setCurrentProject', 'updateCurrentProject']),
onEditorChange() {
const data = {
projectId: this.$route.params.id,
guideline: this.editorText
}
this.updateCurrentProject(data)
}
...mapActions('projects', ['setCurrentProject', 'updateCurrentProject'])
}
}
</script>

Loading…
Cancel
Save