Skip to content

Commit

Permalink
Add function to restore previous values when user cancels the edition
Browse files Browse the repository at this point in the history
Signed-off-by: RD WebDesign <[email protected]>
  • Loading branch information
rdwebdesign committed Mar 19, 2024
1 parent 9f9ec58 commit bc13e17
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scripts/pi-hole/js/settings-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,26 @@ function saveRecord() {
}

function restoreRecord() {
// Find the row index
const index = $(this).attr("data-index");

// Reset values
$("#enabled_" + index).prop("checked", $("#enabled_" + index).attr("data-initial-value"));
$("#network_" + index).val($("#network_" + index).attr("data-initial-value"));
$("#ip_" + index).val($("#ip_" + index).attr("data-initial-value"));
$("#domain_" + index).val($("#domain_" + index).attr("data-initial-value"));

// Show cancellation message
utils.showAlert("info", "fas fa-undo", "Operation canceled", "Original values restored");

// Finish the edition disabling the fields
$(this).closest("tr").find("td input").prop("disabled", true);

// Show EDIT and DELETE buttons. Hide SAVE and UNDO buttons
$(this).siblings('[id^="edit"]').show();
$(this).siblings('[id^="delete"]').show();
$(this).siblings('[id^="save"]').hide();
$(this).hide();
}

function deleteRecord() {
Expand Down

0 comments on commit bc13e17

Please sign in to comment.