fix: location dropdowns rendered blank (wrong field) + require printer model
The location option label read l.location, but the Location.to_dict() field is locationname, so every option rendered blank - the dropdown looked empty and "massive" (a long list of blank rows). Fixed across all five affected forms: printers, computers, network devices, network device form, and the subnets location filter. Other .location uses (printer-driver URL, search-result label, report bylocation key) are legitimately different fields, left alone. Also require a model on the printer form: asterisk + required attr, plus a JS guard in savePrinter (the native required is skipped while the select is disabled with no vendor picked) that points the user at the vendor first.
This commit is contained in:
@@ -149,7 +149,7 @@
|
||||
:key="l.locationid"
|
||||
:value="l.locationid"
|
||||
>
|
||||
{{ l.location }}
|
||||
{{ l.locationname }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
<select id="locationid" v-model="form.locationid" class="form-control">
|
||||
<option value="">Select Location</option>
|
||||
<option v-for="loc in locations" :key="loc.locationid" :value="loc.locationid">
|
||||
{{ loc.location }}
|
||||
{{ loc.locationname }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<select v-model="locationFilter" class="form-control" @change="loadDevices">
|
||||
<option value="">All Locations</option>
|
||||
<option v-for="loc in locations" :key="loc.locationid" :value="loc.locationid">
|
||||
{{ loc.location }}
|
||||
{{ loc.locationname }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
<select id="locationid" v-model="form.locationid" class="form-control">
|
||||
<option value="">Select Location</option>
|
||||
<option v-for="loc in locations" :key="loc.locationid" :value="loc.locationid">
|
||||
{{ loc.location }}
|
||||
{{ loc.locationname }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -144,12 +144,13 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="modelnumberid">Model</label>
|
||||
<label for="modelnumberid">Model *</label>
|
||||
<select
|
||||
id="modelnumberid"
|
||||
v-model="form.modelnumberid"
|
||||
class="form-control"
|
||||
:disabled="!form.vendorid"
|
||||
required
|
||||
>
|
||||
<option value="">{{ form.vendorid ? 'Select model...' : 'Select a vendor first' }}</option>
|
||||
<option
|
||||
@@ -179,7 +180,7 @@
|
||||
:key="l.locationid"
|
||||
:value="l.locationid"
|
||||
>
|
||||
{{ l.location }}
|
||||
{{ l.locationname }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
@@ -549,6 +550,16 @@ function clearMapPosition() {
|
||||
|
||||
async function savePrinter() {
|
||||
error.value = ''
|
||||
|
||||
// Model is required. The native `required` on the select is skipped while it
|
||||
// is disabled (no vendor picked), so guard here too and point at the vendor.
|
||||
if (!form.value.modelnumberid) {
|
||||
error.value = form.value.vendorid
|
||||
? 'Model is required.'
|
||||
: 'Select a vendor, then a model (model is required).'
|
||||
return
|
||||
}
|
||||
|
||||
saving.value = true
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user