Part-DB-server icon indicating copy to clipboard operation
Part-DB-server copied to clipboard

Be able to set format of storage location in the parts list

Open timbslr opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. I have multiple storage containers whose boxes are each labeled from A1 to D8. So the locations A1 to D8 exist multiple times (with different parent locations).

Describe the solution you'd like I´d like to be able to set the format storage location in the parts list to the arrow representation (Box1->A1, Box3->A1) so I can see the whole storage location in the list instead of having to hover over it to get to the right container.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

timbslr avatar Sep 13 '24 13:09 timbslr

I was looking for a similar behavior and came up with the following patch which shows up to 2 parents (which is enough for my use case):

diff --git i/src/DataTables/Helpers/PartDataTableHelper.php w/src/DataTables/Helpers/PartDataTableHelper.php
index c33c3a82..2bea8772 100644
--- i/src/DataTables/Helpers/PartDataTableHelper.php
+++ w/src/DataTables/Helpers/PartDataTableHelper.php
@@ -108,7 +108,7 @@ class PartDataTableHelper
                 '<a href="%s" title="%s">%s</a>',
                 $this->entityURLGenerator->listPartsURL($lot->getStorageLocation()),
                 htmlspecialchars($lot->getStorageLocation()->getFullPath()),
-                htmlspecialchars($lot->getStorageLocation()->getName())
+                htmlspecialchars($lot->getStorageLocation()->getShortPath())
             );
         }
 
diff --git i/src/Entity/Base/AbstractStructuralDBElement.php w/src/Entity/Base/AbstractStructuralDBElement.php
index 660710db..b33ce24d 100644
--- i/src/Entity/Base/AbstractStructuralDBElement.php
+++ w/src/Entity/Base/AbstractStructuralDBElement.php
@@ -285,6 +285,22 @@ abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
         return implode($delimiter, $this->full_path_strings);
     }
 
+    public function getShortPath(): string
+    {
+        if ($this->full_path_strings === []) {
+            $this->getFullPath();
+        }
+
+        $count = count($this->full_path_strings);
+        if ($count == 1 || $count == 2) {
+            return $this->getFullPath();
+        } else {
+            $end = array_slice($this->full_path_strings, -2);
+            $delim = self::PATH_DELIMITER_ARROW;
+            return $delim . $end[0] . $delim . $end[1];
+        }
+    }
+
     /**
      * Gets the path to this element (including the element itself).
      *

What's still missing is a way to make this configurable, possibly per storage location. If somebody could give me some pointers on howto implement that I could try to prepare a pull request.

rudis avatar Jul 15 '25 20:07 rudis