Entferne alten JSON-basierten Datenquellen-Synonym-Handler

Die Verwaltung der Datenquellen-Synonyme wurde überarbeitet, um ein flexibleres und strukturiertes Konzept zu ermöglichen. Der bestehende JSON-basierte Ansatz wurde durch eine neue Service-basierte Architektur ersetzt, die eine bessere Handhabung und Erweiterbarkeit erlaubt.
This commit is contained in:
Marcel Diegelmann 2025-11-05 12:27:40 +01:00
parent d80ec94227
commit a8b3dce899
30 changed files with 802 additions and 277 deletions

View file

@ -1,9 +1,8 @@
{% extends "admin/base_admin.html.twig" %}
{% block card_title %}
{% set dataSourceName = get_data_source_name('category', 'category.labelp') %}
{% set translatedSource = 'category.labelp'|trans %}
<i class="fas fa-tags fa-fw"></i> {% if dataSourceName != translatedSource %}{{ 'datasource.synonym'|trans({'%name%': translatedSource, '%synonym%': dataSourceName}) }}{% else %}{{ translatedSource }}{% endif %}
<i class="fas fa-tags fa-fw"></i>
{{ data_source_name_with_hint('category', 'category.label') }}
{% endblock %}
{% block additional_pills %}
@ -63,4 +62,4 @@
</div>
{{ form_row(form.eda_info.kicad_symbol) }}
</div>
{% endblock %}
{% endblock %}

View file

@ -1,9 +1,8 @@
{% extends "admin/base_admin.html.twig" %}
{% block card_title %}
{% set dataSourceName = get_data_source_name('footprint', 'footprint.labelp') %}
{% set translatedSource = 'footprint.labelp'|trans %}
<i class="fas fa-microchip fa-fw"></i> {% if dataSourceName != translatedSource %}{{ 'datasource.synonym'|trans({'%name%': translatedSource, '%synonym%': dataSourceName}) }}{% else %}{{ translatedSource }}{% endif %}
<i class="fas fa-microchip fa-fw"></i>
{{ data_source_name_with_hint('footprint', 'footprint.labelp') }}
{% endblock %}
{% block master_picture_block %}
@ -36,4 +35,4 @@
</div>
{{ form_row(form.eda_info.kicad_footprint) }}
</div>
{% endblock %}
{% endblock %}

View file

@ -1,9 +1,8 @@
{% extends "admin/base_company_admin.html.twig" %}
{% block card_title %}
{% set dataSourceName = get_data_source_name('manufacturer', 'manufacturer.caption') %}
{% set translatedSource = 'manufacturer.caption'|trans %}
<i class="fas fa-industry fa-fw"></i> {% if dataSourceName != translatedSource %}{{ 'datasource.synonym'|trans({'%name%': translatedSource, '%synonym%': dataSourceName}) }}{% else %}{{ translatedSource }}{% endif %}
<i class="fas fa-industry fa-fw"></i>
{{ data_source_name_with_hint('manufacturer', 'manufacturer.caption') }}
{% endblock %}
{% block edit_title %}
@ -12,4 +11,4 @@
{% block new_title %}
{% trans %}manufacturer.new{% endtrans %}
{% endblock %}
{% endblock %}

View file

@ -3,9 +3,8 @@
{# @var entity App\Entity\ProjectSystem\Project #}
{% block card_title %}
{% set dataSourceName = get_data_source_name('project', 'project.caption') %}
{% set translatedSource = 'project.caption'|trans %}
<i class="fas fa-archive fa-fw"></i> {% if dataSourceName != translatedSource %}{{ 'datasource.synonym'|trans({'%name%': translatedSource, '%synonym%': dataSourceName}) }}{% else %}{{ translatedSource }}{% endif %}
<i class="fas fa-archive fa-fw"></i>
{{ data_source_name_with_hint('project', 'project.labelp') }}
{% endblock %}
{% block edit_title %}
@ -61,4 +60,4 @@
</a>
{% endif %}
</div>
{% endblock %}
{% endblock %}

View file

@ -2,9 +2,8 @@
{% import "label_system/dropdown_macro.html.twig" as dropdown %}
{% block card_title %}
{% set dataSourceName = get_data_source_name('storagelocation', 'storelocation.labelp') %}
{% set translatedSource = 'storelocation.labelp'|trans %}
<i class="fas fa-cube fa-fw"></i> {% if dataSourceName != translatedSource %}{{ 'datasource.synonym'|trans({'%name%': translatedSource, '%synonym%': dataSourceName}) }}{% else %}{{ translatedSource }}{% endif %}
<i class="fas fa-cube fa-fw"></i>
{{ data_source_name_with_hint('storagelocation', 'storelocation.labelp') }}
{% endblock %}
{% block additional_controls %}
@ -40,4 +39,4 @@
{% block new_title %}
{% trans %}storelocation.new{% endtrans %}
{% endblock %}
{% endblock %}

View file

@ -1,9 +1,8 @@
{% extends "admin/base_company_admin.html.twig" %}
{% block card_title %}
{% set dataSourceName = get_data_source_name('supplier', 'supplier.caption') %}
{% set translatedSource = 'supplier.caption'|trans %}
<i class="fas fa-truck fa-fw"></i> {% if dataSourceName != translatedSource %}{{ 'datasource.synonym'|trans({'%name%': translatedSource, '%synonym%': dataSourceName}) }}{% else %}{{ translatedSource }}{% endif %}
<i class="fas fa-truck fa-fw"></i>
{{ data_source_name_with_hint('supplier', 'supplier.labelp') }}
{% endblock %}
{% block additional_panes %}
@ -21,4 +20,4 @@
{% block new_title %}
{% trans %}supplier.new{% endtrans %}
{% endblock %}
{% endblock %}

View file

@ -20,9 +20,14 @@
{% for source in data_sources %}
{% if source[3] %} {# show_condition #}
<li><button class="tree-btns dropdown-item" data-mode="{{ source[0] }}" data-url="{{ source[1] }}" data-text="{{ get_data_source_name(source[4], source[2]) }}"
{{ stimulus_action('elements/sidebar_tree', 'changeDataSource') }}
>{{ get_data_source_name(source[4], source[2]) }}</button></li>
<li>
<button class="tree-btns dropdown-item"
data-mode="{{ source[0] }}"
data-url="{{ source[1] }}"
data-text="{{ get_data_source_name_plural(source[4], source[2]) }}"
{{ stimulus_action('elements/sidebar_tree', 'changeDataSource') }}
>{{ get_data_source_name_plural(source[4], source[2]) }}</button>
</li>
{% endif %}
{% endfor %}
{% endmacro %}

View file

@ -0,0 +1,48 @@
{% block datasource_synonyms_collection_widget %}
{% set _attrs = attr|default({}) %}
{% set _attrs = _attrs|merge({
class: (_attrs.class|default('') ~ ' datasource-synonyms-collection-widget')|trim
}) %}
{% set has_proto = prototype is defined %}
{% if has_proto %}
{% set __proto %}
<div class="tc-item mb-2 border rounded p-2">
{{ form_widget(prototype) }}
<div class="mt-2">
<button type="button" class="btn btn-outline-danger btn-sm tc-remove" data-action="elements--datasource-synonyms-collection#remove">
<i class="fa fa-trash"></i> {{ 'settings.behavior.data_source_synonyms.collection.remove_entry'|trans }}
</button>
</div>
</div>
{% endset %}
{% set _proto_html = __proto|e('html_attr') %}
{% set _proto_name = form.vars.prototype_name|default('__name__') %}
{% set _index = form|length %}
{% endif %}
<div
{{ stimulus_controller('elements/datasource_synonyms_collection', {
prototype: has_proto ? _proto_html : '',
prototypeName: has_proto ? _proto_name : '__name__',
index: has_proto ? _index : (form|length)
}) }}
{{ block('widget_container_attributes')|raw }}{% for k,v in _attrs %} {{ k }}="{{ v }}"{% endfor %}
>
<div class="tc-items" data-elements--datasource-synonyms-collection-target="items">
{% for child in form %}
<div class="tc-item mb-2 border rounded p-2">
{{ form_widget(child) }}
<div class="mt-2">
<button type="button" class="btn btn-outline-danger btn-sm tc-remove" data-action="elements--datasource-synonyms-collection#remove">
<i class="fa fa-trash"></i> {{ 'settings.behavior.data_source_synonyms.collection.remove_entry'|trans }}
</button>
</div>
</div>
{% endfor %}
</div>
<button type="button" class="btn btn-outline-primary btn-sm mt-2 tc-add" data-action="elements--datasource-synonyms-collection#add">
<i class="fa fa-plus"></i> {{ 'settings.behavior.data_source_synonyms.collection.add_entry'|trans }}
</button>
</div>
{% endblock %}

View file

@ -21,7 +21,7 @@
{% set dataSource = 'project' %}
{% endif %}
{% set dataSourceName = get_data_source_name(dataSource, form.vars.label) %}
{% set dataSourceName = get_data_source_name_plural(dataSource, form.vars.label) %}
{% set translatedSource = form.vars.label|trans %}
{% if dataSourceName != translatedSource %}
{{ translatedSource }}