Warranty form: make Vendor a strict dropdown of the vendor catalog
Replace the free-text/datalist vendor field with a plain select populated from /api/vendors, so a warranty vendor is always one of the site's known vendors. An existing warranty's vendor is kept selectable even if it is absent from the catalog, so editing never blanks it.
This commit is contained in:
@@ -82,12 +82,11 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label>Vendor *</label>
|
||||
<input v-model="form.vendor" type="text" class="form-control" maxlength="100" required
|
||||
list="warranty-vendor-list" placeholder="e.g. Dell" />
|
||||
<datalist id="warranty-vendor-list">
|
||||
<option v-for="name in vendorNames" :key="name" :value="name" />
|
||||
</datalist>
|
||||
<small class="muted">Who backs the warranty. Pick a known vendor or type a new one.</small>
|
||||
<select v-model="form.vendor" class="form-control" required>
|
||||
<option value="" disabled>Select a vendor...</option>
|
||||
<option v-for="name in vendorOptions" :key="name" :value="name">{{ name }}</option>
|
||||
</select>
|
||||
<small class="muted">Who backs the warranty. Manage the list under Vendors.</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Lookup source</label>
|
||||
@@ -202,8 +201,15 @@ const form = ref(blankForm())
|
||||
const selectedAssets = ref([])
|
||||
const assetQuery = ref('')
|
||||
const assetResults = ref([])
|
||||
// Suggestions for the Vendor combobox, pulled from the site vendor catalog.
|
||||
// Vendor dropdown options, pulled from the site vendor catalog.
|
||||
const vendorNames = ref([])
|
||||
// Keep an existing warranty's vendor selectable even if it is not (or no longer)
|
||||
// in the catalog, so editing never silently blanks it.
|
||||
const vendorOptions = computed(() => {
|
||||
const current = (form.value.vendor || '').trim()
|
||||
if (current && !vendorNames.value.includes(current)) return [current, ...vendorNames.value]
|
||||
return vendorNames.value
|
||||
})
|
||||
|
||||
function blankForm() {
|
||||
return { vendor: '', provider: 'manual', servicetag: '', servicelevel: '', startdate: '', enddate: '', notes: '' }
|
||||
|
||||
Reference in New Issue
Block a user