mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-31 00:04:40 +02:00
Show a preview image in builtin attachment select autocomplete.
This commit is contained in:
parent
aa95f130db
commit
f0d0a78f65
6 changed files with 65 additions and 6 deletions
|
@ -432,6 +432,7 @@ $(document).on("ajaxUI:reload ajaxUI:start attachment:create", function () {
|
|||
}
|
||||
});
|
||||
|
||||
//@ts-ignore
|
||||
$(this).typeahead({
|
||||
hint: true,
|
||||
highlight: true,
|
||||
|
@ -439,7 +440,18 @@ $(document).on("ajaxUI:reload ajaxUI:start attachment:create", function () {
|
|||
},
|
||||
{
|
||||
name: 'states',
|
||||
source: engine
|
||||
source: engine,
|
||||
limit: 250,
|
||||
templates: {
|
||||
suggestion: function(data) {
|
||||
if (typeof data === "string") {
|
||||
return "<div>" + data + "</div>";
|
||||
} else if(typeof data === "object" && typeof data.image === "string") {
|
||||
return "<div class='row m-0'><div class='col-2 pl-0 pr-1'><img class='typeahead-image' src='" + data.image + "'/></div><div class='col-10'>" + data.name + "</div></div>"
|
||||
}
|
||||
},
|
||||
},
|
||||
display: 'name',
|
||||
});
|
||||
|
||||
//Make the typeahead input fill the container (remove block-inline attr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue