Browse Source

Remove vuex from guideline page

pull/1234/head
Hironsan 4 years ago
parent
commit
3d0078f62e
1 changed files with 18 additions and 23 deletions
  1. 41
      frontend/pages/projects/_id/guideline/index.vue

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

@ -1,7 +1,6 @@
<template> <template>
<editor <editor
v-if="current"
v-model="editorText"
v-model="project.guideline"
preview-style="vertical" preview-style="vertical"
height="inherit" height="inherit"
:options="editorOptions" :options="editorOptions"
@ -9,52 +8,48 @@
</template> </template>
<script> <script>
import _ from 'lodash'
import 'tui-editor/dist/tui-editor.css' import 'tui-editor/dist/tui-editor.css'
import 'tui-editor/dist/tui-editor-contents.css' import 'tui-editor/dist/tui-editor-contents.css'
import 'codemirror/lib/codemirror.css' import 'codemirror/lib/codemirror.css'
import { Editor } from '@toast-ui/vue-editor' import { Editor } from '@toast-ui/vue-editor'
import { mapState, mapActions } from 'vuex'
import '@/assets/style/editor.css' import '@/assets/style/editor.css'
export default { export default {
layout: 'project', layout: 'project',
components: { components: {
Editor Editor
}, },
data() { data() {
return { return {
editorOptions: { editorOptions: {
language: this.$t('toastui.localeCode') language: this.$t('toastui.localeCode')
}
},
project: {}
} }
}, },
validate({ params }) {
return /^\d+$/.test(params.id)
},
computed: {
...mapState('projects', ['current']),
editorText: {
get() {
return this.current.guideline
},
set(value) {
const data = {
projectId: this.$route.params.id,
guideline: value
}
this.updateCurrentProject(data)
}
watch: {
'project.guideline'() {
this.updateProject()
} }
}, },
async created() { async created() {
await this.setCurrentProject(this.$route.params.id)
const projectId = this.$route.params.id
this.project = await this.$services.project.findById(projectId)
}, },
methods: { methods: {
...mapActions('projects', ['setCurrentProject', 'updateCurrentProject'])
updateProject: _.debounce(function() {
this.$services.project.update(this.project)
}, 1000)
},
validate({ params }) {
return /^\d+$/.test(params.id)
} }
} }
</script> </script>

Loading…
Cancel
Save