Merge pull request #4919 from birarda/master

repairs to domain-server settings for hashes
This commit is contained in:
Seth Alves 2015-05-20 17:59:12 -07:00
commit a935b923c8
2 changed files with 42 additions and 23 deletions

View file

@ -65,6 +65,10 @@ td.buttons {
width: 30px; width: 30px;
} }
td.buttons.reorder-buttons {
width: 40px;
}
td .glyphicon { td .glyphicon {
text-align: center; text-align: center;
font-size: 12px; font-size: 12px;

View file

@ -168,12 +168,20 @@ $(document).ready(function(){
if (sibling.hasClass(Settings.DATA_COL_CLASS)) { if (sibling.hasClass(Settings.DATA_COL_CLASS)) {
// set focus to next input // set focus to next input
sibling.find('input').focus() sibling.find('input').focus();
} else if (sibling.hasClass(Settings.ADD_DEL_BUTTONS_CLASS)) { } else {
sibling.find('.' + Settings.ADD_ROW_BUTTON_CLASS).click()
// set focus to the first input in the new row // jump over the re-order row, if that's what we're on
$target.closest('table').find('tr.inputs input:first').focus() if (sibling.hasClass(Settings.REORDER_BUTTONS_CLASS)) {
sibling = sibling.next();
}
if (sibling.hasClass(Settings.ADD_DEL_BUTTONS_CLASS)) {
sibling.find('.' + Settings.ADD_ROW_BUTTON_CLASS).click()
// set focus to the first input in the new row
$target.closest('table').find('tr.inputs input:first').focus()
}
} }
} else if ($target.is('input')) { } else if ($target.is('input')) {
@ -767,7 +775,8 @@ $('body').on('click', '.save-button', function(e){
}); });
function makeTable(setting, keypath, setting_value, isLocked) { function makeTable(setting, keypath, setting_value, isLocked) {
var isArray = !_.has(setting, 'key') var isArray = !_.has(setting, 'key');
var isHash = !isArray;
if (!isArray && setting.can_order) { if (!isArray && setting.can_order) {
setting.can_order = false; setting.can_order = false;
@ -780,7 +789,8 @@ function makeTable(setting, keypath, setting_value, isLocked) {
} }
html += "<table class='table table-bordered " + (isLocked ? "locked-table" : "") + "' data-short-name='" + setting.name html += "<table class='table table-bordered " + (isLocked ? "locked-table" : "") + "' data-short-name='" + setting.name
+ "' name='" + keypath + "' id='" + setting.html_id + "' data-setting-type='" + (isArray ? 'array' : 'hash') + "'>"; + "' name='" + keypath + "' id='" + (typeof setting.html_id !== 'undefined' ? setting.html_id : keypath)
+ "' data-setting-type='" + (isArray ? 'array' : 'hash') + "'>";
// Column names // Column names
html += "<tr class='headers'>" html += "<tr class='headers'>"
@ -799,8 +809,8 @@ function makeTable(setting, keypath, setting_value, isLocked) {
if (!isLocked && !setting.read_only) { if (!isLocked && !setting.read_only) {
if (setting.can_order) { if (setting.can_order) {
html += "<td class=" + Settings.REORDER_BUTTONS_CLASSES + html += "<td class='" + Settings.REORDER_BUTTONS_CLASSES +
"><a href='javascript:void(0);' class='glyphicon glyphicon-sort'></a></td>"; "'><a href='javascript:void(0);' class='glyphicon glyphicon-sort'></a></td>";
} }
html += "<td class='" + Settings.ADD_DEL_BUTTONS_CLASSES + "'></td></tr>" html += "<td class='" + Settings.ADD_DEL_BUTTONS_CLASSES + "'></td></tr>"
} }
@ -809,33 +819,38 @@ function makeTable(setting, keypath, setting_value, isLocked) {
var row_num = 1; var row_num = 1;
if (keypath.length > 0 && _.size(setting_value) > 0) { if (keypath.length > 0 && _.size(setting_value) > 0) {
_.each(setting_value, function(row, indexOrName) { _.each(setting_value, function(row, rowIndexOrName) {
html += "<tr class='" + Settings.DATA_ROW_CLASS + "'" + (isArray ? "" : "name='" + keypath + "." + indexOrName + "'") + ">" html += "<tr class='" + Settings.DATA_ROW_CLASS + "'" + (isArray ? "" : "name='" + keypath + "." + rowIndexOrName + "'") + ">"
if (setting.numbered === true) { if (setting.numbered === true) {
html += "<td class='numbered'>" + row_num + "</td>" html += "<td class='numbered'>" + row_num + "</td>"
} }
if (setting.key) { if (setting.key) {
html += "<td class='key'>" + indexOrName + "</td>" html += "<td class='key'>" + rowIndexOrName + "</td>"
} }
_.each(setting.columns, function(col) { _.each(setting.columns, function(col) {
html += "<td class='" + Settings.DATA_COL_CLASS + "'>"
if (isArray) { if (isArray) {
rowIsObject = setting.columns.length > 1 rowIsObject = setting.columns.length > 1;
colValue = rowIsObject ? row[col.name] : row colValue = rowIsObject ? row[col.name] : row;
html += colValue colName = keypath + "[" + rowIndexOrName + "]" + (rowIsObject ? "." + col.name : "");
} else {
// for arrays we add a hidden input to this td so that values can be posted appropriately colValue = row[col.name];
html += "<input type='hidden' name='" + keypath + "[" + indexOrName + "]" colName = keypath + "." + rowIndexOrName + "." + col.name;
+ (rowIsObject ? "." + col.name : "") + "' value='" + colValue + "'/>"
} else if (row.hasOwnProperty(col.name)) {
html += row[col.name]
} }
html += "</td>" // setup the td for this column
html += "<td class='" + Settings.DATA_COL_CLASS + "' name='" + colName + "'>";
// 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 += "<input type='hidden' name='" + colName + "' value='" + colValue + "'/>";
html += "</td>";
}) })
if (!isLocked && !setting.read_only) { if (!isLocked && !setting.read_only) {