Tag management working but can't remove default tag from module

This commit is contained in:
chris committed 2013-04-25 12:34:06 +08:00
1 parent bf3d20ea46
commit 19405cf006
68 files changed
+724 -281

No files matched your search

+24
View File
@@ -77,4 +77,28 @@ module OrbitTag
Tag.where(default: true)
end
end
module Merging
protected
def create_default_tag(name, taggings, module_app_ids)
create_tag(@module_app, name, taggings, module_app_ids, true)
end
def create_tag(module_app, name, taggings, module_app_ids=[module_app.id], default=false)
new_tag = module_app.module_tags.create(name_translations: name, module_app_ids: module_app_ids - [module_app.id], is_default: default)
taggings.each do |tagging|
tagging.taggable.taggings.create(tag_id: new_tag.tag.id) unless tagging.taggable.taggings.detect{|t| t.tag_id.eql?(new_tag.tag.id)}
end
end
def merge_default_tags(name, taggings, module_app_ids)
create_default_tag(name, taggings, module_app_ids)
end
def merge_tags(name, taggings, module_app_id)
module_app = ModuleApp.find(module_app_id)
create_tag(module_app, name, taggings)
end
end
end