harden CSV import reconciliation and preserve saved model selections
Default fuzzy reconcile threshold to 0 and refuse merges when digit runs differ so numbered labels like Bay 311 never bind to Bay 310. Keep edit forms from clearing saved model fields when category filtering hides untyped rows. Includes in-progress computers policy and endpoints command feature work.
This commit is contained in:
@@ -370,9 +370,28 @@ const vendors = ref([])
|
||||
const models = ref([])
|
||||
const locations = ref([])
|
||||
|
||||
// Ensure a saved model id is present in models.value even when the filtered
|
||||
// list (category Printer) excluded it because it has no modeltype. Fetches the
|
||||
// single row by id and appends it; a no-op when already present or blank.
|
||||
async function ensureModelLoaded(modelId) {
|
||||
if (!modelId) return
|
||||
if (models.value.some(m => m.modelnumberid === modelId)) return
|
||||
try {
|
||||
const response = await modelsApi.get(modelId)
|
||||
const model = response.data.data
|
||||
if (model) models.value = [...models.value, model]
|
||||
} catch (e) {
|
||||
// Leave it absent; the select shows blank but we did not invent a value.
|
||||
}
|
||||
}
|
||||
|
||||
// Filter models by selected vendor and printer type
|
||||
const filteredModels = computed(() => {
|
||||
const savedId = form.value.modelnumberid
|
||||
return models.value.filter(m => {
|
||||
// Always keep the record's own saved model, so editing a printer never
|
||||
// renders a blank select that clears the field on save.
|
||||
if (m.modelnumberid === savedId) return true
|
||||
// Filter by vendor if selected
|
||||
if (form.value.vendorid && m.vendorid !== form.value.vendorid) {
|
||||
return false
|
||||
@@ -550,6 +569,12 @@ onMounted(async () => {
|
||||
pin: ext.pin || ''
|
||||
}
|
||||
|
||||
// The model list is loaded filtered to category Printer, which the backend
|
||||
// inner-joins against ModelType - so an untyped model is absent. If this
|
||||
// printer's saved model is one of those rows, fetch it by id and merge it
|
||||
// in, or its dropdown would render blank and saving would clear the field.
|
||||
await ensureModelLoaded(form.value.modelnumberid)
|
||||
|
||||
// Don't auto-generate for existing printers
|
||||
manualWindowsName.value = true
|
||||
manualHostname.value = true
|
||||
|
||||
Reference in New Issue
Block a user