diff --git a/app/assets/javascripts/admin/utils/directives/tags_with_translation.js.coffee b/app/assets/javascripts/admin/utils/directives/tags_with_translation.js.coffee index eae1a899c1..6ce7953608 100644 --- a/app/assets/javascripts/admin/utils/directives/tags_with_translation.js.coffee +++ b/app/assets/javascripts/admin/utils/directives/tags_with_translation.js.coffee @@ -1,8 +1,15 @@ -angular.module("admin.utils").directive "tagsWithTranslation", -> +angular.module("admin.utils").directive "tagsWithTranslation", ($timeout) -> restrict: "E" - template: "" + template: "" scope: object: "=" + tagsAttr: "@?" + tagListAttr: "@?" link: (scope, element, attrs) -> - scope.$watchCollection "object.tags", -> - scope.object.tag_list = (tag.text for tag in scope.object.tags).join(",") + $timeout -> + scope.tagsAttr ||= "tags" + scope.tagListAttr ||= "tag_list" + + watchString = "object.#{scope.tagsAttr}" + scope.$watchCollection watchString, -> + scope.object[scope.tagListAttr] = (tag.text for tag in scope.object[scope.tagsAttr]).join(",")