Update (major): fix bugs

This commit is contained in:
2023-08-01 22:37:51 +08:00
parent 511382f6c1
commit f25fea8d68
22 changed files with 92 additions and 50 deletions

View File

@@ -456,39 +456,46 @@ export default {
errors.push("post title");
}
if (!(this.post.publish_date != null)) {
errors.push("publish date");
}
if (!(this.post.slug?.length > 0)) {
errors.push("post slug");
}
if (!(this.post.excerpt?.length > 0)) {
errors.push("post excerpt");
}
if (this.post.status == "publish") {
if (!(this.post.publish_date != null)) {
errors.push("publish date");
}
if (!(this.post.featured_image?.length > 0)) {
errors.push("post featured image");
}
if (!(this.post.excerpt?.length > 0)) {
errors.push("post excerpt");
}
if (!(this.post.body.blocks?.length > 0)) {
errors.push("Post body");
}
if (!(this.post.featured_image?.length > 0)) {
errors.push("post featured image");
}
if (
!(this.post.locale_slug?.length > 0) ||
!(this.post.locale_id != null)
) {
errors.push("Country locality");
}
if (!(this.post.body.blocks?.length > 0)) {
errors.push("Post body");
}
if (!(this.post.categories != null)) {
errors.push("Category");
if (
!(this.post.locale_slug?.length > 0) ||
!(this.post.locale_id != null)
) {
errors.push("Country locality");
}
if (!(this.post.categories != null)) {
errors.push("Category");
}
}
if (errors.length > 0) {
alert("HAIYA many errors! pls fix " + errors.join(", "));
alert(
"HAIYA many errors! For " +
this.post.status +
" status, pls fix " +
errors.join(", ")
);
} else {
this.savePost();
}
@@ -615,6 +622,26 @@ export default {
slug = slug.replace(/\s+/g, "-");
return slug;
},
setAuthor() {
if (this.post.id == null) {
if (this.post.author_id == null) {
for (const [key, _item] of Object.entries(this.authors)) {
this.post.author_id = _item.id;
break;
}
}
}
},
setLocalCategory() {
if (this.post.id == null) {
if (this.post.categories == null) {
for (const [key, _item] of Object.entries(this.localeCategories)) {
this.post.categories = _item.id;
break;
}
}
}
},
},
mounted() {
this.config.tools.image.config.endpoints.byFile = route(
@@ -631,8 +658,12 @@ export default {
setTimeout(
function () {
this.fetchLocaleCategories(this.post.locale_slug);
this.fetchAuthors();
this.fetchLocaleCategories(this.post.locale_slug).then(() => {
this.setLocalCategory();
});
this.fetchAuthors().then(() => {
this.setAuthor();
});
if (this.postId != null) {
this.fetchPostData(this.postId).then(() => {

View File

@@ -0,0 +1,12 @@
<div class="alert alert-success" role="alert">
<h3 class="">Webmaster Announcement</h3>
<div class="text-muted">
<p class="fw-bold mb-0">Change Log 1/8/2023 10.35pm</p>
<li>(Feature) Auto set category on new post</li>
<li>(Feature) Auto set author on new post</li>
<li>(Feature) Only publish status must fill in all post fields, others status can save with minimum title and
slug only</li>
<li>(Fix) Post list has timezone error</li>
</ul>
</div>
</div>

View File

@@ -7,14 +7,13 @@
<h2 class="page-title">
{{ __('Posts') }}
</h2>
<h4>Manage your blog posts here</h4>
</div>
</div>
<div class="page-body">
<div class="container-xl">
<div class="alert alert-info">
<div class="alert-title">Manage your blog posts here.</div>
</div>
@include('admin.partials.webmaster_announcement')
<div class="d-flex mb-3">
<div><a href="{{ route('posts.manage.new') }}" class="btn">New Post</a></div>