diff --git a/scripts/js/settings-dhcp.js b/scripts/js/settings-dhcp.js index 74ae32d1..8d369ba2 100644 --- a/scripts/js/settings-dhcp.js +++ b/scripts/js/settings-dhcp.js @@ -286,8 +286,8 @@ function parseStaticDHCPLine(line) { }; } -// Save button for each row updates only that line in the textarea -$(document).on("click", ".save-static-row", function () { +// Save button for each row updates only that line in the textarea, if it doesn't contain the class ".disabled" +$(document).on("click", ".save-static-row:not(.disabled)", function () { const rowIdx = Number.parseInt($(this).data("row"), 10); const row = $(this).closest("tr"); const hwaddr = row.find(".static-hwaddr").text().trim(); @@ -365,13 +365,15 @@ $(document).on("focus input", "#StaticDHCPTable td[contenteditable]", function ( ); } }); -// On save, re-enable all buttons and remove the hint + +// On save, re-enable all buttons (except buttons with class "disabled") and remove the hint $(document).on("click", ".save-static-row", function () { $( - "#StaticDHCPTable .save-static-row, #StaticDHCPTable .delete-static-row, #StaticDHCPTable .add-static-row" + "#StaticDHCPTable .save-static-row:not(.disabled), #StaticDHCPTable .delete-static-row, #StaticDHCPTable .add-static-row" ).prop("disabled", false); $(".edit-hint-row").remove(); }); + // On table redraw, ensure all buttons are enabled and hints are removed function renderStaticDHCPTable() { const tbody = $("#StaticDHCPTable tbody"); @@ -379,54 +381,59 @@ function renderStaticDHCPTable() { const lines = $("#dhcp-hosts").val().split(/\r?\n/); for (const [idx, line] of lines.entries()) { const parsed = parseStaticDHCPLine(line); + + const saveBtn = $( + '' + ) + .attr("data-row", idx) + .attr("title", "Confirm changes to this line") + .attr("data-toggle", "tooltip"); + + const delBtn = $( + '' + ) + .attr("data-row", idx) + .attr("title", "Delete this line") + .attr("data-toggle", "tooltip"); + + const addBtn = $( + '' + ) + .attr("data-row", idx) + .attr("title", "Add new line after this") + .attr("data-toggle", "tooltip"); + + const tr = $("