From eaaf3ac75c9a26cb2c2b9427ef3c61ea1a096143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 4 Jan 2026 17:36:53 +0100 Subject: [PATCH] Bring provider capabilities into a fixed order for better comparison Fixes #1166 and made PR #1167 obsolete --- .../Providers/ProviderCapabilities.php | 21 ++++++++++++++++--- .../info_providers/providers.macro.html.twig | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Services/InfoProviderSystem/Providers/ProviderCapabilities.php b/src/Services/InfoProviderSystem/Providers/ProviderCapabilities.php index fd67cd2c..bced19de 100644 --- a/src/Services/InfoProviderSystem/Providers/ProviderCapabilities.php +++ b/src/Services/InfoProviderSystem/Providers/ProviderCapabilities.php @@ -31,9 +31,6 @@ enum ProviderCapabilities /** Basic information about a part, like the name, description, part number, manufacturer etc */ case BASIC; - /** Information about the footprint of a part */ - case FOOTPRINT; - /** Provider can provide a picture for a part */ case PICTURE; @@ -43,6 +40,24 @@ enum ProviderCapabilities /** Provider can provide prices for a part */ case PRICE; + /** Information about the footprint of a part */ + case FOOTPRINT; + + /** + * Get the order index for displaying capabilities in a stable order. + * @return int + */ + public function getOrderIndex(): int + { + return match($this) { + self::BASIC => 1, + self::PICTURE => 2, + self::DATASHEET => 3, + self::PRICE => 4, + self::FOOTPRINT => 5, + }; + } + public function getTranslationKey(): string { return 'info_providers.capabilities.' . match($this) { diff --git a/templates/info_providers/providers.macro.html.twig b/templates/info_providers/providers.macro.html.twig index bf530ebd..bec8f24b 100644 --- a/templates/info_providers/providers.macro.html.twig +++ b/templates/info_providers/providers.macro.html.twig @@ -27,7 +27,7 @@ title="{% trans %}info_providers.settings.title{% endtrans %}" > {% endif %} - {% for capability in provider.capabilities %} + {% for capability in provider.capabilities|sort((a, b) => a.orderIndex <=> b.orderIndex) %} {# @var capability \App\Services\InfoProviderSystem\Providers\ProviderCapabilities #}