1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-11-02 16:44:31 +01:00

Autocomplete food on ManageIngredients now show owners

This commit is contained in:
Ehouarn
2025-10-31 23:26:17 +01:00
parent b9bf01f2e3
commit 78372807f8
5 changed files with 17 additions and 11 deletions

View File

@@ -13,11 +13,14 @@ $(document).ready(function () {
target.addClass('is-invalid')
target.removeClass('is-valid')
const isManageIngredients = target.hasClass('manageingredients-autocomplete')
$.getJSON(api_url + (api_url.includes('?') ? '&' : '?') + 'format=json&search=^' + input + api_url_suffix, function (objects) {
let html = '<ul class="list-group list-group-flush" id="' + prefix + '_list">'
objects.results.forEach(function (obj) {
html += li(prefix + '_' + obj.id, obj[name_field])
const extra = isManageIngredients ? ` (${obj.owner_name})` : ''
html += li(`${prefix}_${obj.id}`, `${obj[name_field]}${extra}`)
})
html += '</ul>'