Tag attributes are auto-initialized via directive if not present on object

This commit is contained in:
Rob Harrington
2016-05-26 23:54:54 +10:00
parent 011c8c74d9
commit cb9e3b43f9
4 changed files with 13 additions and 6 deletions

View File

@@ -10,12 +10,15 @@ angular.module("admin.utils").directive "tagsWithTranslation", ($timeout) ->
link: (scope, element, attrs) ->
scope.findTags = undefined unless attrs.hasOwnProperty("findTags")
compileTagList = ->
scope.object[scope.tagListAttr] = (tag.text for tag in scope.object[scope.tagsAttr]).join(",")
$timeout ->
# Initialize properties if necessary
scope.tagsAttr ||= "tags"
scope.tagListAttr ||= "tag_list"
compileTagList = ->
scope.object[scope.tagListAttr] = (tag.text for tag in scope.object[scope.tagsAttr]).join(",")
scope.object[scope.tagsAttr] ||= []
compileTagList()
scope.tagAdded = ->
compileTagList()