This commit is contained in:
2023-02-20 18:42:40 +10:00
parent 7c4f377e2b
commit 83f6bce923

View File

@@ -1,61 +1,64 @@
<template> <template>
<SMPage :page-error="pageError" permission="admin/posts"> <SMPage
<SMRow> class="sm-page-post-edit"
<SMDialog> :page-error="pageError"
<h1>{{ page_title }}</h1> permission="admin/posts">
<SMForm :model-value="form" @submit="handleSubmit"> <template #container>
<SMRow> <h1>{{ page_title }}</h1>
<SMColumn <SMForm :model-value="form" @submit="handleSubmit">
><SMInput control="title" @blur="updateSlug()" <SMRow>
/></SMColumn> <SMColumn
</SMRow> ><SMInput control="title" @blur="updateSlug()"
<SMRow> /></SMColumn>
<SMColumn><SMInput control="slug" /></SMColumn> </SMRow>
<SMColumn> <SMRow>
<SMDatepicker <SMColumn><SMInput control="slug" /></SMColumn>
control="publish_at" <SMColumn>
label="Publish Date"></SMDatepicker> <SMInput
</SMColumn> type="datetime"
</SMRow> control="publish_at"
<SMRow> label="Publish Date" />
<SMColumn> </SMColumn>
<SMInput </SMRow>
control="hero" <SMRow>
type="media" <SMColumn>
label="Hero image" <SMInput
required /> control="hero"
</SMColumn> type="media"
</SMRow> label="Hero image"
<SMRow> required />
<SMColumn> </SMColumn>
<SMSelect </SMRow>
control="user_id" <SMRow>
label="Created By" <SMColumn>
:options="authors"></SMSelect> <SMInput
</SMColumn> control="user_id"
</SMRow> label="Created By"
<SMRow> type="select"
<SMColumn> :options="authors" />
<SMEditor </SMColumn>
v-model:srcContent="form.content.value" </SMRow>
:mime-types="[ <SMRow>
'image/png', <SMColumn>
'image/jpeg', <SMEditor
'image/gif', v-model:srcContent="form.content.value"
]" :mime-types="[
@trix-attachment-add="attachmentAdd" /> 'image/png',
</SMColumn> 'image/jpeg',
</SMRow> 'image/gif',
<SMRow> ]"
<SMFormFooter> @trix-attachment-add="attachmentAdd" />
<template #right> </SMColumn>
<SMButton type="submit" label="Save" /> </SMRow>
</template> <SMRow>
</SMFormFooter> <SMFormFooter>
</SMRow> <template #right>
</SMForm> <SMButton type="submit" label="Save" />
</SMDialog> </template>
</SMRow> </SMFormFooter>
</SMRow>
</SMForm>
</template>
</SMPage> </SMPage>
</template> </template>
@@ -69,9 +72,6 @@ import { useUserStore } from "../../store/UserStore";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import SMInput from "../../components/SMInput.vue"; import SMInput from "../../components/SMInput.vue";
import SMButton from "../../components/SMButton.vue"; import SMButton from "../../components/SMButton.vue";
import SMDialog from "../../components/SMDialog.vue";
import SMSelect from "../../components/SMSelect.vue";
import SMDatepicker from "../../components/SMDatePicker.vue";
import SMEditor from "../../components/SMEditor.vue"; import SMEditor from "../../components/SMEditor.vue";
import SMPage from "../../components/SMPage.vue"; import SMPage from "../../components/SMPage.vue";
import SMForm from "../../components/SMForm.vue"; import SMForm from "../../components/SMForm.vue";
@@ -141,6 +141,8 @@ const loadData = async () => {
throw new Error("The server is currently not available"); throw new Error("The server is currently not available");
} }
console.log(res.data);
form.title.value = res.data.post.title; form.title.value = res.data.post.title;
form.slug.value = res.data.post.slug; form.slug.value = res.data.post.slug;
form.user_id.value = res.data.post.user_id; form.user_id.value = res.data.post.user_id;
@@ -149,7 +151,7 @@ const loadData = async () => {
? new SMDate(res.data.post.publish_at, { ? new SMDate(res.data.post.publish_at, {
format: "yMd", format: "yMd",
utc: true, utc: true,
}) }).format("dd/MM/yyyy HH:mm")
: ""; : "";
form.content.value = res.data.post.content; form.content.value = res.data.post.content;
form.hero.value = res.data.post.hero; form.hero.value = res.data.post.hero;
@@ -158,7 +160,7 @@ const loadData = async () => {
} }
} }
formLoading.value = false; form.loading(false);
}; };
const handleSubmit = async () => { const handleSubmit = async () => {
@@ -269,3 +271,9 @@ const loadOptionsAuthors = async () => {
loadOptionsAuthors(); loadOptionsAuthors();
loadData(); loadData();
</script> </script>
<style lang="scss">
.sm-page-post-edit {
background-color: #f8f8f8;
}
</style>