Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/iNavFlight/inav-configurator.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorPawel Spychalski (DzikuVx) <pspychalski@gmail.com>2020-04-14 12:55:23 +0300
committerPawel Spychalski (DzikuVx) <pspychalski@gmail.com>2020-04-14 12:55:23 +0300
commitc005214a2be16fbdf5024462267b7509f4234778 (patch)
tree64f58c8d904c49d67164c815c92209e216183950 /js
parentdd551f5ecb37a1e34007ef9c4450c5a592b06883 (diff)
Unified LogicConditions selector
Diffstat (limited to 'js')
-rw-r--r--js/globalFunction.js22
-rw-r--r--js/gui.js22
2 files changed, 29 insertions, 15 deletions
diff --git a/js/globalFunction.js b/js/globalFunction.js
index 933ba078..be1a22e2 100644
--- a/js/globalFunction.js
+++ b/js/globalFunction.js
@@ -165,21 +165,13 @@ let GlobalFunction = function (enabled, conditionId, action, operandType, operan
self.renderLogicId = function($row) {
if (self.getEnabled()) {
-
- $row.find('.function_cell__logicId').html("<select class='function__logicId' ></select>");
- let $t = $row.find(".function__logicId");
- let count = LOGIC_CONDITIONS.getCount();
-
- console.log(self.getConditionId());
-
- for (let i = 0; i < count ; i++) {
- if (i == self.getConditionId()) {
- $t.append('<option value="' + i + '" selected>Logic Condition ' + i + ' </option>');
- } else {
- $t.append('<option value="' + i + '">Logic Condition ' + i + ' </option>');
- }
- }
- $t.change(self.onLogicIdChange);
+ GUI.renderLogicConditionSelect(
+ $row.find('.function_cell__logicId'),
+ LOGIC_CONDITIONS,
+ self.getConditionId(),
+ self.onLogicIdChange,
+ true
+ );
} else {
$row.find('.function_cell__logicId').html("");
}
diff --git a/js/gui.js b/js/gui.js
index 4f7362d1..5e30ac1b 100644
--- a/js/gui.js
+++ b/js/gui.js
@@ -292,5 +292,27 @@ GUI_control.prototype.renderOperandValue = function ($container, operandMetadata
$container.find('.logic_element__operand--value').change(onChange);
};
+/**
+ * @param {jQuery} $container
+ * @param {LogicConditionsCollection} logicConditions
+ * @param {int} current
+ * @param {function} onChange
+ * @param {boolean} withAlways
+ */
+GUI_control.prototype.renderLogicConditionSelect = function ($container, logicConditions, current, onChange, withAlways) {
+
+ let $select = $container.append('<select class="mix-rule-condition">').find("select"),
+ lcCount = logicConditions.getCount();
+
+ if (withAlways) {
+ $select.append('<option value="-1">Always</option>')
+ }
+ for (let i = 0; i < lcCount ; i++) {
+ $select.append('<option value="' + i + '">Logic Condition ' + i + ' </option>');
+ }
+
+ $select.val(current).change(onChange);
+}
+
// initialize object into GUI variable
var GUI = new GUI_control();