Visual enhancement for custom JS tree widget

* adds proper css behaviour for collapsed icon
* adds minor js comments
This commit is contained in:
mpeltriaux 2022-05-10 15:07:21 +02:00
parent 2c2075fe4a
commit 18789c231d
3 changed files with 17 additions and 3 deletions

View File

@ -262,4 +262,13 @@ Similar to bootstraps 'shadow-lg'
padding-left: 2em; padding-left: 2em;
} }
*/ */
.collapse-icn > i{
transition: all 0.3s ease;
}
.collapsed .collapse-icn > i{
transform: rotate(-90deg);
}
.tree-label.badge{
font-size: 90%;
}

View File

@ -2,11 +2,13 @@
{% for code in codes %} {% for code in codes %}
<div class="ml-4 tree-element"> <div class="ml-4 tree-element">
<label class="tree-label" role="{% if not code.is_leaf%}button{% endif %}" for="input_{{code.pk|unlocalize}}" id="{{code.pk|unlocalize}}" data-toggle="collapse" data-target="#children_{{code.pk|unlocalize}}" aria-expanded="true" aria-controls="children_{{code.pk|unlocalize}}"> <label class="tree-label collapsed" role="{% if not code.is_leaf%}button{% endif %}" for="input_{{code.pk|unlocalize}}" id="{{code.pk|unlocalize}}" data-toggle="collapse" data-target="#children_{{code.pk|unlocalize}}" aria-expanded="true" aria-controls="children_{{code.pk|unlocalize}}">
{% if code.is_leaf%} {% if code.is_leaf%}
<input class="tree-input" id="input_{{code.pk|unlocalize}}" name="{{ widget.name }}" type="checkbox" value="{{code.pk|unlocalize}}" {% if code.pk|unlocalize in widget.value %}checked{% endif %}/> <input class="tree-input" id="input_{{code.pk|unlocalize}}" name="{{ widget.name }}" type="checkbox" value="{{code.pk|unlocalize}}" {% if code.pk|unlocalize in widget.value %}checked{% endif %}/>
{% else %} {% else %}
{% fa5_icon 'angle-right' %} <span class="collapse-icn">
{% fa5_icon 'angle-down' %}
</span>
{% endif %} {% endif %}
{{code.long_name}} {{code.long_name}}
</label> </label>

View File

@ -47,9 +47,12 @@
} }
); );
if(val.length > 0){ if(val.length > 0){
// Hide everything
allTreeElements.hide() allTreeElements.hide()
// Now show again everything matching the query
allTreeElementsContain.show() allTreeElementsContain.show()
}else{ }else{
// Show everything if no query exists
allTreeElements.show() allTreeElements.show()
} }
} }