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 #}