mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-25 17:25:14 +03:00
Unified LogicConditions selector
This commit is contained in:
parent
dd551f5ecb
commit
c005214a2b
3 changed files with 39 additions and 24 deletions
|
@ -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("");
|
||||
}
|
||||
|
|
22
js/gui.js
22
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();
|
||||
|
|
|
@ -103,21 +103,22 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
|||
<td class="mixer-fixed-value-col"><input type="number" class="mix-rule-fixed-value" min="875" max="2125" disabled /></td> \
|
||||
<td><input type="number" class="mix-rule-rate" step="1" min="-125" max="125" /></td>\
|
||||
<td><input type="number" class="mix-rule-speed" step="1" min="0" max="255" /></td>\
|
||||
<td><select class="mix-rule-condition"></td>\
|
||||
<td class="mixer-table__condition"></td>\
|
||||
<td><span class="btn default_btn narrow red"><a href="#" data-role="role-servo-delete" data-i18n="servoMixerDelete"></a></span></td>\
|
||||
</tr>\
|
||||
');
|
||||
|
||||
const $row = $servoMixTableBody.find('tr:last');
|
||||
const $conditions = $row.find('.mix-rule-condition');
|
||||
|
||||
$conditions.append('<option value="-1">Always</option>')
|
||||
for (let i = 0; i < 16 ; i++) {
|
||||
$conditions.append('<option value="' + i + '">Logic Condition ' + i + ' </option>');
|
||||
}
|
||||
$conditions.val(servoRule.getConditionId()).change(function () {
|
||||
GUI.renderLogicConditionSelect(
|
||||
$row.find('.mixer-table__condition'),
|
||||
LOGIC_CONDITIONS,
|
||||
servoRule.getConditionId(),
|
||||
function () {
|
||||
servoRule.setConditionId($(this).val());
|
||||
});
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
GUI.fillSelect($row.find(".mix-rule-input"), FC.getServoMixInputNames(), servoRule.getInput());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue