|
@@ -51,6 +51,7 @@
|
|
|
<editor
|
|
|
@editorMounted="initBlogContent"
|
|
|
@editorUpdated="updateBlog"
|
|
|
+ :isSaving="isSaving"
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -68,7 +69,8 @@ export default {
|
|
|
},
|
|
|
computed : {
|
|
|
...mapState({
|
|
|
- blog: ({instructor}) => instructor.blog.item
|
|
|
+ blog: ({instructor}) => instructor.blog.item,
|
|
|
+ isSaving: ({instructor}) => instructor.blog.isSaving
|
|
|
})
|
|
|
},
|
|
|
async fetch({params, store}){
|
|
@@ -81,15 +83,16 @@ export default {
|
|
|
// }
|
|
|
// }
|
|
|
initBlogContent(initContent) {
|
|
|
- debugger
|
|
|
if (this.blog && this.blog.content) {
|
|
|
initContent(this.blog.content)
|
|
|
}
|
|
|
},
|
|
|
async updateBlog(blogData) {
|
|
|
try{
|
|
|
- await this.$store.dispatch('instructor/blog/updateBlog', {data: blogData, id: this.blog._id})
|
|
|
- this.$toasted.success('Blog Updated!', {duration: 2000})
|
|
|
+ if (!this.isSaving) {
|
|
|
+ await this.$store.dispatch('instructor/blog/updateBlog', {data: blogData, id: this.blog._id})
|
|
|
+ this.$toasted.success('Blog Updated!', {duration: 2000})
|
|
|
+ }
|
|
|
}catch(error){
|
|
|
this.$toasted.error('Blog cannot be saved!', {duration: 2000})
|
|
|
}
|