Tag management module completed
This commit is contained in:
1 parent
218592c1f9
commit
e028791d68
19 files changed
+201
-155
No files matched your search
@@ -12,12 +12,12 @@ class Admin::ModuleTagsController < OrbitBackendController
|
||||
helper 'admin/tags'
|
||||
|
||||
def index
|
||||
@included_tags = @module_app.module_tags.where(is_default: true)
|
||||
@tags = @module_app.module_tags
|
||||
@default_tags = get_default_tags
|
||||
end
|
||||
|
||||
def new
|
||||
@default_tags = get_default_tags_without_included
|
||||
@tag = ModuleTag.new
|
||||
render layout: false
|
||||
end
|
||||
@@ -73,7 +73,11 @@ class Admin::ModuleTagsController < OrbitBackendController
|
||||
end
|
||||
|
||||
def update_included_default
|
||||
@module_app.update_attribute(:module_tag_ids, (@module_app.module_tag_ids - get_default_tag_ids) << params[:ids])
|
||||
default_tags = ModuleTag.find(params[:ids].split(',')) rescue nil
|
||||
default_tags.each do |tag|
|
||||
clone_tag_from_default(tag)
|
||||
end
|
||||
redirect_to admin_module_tags_url(module_app_id: @module_app_id)
|
||||
end
|
||||
|
||||
protected
|
||||
@@ -84,8 +88,8 @@ class Admin::ModuleTagsController < OrbitBackendController
|
||||
@module_app_id = @module_app.id rescue nil
|
||||
end
|
||||
|
||||
def get_default_tags
|
||||
ModuleTag.where(is_default: true)
|
||||
def get_default_tags_without_included
|
||||
ModuleTag.where(is_default: true, parent_id: nil) - @module_app.module_tags.where(is_default: true).map{|m| m.parent }
|
||||
end
|
||||
|
||||
def get_default_tag_ids
|
||||
|
||||
@@ -50,11 +50,7 @@ class Admin::TagsController < OrbitBackendController
|
||||
if module_tags
|
||||
module_tags.each do |module_tag|
|
||||
module_tag.update_attribute(:is_default, true)
|
||||
new_tag = module_tag.clone
|
||||
new_tag['_id'] = BSON::ObjectId.new
|
||||
new_tag['module_app_id'] = @module_app.id
|
||||
new_tag.save
|
||||
module_tag.update_attribute(:parent_id, new_tag.id)
|
||||
clone_tag_to_default(module_tag)
|
||||
end
|
||||
end
|
||||
redirect_to admin_tags_url
|
||||
|
||||
Reference in new issue
Block a user