Adding tags to variant overrides

This commit is contained in:
Rob Harrington
2016-04-15 11:44:19 +10:00
parent ddc7e86e6c
commit 3f8420b0e9
18 changed files with 152 additions and 63 deletions

View File

@@ -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()