fix: normalize Mine Map shelf labels

This commit is contained in:
lussierj committed 2026-08-11 15:31:01 +00:00
1 parent 06ed8248f5
commit c6d01df31c
1 file changed
+9 -4
+9 -4
View File
@@ -47,6 +47,11 @@
return String(value);
}
function shelfLabel(value) {
const label = display(value, "Unlabelled shelf");
return /^shelf\b/i.test(label) ? label : "Shelf " + label;
}
function words(value) {
return display(value, "Unknown").replaceAll("_", " ").toLowerCase();
}
@@ -497,8 +502,8 @@
rack.appendChild(create("h2", "rack-title", "Rack " + rackEntry[0]));
for (const shelfEntry of rackEntry[1]) {
const shelf = create("section", "map-shelf");
shelf.setAttribute("aria-label", "Shelf " + shelfEntry[0]);
shelf.appendChild(create("h3", "shelf-title", "Shelf " + shelfEntry[0]));
shelf.setAttribute("aria-label", shelfLabel(shelfEntry[0]));
shelf.appendChild(create("h3", "shelf-title", shelfLabel(shelfEntry[0])));
const grid = create("div", "position-grid");
for (const position of shelfEntry[1]) {
grid.appendChild(positionTile(position, scale));
@@ -607,10 +612,10 @@
detailRow("Current IP", position.current_ip);
const location = position.room_id
? [position.site_name, position.room_name, "Rack " + position.rack_name,
"Shelf " + position.shelf_name, display(position.position_label,
shelfLabel(position.shelf_name), display(position.position_label,
"Position " + position.position_index)].join(" / ")
: ["Unscoped", "Room label " + display(position.room_name),
"Rack " + display(position.rack_name), "Shelf " + display(position.shelf_name),
"Rack " + display(position.rack_name), shelfLabel(position.shelf_name),
display(position.position_label, "Position " + position.position_index)].join(" / ");
detailRow("Location", location);
detailRow("Lifecycle", words(position.lifecycle_status));