diff --git a/app/assets/Archive/javascripts/devise.js.erb b/app/assets/Archive/javascripts/devise.js.erb index c6412f9a5..cfe9f50cf 100644 --- a/app/assets/Archive/javascripts/devise.js.erb +++ b/app/assets/Archive/javascripts/devise.js.erb @@ -4,4 +4,4 @@ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // the compiled file. // -//= require new_admin \ No newline at end of file +//= require back_end \ No newline at end of file diff --git a/app/assets/Archive/stylesheets/devise.css.erb b/app/assets/Archive/stylesheets/devise.css.erb index e9bad0ed3..7b9210786 100644 --- a/app/assets/Archive/stylesheets/devise.css.erb +++ b/app/assets/Archive/stylesheets/devise.css.erb @@ -2,5 +2,5 @@ *This is a manifest file that'll automatically include all the stylesheets available in this directory *and any sub-directories. You're free to add application-wide styles to this file and they'll appear at *the top of the compiled file, but it's generally better to create a new file per style scope. - *= require new_admin + *= require back_end */ \ No newline at end of file diff --git a/app/assets/javascripts/admin/module_tags.js b/app/assets/javascripts/admin/module_tags.js new file mode 100644 index 000000000..fd85a18e2 --- /dev/null +++ b/app/assets/javascripts/admin/module_tags.js @@ -0,0 +1 @@ +//= require admin/tags \ No newline at end of file diff --git a/app/assets/javascripts/admin/tags.js b/app/assets/javascripts/admin/tags.js new file mode 100644 index 000000000..6356444a6 --- /dev/null +++ b/app/assets/javascripts/admin/tags.js @@ -0,0 +1 @@ +//= require lib/tags \ No newline at end of file diff --git a/app/assets/javascripts/back_end.js b/app/assets/javascripts/back_end.js new file mode 100644 index 000000000..affd9a06a --- /dev/null +++ b/app/assets/javascripts/back_end.js @@ -0,0 +1,5 @@ +//= require basic +//= require lib/footable-0.1.js +//= require lib/all-list +//= require lib/jquery.fastLiveFilter.js +//= require lib/checkbox.card.js \ No newline at end of file diff --git a/app/assets/javascripts/lib/tags.js b/app/assets/javascripts/lib/tags.js deleted file mode 100644 index bf5f58e7f..000000000 --- a/app/assets/javascripts/lib/tags.js +++ /dev/null @@ -1,118 +0,0 @@ -function checkTagsQuantity() { - var $tagLead = $('.tag-lead'), - $tagsGroups = $('.tags-groups'); - - $tagsGroups.each(function(i) { - var $children = $(this).children().length; - $tagLead.eq(i).children('.badge').text($children); - }) -} - -function checkedLength() { - var $card = $('.card'), - $moduleTags, - $defaultTags, - $toDefault; - $card.on('click', function() { - if($('.default-tags').length) { - $moduleTags = $('.module-tags input[type="checkbox"]:checked'); - $defaultTags = $('.default-tags input[type="checkbox"]:checked'); - - if($moduleTags.length > 1 || $moduleTags.length+$defaultTags.length > 1) { - $('#mergerTags').removeClass('hide'); - } else { - $('#mergerTags').addClass('hide'); - }; - - if ($moduleTags.length > 0 || $defaultTags.length > 0) { - $('#deselect').removeClass('hide'); - $('#deleteTags').removeClass('hide'); - $('#deselect').on('click', deselect); - } else { - $('#deselect').addClass('hide'); - $('#deleteTags').addClass('hide'); - $('#deselect').off('click', deselect); - }; - - if ($moduleTags.length > 0 && $defaultTags.length == 0) { - $('#addDefault').removeClass('hide'); - } else { - $('#addDefault').addClass('hide'); - }; - } else { - $moduleTags = $('.module-tags input[type="checkbox"]:checked'); - - if ($moduleTags.length > 0) { - $('#deselect').removeClass('hide'); - $('#deleteTags').removeClass('hide'); - $('#deselect').on('click', deselect); - } else { - $('#deselect').addClass('hide'); - $('#deleteTags').addClass('hide'); - $('#deselect').off('click', deselect); - }; - }; - }) - $('#mergerTags').on('click', function() { - if($moduleTags || $defaultTags) { - if($moduleTags.length > 1 || $moduleTags.length+$defaultTags.length > 1) { - mergerTags() - } - } - }); - - function deselect() { - $('.tags input[type="checkbox"]').attr('checked', false); - $('.card').removeClass('active'); - $('.bottomnav button').not('.open-slide').addClass('hide'); - } -} - - -function addTagsTab() { - $('#add-tags .nav a').click(function (e) { - e.preventDefault(); - $(this).tab('show'); - }) -} - - -function mergerTags() { - var $moduleTags = $('.module-tags input[type="checkbox"]:checked'), - $defaultTags = $('.default-tags input[type="checkbox"]:checked'); - - $defaultTags.each(function(i) { - $defaultTags.eq(i).parents('.filter-item').clone().appendTo('#tags-merger .tags-groups'); - $('#tags-merger .tags-groups .filter-item').addClass('def'); - }); - $moduleTags.each(function(i) { - $moduleTags.eq(i).parents('.filter-item').clone().appendTo('#tags-merger .tags-groups'); - }); - - $('#tags-merger').modal('show', changeTagName()); - function changeTagName() { - var $tagsMerger = $('#tags-merger'), - $newTagsName = $('.new-tags-name'), - $filterItem = $tagsMerger.find('.filter-item'); - $filterItem.find('.card, .amount').remove(); - $filterItem.find('a').removeAttr('class'); - $filterItem.find('a').removeAttr('href'); - $filterItem.on('click', function() { - $(this).find('.tag').each(function(i) { - $newTagsName.eq(i).val($(this).text()) - }); - }); - } -} -$(function() { - if($('.default-tags').length) { - checkTagsQuantity(); - checkedLength(); - $('#tags-merger').on('hidden', function () { - $(this).find('.filter-item').remove(); - }); - } else { - checkedLength(); - }; - addTagsTab(); -}); \ No newline at end of file diff --git a/app/assets/javascripts/lib/tags.js.erb b/app/assets/javascripts/lib/tags.js.erb new file mode 100644 index 000000000..044a61ac3 --- /dev/null +++ b/app/assets/javascripts/lib/tags.js.erb @@ -0,0 +1,187 @@ +function checkTagsQuantity() { + var $tagLead = $('.tag-lead'), + $tagsGroups = $('.tags-groups'); + + $tagsGroups.each(function(i) { + var $children = $(this).children().length; + $tagLead.eq(i).children('.badge').text($children); + }) +} + +function checkedLength() { + var $card = $('.card'), + $moduleTags, + $defaultTags, + $toDefault; + $card.on('click', function() { + if($('.default-tags').length) { + $moduleTags = $('.module-tags input[type="checkbox"]:checked'); + $defaultTags = $('.default-tags input[type="checkbox"]:checked'); + var ids = new Array(); + + if($moduleTags.length > 1 || $moduleTags.length+$defaultTags.length > 1) { + $('#mergerTags').removeClass('hide'); + } else { + $('#mergerTags').addClass('hide'); + }; + + if ($moduleTags.length > 0 || $defaultTags.length > 0) { + $('#deselect').removeClass('hide'); + var ids = new Array(); + $defaultTags.each(function(i) { + ids.push($defaultTags.eq(i).parent().siblings('.tag_id').val()); + }); + $moduleTags.each(function(i) { + ids.push($moduleTags.eq(i).parent().siblings('.tag_id').val()); + }); + $('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_tags_path %>" + "?ids=" + ids); + $('#deleteTags').removeClass('hide'); + $('#deselect').on('click', deselect); + } else { + $('#deselect').addClass('hide'); + $('#deleteTags').attr('rel', ""); + $('#deleteTags').addClass('hide'); + $('#deselect').off('click', deselect); + }; + + if ($moduleTags.length > 0 && $defaultTags.length == 0) { + var ids = new Array(); + $moduleTags.each(function(i) { + ids.push($moduleTags.eq(i).parent().siblings('.tag_id').val()); + }); + $('#addDefault').attr('href', "<%= Rails.application.routes.url_helpers.add_to_default_admin_tags_path %>" + "?ids=" + ids); + $('#addDefault').removeClass('hide'); + } else { + $('#addDefault').attr('href', ""); + $('#addDefault').addClass('hide'); + }; + } else { + $moduleTags = $('.module-tags li.module input[type="checkbox"]:checked'); + $defaultTags = $('.module-tags li.default input[type="checkbox"]:checked'); + if($defaultTags.length > 0 || $moduleTags.length > 0) { + $('#deselect').removeClass('hide'); + $('#deselect').on('click', deselect); + if($defaultTags.length > 0 && $moduleTags.length > 0) { + $('#deleteTags').attr('rel', ""); + $('#deleteTags').addClass('hide'); + $('#removeDefault').attr('rel', ""); + $('#removeDefault').addClass('hide'); + $('#mergerTags').addClass('hide'); + } else if ($defaultTags.length > 0) { + var ids = new Array(); + $defaultTags.each(function(i) { + ids.push($defaultTags.eq(i).parent().siblings('.tag_id').val()); + }); + $('#removeDefault').attr('rel', "<%= Rails.application.routes.url_helpers.remove_default_admin_module_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids); + $('#removeDefault').removeClass('hide'); + } else { + var ids = new Array(); + $moduleTags.each(function(i) { + ids.push($moduleTags.eq(i).parent().siblings('.tag_id').val()); + }); + $('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_module_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids); + $('#deleteTags').removeClass('hide'); + if($moduleTags.length > 1) { + $('#mergerTags').removeClass('hide'); + } else { + $('#mergerTags').addClass('hide'); + }; + }; + } else { + $('#deselect').addClass('hide'); + $('#deleteTags').attr('rel', ""); + $('#deleteTags').addClass('hide'); + $('#removeDefault').attr('rel', ""); + $('#removeDefault').addClass('hide'); + $('#mergerTags').addClass('hide'); + $('#deselect').off('click', deselect); + }; + }; + }) + $('#mergerTags').on('click', function() { + if($moduleTags || $defaultTags) { + if($moduleTags.length > 1 || $moduleTags.length+$defaultTags.length > 1) { + $('#tags-merger form').attr("action", $(this).attr("rel")); + mergerTags() + } + } + }); + $('#deleteTags').on('click', function() { + $('#delete_tags .tags-groups').empty(); + $('#delete_tags a.delete-tags').attr("href", $(this).attr("rel")); + if($defaultTags) { + $defaultTags.each(function(i) { + $defaultTags.eq(i).parents('.filter-item').clone().appendTo('#delete_tags .tags-groups'); + $('#delete_tags .tags-groups .filter-item').addClass('def'); + }); + } + $moduleTags.each(function(i) { + $moduleTags.eq(i).parents('.filter-item').clone().appendTo('#delete_tags .tags-groups'); + }); + $('#delete_tags').modal('show', cleanTagInputs()); + function cleanTagInputs(){ + var $tagsMerger = $('#delete_tags'), + $filterItem = $tagsMerger.find('.filter-item'); + $filterItem.find('.card, .amount').remove(); + $filterItem.find('a').removeAttr('class'); + $filterItem.find('a').removeAttr('href'); + } + }); + + function deselect() { + $('.tags input[type="checkbox"]').attr('checked', false); + $('.card').removeClass('active'); + $('.bottomnav .toggable').not('.open-slide').addClass('hide'); + $('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_tags_path %>"); + $('#addDefault').attr('href', "<%= Rails.application.routes.url_helpers.add_to_default_admin_tags_path %>"); + } +} + + +function addTagsTab() { + $('#add-tags .nav a').click(function (e) { + e.preventDefault(); + $(this).tab('show'); + }) +} + + +function mergerTags() { + var $moduleTags = $('.module-tags input[type="checkbox"]:checked'), + $defaultTags = $('.default-tags input[type="checkbox"]:checked'); + + $defaultTags.each(function(i) { + $defaultTags.eq(i).parents('.filter-item').clone().appendTo('#tags-merger .tags-groups'); + $('#tags-merger .tags-groups .filter-item').addClass('def'); + }); + $moduleTags.each(function(i) { + $moduleTags.eq(i).parents('.filter-item').clone().appendTo('#tags-merger .tags-groups'); + }); + + $('#tags-merger').modal('show', changeTagName()); + function changeTagName() { + var $tagsMerger = $('#tags-merger'), + $newTagsName = $('.new-tags-name'), + $filterItem = $tagsMerger.find('.filter-item'); + $filterItem.find('.card, .amount').remove(); + $filterItem.find('a').removeAttr('class'); + $filterItem.find('a').removeAttr('href'); + $filterItem.on('click', function() { + $(this).find('.tag').each(function(i) { + $newTagsName.eq(i).val($(this).text()) + }); + }); + } +} +$(function() { + if($('.default-tags').length) { + // checkTagsQuantity(); + checkedLength(); + $('#tags-merger').on('hidden', function () { + $(this).find('.filter-item').remove(); + }); + } else { + checkedLength(); + }; + addTagsTab(); +}); diff --git a/app/assets/stylesheets/admin/module_tags.css b/app/assets/stylesheets/admin/module_tags.css new file mode 100644 index 000000000..1c7952e75 --- /dev/null +++ b/app/assets/stylesheets/admin/module_tags.css @@ -0,0 +1,3 @@ +/* + *= require admin/tags +*/ \ No newline at end of file diff --git a/app/assets/stylesheets/admin/tags.css b/app/assets/stylesheets/admin/tags.css new file mode 100644 index 000000000..16aacf928 --- /dev/null +++ b/app/assets/stylesheets/admin/tags.css @@ -0,0 +1,3 @@ +/* + *= require lib/tags-groups +*/ \ No newline at end of file diff --git a/app/assets/stylesheets/back_end.css b/app/assets/stylesheets/back_end.css new file mode 100644 index 000000000..9106a19bb --- /dev/null +++ b/app/assets/stylesheets/back_end.css @@ -0,0 +1,7 @@ +/* + *= require basic + *= require lib/wrap-nav + *= require lib/main-list + *= require lib/filter + *= require lib/pageslide +*/ \ No newline at end of file diff --git a/app/controllers/admin/dashboards_controller.rb b/app/controllers/admin/dashboards_controller.rb index 756c41b57..328a4a57c 100644 --- a/app/controllers/admin/dashboards_controller.rb +++ b/app/controllers/admin/dashboards_controller.rb @@ -1,5 +1,5 @@ class Admin::DashboardsController < OrbitBackendController - layout "new_admin" + #before_filter :set_current_user #before_filter :authenticate_user!, :except => [:index] # before_filter :is_admin? diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 826c025d3..f85248a88 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -3,7 +3,6 @@ class Admin::DesignsController < OrbitBackendController require "uri" require 'zip/zip' - layout "new_admin" before_filter :authenticate_user! before_filter :is_admin? before_filter :for_admin_only diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb index 5059c88d5..7d7b3ee96 100644 --- a/app/controllers/admin/infos_controller.rb +++ b/app/controllers/admin/infos_controller.rb @@ -1,6 +1,5 @@ class Admin::InfosController < OrbitBackendController - layout "new_admin" before_filter :authenticate_user! before_filter :is_admin? before_filter :set_attribute, :only => [:index, :show, :new, :edit] diff --git a/app/controllers/admin/items_controller.rb b/app/controllers/admin/items_controller.rb index db18870da..e5a2c2be7 100644 --- a/app/controllers/admin/items_controller.rb +++ b/app/controllers/admin/items_controller.rb @@ -1,11 +1,13 @@ class Admin::ItemsController < OrbitBackendController layout "structure" - + + # TODO = put back ======================== # before_filter :authenticate_user! # before_filter :find_parent_item # before_filter :is_admin? # before_filter :set_current_item + #========================================= def index if params[:item_id] diff --git a/app/controllers/admin/member_selects_controller.rb b/app/controllers/admin/member_selects_controller.rb index 9d7e6643d..c61c94b4d 100644 --- a/app/controllers/admin/member_selects_controller.rb +++ b/app/controllers/admin/member_selects_controller.rb @@ -1,7 +1,5 @@ class Admin::MemberSelectsController < OrbitBackendController - layout "new_admin" - def index # @member_selects = OrbitApp::Module::Role.all diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index c80f7228e..ccbe6962e 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -2,7 +2,6 @@ class Admin::ModuleAppsController < OrbitBackendController before_filter :user_has_manager_privilege?, :only => [ :assign_manager, :remove_manager ] before_filter :user_has_sub_manager_privilege?, :only => [ :assign_sub_manager, :remove_sub_manager ] - layout "new_admin" helper Admin::PagePartsHelper def index @module_apps = ModuleApp.all.entries diff --git a/app/controllers/admin/module_apps_new_interface_controller.rb b/app/controllers/admin/module_apps_new_interface_controller.rb index b0af8bd67..ccdd53a8a 100644 --- a/app/controllers/admin/module_apps_new_interface_controller.rb +++ b/app/controllers/admin/module_apps_new_interface_controller.rb @@ -3,8 +3,6 @@ class Admin::ModuleAppsNewInterfaceController < OrbitBackendController # before_filter :authenticate_user! # before_filter :is_admin? include AdminHelper - - layout "new_admin" def check_auth diff --git a/app/controllers/admin/module_store_controller.rb b/app/controllers/admin/module_store_controller.rb index 263a07327..0bbc5aa88 100644 --- a/app/controllers/admin/module_store_controller.rb +++ b/app/controllers/admin/module_store_controller.rb @@ -1,6 +1,6 @@ class Admin::ModuleStoreController < ApplicationController - layout "new_admin" + layout "back_end" def index end diff --git a/app/controllers/admin/module_tags_controller.rb b/app/controllers/admin/module_tags_controller.rb index 1eb3e801d..6d83685df 100644 --- a/app/controllers/admin/module_tags_controller.rb +++ b/app/controllers/admin/module_tags_controller.rb @@ -1,7 +1,10 @@ class Admin::ModuleTagsController < OrbitBackendController + include OrbitTag::Merging before_filter :force_order_for_visitor, only: [:index] before_filter :force_order_for_user, except: [:index] before_filter :for_app_sub_manager, except: [:index] + + helper 'admin/tags' def index @tags = get_tags @@ -10,28 +13,63 @@ class Admin::ModuleTagsController < OrbitBackendController end def new - + @tag = Tag.new + render layout: false end def edit @tag = Tag.find(params[:id]) + render layout: false end def create - @tag = @module_app ? @module_app.module_tags.create(params[:tag]) + @tag = @module_app.module_tags.build(params[:tag]) + if @tag.save + redirect_to admin_module_tags_url(module_app_id: @module_app_id) + else + @tag = Tag.new(params[:tag]) + flash.now[:error] = t('create.error.tag') + render :action => "new" + end end def update @tag = Tag.find(params[:id]) - @tag.update_attributes(params[:tag]) + if @tag.update_attributes(params[:tag]) + redirect_to admin_module_tags_url(module_app_id: @module_app_id) + else + flash.now[:error] = t('update.error.link') + render :action => "edit" + end end - def destroy - @tag = Tag.find(params[:id]) - @tag.destroy - respond_to do |format| - format.js { render 'js/remove_element', :locals => {:id => "#{dom_id @tag}"} } + def delete_tags + tags = Tag.find(params[:ids].split(',')) rescue nil + if tags + tags.each{|t|t.destroy} end + redirect_to admin_module_tags_url(module_app_id: @module_app_id) + end + + def merge + tags = Tag.find(params[:ids]) + taggings = tags.map{|t| t.taggings}.flatten + tag_leases = tags.map{|t| t.tag_lease} + name = params[:name] + merge_tags(name, taggings, @module_app_id) + tag_leases.each(&:destroy) + redirect_to admin_module_tags_url(module_app_id: @module_app_id) + end + + def remove_default + debugger + # tags = Tag.find(params[:ids].split(',')) rescue nil + # if tags + # tag_leases = tags.map{|t| t.tag_lease}.flatten + # tag_leases.each {|t| t.update_attribute(:module_app_ids, t.module_app_ids - [@module_app.id])} + # tags.each {|t| t.update_attribute(:is_default, true)} + # end + redirect_to admin_module_tags_url(module_app_id: @module_app_id) end def update_included_default diff --git a/app/controllers/admin/object_auths_controller.rb b/app/controllers/admin/object_auths_controller.rb index 086ca28c0..416e570cc 100644 --- a/app/controllers/admin/object_auths_controller.rb +++ b/app/controllers/admin/object_auths_controller.rb @@ -1,6 +1,6 @@ class Admin::ObjectAuthsController < OrbitBackendController include OrbitCoreLib::PermissionUtility - layout "new_admin" + before_filter :force_order # before_filter :is_admin? ,:only => :index diff --git a/app/controllers/admin/plugins_controller.rb b/app/controllers/admin/plugins_controller.rb index 431bc3fe4..1111f6539 100644 --- a/app/controllers/admin/plugins_controller.rb +++ b/app/controllers/admin/plugins_controller.rb @@ -1,6 +1,6 @@ class Admin::PluginsController < ApplicationController - layout "new_admin" + layout "back_end" def index diff --git a/app/controllers/admin/purchases_controller.rb b/app/controllers/admin/purchases_controller.rb index d1d5039e2..e5031e9cf 100644 --- a/app/controllers/admin/purchases_controller.rb +++ b/app/controllers/admin/purchases_controller.rb @@ -3,8 +3,6 @@ class Admin::PurchasesController < OrbitBackendController require "uri" require 'zip/zip' - layout "new_admin" - def index @purchases = Purchase.all.entries end diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index a71d5ca06..f01d859a6 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -1,6 +1,5 @@ class Admin::RolesController < OrbitBackendController - layout "new_admin" before_filter :authenticate_user! before_filter :is_admin? before_filter :set_attribute, :only => [:index, :show, :new, :edit, :role_field, :sub_role, :add_sub_role, :edit_sub_role, :sub_role_field] diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index 33f9582f4..c17a6f166 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -1,6 +1,5 @@ class Admin::SitesController < OrbitBackendController - layout "new_admin" before_filter :authenticate_user! before_filter :is_admin? before_filter :get_site diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index 921cf3c7d..73d0401a5 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -1,4 +1,5 @@ class Admin::TagsController < OrbitBackendController + include OrbitTag::Merging before_filter :force_order_for_visitor, only: [:index] before_filter :force_order_for_user, except: [:index] before_filter :for_app_sub_manager, except: [:index] @@ -9,74 +10,67 @@ class Admin::TagsController < OrbitBackendController end def new - + @tag = Tag.new + render layout: false end def edit @tag = Tag.find(params[:id]) + render layout: false end def create - @tag = @module_app.module_tags.create(params[:tag].merge(is_default: true)) + @tag = @module_app.module_tags.build(params[:tag].merge(is_default: true)) + if @tag.save + redirect_to admin_tags_url + else + @tag = Tag.new(params[:tag]) + flash.now[:error] = t('create.error.tag') + render :action => "new" + end end def update @tag = Tag.find(params[:id]) - @tag.update_attributes(params[:tag]) - end - - def destroy - @tag = Tag.find(params[:id]) - @tag.destroy - respond_to do |format| - format.js { render 'js/remove_element', :locals => {:id => "#{dom_id @tag}"} } + if @tag.update_attributes(params[:tag]) + redirect_to action: :index + else + flash.now[:error] = t('update.error.link') + render :action => "edit" end end def add_to_default - tags = Tag.find(params[:ids]) - tag_leases = tags.map{|t| t.tag_lease} - tags.each {|t| t.update_attribute(:is_default, true)} - tag_leases.each {|t| t.update_attribute(:module_app_ids, module_app_ids << @module_app.id)} + tags = Tag.find(params[:ids].split(',')) rescue nil + if tags + tag_leases = tags.map{|t| t.tag_lease}.flatten + tags.each {|t| t.update_attribute(:is_default, true)} + tag_leases.each {|t| t.update_attribute(:module_app_ids, t.module_app_ids << @module_app.id)} + end + redirect_to admin_tags_url + end + + def delete_tags + tags = Tag.find(params[:ids].split(',')) rescue nil + if tags + tags.each{|t|t.destroy} + end + redirect_to admin_tags_url end def merge tags = Tag.find(params[:ids]) - taggings = tags.map{|t| t.taggings} + taggings = tags.map{|t| t.taggings}.flatten tag_leases = tags.map{|t| t.tag_lease} name = params[:name] module_app_ids = tag_leases.map{|t| t.module_app_ids}.flatten.uniq if tags.detect{|t| t.is_default == true} || module_app_ids.count > 1 merge_default_tags(name, taggings, module_app_ids) else - merge_tags(name, tags, module_app_ids[0]) + merge_tags(name, taggings, module_app_ids[0]) end - taggings.each(&:destroy) tag_leases.each(&:destroy) - end - - 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], default=false) - new_tag = module_app.tags.create(name_translations: name, is_default: default) - taggings.each do |tagging| - tagging.tag = new_tag - tagging.save - end - tag_lease = new_tag.create_tag_lease(module_app_ids: (module_app_ids << module_app).uniq, is_default: default) - 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) + redirect_to admin_tags_url end end diff --git a/app/controllers/admin/template_store_controller.rb b/app/controllers/admin/template_store_controller.rb index a8656d82a..ee1571eb0 100644 --- a/app/controllers/admin/template_store_controller.rb +++ b/app/controllers/admin/template_store_controller.rb @@ -1,6 +1,6 @@ class Admin::TemplateStoreController < ApplicationController - layout "new_admin" + layout "back_end" def index @templates = JSON.parse(get_templates) diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 23eace929..38a52ba39 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -1,6 +1,5 @@ class Admin::UsersNewInterfaceController < OrbitBackendController - layout "new_admin" # before_filter :authenticate_user! # before_filter :set_attribute, :only => [:index, :show, :new, :edit] diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7bcd90e03..afdf89757 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -13,7 +13,7 @@ class ApplicationController < ActionController::Base layout :layout_by_resource helper :admin, :orbit_form - before_filter :set_site, :set_locale, :prepare_for_mobile + before_filter :set_locale, :set_site, :prepare_for_mobile helper_attr :site_valid_locales diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 338c9d1c5..9a79ab45c 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -5,7 +5,7 @@ class OrbitBackendController < ApplicationController include AdminHelper include ApplicationHelper - layout 'new_admin' + layout "back_end" def setup_vars @app_title ||= controller_path.split('/')[1].singularize diff --git a/app/helpers/admin/items_helper.rb b/app/helpers/admin/items_helper.rb index 52ca9c85f..7df0dad70 100644 --- a/app/helpers/admin/items_helper.rb +++ b/app/helpers/admin/items_helper.rb @@ -40,14 +40,5 @@ module Admin::ItemsHelper '' end end - - def get_item_module_infos(item) - if module_app = item.module_app - app = OrbitApp::Module::Registration.find_by_key(module_app.key) - [t(app.get_label_i18n), (app.get_icon_class rescue 'icons-daniel-bruce-2')] - else - [t(:no_app), 'icons-daniel-bruce-2'] - end - end end diff --git a/app/helpers/admin/tags_helper.rb b/app/helpers/admin/tags_helper.rb new file mode 100644 index 000000000..afdcaaebf --- /dev/null +++ b/app/helpers/admin/tags_helper.rb @@ -0,0 +1,10 @@ +module Admin::TagsHelper + + def show_names_slash(tag) + span_names = @site_valid_locales.inject([]) do |names, locale| + names << content_tag(:span, tag.name_translations[locale], class: "tag") + end + span_names.join(" / ").html_safe + end + +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d9e4f512a..9c1e3c785 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -272,4 +272,9 @@ module ApplicationHelper "http://#{request.host}:2#{site_number}00" end + def get_module_app_icon(module_app) + app = OrbitApp::Module::Registration.find_by_key(module_app.key) + app.get_icon_class rescue 'icons-daniel-bruce-2' + end + end diff --git a/app/models/module_tag.rb b/app/models/module_tag.rb index 52eac9b43..415a9cd14 100644 --- a/app/models/module_tag.rb +++ b/app/models/module_tag.rb @@ -2,19 +2,25 @@ class ModuleTag include Mongoid::Document include Mongoid::Timestamps - field :is_default, type: Boolean, deault: false + field :is_default, type: Boolean, default: false - has_one :tag, as: :tag_lease, dependent: :destroy, autosave: true + has_one :tag, as: :tag_lease, autosave: true has_and_belongs_to_many :module_apps after_initialize :init_tag + before_destroy :destroy_tag private def init_tag if new_record? self.build_tag(name_translations: self.name_translations, is_default: self.is_default) - self.remove_attribute(:name_translations) + end + end + + def destroy_tag + Tag.without_callback(:destroy, :before, :destroy_module_tag) do + self.tag.destroy end end diff --git a/app/models/tag.rb b/app/models/tag.rb index 48c350c87..9077453a4 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -12,12 +12,16 @@ class Tag field :name, localize: true field :cloud_view_count, type: Integer, default: 0 - field :is_default, type: Boolean, deault: false + field :is_default, type: Boolean, default: false field :view_count, type: Integer, default: 0 - belongs_to :tag_lease, polymorphic: true, dependent: :destroy + belongs_to :tag_lease, polymorphic: true has_many :taggings, dependent: :destroy + validates :name, :at_least_one => true + + before_destroy :destroy_module_tag, if: Proc.new { |tag| tag.tag_lease_type.eql?("ModuleTag") } + def self.sorted_for_cloud tags = {} self.all.each{ |tag| @@ -46,4 +50,12 @@ class Tag item_tag.impressions.where(:created_at.gte=> 14.days.ago,:created_at.lte => Time.now).count end + private + + def destroy_module_tag + ModuleTag.without_callback(:destroy, :before, :destroy_tag) do + self.tag_lease.destroy + end + end + end diff --git a/app/views/admin/items/_node.html.erb b/app/views/admin/items/_node.html.erb index b67db54ee..732d500d9 100644 --- a/app/views/admin/items/_node.html.erb +++ b/app/views/admin/items/_node.html.erb @@ -10,7 +10,7 @@ <% end %>
- <%= link_to node.title, "/"+node.path %> + <%= link_to node.title, "/" + node.path %>
<%= link_to content_tag(:i, nil, class: "icon-eye-open"), eval("admin_#{node.class.to_s.downcase}_path(node)"), class: "view-page open-slide tip", title: t(:view) if node.class.to_s.eql?('Page') %> <%= link_to content_tag(:i, nil, class: "icon-edit"), eval("edit_admin_#{node.class.to_s.downcase}_path(node)"), class: "open-slide tip", title: t(:edit) %> diff --git a/app/views/admin/module_tags/_add.html.erb b/app/views/admin/module_tags/_add.html.erb index d09a74a6b..4e9bb1d82 100644 --- a/app/views/admin/module_tags/_add.html.erb +++ b/app/views/admin/module_tags/_add.html.erb @@ -1,4 +1,4 @@ -<%= form_for :tag, :url => admin_tags_path, :remote => true, :html => {:id => 'tag_form'} do |f| %> +<%= form_for :tag, :url => admin_module_tags_path, :remote => true, :html => {:id => 'tag_form'} do |f| %> <%= f.fields_for :name_translations do |f| %> <% @site_valid_locales.each do |locale| %> <%= I18nVariable.from_locale(locale) %>:<%= f.text_field locale %> diff --git a/app/views/admin/module_tags/_edit.html.erb b/app/views/admin/module_tags/_edit.html.erb new file mode 100644 index 000000000..0725c75a3 --- /dev/null +++ b/app/views/admin/module_tags/_edit.html.erb @@ -0,0 +1,10 @@ +<%= form_for @tag, url: admin_module_tag_path(@tag, module_app_id: @module_app_id), remote: true do |f| %> +
+ <%= t('editing.tag') %> + <%= render partial: "admin/tags/form", :locals => { :f => f } %> +
+ <%= t(:cancel) %> + <%= f.submit t(:update_), class: 'btn btn-primary btn-small' %> +
+
+<% end %> diff --git a/app/views/admin/module_tags/_form.html.erb b/app/views/admin/module_tags/_form.html.erb deleted file mode 100644 index 5715b8dfc..000000000 --- a/app/views/admin/module_tags/_form.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<%= form_for :tag, :url => admin_tag_path(tag), :method => :put, :remote => true do |f| %> - <%= f.fields_for :name_translations do |f| %> - <% @site_valid_locales.each do |locale| %> - <%= I18nVariable.from_locale(locale) %>:<%= f.text_field locale, value: @tag.name_translations[locale] %> - <% end %> - <% end %> - <%= hidden_field_tag :module_app_id, @module_app_id %> - <%= f.submit t(:update_) %> -<% end %> \ No newline at end of file diff --git a/app/views/admin/module_tags/_index.html.erb b/app/views/admin/module_tags/_index.html.erb new file mode 100644 index 000000000..410cb7c49 --- /dev/null +++ b/app/views/admin/module_tags/_index.html.erb @@ -0,0 +1,31 @@ +<%= hidden_field_tag 'module_app_id', @module_app_id %> + + +
+
+ + <%= link_to t(:delete), '#', id: "deleteTags", class: "btn btn-danger toggable hide", rel: '' %> + <%= link_to t(:merge), '#', id: "mergerTags", class: "btn btn-success toggable hide", rel: merge_admin_module_tags_path(module_app_id: @module_app_id) %> + <%= link_to t(:remove_default), remove_default_admin_module_tags_path(module_app_id: @module_app_id), id: "removeDefault", class: "btn btn-info toggable hide", method: :post %> + <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), new_admin_module_tag_path(module_app_id: @module_app_id), class: "btn btn-primary open-slide" %> +
+
+ + + +
+
+
    + <%= render partial: "tag", collection: @tags %> +
+
+
+ + + +<%= render 'admin/tags/merge_modal' %> + + + +<%= render 'admin/tags/delete_modal' %> + \ No newline at end of file diff --git a/app/views/admin/module_tags/_new.html.erb b/app/views/admin/module_tags/_new.html.erb new file mode 100644 index 000000000..a19a671c5 --- /dev/null +++ b/app/views/admin/module_tags/_new.html.erb @@ -0,0 +1,80 @@ +
+Add Tags + +
+ +
+ <%= form_for @tag, url: admin_module_tags_path(module_app_id: @module_app_id), remote: true, id: 'create_new_tags' do |f| %> +
+ <%= render partial: "admin/tags/form", :locals => { :f => f } %> +
+ <%= t(:cancel) %> + <%= f.submit t(:create_), class: 'btn btn-primary btn-small' %> +
+
+ <% end %> +
+ + +
+
\ No newline at end of file diff --git a/app/views/admin/module_tags/_tag.html.erb b/app/views/admin/module_tags/_tag.html.erb index d8e43df26..9105c232e 100644 --- a/app/views/admin/module_tags/_tag.html.erb +++ b/app/views/admin/module_tags/_tag.html.erb @@ -1,13 +1,17 @@ -
-
- - <% @site_valid_locales.each do |locale| %> - <%#= I18nVariable.from_locale(locale) %> - <%= tag.name_translations[locale] %> - <% end %> -
-
- <%= link_to t(:edit), edit_admin_tag_path(tag, :module_app_id => @module_app_id), :remote => true %> - <%= link_to t(:delete_), admin_tag_path(tag), :confirm => t('sure?'), :method => :delete, :remote => true %> -
-
\ No newline at end of file +
  • +

    + +

    + <%= hidden_field_tag "ids[]", tag.id, class: "tag_id" %> + <% if tag.is_default %> + + <%= tag.taggings.count %> + <%= show_names_slash(tag) %> + + <% else %> + <%= link_to edit_admin_module_tag_path(tag, module_app_id: @module_app_id), class: "open-slide" do %> + <%= tag.taggings.count %> + <%= show_names_slash(tag) %> + <% end %> + <% end %> +
  • \ No newline at end of file diff --git a/app/views/admin/module_tags/create.js.erb b/app/views/admin/module_tags/create.js.erb deleted file mode 100644 index 8c1ca6ad1..000000000 --- a/app/views/admin/module_tags/create.js.erb +++ /dev/null @@ -1,4 +0,0 @@ -$('#tag_form').each(function(){ - this.reset(); -}); -$('#tags').append("<%= j render :partial => 'tag', :object => @tag %>") \ No newline at end of file diff --git a/app/views/admin/module_tags/edit.html.erb b/app/views/admin/module_tags/edit.html.erb new file mode 100644 index 000000000..96ba353ad --- /dev/null +++ b/app/views/admin/module_tags/edit.html.erb @@ -0,0 +1 @@ +<%= render 'edit' %> diff --git a/app/views/admin/module_tags/edit.js.erb b/app/views/admin/module_tags/edit.js.erb index 74fd34ec6..30d88e18a 100644 --- a/app/views/admin/module_tags/edit.js.erb +++ b/app/views/admin/module_tags/edit.js.erb @@ -1 +1 @@ -$('#<%= dom_id @tag %>').html("<%= j render :partial => 'form', :locals => {:tag => @tag} %>") \ No newline at end of file +$('#view-page .content').html("<%= j render 'edit' %>"); \ No newline at end of file diff --git a/app/views/admin/module_tags/index.html.erb b/app/views/admin/module_tags/index.html.erb index 2056bdd88..1ebc6c15e 100644 --- a/app/views/admin/module_tags/index.html.erb +++ b/app/views/admin/module_tags/index.html.erb @@ -1,17 +1,3 @@ - -
    - <%= render :partial => 'tag', :collection => @tags %> -
    -
    - <%= render 'add' %> +
    + <%= render 'index' %>
    \ No newline at end of file diff --git a/app/views/admin/module_tags/index.js.erb b/app/views/admin/module_tags/index.js.erb new file mode 100644 index 000000000..a1c2e5e7f --- /dev/null +++ b/app/views/admin/module_tags/index.js.erb @@ -0,0 +1,7 @@ +$("#delete_tags").modal('hide'); +$("#tags-merger").modal('hide'); +$("#tags_index").html("<%= j render 'index' %>") +$.pageslide.close(); +openSlide(); +cardCheck(); +checkedLength() \ No newline at end of file diff --git a/app/views/admin/module_tags/new.html.erb b/app/views/admin/module_tags/new.html.erb new file mode 100644 index 000000000..41230acde --- /dev/null +++ b/app/views/admin/module_tags/new.html.erb @@ -0,0 +1 @@ +<%= render 'new' %> diff --git a/app/views/admin/module_tags/new.js.erb b/app/views/admin/module_tags/new.js.erb new file mode 100644 index 000000000..5ecf8f163 --- /dev/null +++ b/app/views/admin/module_tags/new.js.erb @@ -0,0 +1 @@ +$('#view-page .content').html("<%= j render 'new' %>"); \ No newline at end of file diff --git a/app/views/admin/tags/_delete_modal.html.erb b/app/views/admin/tags/_delete_modal.html.erb new file mode 100644 index 000000000..4dc173817 --- /dev/null +++ b/app/views/admin/tags/_delete_modal.html.erb @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/app/views/admin/tags/_edit.html.erb b/app/views/admin/tags/_edit.html.erb new file mode 100644 index 000000000..089d87fbc --- /dev/null +++ b/app/views/admin/tags/_edit.html.erb @@ -0,0 +1,10 @@ +<%= form_for @tag, url: admin_tag_path(@tag), remote: true do |f| %> +
    + <%= t('editing.tag') %> + <%= render partial: "form", :locals => { :f => f } %> +
    + <%= t(:cancel) %> + <%= f.submit t(:update_), class: 'btn btn-primary btn-small' %> +
    +
    +<% end %> diff --git a/app/views/admin/tags/_form.html.erb b/app/views/admin/tags/_form.html.erb new file mode 100644 index 000000000..d89a705d3 --- /dev/null +++ b/app/views/admin/tags/_form.html.erb @@ -0,0 +1,9 @@ +<%= flash_messages %> +<%= f.error_messages %> + +<%= f.fields_for :name_translations do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= f.label :locale, "#{t(:name)} #{I18nVariable.from_locale(locale)}" %> + <%= f.text_field locale, class: 'input-large', placeholder: "#{t(:name)} #{I18nVariable.from_locale(locale)}", value: (@tag.name_translations[locale] rescue nil) %> + <% end %> +<% end %> diff --git a/app/views/admin/tags/_index.html.erb b/app/views/admin/tags/_index.html.erb new file mode 100644 index 000000000..1f3385c3f --- /dev/null +++ b/app/views/admin/tags/_index.html.erb @@ -0,0 +1,38 @@ + +
    +
    + + <%= link_to t(:delete), '#', id: "deleteTags", class: "btn btn-danger toggable hide", rel: '' %> + <%= link_to t(:merge), '#', id: "mergerTags", class: "btn btn-success toggable hide", rel: merge_admin_tags_path %> + <%= link_to t(:add_to_default), add_to_default_admin_tags_path, id: "addDefault", class: "btn btn-info toggable hide", method: :post, remote: true %> + <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), new_admin_tag_path, class: "btn btn-primary open-slide" %> +
    +
    + + + +
    +
    +

    <%= t(:default) %> <%= @tags.count %>

    +
      + <%= render partial: "tag", collection: @tags %> +
    + <% @module_apps.each do |module_app| %> + <% tags = module_app.tags %> + <% icon_name = get_module_app_icon(module_app) %> +

    <%= module_app.title %> <%= tags.count %>

    +
      + <%= render partial: "tag", collection: tags, locals: {in_module: true} %> +
    + <% end %> +
    +
    + + + +<%= render 'merge_modal' %> + + + +<%= render 'delete_modal' %> + diff --git a/app/views/admin/tags/_merge_modal.html.erb b/app/views/admin/tags/_merge_modal.html.erb new file mode 100644 index 000000000..9b09a9f57 --- /dev/null +++ b/app/views/admin/tags/_merge_modal.html.erb @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/app/views/admin/tags/_new.html.erb b/app/views/admin/tags/_new.html.erb new file mode 100644 index 000000000..de1d96650 --- /dev/null +++ b/app/views/admin/tags/_new.html.erb @@ -0,0 +1,10 @@ +<%= form_for @tag, url: admin_tags_path, remote: true do |f| %> +
    + <%= t('new.tag') %> + <%= render partial: "form", :locals => { :f => f } %> +
    + <%= t(:cancel) %> + <%= f.submit t(:create_), class: 'btn btn-primary btn-small' %> +
    +
    +<% end %> diff --git a/app/views/admin/tags/_tag.html.erb b/app/views/admin/tags/_tag.html.erb new file mode 100644 index 000000000..49b1cd040 --- /dev/null +++ b/app/views/admin/tags/_tag.html.erb @@ -0,0 +1,12 @@ +
  • + <% unless defined?(in_module) && tag.is_default %> +

    + +

    + <%= hidden_field_tag "ids[]", tag.id, class: "tag_id" %> + <% end %> + <%= link_to edit_admin_tag_path(tag), class: "open-slide" do %> + <%= tag.taggings.count %> + <%= show_names_slash(tag) %> + <% end %> +
  • \ No newline at end of file diff --git a/app/views/admin/tags/edit.html.erb b/app/views/admin/tags/edit.html.erb new file mode 100644 index 000000000..96ba353ad --- /dev/null +++ b/app/views/admin/tags/edit.html.erb @@ -0,0 +1 @@ +<%= render 'edit' %> diff --git a/app/views/admin/tags/edit.js.erb b/app/views/admin/tags/edit.js.erb new file mode 100644 index 000000000..30d88e18a --- /dev/null +++ b/app/views/admin/tags/edit.js.erb @@ -0,0 +1 @@ +$('#view-page .content').html("<%= j render 'edit' %>"); \ No newline at end of file diff --git a/app/views/admin/tags/index.html.erb b/app/views/admin/tags/index.html.erb new file mode 100644 index 000000000..c0ac9b508 --- /dev/null +++ b/app/views/admin/tags/index.html.erb @@ -0,0 +1,3 @@ +
    + <%= render 'index' %> +
    diff --git a/app/views/admin/tags/index.js.erb b/app/views/admin/tags/index.js.erb new file mode 100644 index 000000000..a1c2e5e7f --- /dev/null +++ b/app/views/admin/tags/index.js.erb @@ -0,0 +1,7 @@ +$("#delete_tags").modal('hide'); +$("#tags-merger").modal('hide'); +$("#tags_index").html("<%= j render 'index' %>") +$.pageslide.close(); +openSlide(); +cardCheck(); +checkedLength() \ No newline at end of file diff --git a/app/views/admin/tags/new.html.erb b/app/views/admin/tags/new.html.erb new file mode 100644 index 000000000..41230acde --- /dev/null +++ b/app/views/admin/tags/new.html.erb @@ -0,0 +1 @@ +<%= render 'new' %> diff --git a/app/views/admin/tags/new.js.erb b/app/views/admin/tags/new.js.erb new file mode 100644 index 000000000..5ecf8f163 --- /dev/null +++ b/app/views/admin/tags/new.js.erb @@ -0,0 +1 @@ +$('#view-page .content').html("<%= j render 'new' %>"); \ No newline at end of file diff --git a/app/views/layouts/back_end.html.erb b/app/views/layouts/back_end.html.erb new file mode 100644 index 000000000..25baa5d6e --- /dev/null +++ b/app/views/layouts/back_end.html.erb @@ -0,0 +1,37 @@ + + + + <%= @title || APP_CONFIG['orbit'] %> + <%= render 'layouts/meta' %> + <%= render 'layouts/google_font' %> + <%= stylesheet_link_tag "back_end" %> + <%= stylesheet_link_tag params[:controller] rescue nil %> + <%= render 'layouts/ie_html5_fix' %> + <%= javascript_include_tag "back_end" %> + <%= javascript_include_tag params[:controller] rescue nil %> + <%= yield :page_specific_css %> + <%= yield :page_specific_javascript %> + <%= csrf_meta_tag %> + + + <%= render 'layouts/orbit_bar' unless @no_orbit_bar %> + <%#= render 'layouts/side_bar' unless @no_side_bar %> + +
    +
    + <%= yield %> + + <%= javascript_include_tag "lib/jquery.pageslide.js" %> +
    +
    + + diff --git a/app/views/layouts/new_admin.html.erb b/app/views/layouts/new_admin.html.erb deleted file mode 100644 index 26f299fb2..000000000 --- a/app/views/layouts/new_admin.html.erb +++ /dev/null @@ -1,28 +0,0 @@ - - - - - <%= @title || APP_CONFIG['orbit'] %> - "> - - <%= stylesheet_link_tag "new_admin" %> - <%= javascript_include_tag "new_admin" %> - <%= yield :page_specific_css %> - <%= yield :page_specific_javascript %> - <%= csrf_meta_tag %> - - - <%= render 'layouts/orbit_bar' %> - <% if !(yield :side_bar).blank? %> - <%= yield :side_bar %> - <% else %> - <%= render 'layouts/side_bar' %> - <% end %> - -
    - <%= yield %> -
    - - diff --git a/config/locales/new_ui.en.yml b/config/locales/new_ui.en.yml index 646aa3742..51f282592 100644 --- a/config/locales/new_ui.en.yml +++ b/config/locales/new_ui.en.yml @@ -1,5 +1,25 @@ en: add_link: Add link add_page: Add page + add_to_default: Add to default + create: + error: + tag: Error when creating tag. + deselect: Deselect + editing: + tag: Editing tag login_orbit: Log In to Orbit - no_app: No module \ No newline at end of file + merge: Merge + new: + tag: New tag + no_app: No module + tag: + add: Add tag + delete: Delete tags + new_name: New tag name + merge_help: Select the name you want to use or own defined + merger: Tag Merger + warning: This action can not be restored, are you sure you want to delete these tags? + update: + error: + tag: Error when updating tag. \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 4cd690201..036fd9518 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -111,7 +111,13 @@ Orbit::Application.routes.draw do end end - resources :module_tags + resources :module_tags do + collection do + post 'delete_tags' + post 'merge' + post 'remove_default' + end + end resources :page_parts do member do @@ -153,7 +159,13 @@ Orbit::Application.routes.draw do get 'change_design' end - resources :tags + resources :tags do + collection do + post 'add_to_default' + post 'delete_tags' + post 'merge' + end + end resources :users resources :users_new_interface do diff --git a/lib/orbit_tag/taggable.rb b/lib/orbit_tag/taggable.rb index 248145f6e..0e14c3eb1 100644 --- a/lib/orbit_tag/taggable.rb +++ b/lib/orbit_tag/taggable.rb @@ -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 diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_files_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_files_controller.rb index 223e2ba53..a3ac3d0ff 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_files_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_files_controller.rb @@ -1,6 +1,6 @@ class Panel::Announcement::BackEnd::BulletinFilesController < ApplicationController - layout 'new_admin' + layout 'back_end' def index @bulletin_files = BulletinFile.all diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb index 59f164d9d..022d89649 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb @@ -1,6 +1,6 @@ class Panel::Announcement::BackEnd::BulletinLinksController < ApplicationController - layout 'new_admin' + layout 'back_end' def index @bulletin_links = BulletinLink.all