diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php
index 578984f4..99291c2a 100644
--- a/src/Twig/AppExtension.php
+++ b/src/Twig/AppExtension.php
@@ -42,9 +42,20 @@ declare(strict_types=1);
namespace App\Twig;
+use App\Entity\Attachments\Attachment;
use App\Entity\Base\AbstractDBElement;
+use App\Entity\Devices\Device;
+use App\Entity\LabelSystem\LabelProfile;
+use App\Entity\Parts\Category;
+use App\Entity\Parts\Footprint;
+use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\MeasurementUnit;
+use App\Entity\Parts\Part;
+use App\Entity\Parts\Storelocation;
+use App\Entity\Parts\Supplier;
use App\Entity\PriceInformations\Currency;
+use App\Entity\UserSystem\Group;
+use App\Entity\UserSystem\User;
use App\Services\AmountFormatter;
use App\Services\Attachments\AttachmentURLGenerator;
use App\Services\EntityURLGenerator;
@@ -116,6 +127,12 @@ class AppExtension extends AbstractExtension
new TwigTest('instanceof', static function ($var, $instance) {
return $var instanceof $instance;
}),
+ new TwigTest('entity', static function ($var) {
+ return $var instanceof AbstractDBElement;
+ }),
+ new TwigTest('object', static function ($var) {
+ return is_object($var);
+ }),
];
}
@@ -125,9 +142,31 @@ class AppExtension extends AbstractExtension
new TwigFunction('generateTreeData', [$this, 'treeData']),
new TwigFunction('attachment_thumbnail', [$this->attachmentURLGenerator, 'getThumbnailURL']),
new TwigFunction('ext_to_fa_icon', [$this->FAIconGenerator, 'fileExtensionToFAType']),
+ new TwigFunction('entity_type', [$this, 'getEntityType']),
];
}
+ public function getEntityType($entity): ?string
+ {
+ $map = [
+ Part::class => 'part',
+ Footprint::class => 'footprint',
+ Storelocation::class => 'storelocation',
+ Manufacturer::class => 'manufacturer',
+ Category::class => 'category',
+ Device::class => 'device',
+ Attachment::class => 'attachment',
+ Supplier::class => 'supplier',
+ User::class => 'user',
+ Group::class => 'group',
+ Currency::class => 'currency',
+ MeasurementUnit::class => 'measurement_unit',
+ LabelProfile::class => 'label_profile',
+ ];
+
+ return $map[get_class($entity)] ?? null;
+ }
+
public function treeData(AbstractDBElement $element, string $type = 'newEdit'): string
{
$tree = $this->treeBuilder->getTreeView(get_class($element), null, $type, $element);
diff --git a/templates/Parts/lists/_info_card.html.twig b/templates/Parts/lists/_info_card.html.twig
index 33879611..da038760 100644
--- a/templates/Parts/lists/_info_card.html.twig
+++ b/templates/Parts/lists/_info_card.html.twig
@@ -9,6 +9,8 @@
diff --git a/templates/helper.twig b/templates/helper.twig
index 67528e8b..34e22791 100644
--- a/templates/helper.twig
+++ b/templates/helper.twig
@@ -71,20 +71,58 @@
{% endif %}
{% endmacro %}
-{% macro breadcrumb_entity_link(entity, link_type = "list_parts") %}
-
+{% macro entity_icon(entity_or_type, classes = "", style = "") %}
+ {% set map = {
+ "attachment_type": ["fa-solid fa-file-alt", "attachment_type.label"],
+ "category": ["fa-solid fa-tags", "category.label"],
+ "currency": ["fa-solid fa-coins", "currency.label"],
+ "device": ["fa-solid fa-archive", "device.label"],
+ "footprint": ["fa-solid fa-microchip", "footprint.label"],
+ "group": ["fa-solid fa-users", "group.label"],
+ "label_profile": ["fa-solid fa-qrcode", "label_profile.label"],
+ "manufacturer": ["fa-solid fa-industry", "manufacturer.label"],
+ "measurement_unit": ["fa-solid fa-balance-scale", "measurement_unit.label"],
+ "storelocation": ["fa-solid fa-cube", "storelocation.label"],
+ "supplier": ["fa-solid fa-truck", "supplier.label"],
+ "user": ["fa-solid fa-user", "user.label"],
+ } %}
+
+ {% if entity_or_type is entity %}
+ {% set type = entity_type(entity_or_type) %}
+ {% else %}
+ {% set type = entity_or_type %}
+ {% endif %}
+
+ {% if type is not null and map[type] is defined %}
+ {% set icon = map[type][0] %}
+ {% set label = map[type][1] %}
+ {% else %}
+ {% set icon = "fa-solid fa-question" %}
+ {% set label = "Unknown type " ~ type %}
+ {% endif %}
+
+
+{% endmacro %}
+
+{% macro breadcrumb_entity_link(entity, link_type = "list_parts", icon = "") %}
+
{% endmacro %}
{% macro bool_icon(bool) %}