Link Here
|
159 |
[% Asset.js("js/acq.js") | $raw %] |
159 |
[% Asset.js("js/acq.js") | $raw %] |
160 |
[% INCLUDE 'select2.inc' %] |
160 |
[% INCLUDE 'select2.inc' %] |
161 |
<script> |
161 |
<script> |
162 |
|
|
|
163 |
$(document).ready(function() { |
164 |
|
165 |
function display_bookseller (state) { |
162 |
function display_bookseller (state) { |
166 |
var $text; |
163 |
var $text; |
167 |
$text = $('<span>'+state.text+'</span>'); |
164 |
$text = $('<span>'+state.text+'</span>'); |
168 |
|
|
|
169 |
return $text; |
165 |
return $text; |
170 |
}; |
166 |
}; |
171 |
|
167 |
|
172 |
$("#basketbooksellerid").kohaSelect({ |
168 |
$(document).ready(function() { |
173 |
width: 'resolve', |
169 |
let select2 = $('#basketbooksellerid'); |
174 |
allowClear: false, |
170 |
select2.kohaSelect({ |
175 |
ajax: { |
171 |
width: 'resolve', |
176 |
url: '/api/v1/acquisitions/vendors', |
172 |
allowClear: false, |
177 |
delay: 300, // wait 300 milliseconds before triggering the request |
173 |
ajax: { |
178 |
cache: true, |
174 |
url: '/api/v1/acquisitions/vendors', |
179 |
dataType: 'json', |
175 |
delay: 300, // wait 300 milliseconds before triggering the request |
180 |
data: function (params) { |
176 |
cache: true, |
181 |
var search_term = (params.term === undefined) ? '' : params.term; |
177 |
dataType: 'json', |
182 |
var query = { |
178 |
data: function (params) { |
183 |
"q": JSON.stringify({"name":{"-like":'%'+search_term+'%'}}), |
179 |
var search_term = (params.term === undefined) ? '' : params.term; |
184 |
"_order_by": "name", |
180 |
var query = { |
185 |
"_page": params.page |
181 |
"q": JSON.stringify({"name":{"-like":'%'+search_term+'%'}}), |
186 |
}; |
182 |
"_order_by": "name", |
|
|
183 |
"_page": params.page |
184 |
}; |
187 |
|
185 |
|
188 |
return query; |
186 |
return query; |
|
|
187 |
}, |
188 |
processResults: function (data) { |
189 |
var results = []; |
190 |
data.results.forEach( function ( vendor ) { |
191 |
results.push( |
192 |
{ |
193 |
"id": vendor.id, |
194 |
"text": vendor.name.escapeHtml() |
195 |
} |
196 |
); |
197 |
}); |
198 |
return { "results": results, "pagination": { "more": data.pagination.more } }; |
199 |
} |
189 |
}, |
200 |
}, |
190 |
processResults: function (data) { |
201 |
templateResult: display_bookseller |
191 |
var results = []; |
202 |
}); |
192 |
data.results.forEach( function ( vendor ) { |
|
|
193 |
results.push( |
194 |
{ |
195 |
"id": vendor.id.escapeHtml(), |
196 |
"text": vendor.name.escapeHtml() |
197 |
} |
198 |
); |
199 |
}); |
200 |
return { "results": results, "pagination": { "more": data.pagination.more } }; |
201 |
} |
202 |
}, |
203 |
template: display_bookseller |
204 |
}); |
203 |
}); |
205 |
}); |
|
|
206 |
</script> |
204 |
</script> |
207 |
[% END %] |
205 |
[% END %] |
208 |
|
206 |
|
209 |
- |
|
|