when saving object, show original query list

This commit is contained in:
2023-05-20 18:34:06 +10:00
parent 7a0d3fc8a0
commit 11eb12324e
10 changed files with 76 additions and 9 deletions

View File

@@ -241,7 +241,13 @@ const handleSubmit = async () => {
type: "success",
});
router.push({ name: "dashboard-article-list" });
const urlParams = new URLSearchParams(window.location.search);
const returnUrl = urlParams.get("return");
if (returnUrl) {
router.push(decodeURIComponent(returnUrl));
} else {
router.push({ name: "dashboard-article-list" });
}
} catch (error) {
form.apiErrors(error);
}

View File

@@ -192,7 +192,15 @@ const handleLoad = async () => {
* @param {Artile} item The article item.
*/
const handleEdit = (item: Article) => {
router.push({ name: "dashboard-article-edit", params: { id: item.id } });
router.push({
name: "dashboard-article-edit",
params: { id: item.id },
query: {
return: encodeURIComponent(
window.location.pathname + window.location.search
),
},
});
};
/**

View File

@@ -389,7 +389,13 @@ const handleSubmit = async () => {
type: "success",
});
router.push({ name: "dashboard-event-list" });
const urlParams = new URLSearchParams(window.location.search);
const returnUrl = urlParams.get("return");
if (returnUrl) {
router.push(decodeURIComponent(returnUrl));
} else {
router.push({ name: "dashboard-event-list" });
}
} catch (error) {
useToastStore().addToast({
title: "Server error",

View File

@@ -262,7 +262,15 @@ const handleDuplicate = async (item: Event): Promise<void> => {
* @param {Event} item The event item.
*/
const handleEdit = (item: Event) => {
router.push({ name: "dashboard-event-edit", params: { id: item.id } });
router.push({
name: "dashboard-event-edit",
params: { id: item.id },
query: {
return: encodeURIComponent(
window.location.pathname + window.location.search
),
},
});
};
/**

View File

@@ -237,7 +237,13 @@ const handleSubmit = async () => {
type: "success",
});
router.push({ name: "dashboard-media-list" });
const urlParams = new URLSearchParams(window.location.search);
const returnUrl = urlParams.get("return");
if (returnUrl) {
router.push(decodeURIComponent(returnUrl));
} else {
router.push({ name: "dashboard-media-list" });
}
} catch (error) {
useToastStore().addToast({
title: "Server error",

View File

@@ -202,7 +202,15 @@ const handleLoad = async () => {
* @param {Media} item The media item.
*/
const handleEdit = (item: Media) => {
router.push({ name: "dashboard-media-edit", params: { id: item.id } });
router.push({
name: "dashboard-media-edit",
params: { id: item.id },
query: {
return: encodeURIComponent(
window.location.pathname + window.location.search
),
},
});
};
/**

View File

@@ -154,7 +154,13 @@ const handleSubmit = async () => {
});
}
router.push({ name: "dashboard" });
const urlParams = new URLSearchParams(window.location.search);
const returnUrl = urlParams.get("return");
if (returnUrl) {
router.push(decodeURIComponent(returnUrl));
} else {
router.push({ name: "dashboard-shortlink-list" });
}
} catch (err) {
form.apiErrors(err);
} finally {

View File

@@ -163,6 +163,11 @@ const handleEdit = (shortlink: Shortlink) => {
router.push({
name: "dashboard-shortlink-edit",
params: { id: shortlink.id },
query: {
return: encodeURIComponent(
window.location.pathname + window.location.search
),
},
});
};

View File

@@ -228,7 +228,13 @@ const handleSubmit = async () => {
});
}
router.push({ name: "dashboard" });
const urlParams = new URLSearchParams(window.location.search);
const returnUrl = urlParams.get("return");
if (returnUrl) {
router.push(decodeURIComponent(returnUrl));
} else {
router.push({ name: "dashboard-user-list" });
}
} catch (err) {
form.apiErrors(err);
} finally {

View File

@@ -168,7 +168,15 @@ const handleLoad = async () => {
};
const handleEdit = (user: User) => {
router.push({ name: "dashboard-user-edit", params: { id: user.id } });
router.push({
name: "dashboard-user-edit",
params: { id: user.id },
query: {
return: encodeURIComponent(
window.location.pathname + window.location.search
),
},
});
};
const handleDelete = async (user: User) => {