Create a new Client term on the fly instead of rejecting unknown names
updateField()'s client branch previously rejected any name that didn't match an existing "Client" term, on the assumption the front-end's datalist restricted input to known names -- it doesn't, it only suggests them, so this blocked adding a genuinely new client from the inline edit even though the content type itself allows it. Now creates the term (same "autocreate" behavior as a standard Drupal entity reference autocomplete widget) rather than erroring. Frontend also appends the newly created name to allClientsList so it shows up in the filter dropdown/datalist immediately, not just after a reload picks it up via fetchClientNames(). Verified live: typed a brand-new client name inline, save succeeded, confirmed the taxonomy term was actually created in the database and the filter datalist updated immediately -- then reverted the test node and deleted the test term.
This commit is contained in:
@@ -816,6 +816,13 @@
|
||||
const result = await updateLigneField(item.nid, field, newValue);
|
||||
const row = this.rows.find((r) => r.id === item.id);
|
||||
if (row) row[field] = result.value;
|
||||
// A client name with no existing match gets created on the fly
|
||||
// (server-side) rather than rejected -- reflect it in the
|
||||
// filter dropdown/datalist immediately instead of only after a
|
||||
// reload picks up the new taxonomy term via fetchClientNames().
|
||||
if (field === 'client' && result.value && !this.allClientsList.includes(result.value)) {
|
||||
this.allClientsList = [...this.allClientsList, result.value].sort();
|
||||
}
|
||||
} catch (err) {
|
||||
this.typeUpdateError = err.message;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user