WIP: Streamlining controls to not overly depend on types anymore

This commit is contained in:
Gina Häußge 2015-03-09 11:40:47 +01:00
parent 8f6784d5d2
commit 8cba11930f
3 changed files with 18 additions and 20 deletions

View file

@ -98,22 +98,22 @@ of the types: ``name`` and ``type``.
Types
-----
.. _sec-configuration-custom_controls-types:
.. _sec-configuration-custom_controls-types-sections:
Sections
........
.. _sec-configuration-custom_controls-types:
.. _sec-configuration-custom_controls-types-rows:
Rows
....
.. _sec-configuration-custom_controls-types:
.. _sec-configuration-custom_controls-types-section_rows:
Section rows
............
.. _sec-configuration-custom_controls-types:
.. _sec-configuration-custom_controls-types-commands:
Commands
........

View file

@ -125,8 +125,13 @@ $(function() {
if (control.type == "feedback_command" || control.type == "feedback") {
control.output = ko.observable("");
self.feedbackControlLookup[control.name] = control.output;
} else if (control.type == "section" || control.type == "row" || control.type == "section_row") {
}
if (control.hasOwnProperty("children")) {
control.children = self._processControls(control.children);
if (!control.hasOwnProperty("layout") || !(control.layout == "vertical" || control.layout == "horizontal")) {
control.layout = "vertical";
}
}
if (control.hasOwnProperty("input")) {
@ -324,12 +329,9 @@ $(function() {
self.displayMode = function (customControl) {
switch (customControl.type) {
case "container":
case "section":
return "customControls_sectionTemplate";
case "row":
return "customControls_rowTemplate";
case "section_row":
return "customControls_sectionRowTemplate";
case "command":
case "commands":
case "script":

View file

@ -106,25 +106,21 @@
<!-- Templates for custom controls -->
<script type="text/html" id="customControls_sectionTemplate">
<!-- ko if: name -->
<h1 data-bind="text: name"></h1>
<!-- /ko -->
<!-- ko if: layout == 'vertical' -->
<div class="custom_section" data-bind="template: { name: $root.displayMode, foreach: children }"></div>
</script>
<script type="text/html" id="customControls_rowTemplate">
<!-- /ko -->
<!-- ko if: layout == 'horizontal' -->
<div class="row-fluid custom_row">
<!-- ko foreach: children -->
<div data-bind="template: { name: $root.displayMode }, css: $root.rowCss($data)"></div>
<!-- /ko -->
</div>
</script>
<script type="text/html" id="customControls_sectionRowTemplate">
<h1 data-bind="text: name"></h1>
<div class="row-fluid custom_row custom_section">
<!-- ko foreach: children -->
<div data-bind="template: { name: $root.displayMode }, css: $root.rowCss($data)"></div>
<!-- /ko -->
</div>
<!-- /ko -->
</script>
<script type="text/html" id="customControls_commandTemplate">
<form class="form-inline custom_command">