Reorganized treeview code for AdminPage treeview.

This commit is contained in:
Jan Böhmer 2022-07-31 15:54:27 +02:00
parent fc90259032
commit 5ec87f911b
4 changed files with 26 additions and 21 deletions

View file

@ -1,3 +1,5 @@
{% import "components/tree_macros.html.twig" as tree %}
{% extends "main_card.html.twig" %} {% extends "main_card.html.twig" %}
{% block title %} {% block title %}
@ -23,7 +25,7 @@
<div class="col-sm-4"> <div class="col-sm-4">
<turbo-frame id="admin-tree-frame" target="admin-content-frame" data-turbo-action="advance"> <turbo-frame id="admin-tree-frame" target="admin-content-frame" data-turbo-action="advance">
{% include "elements/_tree_view.html.twig" %} {{ tree.treeview(entity) }}
</turbo-frame> </turbo-frame>
</div> </div>

View file

@ -1,4 +1,4 @@
{% import "elements/tree_macros.html.twig" as tree %} {% import "components/tree_macros.html.twig" as tree %}
<div class="nav flex-column"> <div class="nav flex-column">

View file

@ -38,3 +38,25 @@
<div id="tree-categories" {{ stimulus_target('elements/sidebar_tree', 'tree') }}></div> <div id="tree-categories" {{ stimulus_target('elements/sidebar_tree', 'tree') }}></div>
</div> </div>
{% endmacro %} {% endmacro %}
{% macro treeview(entity) %}
<div {{ stimulus_controller('elements/tree') }} data-tree-data="{{ generateTreeData(entity) }}">
<div class="row" >
<div class="col-8">
<input type="search" class="form-control" placeholder="{% trans %}search.placeholder{% endtrans %}" {{ stimulus_action('elements/tree', 'searchInput') }}>
</div>
<div class="btn-group btn-group-sm col-4" role="group">
<button type="button" class="btn btn-outline-secondary" {{ stimulus_action('elements/tree', 'expandAll') }}
title="{% trans %}expandAll{% endtrans %}">
<i class="fas fa-plus fa-fw"></i>
</button>
<button type="button" class="btn btn-outline-secondary" {{ stimulus_action('elements/tree', 'collapseAll') }}
title="{% trans %}reduceAll{% endtrans %}">
<i class="fas fa-minus fa-fw"></i>
</button>
</div>
</div>
<div class="treeview-sm mt-2" {{ stimulus_target('elements/tree', 'tree') }}></div>
</div>
{% endmacro %}

View file

@ -1,19 +0,0 @@
<div {{ stimulus_controller('elements/tree') }} data-tree-data="{{ generateTreeData(entity) }}">
<div class="row" >
<div class="col-8">
<input type="search" class="form-control" placeholder="{% trans %}search.placeholder{% endtrans %}" {{ stimulus_action('elements/tree', 'searchInput') }}>
</div>
<div class="btn-group btn-group-sm col-4" role="group">
<button type="button" class="btn btn-outline-secondary" {{ stimulus_action('elements/tree', 'expandAll') }}
title="{% trans %}expandAll{% endtrans %}">
<i class="fas fa-plus fa-fw"></i>
</button>
<button type="button" class="btn btn-outline-secondary" {{ stimulus_action('elements/tree', 'collapseAll') }}
title="{% trans %}reduceAll{% endtrans %}">
<i class="fas fa-minus fa-fw"></i>
</button>
</div>
</div>
<div class="treeview-sm mt-2" {{ stimulus_target('elements/tree', 'tree') }}></div>
</div>