mirror of
https://github.com/slawkens/myaac.git
synced 2026-02-03 11:56:22 +01:00
Settings: fix show_if for selects
This commit is contained in:
@@ -37,21 +37,31 @@
|
|||||||
{% for key, value in settings %}
|
{% for key, value in settings %}
|
||||||
{% if value.show_if is defined %}
|
{% if value.show_if is defined %}
|
||||||
$(function () {
|
$(function () {
|
||||||
$('input[name="settings[{{ value.show_if[0] }}]"]').change(function () {
|
{% set inputType = 'input' %}
|
||||||
|
|
||||||
|
{% if settings[value.show_if[0]]['type'] == 'options' %}
|
||||||
|
{% set inputType = 'select' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
$('{{ inputType }}[name="settings[{{ value.show_if[0] }}]"]').change(function () {
|
||||||
performChecks_{{ key }}(this);
|
performChecks_{{ key }}(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
{% if settings[value.show_if[0]]['type'] == 'boolean' %}
|
{% if settings[value.show_if[0]]['type'] == 'boolean' %}
|
||||||
performChecks_{{ key }}('input[name="settings[{{ value.show_if[0] }}]"]:checked');
|
performChecks_{{ key }}('input[name="settings[{{ value.show_if[0] }}]"]:checked');
|
||||||
{% else %}
|
{% else %}
|
||||||
performChecks_{{ key }}('input[name="settings[{{ value.show_if[0] }}]"]');
|
performChecks_{{ key }}('{{ inputType }}[name="settings[{{ value.show_if[0] }}]"]');
|
||||||
{% endif %}
|
{% endif %}
|
||||||
});
|
});
|
||||||
|
|
||||||
function performChecks_{{ key }}(el)
|
function performChecks_{{ key }}(el)
|
||||||
{
|
{
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
let thisVal = $(el).val();
|
let thisVal = $(el).val();
|
||||||
|
{% if settings[value.show_if[0]]['type'] == 'options' %}
|
||||||
|
thisVal = $(el).find(":selected").val();
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
let operator = '{{ value.show_if[1]|raw }}';
|
let operator = '{{ value.show_if[1]|raw }}';
|
||||||
if (operator === '>') {
|
if (operator === '>') {
|
||||||
|
|||||||
Reference in New Issue
Block a user