Merge branch 'pr/Salandora/patch3' into devel

This commit is contained in:
Gina Häußge 2015-04-23 10:41:34 +02:00
commit a55de71233
8 changed files with 73 additions and 39 deletions

File diff suppressed because one or more lines are too long

View file

@ -431,3 +431,17 @@ function showOfflineOverlay(title, message, reconnectCallback) {
function hideOfflineOverlay() {
$("#offline_overlay").hide();
}
function showConfirmationDialog(message, onacknowledge) {
var confirmationDialog = $("#confirmation_dialog");
var confirmationDialogAck = $(".confirmation_dialog_acknowledge", confirmationDialog);
$(".confirmation_dialog_message", confirmationDialog).text(message);
confirmationDialogAck.unbind("click");
confirmationDialogAck.bind("click", function (e) {
e.preventDefault();
$("#confirmation_dialog").modal("hide");
onacknowledge(e);
});
confirmationDialog.modal("show");
}

View file

@ -317,6 +317,7 @@ $(function() {
$(settings.menuSelector)
.data("invokedOn", $(e.target))
.data("contextParent", $(this))
.show()
.css({
position: "absolute",
@ -330,10 +331,7 @@ $(function() {
$(this).hide();
var $invokedOn = $(this).data("invokedOn");
var $selectedMenu = $(e.target);
settings.menuSelected.call(this, $invokedOn, $selectedMenu);
settings.menuSelected.call(this, $(this).data('invokedOn'), $(this).data('contextParent'), $(e.target));
});
return false;
@ -460,7 +458,7 @@ $(function() {
ko.applyBindings(viewModel, element);
log.debug("View model", viewModel.constructor.name, "bound to", target);
} catch (exc) {
log.error("Could not bind view model", viewModel.constructor.name, "to target", target, ":", exc.stack);
log.error("Could not bind view model", viewModel.constructor.name, "to target", target, ":", (exc.stack || exc));
}
});
}

View file

@ -87,6 +87,10 @@ $(function() {
self.isLoading(data.flags.loading);
};
self.onEventSettingsUpdated = function (payload) {
self.requestData();
};
self.onEventRegisteredMessageReceived = function(payload) {
if (payload.key in self.feedbackControlLookup) {
var outputs = self.feedbackControlLookup[payload.key];
@ -132,7 +136,7 @@ $(function() {
}
if (control.hasOwnProperty("template") && control.hasOwnProperty("key") && control.hasOwnProperty("template_key") && !control.hasOwnProperty("output")) {
control.output = ko.observable("");
control.output = ko.observable(control.defaultValue || "");
if (!self.feedbackControlLookup.hasOwnProperty(control.key)) {
self.feedbackControlLookup[control.key] = {};
}
@ -141,14 +145,18 @@ $(function() {
if (control.hasOwnProperty("children")) {
control.children = ko.observableArray(self._processControls(control.children));
if (!control.hasOwnProperty("layout") || !(control.layout == "vertical" || control.layout == "horizontal")) {
if (!control.hasOwnProperty("layout") || !(control.layout == "vertical" || control.layout == "horizontal" || control.layout == "horizontal_grid")) {
control.layout = "vertical";
}
if (!control.hasOwnProperty("collapsed")) {
control.collapsed = false;
}
}
if (control.hasOwnProperty("input")) {
for (var i = 0; i < control.input.length; i++) {
control.input[i].value = ko.observable(control.input[i].default);
control.input[i].value = ko.observable(control.input[i].defaultValue || "0");
if (!control.input[i].hasOwnProperty("slider")) {
control.input[i].slider = false;
}
@ -199,17 +207,9 @@ $(function() {
}
if (data.confirm) {
var confirmationDialog = $("#confirmation_dialog");
var confirmationDialogAck = $(".confirmation_dialog_acknowledge", confirmationDialog);
$(".confirmation_dialog_message", confirmationDialog).text(data.confirm);
confirmationDialogAck.unbind("click");
confirmationDialogAck.bind("click", function (e) {
e.preventDefault();
$("#confirmation_dialog").modal("hide");
showConfirmationDialog(data.confirm, function (e) {
callback(data);
});
confirmationDialog.modal("show");
} else {
callback(data);
}
@ -341,7 +341,11 @@ $(function() {
self.displayMode = function (customControl) {
if (customControl.hasOwnProperty("children")) {
return "customControls_containerTemplate";
if (customControl.name) {
return "customControls_containerTemplate_collapsable";
} else {
return "customControls_containerTemplate_nameless";
}
} else {
return "customControls_controlTemplate";
}

View file

@ -35,17 +35,9 @@ $(function() {
})
};
if (action.confirm) {
var confirmationDialog = $("#confirmation_dialog");
var confirmationDialogAck = $(".confirmation_dialog_acknowledge", confirmationDialog);
$(".confirmation_dialog_message", confirmationDialog).text(action.confirm);
confirmationDialogAck.unbind("click");
confirmationDialogAck.bind("click", function(e) {
e.preventDefault();
$("#confirmation_dialog").modal("hide");
callback();
showConfirmationDialog(action.confirm, function (e) {
callback();
});
confirmationDialog.modal("show");
} else {
callback();
}

View file

@ -156,6 +156,13 @@ $(function() {
}
});
});
self.settingsDialog.on('beforeSave', function () {
_.each(allViewModels, function (viewModel) {
if (viewModel.hasOwnProperty("onSettingsBeforeSave")) {
viewModel.onSettingsBeforeSave();
}
});
});
};
self.show = function() {
@ -257,7 +264,9 @@ $(function() {
self.terminalFilters(response.terminalFilters);
};
self.saveData = function() {
self.saveData = function () {
self.settingsDialog.trigger("beforeSave");
var data = ko.mapping.toJS(self.settings);
data = _.extend(data, {

View file

@ -595,10 +595,20 @@ ul.dropdown-menu li a {
margin-top: -3px;
}
.custom_section {
h1 {
cursor: pointer;
}
}
.custom_section_horizontal .custom_control {
display: inline-block;
}
.custom_section_vertical .custom_control {
display:block;
}
.custom_control {
.slider {
margin-left: 10px;

View file

@ -105,21 +105,28 @@
<div style="clear: both; display: none;" data-bind="visible: loginState.isUser, template: { name: $root.displayMode, foreach: controls }"></div>
<!-- Templates for custom controls -->
<script type="text/html" id="customControls_containerTemplate_nameless">
<div class="custom_section">
<!-- ko template: { name: 'customControls_containerTemplate', data: $data } --><!-- /ko -->
</div>
</script>
<script type="text/html" id="customControls_containerTemplate_collapsable">
<div class="custom_section">
<h1 onclick="$(this).children().first().toggleClass('icon-caret-down icon-caret-right').parent().next().slideToggle('fast')"><i data-bind="css: {'icon-caret-down': !collapsed, 'icon-caret-right': collapsed}"></i> <span data-bind="text: name"></span></h1>
<!-- ko template: { name: 'customControls_containerTemplate', data: $data } --><!-- /ko -->
</div>
</script>
<script type="text/html" id="customControls_containerTemplate">
<!-- ko if: name -->
<h1 data-bind="text: name"></h1>
<!-- /ko -->
<!-- ko if: layout == 'vertical' -->
<div class="custom_section custom_section_vertical" data-bind="template: { name: $root.displayMode, foreach: children }"></div>
<div class="custom_section_vertical" data-bind="template: { name: $root.displayMode, foreach: children }, css: {hide: collapsed && name}"></div>
<!-- /ko -->
<!-- ko if: layout == 'horizontal' -->
<div class="custom_section custom_section_horizontal" data-bind="template: { name: $root.displayMode, foreach: children }"></div>
<div class="custom_section_horizontal" data-bind="template: { name: $root.displayMode, foreach: children }, css: {hide: collapsed && name}"></div>
<!-- /ko -->
<!-- ko if: layout == 'horizontal_grid' -->
<div class="row-fluid custom_section custom_section_horizontal_grid">
<div class="row-fluid custom_section_horizontal_grid" data-bind="css: {hide: collapsed && name}">
<!-- ko foreach: children -->
<div data-bind="template: { name: $root.displayMode }, css: $root.rowCss($data)"></div>
<!-- /ko -->
@ -135,7 +142,7 @@
</script>
<script type="text/html" id="customControls_controlTemplate_input">
<!-- ko foreach: input -->
<label data-bind="text: name"></label>
<label style="cursor: default" data-bind="text: name"></label>
<!-- ko if: slider -->
<input type="number" style="width: 100px" data-bind="slider: {value: value, min: slider.min, max: slider.max, step: slider.step}">
<!-- /ko -->
@ -145,7 +152,7 @@
<!-- /ko -->
</script>
<script type="text/html" id="customControls_controlTemplate_output">
<label data-bind="text: output"></label>
<label style="cursor: default" data-bind="text: output"></label>
</script>
<script type="text/html" id="customControls_controlTemplate_command">
<button class="btn" data-bind="text: name, enable: $root.isCustomEnabled($data), click: function() { $root.clickCustom($data) }"></button>