bug fixes
This commit is contained in:
@@ -175,7 +175,7 @@ const handleAddToGallery = async () => {
|
||||
if (result) {
|
||||
const mediaResult = result as Media[];
|
||||
let newValue = props.modelValue;
|
||||
let galleryIds = new Set(newValue.map((item) => item.id));
|
||||
let galleryIds = new Set(mediaResult.map((item) => (item as Media).id));
|
||||
|
||||
mediaResult.forEach((item) => {
|
||||
if (!galleryIds.has(item.id)) {
|
||||
@@ -184,7 +184,7 @@ const handleAddToGallery = async () => {
|
||||
}
|
||||
});
|
||||
|
||||
emits("update:modelValue", newValue);
|
||||
emits("update:modelValue", mediaResult);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -377,7 +377,7 @@
|
||||
)}')`,
|
||||
}">
|
||||
<SMLoading
|
||||
v-if="true"
|
||||
v-if="getMediaStatus(item).busy"
|
||||
small
|
||||
class="bg-white bg-op-90 w-full h-full" />
|
||||
<div
|
||||
|
||||
@@ -78,7 +78,11 @@ import SMInput from "../../components/SMInput.vue";
|
||||
import SMDropdown from "../../components/SMDropdown.vue";
|
||||
import SMAttachments from "../../components/SMAttachments.vue";
|
||||
import { api } from "../../helpers/api";
|
||||
import { ArticleResponse, UserCollection } from "../../helpers/api.types";
|
||||
import {
|
||||
ArticleResponse,
|
||||
Media,
|
||||
UserCollection,
|
||||
} from "../../helpers/api.types";
|
||||
import { SMDate } from "../../helpers/datetime";
|
||||
import { Form, FormControl } from "../../helpers/form";
|
||||
import { And, DateTime, Min, Required } from "../../helpers/validate";
|
||||
@@ -108,7 +112,7 @@ const form = reactive(
|
||||
route.params.id ? "" : new SMDate("now").format("d/M/yy h:mm aa"),
|
||||
DateTime(),
|
||||
),
|
||||
hero: FormControl(),
|
||||
hero: FormControl("", Required()),
|
||||
user_id: FormControl(userStore.id),
|
||||
content: FormControl(),
|
||||
}),
|
||||
@@ -206,15 +210,12 @@ const handleSubmit = async (enableFormCallBack) => {
|
||||
).format("yyyy/MM/dd HH:mm:ss", { utc: true }),
|
||||
user_id: form.controls.user_id.value,
|
||||
content: form.controls.content.value,
|
||||
hero: form.controls.hero.value.id,
|
||||
hero: (form.controls.hero.value as Media).id,
|
||||
gallery: gallery.value.map((item) => item.id),
|
||||
attachments: attachments.value.map((item) => item.id),
|
||||
};
|
||||
|
||||
let article_id = "";
|
||||
|
||||
if (route.params.id) {
|
||||
article_id = route.params.id as string;
|
||||
await api.put({
|
||||
url: `/articles/{id}`,
|
||||
params: {
|
||||
@@ -223,15 +224,10 @@ const handleSubmit = async (enableFormCallBack) => {
|
||||
body: data,
|
||||
});
|
||||
} else {
|
||||
let result = await api.post({
|
||||
await api.post({
|
||||
url: "/articles",
|
||||
body: data,
|
||||
});
|
||||
|
||||
if (result.data) {
|
||||
const data = result.data as ArticleResponse;
|
||||
article_id = data.article.id;
|
||||
}
|
||||
}
|
||||
|
||||
useToastStore().addToast({
|
||||
@@ -250,6 +246,7 @@ const handleSubmit = async (enableFormCallBack) => {
|
||||
router.push({ name: "dashboard-article-list" });
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
form.apiErrors(error, (message) => {
|
||||
useToastStore().addToast({
|
||||
title: "An error occurred",
|
||||
|
||||
Reference in New Issue
Block a user