Tag management working but can't remove default tag from module
This commit is contained in:
parent
bf3d20ea46
commit
19405cf006
|
@ -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
|
||||
//= require back_end
|
|
@ -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
|
||||
*/
|
|
@ -0,0 +1 @@
|
|||
//= require admin/tags
|
|
@ -0,0 +1 @@
|
|||
//= require lib/tags
|
|
@ -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
|
|
@ -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();
|
||||
});
|
|
@ -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();
|
||||
});
|
|
@ -0,0 +1,3 @@
|
|||
/*
|
||||
*= require admin/tags
|
||||
*/
|
|
@ -0,0 +1,3 @@
|
|||
/*
|
||||
*= require lib/tags-groups
|
||||
*/
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
*= require basic
|
||||
*= require lib/wrap-nav
|
||||
*= require lib/main-list
|
||||
*= require lib/filter
|
||||
*= require lib/pageslide
|
||||
*/
|
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
class Admin::MemberSelectsController < OrbitBackendController
|
||||
|
||||
layout "new_admin"
|
||||
|
||||
def index
|
||||
|
||||
# @member_selects = OrbitApp::Module::Role.all
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,8 +3,6 @@ class Admin::ModuleAppsNewInterfaceController < OrbitBackendController
|
|||
# before_filter :authenticate_user!
|
||||
# before_filter :is_admin?
|
||||
include AdminHelper
|
||||
|
||||
layout "new_admin"
|
||||
|
||||
def check_auth
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Admin::ModuleStoreController < ApplicationController
|
||||
|
||||
layout "new_admin"
|
||||
layout "back_end"
|
||||
|
||||
def index
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Admin::ObjectAuthsController < OrbitBackendController
|
||||
include OrbitCoreLib::PermissionUtility
|
||||
layout "new_admin"
|
||||
|
||||
before_filter :force_order
|
||||
# before_filter :is_admin? ,:only => :index
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Admin::PluginsController < ApplicationController
|
||||
|
||||
layout "new_admin"
|
||||
layout "back_end"
|
||||
|
||||
def index
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ class Admin::PurchasesController < OrbitBackendController
|
|||
require "uri"
|
||||
require 'zip/zip'
|
||||
|
||||
layout "new_admin"
|
||||
|
||||
def index
|
||||
@purchases = Purchase.all.entries
|
||||
end
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class Admin::SitesController < OrbitBackendController
|
||||
|
||||
layout "new_admin"
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
before_filter :get_site
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Admin::TemplateStoreController < ApplicationController
|
||||
|
||||
layout "new_admin"
|
||||
layout "back_end"
|
||||
|
||||
def index
|
||||
@templates = JSON.parse(get_templates)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class Admin::UsersNewInterfaceController < OrbitBackendController
|
||||
|
||||
layout "new_admin"
|
||||
# before_filter :authenticate_user!
|
||||
# before_filter :set_attribute, :only => [:index, :show, :new, :edit]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<span title="<%= t(:link) %>" class="item-type link tip"><i class="icon-link"></i></span>
|
||||
<% end %>
|
||||
<div class="item-title">
|
||||
<%= link_to node.title, "/"+node.path %>
|
||||
<%= link_to node.title, "/" + node.path %>
|
||||
<div class="item-menu">
|
||||
<%= 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) %>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<%= form_for @tag, url: admin_module_tag_path(@tag, module_app_id: @module_app_id), remote: true do |f| %>
|
||||
<fieldset>
|
||||
<legend><%= t('editing.tag') %></legend>
|
||||
<%= render partial: "admin/tags/form", :locals => { :f => f } %>
|
||||
<div class="form-actions">
|
||||
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||
<%= f.submit t(:update_), class: 'btn btn-primary btn-small' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -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 %>
|
|
@ -0,0 +1,31 @@
|
|||
<%= hidden_field_tag 'module_app_id', @module_app_id %>
|
||||
|
||||
<!-- footer -->
|
||||
<div class="bottomnav clearfix">
|
||||
<div class="action pull-right">
|
||||
<button id="deselect" class="btn btn-inverse toggable hide"><%= t(:deselect) %></button>
|
||||
<%= 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" %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- footer:end -->
|
||||
|
||||
<!-- tags -->
|
||||
<div class="tags">
|
||||
<div id="tags-list">
|
||||
<ul class="tags-groups checkbox-card module-tags">
|
||||
<%= render partial: "tag", collection: @tags %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<!-- tags:end -->
|
||||
|
||||
<!-- merge -->
|
||||
<%= render 'admin/tags/merge_modal' %>
|
||||
<!-- merge:end -->
|
||||
|
||||
<!-- delete -->
|
||||
<%= render 'admin/tags/delete_modal' %>
|
||||
<!-- delete:end -->
|
|
@ -0,0 +1,80 @@
|
|||
<div id="add-tags">
|
||||
<legend>Add Tags</legend>
|
||||
<ul class="nav nav-pills">
|
||||
<li class="active"><a href=".set_new" data-toggle="tab">Create new</a></li>
|
||||
<li><a href=".selete_defat" data-toggle="tab">Use Default</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
|
||||
<div class="set_new tab-pane fade active in">
|
||||
<%= form_for @tag, url: admin_module_tags_path(module_app_id: @module_app_id), remote: true, id: 'create_new_tags' do |f| %>
|
||||
<fieldset>
|
||||
<%= render partial: "admin/tags/form", :locals => { :f => f } %>
|
||||
<div class="form-actions">
|
||||
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||
<%= f.submit t(:create_), class: 'btn btn-primary btn-small' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="selete_defat tags tab-pane fade">
|
||||
<input class="search-query" type="text" placeholder="Search Tags" value="">
|
||||
<form id="use_default_tags">
|
||||
<fieldset>
|
||||
<ul class="add-defalt-tags-list tags-groups checkbox-card">
|
||||
<li class="filter-item default">
|
||||
<p class="card pull-left">
|
||||
<input type="checkbox">
|
||||
</p>
|
||||
<a>
|
||||
<span class="amount">8</span>
|
||||
<span class="tag">Apple</span> / <span class="tag">蘋果</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="filter-item default">
|
||||
<p class="card pull-left">
|
||||
<input type="checkbox">
|
||||
</p>
|
||||
<a>
|
||||
<span class="amount">8</span>
|
||||
<span class="tag">Bus</span> / <span class="tag">巴士</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="filter-item default">
|
||||
<p class="card pull-left">
|
||||
<input type="checkbox">
|
||||
</p>
|
||||
<a>
|
||||
<span class="amount">8</span>
|
||||
<span class="tag">Cake</span> / <span class="tag">蛋糕</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="filter-item default">
|
||||
<p class="card pull-left">
|
||||
<input type="checkbox">
|
||||
</p>
|
||||
<a>
|
||||
<span class="amount">8</span>
|
||||
<span class="tag">Dog</span> / <span class="tag">狗</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="filter-item default">
|
||||
<p class="card pull-left">
|
||||
<input type="checkbox">
|
||||
</p>
|
||||
<a>
|
||||
<span class="amount">8</span>
|
||||
<span class="tag">Elephant</span> / <span class="tag">大象</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="form-actions">
|
||||
<a href="javascript:$.pageslide.close()" class="btn btn-small">Cancel</a>
|
||||
<a class="btn btn-primary btn-small">Submit</a>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,13 +1,17 @@
|
|||
<div id="<%= dom_id tag %>" class="tag clear">
|
||||
<div class="tagitem">
|
||||
<i class="icons-tag"></i>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<%#= I18nVariable.from_locale(locale) %>
|
||||
<%= tag.name_translations[locale] %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="action">
|
||||
<%= 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 %>
|
||||
</div>
|
||||
</div>
|
||||
<li class="filter-item <%= tag.is_default ? 'default' : 'module' %>">
|
||||
<p class="card pull-left">
|
||||
<input type="checkbox">
|
||||
</p>
|
||||
<%= hidden_field_tag "ids[]", tag.id, class: "tag_id" %>
|
||||
<% if tag.is_default %>
|
||||
<a>
|
||||
<span class="amount"><%= tag.taggings.count %></span>
|
||||
<%= show_names_slash(tag) %>
|
||||
</a>
|
||||
<% else %>
|
||||
<%= link_to edit_admin_module_tag_path(tag, module_app_id: @module_app_id), class: "open-slide" do %>
|
||||
<span class="amount"><%= tag.taggings.count %></span>
|
||||
<%= show_names_slash(tag) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</li>
|
|
@ -1,4 +0,0 @@
|
|||
$('#tag_form').each(function(){
|
||||
this.reset();
|
||||
});
|
||||
$('#tags').append("<%= j render :partial => 'tag', :object => @tag %>")
|
|
@ -0,0 +1 @@
|
|||
<%= render 'edit' %>
|
|
@ -1 +1 @@
|
|||
$('#<%= dom_id @tag %>').html("<%= j render :partial => 'form', :locals => {:tag => @tag} %>")
|
||||
$('#view-page .content').html("<%= j render 'edit' %>");
|
|
@ -1,17 +1,3 @@
|
|||
<!--<div class="subnav">
|
||||
<ul class="nav nav-pills filter">
|
||||
<li class="accordion-group">
|
||||
<form class="form-search">
|
||||
<input type="text" class="input-medium search-query">
|
||||
<button type="submit" class="btn">Search</button>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
-->
|
||||
<div id='tags' class="clear">
|
||||
<%= render :partial => 'tag', :collection => @tags %>
|
||||
</div>
|
||||
<div class="form-actions form-fixed pagination-right">
|
||||
<%= render 'add' %>
|
||||
<div id="tags_index">
|
||||
<%= render 'index' %>
|
||||
</div>
|
|
@ -0,0 +1,7 @@
|
|||
$("#delete_tags").modal('hide');
|
||||
$("#tags-merger").modal('hide');
|
||||
$("#tags_index").html("<%= j render 'index' %>")
|
||||
$.pageslide.close();
|
||||
openSlide();
|
||||
cardCheck();
|
||||
checkedLength()
|
|
@ -0,0 +1 @@
|
|||
<%= render 'new' %>
|
|
@ -0,0 +1 @@
|
|||
$('#view-page .content').html("<%= j render 'new' %>");
|
|
@ -0,0 +1,16 @@
|
|||
<div id="delete_tags" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel"><%= t('tag.delete') %></h3>
|
||||
</div>
|
||||
<div class="modal-body tags">
|
||||
<span class="text-warning text-center"><%= t('tag.warning') %></span>
|
||||
<hr>
|
||||
<ul class="tags-groups checkbox-card">
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
<%= link_to t(:delete_), nil, class: "delete-tags btn btn-danger", method: :post, remote: true %>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,10 @@
|
|||
<%= form_for @tag, url: admin_tag_path(@tag), remote: true do |f| %>
|
||||
<fieldset>
|
||||
<legend><%= t('editing.tag') %></legend>
|
||||
<%= render partial: "form", :locals => { :f => f } %>
|
||||
<div class="form-actions">
|
||||
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||
<%= f.submit t(:update_), class: 'btn btn-primary btn-small' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -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 %>
|
|
@ -0,0 +1,38 @@
|
|||
<!-- footer -->
|
||||
<div class="bottomnav clearfix">
|
||||
<div class="action pull-right">
|
||||
<button id="deselect" class="btn btn-inverse toggable hide"><%= t(:deselect) %></button>
|
||||
<%= 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" %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- footer:end -->
|
||||
|
||||
<!-- tags -->
|
||||
<div class="tags">
|
||||
<div id="tags-list">
|
||||
<p class="tag-lead lead muted"><i class="icons-tag"></i> <%= t(:default) %> <span class="badge pull-right"><%= @tags.count %></span></p>
|
||||
<ul class="tags-groups checkbox-card default-tags">
|
||||
<%= render partial: "tag", collection: @tags %>
|
||||
</ul>
|
||||
<% @module_apps.each do |module_app| %>
|
||||
<% tags = module_app.tags %>
|
||||
<% icon_name = get_module_app_icon(module_app) %>
|
||||
<p class="tag-lead lead muted"><i class="<%= icon_name %>"></i> <%= module_app.title %> <span class="badge pull-right"><%= tags.count %></span></p>
|
||||
<ul class="tags-groups checkbox-card module-tags">
|
||||
<%= render partial: "tag", collection: tags, locals: {in_module: true} %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- tags:end -->
|
||||
|
||||
<!-- merge -->
|
||||
<%= render 'merge_modal' %>
|
||||
<!-- merge:end -->
|
||||
|
||||
<!-- delete -->
|
||||
<%= render 'delete_modal' %>
|
||||
<!-- delete:end -->
|
|
@ -0,0 +1,26 @@
|
|||
<div id="tags-merger" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<%= form_tag '', remote: true do %>
|
||||
<fieldset>
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel"><%= t('tag.merger') %></h3>
|
||||
</div>
|
||||
<div class="modal-body tags">
|
||||
<div class="clearfix">
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<%= label_tag :locale, I18nVariable.from_locale(locale) %>
|
||||
<%= text_field_tag "name[#{locale}]", nil, class: 'new-tags-name', placeholder: t('tag.new_name') %>
|
||||
<% end %>
|
||||
</div>
|
||||
<span class="help-block"><%= t('tag.merge_help') %></span>
|
||||
<hr>
|
||||
<ul class="tags-groups checkbox-card">
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:cancel) %></button>
|
||||
<button class="btn btn-primary"><%= t(:submit) %></button>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
</div>
|
|
@ -0,0 +1,10 @@
|
|||
<%= form_for @tag, url: admin_tags_path, remote: true do |f| %>
|
||||
<fieldset>
|
||||
<legend><%= t('new.tag') %></legend>
|
||||
<%= render partial: "form", :locals => { :f => f } %>
|
||||
<div class="form-actions">
|
||||
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||
<%= f.submit t(:create_), class: 'btn btn-primary btn-small' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -0,0 +1,12 @@
|
|||
<li class="filter-item <%= tag.is_default ? 'default' : '' %>">
|
||||
<% unless defined?(in_module) && tag.is_default %>
|
||||
<p class="card pull-left">
|
||||
<input type="checkbox">
|
||||
</p>
|
||||
<%= hidden_field_tag "ids[]", tag.id, class: "tag_id" %>
|
||||
<% end %>
|
||||
<%= link_to edit_admin_tag_path(tag), class: "open-slide" do %>
|
||||
<span class="amount"><%= tag.taggings.count %></span>
|
||||
<%= show_names_slash(tag) %>
|
||||
<% end %>
|
||||
</li>
|
|
@ -0,0 +1 @@
|
|||
<%= render 'edit' %>
|
|
@ -0,0 +1 @@
|
|||
$('#view-page .content').html("<%= j render 'edit' %>");
|
|
@ -0,0 +1,3 @@
|
|||
<div id="tags_index">
|
||||
<%= render 'index' %>
|
||||
</div>
|
|
@ -0,0 +1,7 @@
|
|||
$("#delete_tags").modal('hide');
|
||||
$("#tags-merger").modal('hide');
|
||||
$("#tags_index").html("<%= j render 'index' %>")
|
||||
$.pageslide.close();
|
||||
openSlide();
|
||||
cardCheck();
|
||||
checkedLength()
|
|
@ -0,0 +1 @@
|
|||
<%= render 'new' %>
|
|
@ -0,0 +1 @@
|
|||
$('#view-page .content').html("<%= j render 'new' %>");
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title><%= @title || APP_CONFIG['orbit'] %></title>
|
||||
<%= 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 %>
|
||||
</head>
|
||||
<body id="dashboards">
|
||||
<%= render 'layouts/orbit_bar' unless @no_orbit_bar %>
|
||||
<%#= render 'layouts/side_bar' unless @no_side_bar %>
|
||||
<nav id="sidebar">
|
||||
<h2 class="position"><a href="#"><i class="icons-gauge"></i></a></h2>
|
||||
<div id="sidebar-menu">
|
||||
<div class="scroller">
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<section id="main-wrap">
|
||||
<div class="wrap-inner">
|
||||
<%= yield %>
|
||||
<div id="view-page" class="nano" style="display:none">
|
||||
<div class="content">
|
||||
</div>
|
||||
</div>
|
||||
<%= javascript_include_tag "lib/jquery.pageslide.js" %>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
|
@ -1,28 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><%= @title || APP_CONFIG['orbit'] %></title>
|
||||
<link rel="shortcut icon" href="<%= asset_path "ncculogo.ico" %>">
|
||||
<!--[if lt IE 9]>
|
||||
<%= javascript_include_tag "html5" %>
|
||||
<![endif]-->
|
||||
<%= stylesheet_link_tag "new_admin" %>
|
||||
<%= javascript_include_tag "new_admin" %>
|
||||
<%= yield :page_specific_css %>
|
||||
<%= yield :page_specific_javascript %>
|
||||
<%= csrf_meta_tag %>
|
||||
</head>
|
||||
<body class="folded">
|
||||
<%= render 'layouts/orbit_bar' %>
|
||||
<% if !(yield :side_bar).blank? %>
|
||||
<%= yield :side_bar %>
|
||||
<% else %>
|
||||
<%= render 'layouts/side_bar' %>
|
||||
<% end %>
|
||||
|
||||
<div id="main-wrap">
|
||||
<%= yield %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -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
|
||||
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.
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Panel::Announcement::BackEnd::BulletinFilesController < ApplicationController
|
||||
|
||||
layout 'new_admin'
|
||||
layout 'back_end'
|
||||
|
||||
def index
|
||||
@bulletin_files = BulletinFile.all
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class Panel::Announcement::BackEnd::BulletinLinksController < ApplicationController
|
||||
|
||||
layout 'new_admin'
|
||||
layout 'back_end'
|
||||
|
||||
def index
|
||||
@bulletin_links = BulletinLink.all
|
||||
|
|
Loading…
Reference in New Issue