|
@@ -9,7 +9,7 @@
|
|
<div class="full-page-takeover-header-button">
|
|
<div class="full-page-takeover-header-button">
|
|
<!-- TODO: Check blog validity before publishing -->
|
|
<!-- TODO: Check blog validity before publishing -->
|
|
<Modal
|
|
<Modal
|
|
- @submitted="publishBlog"
|
|
|
|
|
|
+ @submitted="updateBlogStatus($event, 'published')"
|
|
@opened="checkBlogValidity"
|
|
@opened="checkBlogValidity"
|
|
openTitle="Publish"
|
|
openTitle="Publish"
|
|
openBtnClass="button is-success is-medium is-inverted is-outlined"
|
|
openBtnClass="button is-success is-medium is-inverted is-outlined"
|
|
@@ -38,6 +38,7 @@
|
|
<template v-else #actionMenu>
|
|
<template v-else #actionMenu>
|
|
<div class="full-page-takeover-header-button">
|
|
<div class="full-page-takeover-header-button">
|
|
<Modal
|
|
<Modal
|
|
|
|
+ @submitted="updateBlogStatus($event, 'active')"
|
|
openTitle="Unpublish"
|
|
openTitle="Unpublish"
|
|
openBtnClass="button is-success is-medium is-inverted is-outlined"
|
|
openBtnClass="button is-success is-medium is-inverted is-outlined"
|
|
title="Unpublish Blog">
|
|
title="Unpublish Blog">
|
|
@@ -111,12 +112,15 @@ export default {
|
|
this.$toasted.error('Blog cannot be saved!', {duration: 2000})
|
|
this.$toasted.error('Blog cannot be saved!', {duration: 2000})
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- async publishBlog({closeModal}) {
|
|
|
|
|
|
+ async updateBlogStatus({closeModal}, status) {
|
|
const blogContent = this.editor.getContent()
|
|
const blogContent = this.editor.getContent()
|
|
- blogContent.status = 'published'
|
|
|
|
|
|
+ // blogContent.status = 'published'
|
|
|
|
+ blogContent.status = status
|
|
|
|
+ const message = status === 'published' ? 'Blog has been published!' : 'Blog has been un-published!'
|
|
|
|
+
|
|
try {
|
|
try {
|
|
await this.$store.dispatch('instructor/blog/updateBlog', {data: blogContent, id: this.blog._id})
|
|
await this.$store.dispatch('instructor/blog/updateBlog', {data: blogContent, id: this.blog._id})
|
|
- this.$toasted.success('Blog has been published!', {duration: 3000})
|
|
|
|
|
|
+ this.$toasted.success(message, {duration: 3000})
|
|
closeModal()
|
|
closeModal()
|
|
} catch (error) {
|
|
} catch (error) {
|
|
this.$toasted.error('Blog cannot be published!', {duration: 3000})
|
|
this.$toasted.error('Blog cannot be published!', {duration: 3000})
|