fix date picker initial content

This commit is contained in:
2023-01-25 11:55:49 +10:00
parent 349ce71e34
commit c5e801a45f
4 changed files with 16 additions and 4 deletions

View File

@@ -124,7 +124,10 @@ const computedEnableTime = computed(() => {
});
watch(initialContent, (newContent) => {
if (typeof date.value == "undefined") {
if (
typeof date.value == "undefined" ||
(typeof date.value == "string" && date.value.length == 0)
) {
date.value = newContent === undefined ? "" : newContent;
}
});

View File

@@ -162,7 +162,6 @@ import {
restParseErrors,
} from "../../helpers/validation";
import { useRoute } from "vue-router";
import { formatAusDateToUniversal } from "../../helpers/common";
import { parseISO } from "date-fns";
const route = useRoute();

View File

@@ -135,8 +135,11 @@ const formData = reactive({
},
},
publish_at: {
value: "",
value: null,
error: "",
rules: {
datetime: true,
},
},
hero: {
value: "",
@@ -200,11 +203,14 @@ const loadData = async () => {
throw new Error("The server is currently not available");
}
console.log(res.data.post);
formData.title.value = res.data.post.title;
formData.slug.value = res.data.post.slug;
formData.user_id.value = res.data.post.user_id;
formData.content.value = res.data.post.content;
formData.publish_at.value = res.data.post.publish_at;
formData.publish_at.value = res.data.post.publish_at
? new Date(res.data.post.publish_at)
: "";
formData.content.value = res.data.post.content;
formData.hero.value = res.data.post.hero;
} catch (err) {

View File

@@ -68,6 +68,7 @@ const search = ref("");
const headers = [
{ text: "Title", value: "title", sortable: true },
{ text: "Published", value: "publish_at", sortable: true },
{ text: "Created", value: "created_at", sortable: true },
{ text: "Updated", value: "updated_at", sortable: true },
{ text: "Actions", value: "actions" },
@@ -127,6 +128,9 @@ const loadFromServer = async () => {
if (row.updated_at !== "undefined") {
row.updated_at = relativeDate(row.updated_at);
}
if (row.publish_at !== "undefined") {
row.publish_at = relativeDate(row.publish_at);
}
});
serverItemsLength.value = res.data.total;