diff --git a/assets/controllers/elements/datasource_synonyms_collection_controller.js b/assets/controllers/pages/synonyms_collection_controller.js similarity index 100% rename from assets/controllers/elements/datasource_synonyms_collection_controller.js rename to assets/controllers/pages/synonyms_collection_controller.js diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index b9fdf5bd..95ae4f3b 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -1,6 +1,6 @@ twig: default_path: '%kernel.project_dir%/templates' - form_themes: ['bootstrap_5_horizontal_layout.html.twig', 'form/extended_bootstrap_layout.html.twig', 'form/permission_layout.html.twig', 'form/filter_types_layout.html.twig', 'form/datasource_synonyms_collection.html.twig'] + form_themes: ['bootstrap_5_horizontal_layout.html.twig', 'form/extended_bootstrap_layout.html.twig', 'form/permission_layout.html.twig', 'form/filter_types_layout.html.twig', 'form/synonyms_collection.html.twig'] paths: '%kernel.project_dir%/assets/css': css diff --git a/src/Form/Type/LanguageMenuEntriesType.php b/src/Form/Settings/LanguageMenuEntriesType.php similarity index 95% rename from src/Form/Type/LanguageMenuEntriesType.php rename to src/Form/Settings/LanguageMenuEntriesType.php index a3bba77f..9bc2e850 100644 --- a/src/Form/Type/LanguageMenuEntriesType.php +++ b/src/Form/Settings/LanguageMenuEntriesType.php @@ -21,12 +21,11 @@ declare(strict_types=1); -namespace App\Form\Type; +namespace App\Form\Settings; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\LanguageType; -use Symfony\Component\Form\Extension\Core\Type\LocaleType; use Symfony\Component\Intl\Languages; use Symfony\Component\OptionsResolver\OptionsResolver; diff --git a/src/Form/Type/DataSourceSynonymRowType.php b/src/Form/Settings/TypeSynonymRowType.php similarity index 92% rename from src/Form/Type/DataSourceSynonymRowType.php rename to src/Form/Settings/TypeSynonymRowType.php index c35ad81f..332db907 100644 --- a/src/Form/Type/DataSourceSynonymRowType.php +++ b/src/Form/Settings/TypeSynonymRowType.php @@ -20,28 +20,26 @@ declare(strict_types=1); -namespace App\Form\Type; +namespace App\Form\Settings; use App\Services\ElementTypes; use App\Settings\SystemSettings\LocalizationSettings; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\EnumType; use Symfony\Component\Form\Extension\Core\Type\LocaleType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Intl\Locales; -use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraints as Assert; /** * A single translation row: data source + language + translations (singular/plural). */ -class DataSourceSynonymRowType extends AbstractType +class TypeSynonymRowType extends AbstractType { - private const PREFFERED_TYPES = [ + private const PREFERRED_TYPES = [ ElementTypes::CATEGORY, ElementTypes::STORAGE_LOCATION, ElementTypes::FOOTPRINT, @@ -62,14 +60,13 @@ class DataSourceSynonymRowType extends AbstractType ->add('dataSource', EnumType::class, [ 'class' => ElementTypes::class, 'label' => false, - //'choices' => $this->buildDataSourceChoices($options['data_sources']), 'required' => true, 'constraints' => [ new Assert\NotBlank(), ], 'row_attr' => ['class' => 'mb-0'], 'attr' => ['class' => 'form-select-sm'], - 'preferred_choices' => self::PREFFERED_TYPES + 'preferred_choices' => self::PREFERRED_TYPES ]) ->add('locale', LocaleType::class, [ 'label' => false, diff --git a/src/Form/Type/DataSourceSynonymsCollectionType.php b/src/Form/Settings/TypeSynonymsCollectionType.php similarity index 87% rename from src/Form/Type/DataSourceSynonymsCollectionType.php rename to src/Form/Settings/TypeSynonymsCollectionType.php index c8c44a50..9c239c21 100644 --- a/src/Form/Type/DataSourceSynonymsCollectionType.php +++ b/src/Form/Settings/TypeSynonymsCollectionType.php @@ -1,8 +1,26 @@ . + */ declare(strict_types=1); -namespace App\Form\Type; +namespace App\Form\Settings; use App\Services\ElementTypes; use Symfony\Component\Form\AbstractType; @@ -21,7 +39,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; * View data: list [{dataSource, locale, translation_singular, translation_plural}, ...] * Model data: same structure (list). Optionally expands a nested map to a list. */ -class DataSourceSynonymsCollectionType extends AbstractType +class TypeSynonymsCollectionType extends AbstractType { public function __construct(private readonly TranslatorInterface $translator) { @@ -180,7 +198,7 @@ class DataSourceSynonymsCollectionType extends AbstractType // Defaults for the collection and entry type $resolver->setDefaults([ - 'entry_type' => DataSourceSynonymRowType::class, + 'entry_type' => TypeSynonymRowType::class, 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, @@ -198,6 +216,6 @@ class DataSourceSynonymsCollectionType extends AbstractType public function getBlockPrefix(): string { - return 'datasource_synonyms_collection'; + return 'type_synonyms_collection'; } } diff --git a/src/Settings/SynonymSettings.php b/src/Settings/SynonymSettings.php index e952d97a..4a8e94ab 100644 --- a/src/Settings/SynonymSettings.php +++ b/src/Settings/SynonymSettings.php @@ -22,7 +22,7 @@ declare(strict_types=1); namespace App\Settings; -use App\Form\Type\DataSourceSynonymsCollectionType; +use App\Form\Settings\TypeSynonymsCollectionType; use App\Services\ElementTypes; use Jbtronics\SettingsBundle\ParameterTypes\ArrayType; use Jbtronics\SettingsBundle\ParameterTypes\SerializeType; @@ -43,7 +43,7 @@ class SynonymSettings label: new TM("settings.system.synonyms.type_synonyms"), description: new TM("settings.system.synonyms.type_synonyms.help"), options: ['type' => SerializeType::class], - formType: DataSourceSynonymsCollectionType::class, + formType: TypeSynonymsCollectionType::class, formOptions: [ 'required' => false, ], diff --git a/src/Settings/SystemSettings/LocalizationSettings.php b/src/Settings/SystemSettings/LocalizationSettings.php index 7c83d1ef..c6780c6c 100644 --- a/src/Settings/SystemSettings/LocalizationSettings.php +++ b/src/Settings/SystemSettings/LocalizationSettings.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace App\Settings\SystemSettings; -use App\Form\Type\LanguageMenuEntriesType; +use App\Form\Settings\LanguageMenuEntriesType; use App\Form\Type\LocaleSelectType; use App\Settings\SettingsIcon; use Jbtronics\SettingsBundle\Metadata\EnvVarMode; diff --git a/templates/form/datasource_synonyms_collection.html.twig b/templates/form/synonyms_collection.html.twig similarity index 56% rename from templates/form/datasource_synonyms_collection.html.twig rename to templates/form/synonyms_collection.html.twig index 27c4a051..ee69dffc 100644 --- a/templates/form/datasource_synonyms_collection.html.twig +++ b/templates/form/synonyms_collection.html.twig @@ -7,18 +7,18 @@
{{ form_row(child.translation_singular) }}
{{ form_row(child.translation_plural) }}
-
{% endmacro %} -{% block datasource_synonyms_collection_widget %} +{% block type_synonyms_collection_widget %} {% set _attrs = attr|default({}) %} {% set _attrs = _attrs|merge({ - class: (_attrs.class|default('') ~ ' datasource-synonyms-collection-widget')|trim + class: (_attrs.class|default('') ~ ' type_synonyms_collection-widget')|trim }) %} {% set has_proto = prototype is defined %} @@ -32,7 +32,7 @@ {% endif %}
-
{% trans %}settings.behavior.data_source_synonyms.row_type.form.datasource{% endtrans %}
-
{% trans %}settings.behavior.data_source_synonyms.row_type.form.locale{% endtrans %}
-
{% trans %}settings.behavior.data_source_synonyms.row_type.form.translation_singular{% endtrans %}
-
{% trans %}settings.behavior.data_source_synonyms.row_type.form.translation_plural{% endtrans %}
+
{% trans%}settings.synonyms.type_synonym.type{% endtrans%}
+
{% trans%}settings.synonyms.type_synonym.language{% endtrans%}
+
{% trans%}settings.synonyms.type_synonym.translation_singular{% endtrans%}
+
{% trans%}settings.synonyms.type_synonym.translation_plural{% endtrans%}
-
+
{% for child in form %} {{ _self.renderForm(child) }} {% endfor %}
-
{% endblock %} diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index 43159587..ac46c069 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -14486,5 +14486,41 @@ Please note that this system is currently experimental, and the synonyms defined Type synonyms allow you to replace the labels of built-in data types. For example, you can rename "Footprint" to something else. + + + settings.synonyms.type_synonym.type + Type + + + + + settings.synonyms.type_synonym.language + Language + + + + + settings.synonyms.type_synonym.translation_singular + Translation Singular + + + + + settings.synonyms.type_synonym.translation_plural + Translation Plural + + + + + settings.synonyms.type_synonym.add_entry + Add entry + + + + + settings.synonyms.type_synonym.remove_entry + Remove entry + +