mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Improved UX of entity adding from part edit page.
This commit is contained in:
parent
25be76b311
commit
dc012b56a8
4 changed files with 31 additions and 20 deletions
|
@ -34,21 +34,29 @@ export default class extends Controller {
|
|||
this._emptyMessage = this.element.getAttribute("data-empty-message") ?? "";
|
||||
|
||||
const allowAdd = this.element.getAttribute("data-allow-add") === "true";
|
||||
const addHint = this.element.getAttribute("data-add-hint") ?? "";
|
||||
|
||||
let settings = {
|
||||
allowEmptyOption: true,
|
||||
selectOnTab: true,
|
||||
maxOptions: null,
|
||||
create: allowAdd,
|
||||
createFilter: /\D/, //Must contain a non-digit character, otherwise they would be recognized as DB ID
|
||||
|
||||
searchField: [
|
||||
{field: "text", weight : 2},
|
||||
{field: "parent", weight : 0.5},
|
||||
{field: "path", weight : 1.0},
|
||||
],
|
||||
|
||||
render: {
|
||||
item: this.renderItem.bind(this),
|
||||
option: this.renderOption.bind(this),
|
||||
option_create: function(data, escape) {
|
||||
return '<div class="create">Add <strong>' + escape(data.input) + '</strong>… ' +
|
||||
'<small class="text-muted float-end">(' + addHint +')</small>' +
|
||||
'</div>';
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue