Hide non-applicable operators in user scripts config

Fixes #3178
This commit is contained in:
emanuele-f 2020-01-02 10:58:48 +01:00
parent 92ea3cf5a0
commit 9f0fca8c12
2 changed files with 29 additions and 30 deletions

View file

@ -257,13 +257,17 @@
return $("<p>Not enabled!</p>")
}
else if (input_builder == 'threshold_cross') {
var operators = ["gt", "lt"];
var select = $(`<select class='btn btn-outline-secondary'></select>`);
operators.forEach((op) => {
/* If a field_operator is set, only show that operator */
if((!field_operator) || (field_operator == op))
select.append($(`<option value="${op}">&${op}</option>`))
});
return $(`<div class='input-group template w-75'></div>`)
.append(`<div class='input-group-prepend'>
<select class='btn btn-outline-secondary'>
<option selected value="gt">&gt</option>
<option value="lt">&lt;</option>
</select>
</div>`)
.append(`<div class='input-group-prepend'></div>`).html(select)
.append(`<input type='number'
class='form-control'
min='${field_min == undefined ? '' : field_min}'
@ -528,4 +532,4 @@
$disabled_button.html(`${i18n.disabled} (${disabled_count})`);
}
});
});