Some bugfixing, optimization and cleaning
This commit is contained in:
parent
75cb6dda74
commit
b7179b75a8
@ -88,10 +88,10 @@
|
|||||||
var input = {
|
var input = {
|
||||||
name: ko.observable(element.name),
|
name: ko.observable(element.name),
|
||||||
parameter: ko.observable(element.parameter),
|
parameter: ko.observable(element.parameter),
|
||||||
default: ko.observable(element.default != "" ? element.default : undefined)
|
default: ko.observable(element.hasOwnProperty("default") ? element.default : undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.hasOwnProperty("slider") && typeof element.slider == "object") {
|
if (element.hasOwnProperty("slider") && _.isObject(element.slider)) {
|
||||||
input.slider = {
|
input.slider = {
|
||||||
min: ko.observable(element.slider.min),
|
min: ko.observable(element.slider.min),
|
||||||
max: ko.observable(element.slider.max),
|
max: ko.observable(element.slider.max),
|
||||||
@ -139,8 +139,7 @@
|
|||||||
control.template = ko.observable(control.template);
|
control.template = ko.observable(control.template);
|
||||||
control.regex = ko.observable(control.regex);
|
control.regex = ko.observable(control.regex);
|
||||||
control.default = ko.observable(control.default || "");
|
control.default = ko.observable(control.default || "");
|
||||||
control.value = control.default;
|
control.value = ko.computed(function () { return control.default(); });
|
||||||
|
|
||||||
|
|
||||||
delete control.key;
|
delete control.key;
|
||||||
delete control.template_key;
|
delete control.template_key;
|
||||||
@ -284,7 +283,7 @@
|
|||||||
if (element.hasOwnProperty("template")) {
|
if (element.hasOwnProperty("template")) {
|
||||||
data.template = element.template();
|
data.template = element.template();
|
||||||
data.regex = element.regex();
|
data.regex = element.regex();
|
||||||
data.default = element.default() || "";
|
data.defaultValue = element.default() || "";
|
||||||
|
|
||||||
title = "Edit Output";
|
title = "Edit Output";
|
||||||
type = "output";
|
type = "output";
|
||||||
@ -327,10 +326,10 @@
|
|||||||
{
|
{
|
||||||
data.input = [];
|
data.input = [];
|
||||||
_.each(element.input(), function (element, index, list) {
|
_.each(element.input(), function (element, index, list) {
|
||||||
|
data.input[index] = ko.mapping.toJS(element);
|
||||||
if (element.hasOwnProperty("default")) {
|
if (element.hasOwnProperty("default")) {
|
||||||
data.input[index].defaultValue = element.default;
|
data.input[index].defaultValue = element.default;
|
||||||
}
|
}
|
||||||
data.input[index] = ko.mapping.toJS(element);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,9 +393,9 @@
|
|||||||
element.regex = ko.observable(ret.regex);
|
element.regex = ko.observable(ret.regex);
|
||||||
|
|
||||||
if (element.hasOwnProperty("default"))
|
if (element.hasOwnProperty("default"))
|
||||||
element.default(ret.defaultValue);
|
element.default(ret.default);
|
||||||
else
|
else
|
||||||
element.default = ko.observable(ret.defaultValue);
|
element.default = ko.observable(ret.default);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -490,34 +489,50 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.recursiveDeleteProperties = function (list) {
|
self.recursiveDeleteProperties = function (list) {
|
||||||
for (var i = 0; i < list.length; i++) {
|
_.each(list, function (element, index, ll) {
|
||||||
if (!list[i].parent || (list[i].parent.hasOwnProperty("layout") && list[i].parent.layout() != "horizontal_grid"))
|
if (!element.parent || (element.parent.hasOwnProperty("layout") && element.parent.layout() != "horizontal_grid")) {
|
||||||
{
|
delete element.width;
|
||||||
delete list[i].width;
|
delete element.offset;
|
||||||
delete list[i].offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete list[i].id;
|
if (element.default == "")
|
||||||
delete list[i].parent;
|
delete element.default;
|
||||||
delete list[i].processed;
|
|
||||||
delete list[i].output;
|
|
||||||
delete list[i].key;
|
|
||||||
delete list[i].template_key;
|
|
||||||
delete list[i].value;
|
|
||||||
|
|
||||||
if (list[i].hasOwnProperty("width") && list[i].width() == "")
|
delete element.id;
|
||||||
delete list[i].width;
|
delete element.parent;
|
||||||
if (list[i].hasOwnProperty("offset") && list[i].offset() == "")
|
delete element.processed;
|
||||||
delete list[i].offset;
|
delete element.output;
|
||||||
|
delete element.key;
|
||||||
|
delete element.template_key;
|
||||||
|
delete element.value;
|
||||||
|
|
||||||
if (!list[i].hasOwnProperty("name") || list[i].name() == "") {
|
if (element.hasOwnProperty("input")) {
|
||||||
delete list[i].name;
|
_.each(element.input(), function (e, i, l) {
|
||||||
delete list[i].collapsable;
|
if (e.default == "")
|
||||||
|
delete e.default;
|
||||||
|
|
||||||
|
delete e.value;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list[i].hasOwnProperty("children"))
|
if (element.hasOwnProperty("width") && element.width() == "")
|
||||||
self.recursiveDeleteProperties(list[i].children());
|
delete element.width;
|
||||||
|
if (element.hasOwnProperty("offset") && element.offset() == "")
|
||||||
|
delete element.offset;
|
||||||
|
|
||||||
|
if (!element.hasOwnProperty("name") || element.name() == "") {
|
||||||
|
delete element.name;
|
||||||
|
delete element.collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (element.hasOwnProperty("children")) {
|
||||||
|
if (element.hasOwnProperty("collapsed") && !element.collapsed())
|
||||||
|
delete element.collapsed;
|
||||||
|
|
||||||
|
self.recursiveDeleteProperties(element.children());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
self.onSettingsBeforeSave = function () {
|
self.onSettingsBeforeSave = function () {
|
||||||
self.recursiveDeleteProperties(self.controlsFromServer);
|
self.recursiveDeleteProperties(self.controlsFromServer);
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
<form class="form-inline custom_control" style="min-height:15px; border:1px dotted #000000" data-bind="contextMenu: { menuSelector: '#commandContextMenu', menuSelected: $root.controlContextMenu }, attr: { 'id': id }">
|
<form class="form-inline custom_control" style="min-height:15px; border:1px dotted #000000" data-bind="contextMenu: { menuSelector: '#commandContextMenu', menuSelected: $root.controlContextMenu }, attr: { 'id': id }">
|
||||||
<!-- ko template: { name: 'settingsCustomControls_controlTemplate_input', data: $data, if: $data.hasOwnProperty('input') } --><!-- /ko -->
|
<!-- ko template: { name: 'settingsCustomControls_controlTemplate_input', data: $data, if: $data.hasOwnProperty('input') } --><!-- /ko -->
|
||||||
<!-- ko template: { name: 'settingsCustomControls_controlTemplate_command', data: $data, if: $data.hasOwnProperty('command') || $data.hasOwnProperty('commands') || $data.hasOwnProperty('script') || $data.hasOwnProperty('javascript') } --><!-- /ko -->
|
<!-- ko template: { name: 'settingsCustomControls_controlTemplate_command', data: $data, if: $data.hasOwnProperty('command') || $data.hasOwnProperty('commands') || $data.hasOwnProperty('script') || $data.hasOwnProperty('javascript') } --><!-- /ko -->
|
||||||
<!-- ko template: { name: 'settingsCustomControls_controlTemplate_output', data: $data, if: $data.hasOwnProperty('defaultValue') && defaultValue() } --><!-- /ko -->
|
<!-- ko template: { name: 'settingsCustomControls_controlTemplate_output', data: $data, if: $data.hasOwnProperty('value') } --><!-- /ko -->
|
||||||
</form>
|
</form>
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" id="settingsCustomControls_controlTemplate_input">
|
<script type="text/html" id="settingsCustomControls_controlTemplate_input">
|
||||||
|
Loading…
Reference in New Issue
Block a user