mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +03:00
Basic render of global function table
This commit is contained in:
parent
a15277ae25
commit
7478f6cd04
8 changed files with 256 additions and 35 deletions
|
@ -100,7 +100,7 @@ let LogicCondition = function (enabled, operation, operandAType, operandAValue,
|
|||
self.setOperandBValue(operandMetadata.default);
|
||||
}
|
||||
|
||||
self.renderOperandValue($container, operandMetadata, operand, operandMetadata.default);
|
||||
GUI.renderOperandValue($container, operandMetadata, operand, operandMetadata.default, self.onOperatorValueChange);
|
||||
};
|
||||
|
||||
self.onOperatorValueChange = function (event) {
|
||||
|
@ -114,39 +114,6 @@ let LogicCondition = function (enabled, operation, operandAType, operandAValue,
|
|||
}
|
||||
};
|
||||
|
||||
self.renderOperandValue = function ($container, operandMetadata, operand, value) {
|
||||
|
||||
$container.find('.logic_element__operand--value').remove();
|
||||
|
||||
switch (operandMetadata.type) {
|
||||
case "value":
|
||||
$container.append('<input type="number" class="logic_element__operand--value" data-operand="' + operand + '" step="' + operandMetadata.step + '" min="' + operandMetadata.min + '" max="' + operandMetadata.max + '" value="' + value + '" />');
|
||||
break;
|
||||
case "range":
|
||||
case "dictionary":
|
||||
$container.append('<select class="logic_element__operand--value" data-operand="' + operand + '"></select>');
|
||||
let $t = $container.find('.logic_element__operand--value');
|
||||
|
||||
if (operandMetadata.type == "range") {
|
||||
for (let i = operandMetadata.range[0]; i <= operandMetadata.range[1]; i++) {
|
||||
$t.append('<option value="' + i + '">' + i + '</option>');
|
||||
}
|
||||
} else if (operandMetadata.type == "dictionary") {
|
||||
for (let k in operandMetadata.values) {
|
||||
if (operandMetadata.values.hasOwnProperty(k)) {
|
||||
$t.append('<option value="' + k + '">' + operandMetadata.values[k] + '</option>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$t.val(value);
|
||||
break;
|
||||
}
|
||||
|
||||
$container.find('.logic_element__operand--value').change(self.onOperatorValueChange);
|
||||
|
||||
};
|
||||
|
||||
self.renderOperand = function (operand) {
|
||||
let type, value, $container;
|
||||
if (operand == 0) {
|
||||
|
@ -175,7 +142,7 @@ let LogicCondition = function (enabled, operation, operandAType, operandAValue,
|
|||
/*
|
||||
* Render value element depending on type
|
||||
*/
|
||||
self.renderOperandValue($container, op, operand, value);
|
||||
GUI.renderOperandValue($container, op, operand, value, self.onOperatorValueChange);
|
||||
|
||||
} else {
|
||||
$t.append('<option value="' + k + '">' + op.name + '</option>');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue