mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-10 03:30:22 +00:00
Adding tags to variant overrides
This commit is contained in:
@@ -6,11 +6,20 @@ angular.module("admin.utils").directive "tagsWithTranslation", ($timeout) ->
|
||||
tagsAttr: "@?"
|
||||
tagListAttr: "@?"
|
||||
findTags: "&"
|
||||
form: '=?'
|
||||
link: (scope, element, attrs) ->
|
||||
$timeout ->
|
||||
scope.tagsAttr ||= "tags"
|
||||
scope.tagListAttr ||= "tag_list"
|
||||
|
||||
watchString = "object.#{scope.tagsAttr}"
|
||||
scope.$watchCollection watchString, ->
|
||||
compileTagList = ->
|
||||
scope.object[scope.tagListAttr] = (tag.text for tag in scope.object[scope.tagsAttr]).join(",")
|
||||
|
||||
scope.tagAdded = ->
|
||||
compileTagList()
|
||||
|
||||
scope.tagRemoved = ->
|
||||
# For some reason the tags input doesn't mark the form
|
||||
# as dirty when a tag is removed, which breaks the save bar
|
||||
scope.form.$setDirty(true) if typeof scope.form isnt 'undefined'
|
||||
compileTagList()
|
||||
|
||||
Reference in New Issue
Block a user