From add2d269ac4d7673603c872539ed0cb4e7e47b3f Mon Sep 17 00:00:00 2001 From: Miguel Ribeiro Date: Sun, 1 Sep 2024 21:51:06 +0200 Subject: [PATCH] feat: open edit form after cloning subscription --- endpoints/subscription/clone.php | 3 ++- scripts/dashboard.js | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/endpoints/subscription/clone.php b/endpoints/subscription/clone.php index 35282bb14..9d78164d3 100644 --- a/endpoints/subscription/clone.php +++ b/endpoints/subscription/clone.php @@ -40,7 +40,8 @@ if ($cloneStmt->execute()) { $response = [ "success" => true, - "message" => translate('success', $i18n) + "message" => translate('success', $i18n), + "id" => $db->lastInsertRowID() ]; echo json_encode($response); } else { diff --git a/scripts/dashboard.js b/scripts/dashboard.js index 5090fcd7b..1d86e6e31 100644 --- a/scripts/dashboard.js +++ b/scripts/dashboard.js @@ -207,7 +207,8 @@ function cloneSubscription(event, id) { }) .then(data => { if (data.success) { - fetchSubscriptions(); + const id = data.id; + fetchSubscriptions(id, event); showSuccessMessage(decodeURI(data.message)); } else { showErrorMessage(data.message || translate('error')); @@ -288,7 +289,7 @@ function closeLogoSearch() { logoResults.innerHTML = ""; } -function fetchSubscriptions() { +function fetchSubscriptions(id, event) { const subscriptionsContainer = document.querySelector("#subscriptions"); let getSubscriptions = "endpoints/subscriptions/get.php"; @@ -317,6 +318,10 @@ function fetchSubscriptions() { mainActions.classList.remove("hidden"); } } + + if (id && event) { + openEditSubscription(event, id); + } }) .catch(error => { console.error(translate('error_reloading_subscription'), error);