map: fix subtype filter dropping every measuring tool
Some checks failed
CI / backend (push) Has been cancelled
CI / naming (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / migrations-mysql (push) Has been cancelled

MapView carried its own copy of the per-type subtype-id lookup and it
never gained a Measuring Tool branch, so selecting any measuring-tool
subtype filtered out all assets. Marker coloring and the PDF export were
unaffected because both already used the shared getSubtypeId helper.

Point the filter at that shared helper and delete the duplicate copy in
ShopFloorMap too, so one definition serves filter, coloring and export.
Adds a table-driven spec covering every subtype-carrying asset type.
This commit is contained in:
cproudlock
2026-07-31 07:56:09 -04:00
parent 86697a4e7b
commit 71982fc0f1
3 changed files with 46 additions and 30 deletions

View File

@@ -85,6 +85,7 @@ import { useAuthStore } from '../stores/auth'
import { loadMapConfig, state as mapConfig } from '../composables/mapConfig'
import { exportMapPdf } from '../utils/mapPdf'
import { assetTypeLabel, assetDetailRoute } from '../utils/assetTypes'
import { getSubtypeId } from '../utils/mapColors'
import { useToast } from '../composables/toast'
const toast = useToast()
@@ -133,7 +134,8 @@ const subtypeLabel = computed(() => {
'machine': 'All Machine Types',
'computer': 'All Computer Types',
'network device': 'All Device Types',
'printer': 'All Printer Types'
'printer': 'All Printer Types',
'measuring tool': 'All Tool Types'
}
return labels[selectedType.value.toLowerCase().replace(/_/g, ' ')] || 'All Subtypes'
})
@@ -175,24 +177,12 @@ const filteredAssets = computed(() => {
result = result.filter(a => a.assettype && a.assettype.toLowerCase() === selectedLower)
}
// Filter by subtype (normalize network_device -> network device)
// Filter by subtype. Uses the shared getSubtypeId helper so this stays in
// step with the marker coloring - a local copy of the per-type id lookup went
// stale and silently dropped every measuring tool.
if (selectedSubtype.value) {
const subtypeId = parseInt(selectedSubtype.value)
const typeLower = (selectedType.value || '').toLowerCase().replace(/_/g, ' ')
result = result.filter(a => {
if (!a.typedata) return false
// Check different ID fields based on asset type
if (typeLower === 'machine') {
return a.typedata.machinetypeid === subtypeId
} else if (typeLower === 'computer') {
return a.typedata.computertypeid === subtypeId
} else if (typeLower === 'network device') {
return a.typedata.networkdevicetypeid === subtypeId
} else if (typeLower === 'printer') {
return a.typedata.printertypeid === subtypeId
}
return false
})
result = result.filter(a => getSubtypeId(a) === subtypeId)
}
// Filter by business unit