Display role vocabulary, migration commit fix, stale enforcement reports
This commit is contained in:
@@ -77,10 +77,10 @@
|
||||
<option v-for="r in roleOptions" :key="r.value" :value="r.value">{{ r.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" v-if="form.displayrole === 'dashboard'">
|
||||
<div class="form-group" v-if="form.displayrole === 'Dashboard'">
|
||||
<label for="businessunitid">Location *</label>
|
||||
<select id="businessunitid" v-model="form.businessunitid" class="form-control"
|
||||
:required="form.displayrole === 'dashboard'">
|
||||
:required="form.displayrole === 'Dashboard'">
|
||||
<option value="">Select location...</option>
|
||||
<option v-for="bu in businessUnits" :key="bu.businessunitid" :value="bu.businessunitid">
|
||||
{{ bu.businessunit }}
|
||||
@@ -127,13 +127,33 @@ import { useToast } from '../../composables/toast'
|
||||
import { apiError } from '../../utils/apiError'
|
||||
const toast = useToast()
|
||||
|
||||
// Values are the kiosk's own vocabulary - the literal contents of
|
||||
// C:\Enrollment\display-type.txt - so what is picked here is what a display
|
||||
// reports. Must stay in step with DISPLAY_ROLE_PATHS in
|
||||
// shopdb/core/models/dashboarddefault.py.
|
||||
const roleOptions = [
|
||||
{ value: 'dashboard', label: 'Shopfloor Dashboard' },
|
||||
{ value: 'lobby', label: 'Lobby Slideshow' },
|
||||
{ value: 'partskiosk', label: '3D Parts Kiosk' },
|
||||
{ value: 'Dashboard', label: 'Shopfloor Dashboard' },
|
||||
{ value: 'Lobby', label: 'Lobby Slideshow' },
|
||||
{ value: '3DPrintRoom', label: '3D Print Room Kiosk' },
|
||||
]
|
||||
// Rows written before the vocabularies merged still carry the old spelling, so
|
||||
// match case-insensitively and fall back to the retired name.
|
||||
const legacyRoleLabels = { partskiosk: '3D Print Room Kiosk' }
|
||||
const legacyRoleValues = { partskiosk: '3DPrintRoom' }
|
||||
// Canonical value for any stored spelling. Without this, opening a row saved
|
||||
// before the merge puts a value in the select that matches no option, and the
|
||||
// dropdown renders blank as if the row had no role.
|
||||
function canonicalRole(value) {
|
||||
const wanted = (value || '').toLowerCase()
|
||||
return roleOptions.find(r => r.value.toLowerCase() === wanted)?.value
|
||||
|| legacyRoleValues[wanted]
|
||||
|| 'Dashboard'
|
||||
}
|
||||
function roleLabel(value) {
|
||||
return roleOptions.find(r => r.value === value)?.label || value
|
||||
const wanted = (value || '').toLowerCase()
|
||||
return roleOptions.find(r => r.value.toLowerCase() === wanted)?.label
|
||||
|| legacyRoleLabels[wanted]
|
||||
|| value
|
||||
}
|
||||
|
||||
const items = ref([])
|
||||
@@ -149,7 +169,7 @@ const error = ref('')
|
||||
const showDeleteModal = ref(false)
|
||||
const toDelete = ref(null)
|
||||
|
||||
const form = ref({ fqdn: '', ipaddress: '', displayrole: 'dashboard', businessunitid: '', description: '' })
|
||||
const form = ref({ fqdn: '', ipaddress: '', displayrole: 'Dashboard', businessunitid: '', description: '' })
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
@@ -184,10 +204,10 @@ function openModal(item = null) {
|
||||
form.value = item ? {
|
||||
fqdn: item.fqdn || '',
|
||||
ipaddress: item.ipaddress || '',
|
||||
displayrole: item.displayrole || 'dashboard',
|
||||
displayrole: canonicalRole(item.displayrole),
|
||||
businessunitid: item.businessunitid || '',
|
||||
description: item.description || ''
|
||||
} : { fqdn: '', ipaddress: '', displayrole: 'dashboard', businessunitid: '', description: '' }
|
||||
} : { fqdn: '', ipaddress: '', displayrole: 'Dashboard', businessunitid: '', description: '' }
|
||||
error.value = ''
|
||||
showModal.value = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user