mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 14:29:13 +02:00
working toward a grid on domain-server settigns page
This commit is contained in:
parent
791744085a
commit
f082201941
2 changed files with 23 additions and 43 deletions
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": 1.2,
|
"version": 1.3,
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
"name": "metaverse",
|
"name": "metaverse",
|
||||||
|
|
|
@ -1089,10 +1089,6 @@ function addTableRow(add_glyphicon) {
|
||||||
var table = row.parents('table')
|
var table = row.parents('table')
|
||||||
var isArray = table.data('setting-type') === 'array'
|
var isArray = table.data('setting-type') === 'array'
|
||||||
|
|
||||||
console.log("------------------------");
|
|
||||||
console.log("table = " + table.name + " " + table.id);
|
|
||||||
console.log("isArray = " + isArray);
|
|
||||||
|
|
||||||
var columns = row.parent().children('.' + Settings.DATA_ROW_CLASS)
|
var columns = row.parent().children('.' + Settings.DATA_ROW_CLASS)
|
||||||
|
|
||||||
if (!isArray) {
|
if (!isArray) {
|
||||||
|
@ -1136,17 +1132,11 @@ function addTableRow(add_glyphicon) {
|
||||||
var table = row.parents("table")
|
var table = row.parents("table")
|
||||||
var setting_name = table.attr("name")
|
var setting_name = table.attr("name")
|
||||||
var full_name = setting_name + "." + key
|
var full_name = setting_name + "." + key
|
||||||
|
|
||||||
console.log("table = " + table);
|
|
||||||
console.log("setting_name = " + setting_name);
|
|
||||||
console.log("full_name = " + full_name);
|
|
||||||
|
|
||||||
row.addClass(Settings.DATA_ROW_CLASS + " " + Settings.NEW_ROW_CLASS)
|
row.addClass(Settings.DATA_ROW_CLASS + " " + Settings.NEW_ROW_CLASS)
|
||||||
row.removeClass("inputs")
|
row.removeClass("inputs")
|
||||||
|
|
||||||
_.each(row.children(), function(element) {
|
_.each(row.children(), function(element) {
|
||||||
if ($(element).hasClass("numbered")) {
|
if ($(element).hasClass("numbered")) {
|
||||||
console.log("A");
|
|
||||||
// Index row
|
// Index row
|
||||||
var numbers = columns.children(".numbered")
|
var numbers = columns.children(".numbered")
|
||||||
if (numbers.length > 0) {
|
if (numbers.length > 0) {
|
||||||
|
@ -1155,69 +1145,59 @@ function addTableRow(add_glyphicon) {
|
||||||
$(element).html(1)
|
$(element).html(1)
|
||||||
}
|
}
|
||||||
} else if ($(element).hasClass(Settings.REORDER_BUTTONS_CLASS)) {
|
} else if ($(element).hasClass(Settings.REORDER_BUTTONS_CLASS)) {
|
||||||
console.log("B");
|
|
||||||
$(element).html("<td class='" + Settings.REORDER_BUTTONS_CLASSES + "'><a href='javascript:void(0);'"
|
$(element).html("<td class='" + Settings.REORDER_BUTTONS_CLASSES + "'><a href='javascript:void(0);'"
|
||||||
+ " class='" + Settings.MOVE_UP_SPAN_CLASSES + "'></a><a href='javascript:void(0);' class='"
|
+ " class='" + Settings.MOVE_UP_SPAN_CLASSES + "'></a><a href='javascript:void(0);' class='"
|
||||||
+ Settings.MOVE_DOWN_SPAN_CLASSES + "'></span></td>")
|
+ Settings.MOVE_DOWN_SPAN_CLASSES + "'></span></td>")
|
||||||
} else if ($(element).hasClass(Settings.ADD_DEL_BUTTONS_CLASS)) {
|
} else if ($(element).hasClass(Settings.ADD_DEL_BUTTONS_CLASS)) {
|
||||||
console.log("C");
|
|
||||||
// Change buttons
|
// Change buttons
|
||||||
var anchor = $(element).children("a")
|
var anchor = $(element).children("a")
|
||||||
anchor.removeClass(Settings.ADD_ROW_SPAN_CLASSES)
|
anchor.removeClass(Settings.ADD_ROW_SPAN_CLASSES)
|
||||||
anchor.addClass(Settings.DEL_ROW_SPAN_CLASSES)
|
anchor.addClass(Settings.DEL_ROW_SPAN_CLASSES)
|
||||||
} else if ($(element).hasClass("key")) {
|
} else if ($(element).hasClass("key")) {
|
||||||
console.log("D");
|
|
||||||
var input = $(element).children("input")
|
var input = $(element).children("input")
|
||||||
$(element).html(input.val())
|
$(element).html(input.val())
|
||||||
input.remove()
|
input.remove()
|
||||||
} else if ($(element).hasClass(Settings.DATA_COL_CLASS)) {
|
} else if ($(element).hasClass(Settings.DATA_COL_CLASS)) {
|
||||||
console.log("E");
|
|
||||||
// Hide inputs
|
// Hide inputs
|
||||||
console.log("element = " + element);
|
|
||||||
var input = $(element).find("input")
|
var input = $(element).find("input")
|
||||||
|
var isCheckbox = false;
|
||||||
var val = input.val();
|
if (input.hasClass("toggle-checkbox")) {
|
||||||
if (input.attr("type") == "checkbox") {
|
input = $(input).parent().parent();
|
||||||
val = input.is(':checked');
|
isCheckbox = true;
|
||||||
$(element).children().hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input.attr("type", "hidden")
|
var val = input.val();
|
||||||
|
if (isCheckbox) {
|
||||||
|
val = $(input).find("input").is(':checked');
|
||||||
|
// don't hide the checkbox
|
||||||
|
} else {
|
||||||
|
input.attr("type", "hidden")
|
||||||
|
}
|
||||||
|
|
||||||
if (isArray) {
|
if (isArray) {
|
||||||
var row_index = row.siblings('.' + Settings.DATA_ROW_CLASS).length
|
var row_index = row.siblings('.' + Settings.DATA_ROW_CLASS).length
|
||||||
var key = $(element).attr('name')
|
var key = $(element).attr('name')
|
||||||
|
|
||||||
console.log("row_index = " + row_index);
|
|
||||||
console.log("key = " + key);
|
|
||||||
|
|
||||||
// are there multiple columns or just one?
|
// are there multiple columns or just one?
|
||||||
// with multiple we have an array of Objects, with one we have an array of whatever the value type is
|
// with multiple we have an array of Objects, with one we have an array of whatever the value type is
|
||||||
var num_columns = row.children('.' + Settings.DATA_COL_CLASS).length
|
var num_columns = row.children('.' + Settings.DATA_COL_CLASS).length
|
||||||
|
|
||||||
console.log("num_columns = " + num_columns);
|
if (isCheckbox) {
|
||||||
|
$(input).find("input").attr("name", setting_name + "[" + row_index + "]" + (num_columns > 1 ? "." + key : ""))
|
||||||
console.log("input = " + JSON.stringify(input));
|
} else {
|
||||||
console.log("new name = " + setting_name + "[" + row_index + "]" + (num_columns > 1 ? "." + key : ""));
|
input.attr("name", setting_name + "[" + row_index + "]" + (num_columns > 1 ? "." + key : ""))
|
||||||
|
}
|
||||||
input.attr("name", setting_name + "[" + row_index + "]" + (num_columns > 1 ? "." + key : ""))
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
input.attr("name", full_name + "." + $(element).attr("name"))
|
input.attr("name", full_name + "." + $(element).attr("name"))
|
||||||
}
|
}
|
||||||
|
|
||||||
input.attr("data-changed", "true")
|
if (isCheckbox) {
|
||||||
|
$(input).find("input").attr("data-changed", "true");
|
||||||
// if the input is a bootstrapSwitch, we need to move this input up to where it will be found
|
} else {
|
||||||
var inputElement = $(input).detach();
|
input.attr("data-changed", "true");
|
||||||
$(element).append(inputElement);
|
$(element).append(val);
|
||||||
|
}
|
||||||
console.log("input.val() = " + val);
|
|
||||||
|
|
||||||
$(element).append(val)
|
|
||||||
} else {
|
} else {
|
||||||
console.log("F");
|
|
||||||
console.log("Unknown table element")
|
console.log("Unknown table element")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue