add missing delete function for filters table & modal
All checks were successful
Build and Push Docker Image / build (push) Successful in 17s
All checks were successful
Build and Push Docker Image / build (push) Successful in 17s
This commit is contained in:
parent
4646c0a564
commit
aff45f9ac5
@ -69,6 +69,62 @@ async function loadFilterData() {
|
|||||||
await loadTableData(filterTableId, "/api/filters/", "GET");
|
await loadTableData(filterTableId, "/api/filters/", "GET");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Table Delete Btns
|
||||||
|
|
||||||
|
$(filterModalId).find(".modal-del-btn").on("click", async function() {
|
||||||
|
$(filterModalId).modal("hide");
|
||||||
|
|
||||||
|
const id = parseInt($(filterModalId).data("primary-key"));
|
||||||
|
const filter = $(filterTableId).DataTable().row((idx, row) => { return row.id === id }).data();
|
||||||
|
const name = sanitise(filter.name);
|
||||||
|
|
||||||
|
await confirmationModal(
|
||||||
|
`Delete a Content Filter`,
|
||||||
|
`Do you wish to permanently delete <b>${name}</b>?`,
|
||||||
|
"danger",
|
||||||
|
"bi-trash3",
|
||||||
|
async () => {
|
||||||
|
await ajaxRequest(`/api/filters/${filter.id}/`, "DELETE");
|
||||||
|
setTimeout(async () => {
|
||||||
|
$(filterTableId).trigger("doDataLoad");
|
||||||
|
await loadSubModalOptions(
|
||||||
|
$(subModalId).find('[data-field="filters"]'),
|
||||||
|
`/api/filters/?server=${selectedServer.id}`
|
||||||
|
);
|
||||||
|
}, 600);
|
||||||
|
},
|
||||||
|
() => { $(filterModalId).modal("show") }
|
||||||
|
);
|
||||||
|
})
|
||||||
|
|
||||||
|
getTableFiltersComponent(filterTableId).find(".table-del-btn").on("click", async function() {
|
||||||
|
const rows = getSelectedTableRows(filterTableId);
|
||||||
|
const isMany = rows.length > 1;
|
||||||
|
const names = rows.map(row => row.name);
|
||||||
|
const namesString = arrayToHtmlList(names, true).prop("outerHTML");
|
||||||
|
|
||||||
|
await confirmationModal(
|
||||||
|
`Delete ${isMany ? "Many Content Filters" : "a Content Filter"}`,
|
||||||
|
`Do you wish to permanently delete ${isMany ? "these" : "this"} <b>${names.length}</b> content filter${isMany ? "s" : ""}?<br><br>${namesString}`,
|
||||||
|
"danger",
|
||||||
|
"bi-trash3",
|
||||||
|
async () => {
|
||||||
|
rows.forEach(async row => {
|
||||||
|
await ajaxRequest(`/api/filters/${row.id}/`, "DELETE");
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(async () => {
|
||||||
|
$(filterTableId).trigger("doDataLoad");
|
||||||
|
await loadSubModalOptions(
|
||||||
|
$(subModalId).find('[data-field="filters"]'),
|
||||||
|
`/api/filters/?server=${selectedServer.id}`
|
||||||
|
);
|
||||||
|
}, 600);
|
||||||
|
},
|
||||||
|
null
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// region New/Edit Modal
|
// region New/Edit Modal
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user