From ce7fa5146529d1b243c6bee06464ecd5f935381e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 2 Jun 2016 19:59:41 +1200 Subject: [PATCH] Make checkboxes in user permissions table editable --- .../resources/web/settings/js/settings.js | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/domain-server/resources/web/settings/js/settings.js b/domain-server/resources/web/settings/js/settings.js index 52337db601..f5b7a61d2a 100644 --- a/domain-server/resources/web/settings/js/settings.js +++ b/domain-server/resources/web/settings/js/settings.js @@ -232,6 +232,16 @@ $(document).ready(function(){ badgeSidebarForDifferences($(this)); }); + + // Bootstrap switch in table + $('#' + Settings.FORM_ID).on('switchChange.bootstrapSwitch', 'input.toggle-checkbox', function () { + // Bootstrap switches in table: set the changed data attribute for all rows. + var row = $(this).closest('tr'); + row.find('td.' + Settings.DATA_COL_CLASS + ' input').attr('data-changed', true); + updateDataChangedForSiblingRows(row, true); + }); + + $('.advanced-toggle').click(function(){ Settings.showAdvanced = !Settings.showAdvanced var advancedSelector = $('.' + Settings.ADVANCED_CLASS) @@ -966,16 +976,30 @@ function makeTable(setting, keypath, setting_value, isLocked) { colName = keypath + "." + rowIndexOrName + "." + col.name; } - // setup the td for this column - html += ""; + if (isArray && col.type === "checkbox") { - // add the actual value to the td so it is displayed - html += colValue; + html += "" + html += ""; + } else { + + // setup the td for this column + html += ""; + + // add the actual value to the td so it is displayed + html += colValue; + + // for values to be posted properly we add a hidden input to this td + html += ""; + + html += ""; + } - html += ""; }) if (!isLocked && !setting.read_only) {