2022-07-31 15:50:16 +02:00
|
|
|
{% macro sidebar_dropdown() %}
|
2025-11-12 21:35:02 +01:00
|
|
|
{% set currentLocale = app.request.locale %}
|
|
|
|
|
|
2022-10-31 22:47:45 +01:00
|
|
|
{# Format is [mode, route, label, show_condition] #}
|
2022-07-31 15:50:16 +02:00
|
|
|
{% set data_sources = [
|
2025-11-12 21:35:02 +01:00
|
|
|
['categories', path('tree_category_root'), '@category@@', is_granted('@categories.read') and is_granted('@parts.read')],
|
|
|
|
|
['locations', path('tree_location_root'), '@storage_location@@', is_granted('@storelocations.read') and is_granted('@parts.read'), ],
|
|
|
|
|
['footprints', path('tree_footprint_root'), '@footprint@@', is_granted('@footprints.read') and is_granted('@parts.read')],
|
|
|
|
|
['manufacturers', path('tree_manufacturer_root'), '@manufacturer@@', is_granted('@manufacturers.read') and is_granted('@parts.read'), 'manufacturer'],
|
|
|
|
|
['suppliers', path('tree_supplier_root'), '@supplier@@', is_granted('@suppliers.read') and is_granted('@parts.read'), 'supplier'],
|
|
|
|
|
['projects', path('tree_device_root'), '@project@@', is_granted('@projects.read'), 'project'],
|
|
|
|
|
['tools', path('tree_tools'), 'tools.label', true, 'tool'],
|
2022-07-31 15:50:16 +02:00
|
|
|
] %}
|
|
|
|
|
|
|
|
|
|
<li class="dropdown-header">{% trans %}actions{% endtrans %}</li>
|
|
|
|
|
<li><button class="tree-btns dropdown-item" {{ stimulus_action('elements/sidebar_tree', 'expandAll') }}">{% trans %}expandAll{% endtrans %}</a></li>
|
|
|
|
|
<li><button class="tree-btns dropdown-item" {{ stimulus_action('elements/sidebar_tree', 'collapseAll') }}">{% trans %}reduceAll{% endtrans %}</a></li>
|
|
|
|
|
<li role="separator" class="dropdown-divider"></li>
|
|
|
|
|
<li class="dropdown-header">{% trans %}datasource{% endtrans %}</li>
|
|
|
|
|
|
|
|
|
|
{% for source in data_sources %}
|
2022-10-31 22:47:45 +01:00
|
|
|
{% if source[3] %} {# show_condition #}
|
2025-11-12 21:35:02 +01:00
|
|
|
<li>
|
|
|
|
|
{% if source[2] starts with '@' %}
|
|
|
|
|
{% set label = type_label_p(source[2]|replace({'@': ''})) %}
|
|
|
|
|
{% else %}
|
|
|
|
|
{% set label = source[2]|trans %}
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
|
<button class="tree-btns dropdown-item"
|
|
|
|
|
data-mode="{{ source[0] }}"
|
|
|
|
|
data-url="{{ source[1] }}"
|
|
|
|
|
data-text="{{ label }}"
|
|
|
|
|
{{ stimulus_action('elements/sidebar_tree', 'changeDataSource') }}
|
|
|
|
|
>{{ label }}</button>
|
|
|
|
|
</li>
|
2022-10-31 22:47:45 +01:00
|
|
|
{% endif %}
|
2022-07-31 15:50:16 +02:00
|
|
|
{% endfor %}
|
|
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
|
|
{% macro treeview_sidebar(id, default_mode) %}
|
|
|
|
|
<div {{ stimulus_controller('elements/sidebar_tree') }} data-default-mode="{{ default_mode }}" id="{{ id }}">
|
|
|
|
|
<div class="input-group input-group-sm mb-2 mt-1">
|
2023-06-20 01:01:40 +02:00
|
|
|
<button class="btn bg-body-tertiary dropdown-toggle" type="button"
|
2022-07-31 15:50:16 +02:00
|
|
|
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
|
2022-10-31 22:47:45 +01:00
|
|
|
><span class="sidebar-title" {{ stimulus_target('elements/sidebar_tree', 'sourceText') }}>Loading... / Access Denied</span></button>
|
2022-07-31 15:50:16 +02:00
|
|
|
<ul class="dropdown-menu" aria-labelledby="dropdownCat">
|
|
|
|
|
{{ _self.sidebar_dropdown('tree-categories') }}
|
|
|
|
|
</ul>
|
2023-06-19 01:08:11 +02:00
|
|
|
<input type="search" class="form-control bg-body-tertiary border-0" placeholder="{% trans %}search.placeholder{% endtrans %}" {{ stimulus_action('elements/sidebar_tree', 'searchInput') }}>
|
2022-07-31 15:50:16 +02:00
|
|
|
</div>
|
|
|
|
|
|
2022-08-05 00:24:28 +02:00
|
|
|
<div id="{{ id }}Tree" {{ stimulus_target('elements/sidebar_tree', 'tree') }}></div>
|
2022-07-31 15:50:16 +02:00
|
|
|
</div>
|
2022-07-31 15:54:27 +02:00
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
|
|
{% macro treeview(entity) %}
|
2022-09-18 17:50:25 +02:00
|
|
|
<div {{ stimulus_controller('elements/tree') }} data-tree-data="{{ tree_data(entity) }}" data-tree-show-tags="true">
|
2022-07-31 15:54:27 +02:00
|
|
|
<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>
|
2025-11-12 21:35:02 +01:00
|
|
|
{% endmacro %}
|