diff --git a/apps/static/js/home/subscriptions.js b/apps/static/js/home/subscriptions.js
index 058d9ff..7f25e40 100644
--- a/apps/static/js/home/subscriptions.js
+++ b/apps/static/js/home/subscriptions.js
@@ -394,20 +394,59 @@ $(document).on("selectedServerChange", async function() {
// Delete button on the 'edit subscription' modal
$("#deleteEditSub").on("click", async function() {
- const subId = $("#subId").val();
- await deleteSubscription(subId);
- await loadSubscriptions(getCurrentlyActiveServer().guild_id);
+ const subId = parseInt($("#subId").val());
+ const sub = subTable.row(function(idx, data, node) { return data.id === subId }).data();
+
$("#subFormModal").modal("hide");
- showToast("danger", "Deleted Subscription", "Subscription ID: " + subId);
+
+ await confirmDeleteModal(
+ "Confirm Delete",
+ `Do you wish to permanently delete ${sub.name}?`,
+ async () => {
+ await deleteSubscription(subId);
+ await loadSubscriptions(getCurrentlyActiveServer().guild_id);
+ showToast("danger", "Deleted Subscription", "Subscription ID: " + subId);
+ },
+ async () => {
+ $("#subFormModal").modal("show");
+ }
+ );
});
-async function deleteSelectedSubscriptions() {
- var rows = subTable.rows(".selected").data();
- $.each(rows, async function() {
- await deleteSubscription(this.id);
- showToast("danger", "Deleted Subscription", "Subscription ID: " + this.id);
+function arrayToHtmlList(array, bold=false) {
+ $ul = $("
");
+
+ array.forEach(item => {
+ let $li = $("- ");
+ $ul.append(bold ? $li.append($("").text(item)) : $li.text(item));
});
- await loadSubscriptions(getCurrentlyActiveServer().guild_id);
+
+ return $ul;
+}
+
+
+async function deleteSelectedSubscriptions() {
+ const rows = subTable.rows(".selected").data().toArray();
+ const names = rows.map(row => row.name);
+ const namesString = arrayToHtmlList(names, true).prop("outerHTML");
+
+ await confirmDeleteModal(
+ `Confirm ${names.length > 1 ? "Multiple Deletions" : "Deletion"}`,
+ `Do you wish to permanently delete ${names.length > 1 ? "these" : "this"} ${names.length} subscription${names.length > 1 ? "s" : ""}?
${namesString}`,
+ async () => {
+ rows.forEach(async row => { await deleteSubscription(row.id) });
+
+ showToast(
+ "danger",
+ `Deleted ${names.length} Subscription${names.length > 1 ? "s" : ""}`,
+ `${arrayToHtmlList(names, false).prop("outerHTML")}`,
+ 12000
+ )
+
+ await loadSubscriptions(getCurrentlyActiveServer().guild_id);
+ },
+ null
+ )
}
// #endregion
diff --git a/apps/templates/home/index.html b/apps/templates/home/index.html
index c08188b..b7e16f0 100644
--- a/apps/templates/home/index.html
+++ b/apps/templates/home/index.html
@@ -45,7 +45,7 @@
-
+
Warning:
@@ -88,6 +88,7 @@
{% include "home/includes/servermodal.html" %}
{% include "home/includes/submodal.html" %}
{% include "home/includes/filtermodal.html" %}
+{% include "home/includes/deletemodal.html" %}
{% endblock content %}
{% block javascript %}