mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #7712 from guidoDutra/1861-enable-shopfront-sorting-by-producer
Enable sorting by producer in shopfront
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
angular.module("admin.utils").factory 'AutocompleteSelect2', ($sanitize) ->
|
||||
scope: true
|
||||
autocomplete: (
|
||||
multiple,
|
||||
placeholder,
|
||||
element,
|
||||
findByID,
|
||||
findByIDs,
|
||||
findByTerm
|
||||
) ->
|
||||
element.select2
|
||||
placeholder: placeholder
|
||||
multiple: multiple
|
||||
initSelection: (element, callback) ->
|
||||
if multiple
|
||||
callback findByIDs()
|
||||
else
|
||||
callback findByID()
|
||||
query: (query) ->
|
||||
query.callback { results: findByTerm(query.term) }
|
||||
formatResult: (item) ->
|
||||
$sanitize(item.name)
|
||||
formatSelection: (item) ->
|
||||
item.name
|
||||
|
||||
#Allows drag and drop
|
||||
if multiple
|
||||
element.select2("container").find("ul.select2-choices").sortable
|
||||
containment: 'parent'
|
||||
start: -> element.select2("onSortStart")
|
||||
update: -> element.select2("onSortEnd")
|
||||
Reference in New Issue
Block a user