media create
This commit is contained in:
@@ -79,7 +79,7 @@
|
|||||||
<template #left>
|
<template #left>
|
||||||
<SMButton
|
<SMButton
|
||||||
:form="form"
|
:form="form"
|
||||||
v-if="route.params.id"
|
v-if="route.params.id !== 'create'"
|
||||||
type="danger"
|
type="danger"
|
||||||
label="Delete"
|
label="Delete"
|
||||||
@click="handleDelete" />
|
@click="handleDelete" />
|
||||||
@@ -116,7 +116,8 @@ const router = useRouter();
|
|||||||
|
|
||||||
const pageError = ref(200);
|
const pageError = ref(200);
|
||||||
const pageLoading = ref(true);
|
const pageLoading = ref(true);
|
||||||
const pageHeading = route.params.id ? "Edit Media" : "Upload Media";
|
const pageHeading =
|
||||||
|
route.params.id !== "create" ? "Edit Media" : "Upload Media";
|
||||||
|
|
||||||
const form = reactive(
|
const form = reactive(
|
||||||
Form({
|
Form({
|
||||||
@@ -140,7 +141,7 @@ const fileData = reactive({
|
|||||||
const imageUrl = ref("");
|
const imageUrl = ref("");
|
||||||
|
|
||||||
const handleLoad = async () => {
|
const handleLoad = async () => {
|
||||||
if (route.params.id) {
|
if (route.params.id !== "create") {
|
||||||
try {
|
try {
|
||||||
let result = await api.get({
|
let result = await api.get({
|
||||||
url: "/media/{id}",
|
url: "/media/{id}",
|
||||||
@@ -195,7 +196,7 @@ const handleSubmit = async () => {
|
|||||||
form.controls.description.value as string
|
form.controls.description.value as string
|
||||||
);
|
);
|
||||||
|
|
||||||
if (route.params.id) {
|
if (route.params.id !== "create") {
|
||||||
await api.put({
|
await api.put({
|
||||||
url: "/media/{id}",
|
url: "/media/{id}",
|
||||||
params: {
|
params: {
|
||||||
@@ -221,7 +222,10 @@ const handleSubmit = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useToastStore().addToast({
|
useToastStore().addToast({
|
||||||
title: route.params.id ? "Media Updated" : "Media Created",
|
title:
|
||||||
|
route.params.id !== "create"
|
||||||
|
? "Media Updated"
|
||||||
|
: "Media Created",
|
||||||
content: route.params.id
|
content: route.params.id
|
||||||
? "The media item has been updated."
|
? "The media item has been updated."
|
||||||
: "The media item been created.",
|
: "The media item been created.",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<SMContainer class="flex-grow-1">
|
<SMContainer class="flex-grow-1">
|
||||||
<SMToolbar>
|
<SMToolbar>
|
||||||
<SMButton
|
<SMButton
|
||||||
:to="{ name: 'workshops' }"
|
:to="{ name: 'dashboard-media-create' }"
|
||||||
type="primary"
|
type="primary"
|
||||||
label="Upload Media" />
|
label="Upload Media" />
|
||||||
<SMInput
|
<SMInput
|
||||||
|
|||||||
Reference in New Issue
Block a user