mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-09 22:08:19 +02:00
complete addition of paths to DS settings
This commit is contained in:
parent
3daabd262b
commit
c66bd9b1aa
7 changed files with 197 additions and 203 deletions
|
@ -55,7 +55,7 @@
|
|||
"key": {
|
||||
"name": "path",
|
||||
"label": "Path",
|
||||
"placeholder": "/garden"
|
||||
"placeholder": "/"
|
||||
},
|
||||
"columns": [
|
||||
{
|
||||
|
@ -63,12 +63,7 @@
|
|||
"label": "Viewpoint",
|
||||
"placeholder": "/512,512,512"
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"/": {
|
||||
"viewpoint": "/512,512,512"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -21,22 +21,18 @@ var Settings = {
|
|||
};
|
||||
|
||||
var viewHelpers = {
|
||||
getFormGroup: function(groupName, setting, values, isAdvanced, isLocked) {
|
||||
if (groupName) {
|
||||
setting_name = groupName + "." + setting.name;
|
||||
} else {
|
||||
setting_name = setting.name;
|
||||
}
|
||||
|
||||
getFormGroup: function(keypath, setting, values, isAdvanced, isLocked) {
|
||||
form_group = "<div class='form-group " + (isAdvanced ? Settings.ADVANCED_CLASS : "") + "'>";
|
||||
|
||||
if (_.has(values, groupName) && _.has(values[groupName], setting.name)) {
|
||||
setting_value = values[groupName][setting.name];
|
||||
} else if (_.has(setting, 'default')) {
|
||||
setting_value = _(values).valueForKeyPath(keypath);
|
||||
|
||||
if (!setting_value) {
|
||||
if (_.has(setting, 'default')) {
|
||||
setting_value = setting.default;
|
||||
} else {
|
||||
setting_value = "";
|
||||
}
|
||||
}
|
||||
|
||||
label_class = 'control-label';
|
||||
if (isLocked) {
|
||||
|
@ -44,15 +40,15 @@ var viewHelpers = {
|
|||
}
|
||||
|
||||
common_attrs = " class='" + (setting.type !== 'checkbox' ? 'form-control' : '')
|
||||
+ " " + Settings.TRIGGER_CHANGE_CLASS + "' data-short-name='" + setting.name + "' name='" + setting_name + "' "
|
||||
+ "id='" + setting_name + "'";
|
||||
+ " " + Settings.TRIGGER_CHANGE_CLASS + "' data-short-name='" + setting.name + "' name='" + keypath + "' "
|
||||
+ "id='" + keypath + "'";
|
||||
|
||||
if (setting.type === 'checkbox') {
|
||||
if (setting.label) {
|
||||
form_group += "<label class='" + label_class + "'>" + setting.label + "</label>"
|
||||
}
|
||||
form_group += "<div class='checkbox" + (isLocked ? " disabled" : "") + "'>"
|
||||
form_group += "<label for='" + setting_name + "'>"
|
||||
form_group += "<label for='" + keypath + "'>"
|
||||
form_group += "<input type='checkbox'" + common_attrs + (setting_value ? "checked" : "") + (isLocked ? " disabled" : "") + "/>"
|
||||
form_group += " " + setting.help + "</label>";
|
||||
form_group += "</div>"
|
||||
|
@ -60,14 +56,14 @@ var viewHelpers = {
|
|||
input_type = _.has(setting, 'type') ? setting.type : "text"
|
||||
|
||||
if (setting.label) {
|
||||
form_group += "<label for='" + setting_name + "' class='" + label_class + "'>" + setting.label + "</label>";
|
||||
form_group += "<label for='" + keypath + "' class='" + label_class + "'>" + setting.label + "</label>";
|
||||
}
|
||||
|
||||
if (input_type === 'table') {
|
||||
form_group += makeTable(setting, setting_name, setting_value, isLocked)
|
||||
form_group += makeTable(setting, keypath, setting_value, isLocked)
|
||||
} else {
|
||||
if (input_type === 'select') {
|
||||
form_group += "<select class='form-control' data-hidden-input='" + setting_name + "'>'"
|
||||
form_group += "<select class='form-control' data-hidden-input='" + keypath + "'>'"
|
||||
|
||||
_.each(setting.options, function(option) {
|
||||
form_group += "<option value='" + option.value + "'" +
|
||||
|
@ -262,7 +258,7 @@ $('body').on('click', '.save-button', function(e){
|
|||
return false;
|
||||
});
|
||||
|
||||
function makeTable(setting, setting_name, setting_value, isLocked) {
|
||||
function makeTable(setting, keypath, setting_value, isLocked) {
|
||||
var isArray = !_.has(setting, 'key')
|
||||
|
||||
if (!isArray && setting.can_order) {
|
||||
|
@ -275,8 +271,8 @@ function makeTable(setting, setting_name, setting_value, isLocked) {
|
|||
html += "<span class='help-block'>" + setting.help + "</span>"
|
||||
}
|
||||
|
||||
html += "<table class='table table-bordered " + (isLocked ? "locked-table" : "") + "' data-short-name='" + setting.name + "' name='" + setting_name
|
||||
+ "' data-setting-type='" + (isArray ? 'array' : 'hash') + "'>"
|
||||
html += "<table class='table table-bordered " + (isLocked ? "locked-table" : "") + "' data-short-name='" + setting.name
|
||||
+ "' name='" + keypath + "' data-setting-type='" + (isArray ? 'array' : 'hash') + "'>"
|
||||
|
||||
// Column names
|
||||
html += "<tr class='headers'>"
|
||||
|
@ -305,7 +301,7 @@ function makeTable(setting, setting_name, setting_value, isLocked) {
|
|||
var row_num = 1
|
||||
|
||||
_.each(setting_value, function(row, indexOrName) {
|
||||
html += "<tr class='" + Settings.DATA_ROW_CLASS + "'" + (isArray ? "" : "name='" + setting_name + "." + indexOrName + "'") + ">"
|
||||
html += "<tr class='" + Settings.DATA_ROW_CLASS + "'" + (isArray ? "" : "name='" + keypath + "." + indexOrName + "'") + ">"
|
||||
|
||||
if (setting.numbered === true) {
|
||||
html += "<td class='numbered'>" + row_num + "</td>"
|
||||
|
@ -324,7 +320,7 @@ function makeTable(setting, setting_name, setting_value, isLocked) {
|
|||
html += colValue
|
||||
|
||||
// for arrays we add a hidden input to this td so that values can be posted appropriately
|
||||
html += "<input type='hidden' name='" + setting_name + "[" + indexOrName + "]"
|
||||
html += "<input type='hidden' name='" + keypath + "[" + indexOrName + "]"
|
||||
+ (rowIsObject ? "." + col.name : "") + "' value='" + colValue + "'/>"
|
||||
} else if (row.hasOwnProperty(col.name)) {
|
||||
html += row[col.name]
|
||||
|
|
|
@ -49,13 +49,15 @@
|
|||
</div>
|
||||
<div class="panel-body">
|
||||
<% _.each(split_settings[0], function(setting) { %>
|
||||
<%= getFormGroup(group.name, setting, values, false,
|
||||
<% keypath = isGrouped ? group.name + "." + setting.name : setting.name %>
|
||||
<%= getFormGroup(keypath, setting, values, false,
|
||||
(_.has(locked, group.name) && _.has(locked[group.name], setting.name))) %>
|
||||
<% }); %>
|
||||
<% if (!_.isEmpty(split_settings[1])) { %>
|
||||
<% $("#advanced-toggle-button").show() %>
|
||||
<% _.each(split_settings[1], function(setting) { %>
|
||||
<%= getFormGroup(group.name, setting, values, true,
|
||||
<% keypath = isGrouped ? group.name + "." + setting.name : setting.name %>
|
||||
<%= getFormGroup(keypath, setting, values, true,
|
||||
(_.has(locked, group.name) && _.has(locked[group.name], setting.name))) %>
|
||||
<% }); %>
|
||||
<% }%>
|
||||
|
@ -90,6 +92,7 @@
|
|||
|
||||
<!--#include virtual="footer.html"-->
|
||||
<script src='/js/underscore-min.js'></script>
|
||||
<script src='/js/underscore-keypath.min.js'></script>
|
||||
<script src='/js/bootbox.min.js'></script>
|
||||
<script src='/js/sweet-alert.min.js'></script>
|
||||
<script src='/js/settings.js'></script>
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
<script src='js/json.human.js'></script>
|
||||
<script src='js/highcharts-custom.js'></script>
|
||||
<script src='/js/underscore-min.js'></script>
|
||||
<script src='js/underscore-keypath.min.js'></script>
|
||||
<script src='/js/underscore-keypath.min.js'></script>
|
||||
<script src='/js/bootbox.min.js'></script>
|
||||
<!--#include virtual="page-end.html"-->
|
||||
|
|
|
@ -159,7 +159,7 @@ void HifiConfigVariantMap::addMissingValuesToExistingMap(QVariantMap& existingMa
|
|||
}
|
||||
}
|
||||
|
||||
const QVariant* valueForKeyPath(QVariantMap& variantMap, const QString& keyPath) {
|
||||
QVariant* valueForKeyPath(QVariantMap& variantMap, const QString& keyPath) {
|
||||
int dotIndex = keyPath.indexOf('.');
|
||||
|
||||
QString firstKey = (dotIndex == -1) ? keyPath : keyPath.mid(0, dotIndex);
|
||||
|
|
|
@ -37,6 +37,6 @@ private:
|
|||
void addMissingValuesToExistingMap(QVariantMap& existingMap, const QVariantMap& newMap);
|
||||
};
|
||||
|
||||
const QVariant* valueForKeyPath(QVariantMap& variantMap, const QString& keyPath);
|
||||
QVariant* valueForKeyPath(QVariantMap& variantMap, const QString& keyPath);
|
||||
|
||||
#endif // hifi_HifiConfigVariantMap_h
|
||||
|
|
Loading…
Reference in a new issue