From 2eaf401bd6b5391db41c592b46b3553c9a4b4928 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 4 Jun 2016 12:39:55 +1200 Subject: [PATCH] Fix spurious data being submitted from changed permissions in new row --- .../resources/web/settings/js/settings.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/domain-server/resources/web/settings/js/settings.js b/domain-server/resources/web/settings/js/settings.js index 3ddf9722fb..43a3c89534 100644 --- a/domain-server/resources/web/settings/js/settings.js +++ b/domain-server/resources/web/settings/js/settings.js @@ -232,16 +232,17 @@ $(document).ready(function(){ badgeSidebarForDifferences($(this)); }); - // Bootstrap switch in table $('#' + Settings.FORM_ID).on('switchChange.bootstrapSwitch', 'input.table-checkbox', function () { - // Bootstrap switches in table: set the changed data attribute for all rows. + // Bootstrap switches in table: set the changed data attribute for all rows in table. var row = $(this).closest('tr'); - row.find('td.' + Settings.DATA_COL_CLASS + ' input').attr('data-changed', true); - updateDataChangedForSiblingRows(row, true); + if (row.hasClass("value-row")) { // Don't set attribute on input row switches prior to it being added to table. + row.find('td.' + Settings.DATA_COL_CLASS + ' input').attr('data-changed', true); + updateDataChangedForSiblingRows(row, true); + badgeSidebarForDifferences($(this)); + } }); - $('.advanced-toggle').click(function(){ Settings.showAdvanced = !Settings.showAdvanced var advancedSelector = $('.' + Settings.ADVANCED_CLASS) @@ -850,6 +851,7 @@ function reloadSettings(callback) { // setup any bootstrap switches $('.toggle-checkbox').bootstrapSwitch(); + $('.table-checkbox').bootstrapSwitch(); // add tooltip to locked settings $('label.locked').tooltip({ @@ -982,7 +984,7 @@ function makeTable(setting, keypath, setting_value, isLocked) { if (isArray && col.type === "checkbox" && col.editable) { html += "" - + ""; } else { // Use a hidden input so that the values are posted. @@ -1037,7 +1039,7 @@ function makeTableInputs(setting) { _.each(setting.columns, function(col) { if (col.type === "checkbox") { html += "" - + ""; } else { html += "\ @@ -1173,7 +1175,7 @@ function addTableRow(add_glyphicon) { // Hide inputs var input = $(element).find("input") var isCheckbox = false; - if (input.hasClass("toggle-checkbox")) { + if (input.hasClass("table-checkbox")) { input = $(input).parent().parent(); isCheckbox = true; }