forked from saurabh/orbit4-5
Tags & Categories
This commit is contained in:
parent
745790244a
commit
0f0e17ef00
|
@ -0,0 +1,21 @@
|
||||||
|
$(function() {
|
||||||
|
$.pageslide.closeCallback(function(pageslide, item) {
|
||||||
|
$('.filter-item').removeClass("active");
|
||||||
|
});
|
||||||
|
$.pageslide.loadComplete(function(pageslide, item) {
|
||||||
|
$('.filter-item').removeClass("active");
|
||||||
|
item.closest('li').addClass('active');
|
||||||
|
if(item.data('id') == 'new') {
|
||||||
|
resetForm();
|
||||||
|
pageslide.find('form').attr('action', '/admin/module_apps/' + item.data('module') + '/categories/');
|
||||||
|
pageslide.find('form').attr('method', 'post');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setForm(item.data('form'));
|
||||||
|
pageslide.find('form').attr('action', '/admin/module_apps/' + item.data('module') + '/categories/' + item.data('id'));
|
||||||
|
pageslide.find('form').attr('method', 'put');
|
||||||
|
console.log(item.data('disable'));
|
||||||
|
pageslide.find('input[type="checkbox"]').prop( 'checked', item.data('disable') );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
|
@ -1,21 +1,40 @@
|
||||||
//= require lib/tags
|
//= require lib/tags
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
$('a[data-toggle="tab"]').click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$(this).tab('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
// $('#tags-list .filter-item.default .card').click(function(){
|
||||||
|
// $('#removeDefaults').attr('rel', "<%= Rails.application.routes.url_helpers.remove_default_admin_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids);
|
||||||
|
// $('#removeDefaults').removeClass('hide');
|
||||||
|
// console.log("@@");
|
||||||
|
// });
|
||||||
|
|
||||||
$.pageslide.closeCallback(function(pageslide, item) {
|
$.pageslide.closeCallback(function(pageslide, item) {
|
||||||
$('.filter-item').removeClass("active");
|
$('.filter-item').removeClass("active");
|
||||||
});
|
});
|
||||||
|
|
||||||
$.pageslide.loadComplete(function(pageslide, item) {
|
$.pageslide.loadComplete(function(pageslide, item) {
|
||||||
|
|
||||||
$('.filter-item').removeClass("active");
|
$('.filter-item').removeClass("active");
|
||||||
|
|
||||||
item.closest('li').addClass('active');
|
item.closest('li').addClass('active');
|
||||||
|
|
||||||
|
if(item.hasClass('btn')) {
|
||||||
|
$('#filter-default-tag').fastLiveFilter('.add-default-tags-list', '.filter-item', '.tag');
|
||||||
|
}
|
||||||
|
|
||||||
if(item.data('id') == 'new') {
|
if(item.data('id') == 'new') {
|
||||||
resetForm();
|
resetForm();
|
||||||
pageslide.find('form').attr('action', '/admin/tags/');
|
pageslide.find('form:eq(0)').attr('action', window.location.pathname);
|
||||||
pageslide.find('form').attr('method', 'post');
|
pageslide.find('form:eq(0)').attr('method', 'post');
|
||||||
}
|
}else {
|
||||||
else {
|
|
||||||
setForm(item.data('form'));
|
setForm(item.data('form'));
|
||||||
pageslide.find('form').attr('action', '/admin/tags/' + item.data('id'));
|
pageslide.find('form:eq(0)').attr('action', window.location.pathname + '/' + item.data('id'));
|
||||||
pageslide.find('form').attr('method', 'put');
|
pageslide.find('form:eq(0)').attr('method', 'put');
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
|
@ -26,9 +26,9 @@ CKEDITOR.editorConfig = function( config ) {
|
||||||
// config.filebrowserImageBrowseUrl = '/browser/browse.php?type=Images';
|
// config.filebrowserImageBrowseUrl = '/browser/browse.php?type=Images';
|
||||||
// config.filebrowserUploadUrl = '/uploader/upload.php';
|
// config.filebrowserUploadUrl = '/uploader/upload.php';
|
||||||
|
|
||||||
config.filebrowserBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path(:module_app_id=>ModuleApp.where(:key=>'asset').first.id) %>";
|
config.filebrowserBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path(:module_app_id=>ModuleApp.where(:key=>'asset').first.id) rescue '' %>";
|
||||||
config.filebrowserImageBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path(:type=>'image',:module_app_id=>ModuleApp.where(:key=>'asset').first.id) %>";
|
config.filebrowserImageBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path(:type=>'image',:module_app_id=>ModuleApp.where(:key=>'asset').first.id) rescue '' %>";
|
||||||
// config.filebrowserUploadUrl = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>";
|
// config.filebrowserUploadUrl = "<%#= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>";
|
||||||
|
|
||||||
// config.contentsCss = '/orbit_4.0.1/assets/javascripts/lib/ckeditor/plugins/stylesheetparser/samples/assets/sample.css';
|
// config.contentsCss = '/orbit_4.0.1/assets/javascripts/lib/ckeditor/plugins/stylesheetparser/samples/assets/sample.css';
|
||||||
|
|
||||||
|
|
|
@ -1,207 +1,209 @@
|
||||||
function checkTagsQuantity() {
|
function checkTagsQuantity() {
|
||||||
var $tagLead = $('.tag-lead'),
|
var $tagLead = $('.tag-lead'),
|
||||||
$tagsGroups = $('.tags-groups');
|
$tagsGroups = $('.tags-groups');
|
||||||
|
|
||||||
$tagsGroups.each(function(i) {
|
$tagsGroups.each(function(i) {
|
||||||
var $children = $(this).children().length;
|
var $children = $(this).children().length;
|
||||||
$tagLead.eq(i).children('.badge').text($children);
|
$tagLead.eq(i).children('.badge').text($children);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkedLength() {
|
function checkedLength() {
|
||||||
var $tagsList = $('#tags-list'),
|
var $tagsList = $('#tags-list'),
|
||||||
$moduleTags,
|
$moduleTags,
|
||||||
$defaultTags,
|
$defaultTags,
|
||||||
$toDefault;
|
$toDefault;
|
||||||
function reload_links() {
|
function reload_links() {
|
||||||
if($('.default-tags').length) {
|
if($('.default-tags').length) {
|
||||||
$moduleTags = $('.module-tags input[type="checkbox"]:checked');
|
$moduleTags = $('.module-tags input[type="checkbox"]:checked');
|
||||||
$defaultTags = $('.default-tags input[type="checkbox"]:checked');
|
$defaultTags = $('.default-tags input[type="checkbox"]:checked');
|
||||||
|
|
||||||
if($moduleTags.length > 1 || $moduleTags.length+$defaultTags.length > 1) {
|
if($moduleTags.length > 1 || $moduleTags.length+$defaultTags.length > 1) {
|
||||||
$('#mergerTags').removeClass('hide');
|
$('#mergerTags').removeClass('hide');
|
||||||
} else {
|
} else {
|
||||||
$('#mergerTags').addClass('hide');
|
$('#mergerTags').addClass('hide');
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
$moduleTags = $('li.module input[type="checkbox"]:checked');
|
||||||
|
$defaultTags = $('li.default input[type="checkbox"]:checked');
|
||||||
|
|
||||||
if ($moduleTags.length > 0 || $defaultTags.length > 0) {
|
if($defaultTags.length > 0 || $moduleTags.length > 0) {
|
||||||
$('#deselect').removeClass('hide');
|
$('#deselect').removeClass('hide');
|
||||||
var ids = new Array();
|
$('#deselect').on('click', deselect);
|
||||||
$defaultTags.each(function(i) {
|
if($defaultTags.length > 0 && $moduleTags.length > 0) {
|
||||||
ids.push($defaultTags.eq(i).parent().siblings('.tag_id').val());
|
$('#deleteTags').attr('rel', "");
|
||||||
});
|
$('#deleteTags').addClass('hide');
|
||||||
$moduleTags.each(function(i) {
|
$('#removeDefaults').attr('rel', "");
|
||||||
ids.push($moduleTags.eq(i).parent().siblings('.tag_id').val());
|
$('#removeDefaults').addClass('hide');
|
||||||
});
|
$('#mergerTags').addClass('hide');
|
||||||
$('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_tags_path %>" + "?ids=" + ids);
|
} else if ($defaultTags.length > 0) {
|
||||||
$('#deleteTags').removeClass('hide');
|
var ids = new Array();
|
||||||
$('#deselect').on('click', deselect);
|
$defaultTags.each(function(i) {
|
||||||
} else {
|
ids.push($defaultTags.eq(i).parent().siblings('.tag_id').val());
|
||||||
$('#deselect').addClass('hide');
|
});
|
||||||
$('#deleteTags').attr('rel', "");
|
$('#removeDefaults').attr('href', "<%= Rails.application.routes.url_helpers.remove_default_admin_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids);
|
||||||
$('#deleteTags').addClass('hide');
|
$('#removeDefaults').removeClass('hide');
|
||||||
$('#deselect').off('click', deselect);
|
} 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_tags_path %>" + "?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');
|
||||||
|
$('#removeDefaults').attr('rel', "");
|
||||||
|
$('#removeDefaults').addClass('hide');
|
||||||
|
$('#mergerTags').addClass('hide');
|
||||||
|
$('#deselect').off('click', deselect);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
if ($moduleTags.length > 0 && $defaultTags.length == 0) {
|
if ($moduleTags.length > 0 && $defaultTags.length == 0) {
|
||||||
var ids = new Array();
|
var ids = new Array();
|
||||||
$moduleTags.each(function(i) {
|
$moduleTags.each(function(i) {
|
||||||
ids.push($moduleTags.eq(i).parent().siblings('.tag_id').val());
|
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').attr('href', "<%= Rails.application.routes.url_helpers.add_to_default_admin_tags_path %>" + "?ids=" + ids);
|
||||||
$('#addDefault').removeClass('hide');
|
$('#addDefault').removeClass('hide');
|
||||||
} else {
|
} else {
|
||||||
$('#addDefault').attr('href', "");
|
$('#addDefault').attr('href', "");
|
||||||
$('#addDefault').addClass('hide');
|
$('#addDefault').addClass('hide');
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
$moduleTags = $('.module-tags li.module input[type="checkbox"]:checked');
|
if ($moduleTags.length > 0 || $defaultTags.length > 0) {
|
||||||
$defaultTags = $('.module-tags li.default input[type="checkbox"]:checked');
|
$('#deselect').removeClass('hide');
|
||||||
if($defaultTags.length > 0 || $moduleTags.length > 0) {
|
var ids = new Array();
|
||||||
$('#deselect').removeClass('hide');
|
$defaultTags.each(function(i) {
|
||||||
$('#deselect').on('click', deselect);
|
ids.push($defaultTags.eq(i).parent().siblings('.tag_id').val());
|
||||||
if($defaultTags.length > 0 && $moduleTags.length > 0) {
|
});
|
||||||
$('#deleteTags').attr('rel', "");
|
|
||||||
$('#deleteTags').addClass('hide');
|
$moduleTags.each(function(i) {
|
||||||
$('#removeDefaults').attr('rel', "");
|
ids.push($moduleTags.eq(i).parent().siblings('.tag_id').val());
|
||||||
$('#removeDefaults').addClass('hide');
|
});
|
||||||
$('#mergerTags').addClass('hide');
|
$('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_tags_path %>" + "?ids=" + ids);
|
||||||
} else if ($defaultTags.length > 0) {
|
$('#deleteTags').removeClass('hide');
|
||||||
var ids = new Array();
|
$('#deselect').on('click', deselect);
|
||||||
$defaultTags.each(function(i) {
|
} else {
|
||||||
ids.push($defaultTags.eq(i).parent().siblings('.tag_id').val());
|
$('#deselect').addClass('hide');
|
||||||
});
|
$('#deleteTags').attr('rel', "");
|
||||||
$('#removeDefaults').attr('rel', "<%= Rails.application.routes.url_helpers.remove_default_admin_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids);
|
$('#deleteTags').addClass('hide');
|
||||||
$('#removeDefaults').removeClass('hide');
|
$('#deselect').off('click', deselect);
|
||||||
} else {
|
};
|
||||||
var ids = new Array();
|
}
|
||||||
$moduleTags.each(function(i) {
|
$tagsList.delegate('.card', 'click', function() {
|
||||||
ids.push($moduleTags.eq(i).parent().siblings('.tag_id').val());
|
reload_links();
|
||||||
});
|
});
|
||||||
$('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids);
|
$('#selectAllTags').on('click', function() {
|
||||||
$('#deleteTags').removeClass('hide');
|
$('.filter-item:not(".mark") input[type="checkbox"]').attr('checked', true);
|
||||||
if($moduleTags.length > 1) {
|
$('.filter-item:not(".mark") .card').addClass('active');
|
||||||
$('#mergerTags').removeClass('hide');
|
reload_links();
|
||||||
} else {
|
});
|
||||||
$('#mergerTags').addClass('hide');
|
$('#deleteTags').on('click', function() {
|
||||||
};
|
$('#delete_tags .tags-groups').empty();
|
||||||
};
|
|
||||||
} else {
|
|
||||||
$('#deselect').addClass('hide');
|
|
||||||
$('#deleteTags').attr('rel', "");
|
|
||||||
$('#deleteTags').addClass('hide');
|
|
||||||
$('#removeDefaults').attr('rel', "");
|
|
||||||
$('#removeDefaults').addClass('hide');
|
|
||||||
$('#mergerTags').addClass('hide');
|
|
||||||
$('#deselect').off('click', deselect);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
$tagsList.delegate('.card', 'click', function() {
|
|
||||||
reload_links();
|
|
||||||
});
|
|
||||||
$('#selectAllTags').on('click', function() {
|
|
||||||
$('.filter-item:not(".mark") input[type="checkbox"]').attr('checked', true);
|
|
||||||
$('.filter-item:not(".mark") .card').addClass('active');
|
|
||||||
reload_links();
|
|
||||||
});
|
|
||||||
$('#deleteTags').on('click', function() {
|
|
||||||
$('#delete_tags .tags-groups').empty();
|
|
||||||
$('#delete_tags a.delete-tags').attr("href", $(this).attr("rel"));
|
$('#delete_tags a.delete-tags').attr("href", $(this).attr("rel"));
|
||||||
if($defaultTags) {
|
if($defaultTags) {
|
||||||
$defaultTags.each(function(i) {
|
$defaultTags.each(function(i) {
|
||||||
$defaultTags.eq(i).parents('.filter-item').clone().appendTo('#delete_tags .tags-groups');
|
$defaultTags.eq(i).parents('.filter-item').clone().appendTo('#delete_tags .tags-groups');
|
||||||
$('#delete_tags .tags-groups .filter-item').addClass('def');
|
$('#delete_tags .tags-groups .filter-item').addClass('def');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$moduleTags.each(function(i) {
|
$moduleTags.each(function(i) {
|
||||||
$moduleTags.eq(i).parents('.filter-item').clone().appendTo('#delete_tags .tags-groups');
|
$moduleTags.eq(i).parents('.filter-item').clone().appendTo('#delete_tags .tags-groups');
|
||||||
});
|
});
|
||||||
$('#delete_tags').modal('show', cleanTagInputs());
|
$('#delete_tags').modal('show', cleanTagInputs());
|
||||||
function cleanTagInputs(){
|
function cleanTagInputs(){
|
||||||
var $tagsDelete = $('#delete_tags'),
|
var $tagsDelete = $('#delete_tags'),
|
||||||
$filterItem = $tagsDelete.find('.filter-item');
|
$filterItem = $tagsDelete.find('.filter-item');
|
||||||
$filterItem.find('.card, .amount').remove();
|
$filterItem.find('.card, .amount').remove();
|
||||||
$filterItem.find('a').removeAttr('class');
|
$filterItem.find('a').removeAttr('class');
|
||||||
$filterItem.find('a').removeAttr('href');
|
$filterItem.find('a').removeAttr('href');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#mergerTags').on('click', function() {
|
$('#mergerTags').on('click', function() {
|
||||||
if($moduleTags || $defaultTags) {
|
if($moduleTags || $defaultTags) {
|
||||||
if($moduleTags.length > 1 || $moduleTags.length+$defaultTags.length > 1) {
|
if($moduleTags.length > 1 || $moduleTags.length+$defaultTags.length > 1) {
|
||||||
$('#tags-merger form').attr("action", $(this).attr("rel"));
|
$('#tags-merger form').attr("action", $(this).attr("rel"));
|
||||||
mergerTags()
|
mergerTags()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#removeDefaults').on('click', function() {
|
$('#removeDefaults').on('click', function() {
|
||||||
$('#remove_defaults .tags-groups').empty();
|
$('#remove_defaults .tags-groups').empty();
|
||||||
$('#remove_defaults a.remove-defaults').attr("href", $(this).attr("rel"));
|
$('#remove_defaults a.remove-defaults').attr("href", $(this).attr("rel"));
|
||||||
$defaultTags.each(function(i) {
|
$defaultTags.each(function(i) {
|
||||||
$defaultTags.eq(i).parents('.filter-item').clone().appendTo('#remove_defaults .tags-groups');
|
$defaultTags.eq(i).parents('.filter-item').clone().appendTo('#remove_defaults .tags-groups');
|
||||||
});
|
});
|
||||||
$('#remove_defaults').modal('show', cleanTagInputs());
|
$('#remove_defaults').modal('show', cleanTagInputs());
|
||||||
function cleanTagInputs(){
|
function cleanTagInputs(){
|
||||||
var $removeDefaults = $('#remove_defaults'),
|
var $removeDefaults = $('#remove_defaults'),
|
||||||
$filterItem = $removeDefaults.find('.filter-item');
|
$filterItem = $removeDefaults.find('.filter-item');
|
||||||
$filterItem.find('.card, .amount').remove();
|
$filterItem.find('.card, .amount').remove();
|
||||||
$filterItem.find('a').removeAttr('class');
|
$filterItem.find('a').removeAttr('class');
|
||||||
$filterItem.find('a').removeAttr('href');
|
$filterItem.find('a').removeAttr('href');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function deselect() {
|
function deselect() {
|
||||||
$('.tags input[type="checkbox"]').attr('checked', false);
|
$('.tags input[type="checkbox"]').attr('checked', false);
|
||||||
$('.card').removeClass('active');
|
$('.card').removeClass('active');
|
||||||
$('.bottomnav .toggable').not('.open-slide').addClass('hide');
|
$('.bottomnav .toggable').not('.open-slide').addClass('hide');
|
||||||
$('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_tags_path %>");
|
$('#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 %>");
|
$('#addDefault').attr('href', "<%= Rails.application.routes.url_helpers.add_to_default_admin_tags_path %>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function addTagsTab() {
|
function addTagsTab() {
|
||||||
$('a[data-toggle="tab"]').click(function (e) {
|
$('a[data-toggle="tab"]').click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$(this).tab('show');
|
$(this).tab('show');
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function mergerTags() {
|
function mergerTags() {
|
||||||
var $moduleTags = $('.module-tags input[type="checkbox"]:checked'),
|
var $moduleTags = $('.module-tags input[type="checkbox"]:checked'),
|
||||||
$defaultTags = $('.default-tags input[type="checkbox"]:checked');
|
$defaultTags = $('.default-tags input[type="checkbox"]:checked');
|
||||||
|
|
||||||
$defaultTags.each(function(i) {
|
$defaultTags.each(function(i) {
|
||||||
$defaultTags.eq(i).parents('.filter-item').clone().appendTo('#tags-merger .tags-groups');
|
$defaultTags.eq(i).parents('.filter-item').clone().appendTo('#tags-merger .tags-groups');
|
||||||
$('#tags-merger .tags-groups .filter-item').addClass('def');
|
$('#tags-merger .tags-groups .filter-item').addClass('def');
|
||||||
});
|
});
|
||||||
$moduleTags.each(function(i) {
|
$moduleTags.each(function(i) {
|
||||||
$moduleTags.eq(i).parents('.filter-item').clone().appendTo('#tags-merger .tags-groups');
|
$moduleTags.eq(i).parents('.filter-item').clone().appendTo('#tags-merger .tags-groups');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#tags-merger').modal('show', changeTagName());
|
$('#tags-merger').modal('show', changeTagName());
|
||||||
function changeTagName() {
|
function changeTagName() {
|
||||||
var $tagsMerger = $('#tags-merger'),
|
var $tagsMerger = $('#tags-merger'),
|
||||||
$newTagsName = $('.new-tags-name'),
|
$newTagsName = $('.new-tags-name'),
|
||||||
$filterItem = $tagsMerger.find('.filter-item');
|
$filterItem = $tagsMerger.find('.filter-item');
|
||||||
$filterItem.find('.card, .amount').remove();
|
$filterItem.find('.card, .amount').remove();
|
||||||
$filterItem.find('a').removeAttr('class');
|
$filterItem.find('a').removeAttr('class');
|
||||||
$filterItem.find('a').removeAttr('href');
|
$filterItem.find('a').removeAttr('href');
|
||||||
$filterItem.on('click', function() {
|
$filterItem.on('click', function() {
|
||||||
$(this).find('.tag').each(function(i) {
|
$(this).find('.tag').each(function(i) {
|
||||||
$newTagsName.eq(i).val($(this).text())
|
$newTagsName.eq(i).val($(this).text())
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$(function() {
|
$(function() {
|
||||||
if($('.default-tags').length) {
|
if($('.default-tags').length) {
|
||||||
checkedLength();
|
checkedLength();
|
||||||
$('#tags-merger').on('hidden', function () {
|
$('#tags-merger').on('hidden', function () {
|
||||||
$(this).find('.filter-item').remove();
|
$(this).find('.filter-item').remove();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
checkedLength();
|
checkedLength();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
// Place all the styles related to the admin/categories controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||||
|
/*
|
||||||
|
*= require lib/tags-groups
|
||||||
|
*/
|
|
@ -55,6 +55,16 @@
|
||||||
.tags-groups li.active .amount {
|
.tags-groups li.active .amount {
|
||||||
color: #8cb8be;
|
color: #8cb8be;
|
||||||
}
|
}
|
||||||
|
.tags-groups li.add {
|
||||||
|
background-color: #cccccc;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.tags-groups li.add a{
|
||||||
|
color: #333333;
|
||||||
|
}
|
||||||
|
.tags-groups li.disabled {
|
||||||
|
background-color: #707070;
|
||||||
|
}
|
||||||
.tags-groups li a {
|
.tags-groups li a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #ededed;
|
color: #ededed;
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
class Admin::CategoriesController < OrbitAdminController
|
||||||
|
before_action :setup_vars
|
||||||
|
|
||||||
|
def index
|
||||||
|
unless @module_app.nil?
|
||||||
|
@categories = Kaminari.paginate_array(@module_app.categories).page(params[:page]).per(10)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
category = @module_app.categories.build(category_params)
|
||||||
|
category.save
|
||||||
|
redirect_to request.referer, :status => 303
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_in_form
|
||||||
|
@category = @module_app.categories.build(category_params)
|
||||||
|
@category.save
|
||||||
|
render :json => {:id=>@category.id.to_s, :title=>@category.title}.to_json ,:layout => false
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@category = Category.find(params[:id])
|
||||||
|
@category.update_attributes(category_params)
|
||||||
|
redirect_to request.referer, :status => 303
|
||||||
|
end
|
||||||
|
|
||||||
|
def toggle
|
||||||
|
category = Category.find(params[:id])
|
||||||
|
category.disable = category.disable ? false : true
|
||||||
|
category.save!
|
||||||
|
redirect_to request.referer, :status => 303
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def setup_vars
|
||||||
|
@module_apps = params[:module_app_id].blank? ? ModuleApp.where(categorizable: true) : [ModuleApp.find(params[:module_app_id])]
|
||||||
|
@module_app = params[:module_app_id].blank? ? ModuleApp.find_by(:key=>'category') : ModuleApp.find(params[:module_app_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def category_params
|
||||||
|
params.require(:category).permit!
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,39 +1,31 @@
|
||||||
class Admin::TagsController < ApplicationController
|
class Admin::TagsController < OrbitAdminController
|
||||||
before_filter :setup_vars
|
before_filter :setup_vars
|
||||||
|
|
||||||
layout "back_end"
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@tag = Tag.new
|
@tag = Tag.new
|
||||||
@tags = Tag.where(:is_default=>true)
|
@tags = @is_module_tag ? @module_app.tags.where(:is_default=>true) : Tag.where(:is_default=>true)
|
||||||
@module_apps = ModuleApp.where(taggable: true)
|
@default_tags = Tag.where(:is_default=>true).not_in(:id => @module_app.tag_ids)
|
||||||
end
|
|
||||||
|
|
||||||
def new
|
|
||||||
@tag = Tag.new
|
|
||||||
render layout: false
|
|
||||||
end
|
|
||||||
|
|
||||||
def edit
|
|
||||||
@tag = Tag.find(params[:id])
|
|
||||||
render layout: false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@tag = Tag.new(tag_params.merge(is_default: true))
|
@tag = Tag.new(tag_params.merge(is_default: !@is_module_tag))
|
||||||
if @tag.save
|
if @tag.save
|
||||||
redirect_to admin_tags_url
|
@module_app.tags << @tag if @is_module_tag
|
||||||
else
|
end
|
||||||
@tag = Tag.new(tag_params)
|
redirect_to request.referer, :status => 303
|
||||||
flash.now[:error] = t('create.error.tag')
|
end
|
||||||
render :action => "new"
|
|
||||||
end
|
def create_in_form
|
||||||
|
@tag = Tag.new(tag_params.merge(is_default: !@is_module_tag))
|
||||||
|
@tag.save
|
||||||
|
@module_app.tags << @tag
|
||||||
|
render :json => {:id=>@tag.id.to_s, :name=>@tag.name}.to_json ,:layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@tag = Tag.find(params[:id])
|
@tag = Tag.find(params[:id])
|
||||||
if @tag.update_attributes(tag_params)
|
if @tag.update_attributes(tag_params)
|
||||||
redirect_to action: :index, :status => 303
|
redirect_to request.referer, :status => 303
|
||||||
else
|
else
|
||||||
flash.now[:error] = t('update.error.tag')
|
flash.now[:error] = t('update.error.tag')
|
||||||
render :action => "edit"
|
render :action => "edit"
|
||||||
|
@ -45,7 +37,15 @@ class Admin::TagsController < ApplicationController
|
||||||
if tags
|
if tags
|
||||||
tags.each(&:destroy)
|
tags.each(&:destroy)
|
||||||
end
|
end
|
||||||
redirect_to admin_tags_url
|
redirect_to request.referer, :status => 303
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_from_default
|
||||||
|
tags = Tag.find(params[:ids].split(',')) rescue nil
|
||||||
|
if tags
|
||||||
|
@module_app.tags << tags
|
||||||
|
end
|
||||||
|
redirect_to request.referer, :status => 303
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_to_default
|
def add_to_default
|
||||||
|
@ -55,7 +55,17 @@ class Admin::TagsController < ApplicationController
|
||||||
tag.update_attribute(:is_default, true)
|
tag.update_attribute(:is_default, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect_to admin_tags_url
|
redirect_to request.referer, :status => 303
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_default
|
||||||
|
tags = Tag.find(params[:ids].split(',')) rescue nil
|
||||||
|
if tags
|
||||||
|
tags.each do |tag|
|
||||||
|
tag.update_attribute(:is_default, false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
redirect_to request.referer, :status => 303
|
||||||
end
|
end
|
||||||
|
|
||||||
def merge
|
def merge
|
||||||
|
@ -88,17 +98,19 @@ class Admin::TagsController < ApplicationController
|
||||||
|
|
||||||
new_tag.save
|
new_tag.save
|
||||||
|
|
||||||
redirect_to admin_tags_url
|
redirect_to request.referer, :status => 303
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_params
|
def tag_params
|
||||||
params.require(:tag).permit!
|
params.require(:tag).permit! unless params[:tag].blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def setup_vars
|
def setup_vars
|
||||||
@module_app = ModuleApp.where(:key=>"tag").first
|
@is_module_tag = !params[:module_app_id].blank?
|
||||||
|
@module_apps = @is_module_tag ? [ModuleApp.find(params[:module_app_id])] : ModuleApp.where(categorizable: true)
|
||||||
|
@module_app = @is_module_tag ? ModuleApp.find(params[:module_app_id]) : ModuleApp.find_by(:key=>'tag')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -0,0 +1,2 @@
|
||||||
|
module Admin::CategoriesHelper
|
||||||
|
end
|
|
@ -79,6 +79,14 @@ module OrbitBackendHelper
|
||||||
params[:filters][field].include?(value.to_s) ? "active" : "" rescue ""
|
params[:filters][field].include?(value.to_s) ? "active" : "" rescue ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def select_category(f, module_app)
|
||||||
|
render :partial => '/admin/categories/select_form', :locals => {:f=> f, :module_app=>module_app }
|
||||||
|
end
|
||||||
|
|
||||||
|
def select_tag(f, module_app, object)
|
||||||
|
render :partial => '/admin/tags/tag_form', :locals => {:f=> f, :module_app=>module_app, :object=>object }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Orbit::FormBuilder
|
module Orbit::FormBuilder
|
||||||
|
|
|
@ -82,11 +82,19 @@ module OrbitHelper
|
||||||
res << "<li class='active'>#{params[:type].underscore.humanize.capitalize} #{t(:authorization_)}</li>"
|
res << "<li class='active'>#{params[:type].underscore.humanize.capitalize} #{t(:authorization_)}</li>"
|
||||||
end
|
end
|
||||||
when 'categories'
|
when 'categories'
|
||||||
res << "<li>#{@module_app.title}#{divider}</li>"
|
if @module_app.key!='category'
|
||||||
res << "<li class='active'>#{t(:categories)}</li>"
|
res << "<li>#{@module_app.title}#{divider}</li>"
|
||||||
when 'module_tags'
|
res << "<li class='active'>#{t(:categories)}</li>"
|
||||||
res << "<li>#{@module_app.title}#{divider}</li>"
|
else
|
||||||
res << "<li class='active'>#{t(:tags)}</li>"
|
res << "<li class='active'>#{@module_app.title}</li>"
|
||||||
|
end
|
||||||
|
when 'tags'
|
||||||
|
if @module_app.key!='tag'
|
||||||
|
res << "<li>#{@module_app.title}#{divider}</li>"
|
||||||
|
res << "<li class='active'>#{t(:tags)}</li>"
|
||||||
|
else
|
||||||
|
res << "<li class='active'>#{@module_app.title}</li>"
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if params[:action].eql?('index')
|
if params[:action].eql?('index')
|
||||||
res << "<li>#{@module_app.title}</li>"
|
res << "<li>#{@module_app.title}</li>"
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<li class="filter-item <%= "disabled" if category.disable %>">
|
||||||
|
<%= hidden_field_tag "ids[]", category.id, class: "category_id" %>
|
||||||
|
<%= link_to '#', class: "open-slide", data: {title: t(:edit_category), id: category.id.to_s, module: @mod.id.to_s, form: category.title_translations, disable: category.disable} do %>
|
||||||
|
<% if category.disable %>
|
||||||
|
<i class="icon-ban-circle"></i>
|
||||||
|
<% end %>
|
||||||
|
<%= category.title_translations.values.join(" / ") %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
|
@ -0,0 +1,22 @@
|
||||||
|
<!-- categories -->
|
||||||
|
<div class="tags">
|
||||||
|
<div id="tags-list">
|
||||||
|
<% @module_apps.each do |mod| %>
|
||||||
|
<%
|
||||||
|
@mod = mod
|
||||||
|
categories = mod.categories
|
||||||
|
%>
|
||||||
|
<% icon_name = OrbitApp::Module::Registration.find_by_key(mod.key).get_icon_class rescue 'icons-daniel-bruce-2' %>
|
||||||
|
<p class="tag-lead lead muted"><i class="<%= icon_name %>"></i> <%= mod.title %> <span class="badge pull-right"><%= categories.count %></span></p>
|
||||||
|
<ul class="tags-groups checkbox-card module-tags">
|
||||||
|
<li class="add">
|
||||||
|
<%= link_to '#', class: "open-slide", data: {title: t(:add_category), id: 'new', module: mod.id.to_s} do %>
|
||||||
|
<i class='icon-plus-sign'></i><%= t(:new_) %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<%= render partial: "category", collection: categories %>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- categories:end -->
|
|
@ -0,0 +1,56 @@
|
||||||
|
<span id="select_categories">
|
||||||
|
<%= f.select :category_id, module_app.categories.collect{|t| [ t.title, t.id ]} %>
|
||||||
|
</span>
|
||||||
|
<button class="btn" data-toggle="modal" data-target="#categoryModal">
|
||||||
|
<i class='icon-plus'></i> <%= t(:new_category) %>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="modal fade" id="categoryModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h4 class="modal-title" id="myModalLabel"><%= t(:new_category) %></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<% Site.first.in_use_locales.each do |locale| %>
|
||||||
|
<%= label_tag "name-#{locale}", "#{t(:name)} (#{t(locale)})" %>
|
||||||
|
<input class="input-large" id="<%=locale%>" name="category[title_translations][<%=locale%>]" placeholder="<%=t(:name)%>" type="text">
|
||||||
|
<br/><br/>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><%= t(:close) %></button>
|
||||||
|
<button type="button" class="btn btn-primary" id="add_category"><%= t(:add) %></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$("#categoryModal").hide();
|
||||||
|
|
||||||
|
$('#categoryModal').modal('<%= module_app.categories.blank? ? "show" : "hide" %>');
|
||||||
|
|
||||||
|
$("#add_category").click(function(){
|
||||||
|
createCategory();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#categoryModal .modal-body").keypress(function(e) {
|
||||||
|
if(e.which == 13) {
|
||||||
|
createCategory();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var createCategory = function(){
|
||||||
|
$.ajax({
|
||||||
|
url : "<%= create_in_form_admin_module_app_categories_path(:module_app_id=>module_app.id.to_s) %>",
|
||||||
|
type : "post",
|
||||||
|
data: $("input[name^='category']").serialize(),
|
||||||
|
}).done(function(data){
|
||||||
|
$("#select_categories select").append("<option value='"+data['id']+"' selected>"+data['title']+"</option>");
|
||||||
|
$('#categoryModal').modal('hide');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -0,0 +1,36 @@
|
||||||
|
<div id="categories_index">
|
||||||
|
<%= render 'index' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="pageslide">
|
||||||
|
<div class="page-title clearfix">
|
||||||
|
<a class="pull-right" href="javascript:$.pageslide.close()">
|
||||||
|
<i class="icons-arrow-left-2"></i>
|
||||||
|
</a>
|
||||||
|
<span></span>
|
||||||
|
</div>
|
||||||
|
<div class="view-page">
|
||||||
|
<div class="nano">
|
||||||
|
<div class="content">
|
||||||
|
<%= form_for :category, url: nil, remote: true do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<%= f.fields_for :title_translations do |f| %>
|
||||||
|
<% Site.first.in_use_locales.each do |locale| %>
|
||||||
|
<%= label_tag "name-#{locale}", "#{t(:name)} (#{t(locale)})" %>
|
||||||
|
<%= f.text_field locale, :class => 'input-large', :value => (@category.title_translations[locale] rescue ''), placeholder: t(:name), id: locale %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<%= label_tag "disable" do %>
|
||||||
|
<%= f.check_box :disable %>
|
||||||
|
<%= t(:disable) %>
|
||||||
|
<% end %>
|
||||||
|
<div class="form-actions">
|
||||||
|
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||||
|
<%= f.submit t(:submit), class: 'btn btn-primary btn-small' %>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,3 @@
|
||||||
|
$("#categories_index").html("<%= j render 'index' %>")
|
||||||
|
$.pageslide.close();
|
||||||
|
openSlide();
|
|
@ -5,6 +5,7 @@
|
||||||
<button id="deselect" class="btn btn-inverse toggable hide"><%= t(:deselect_all) %></button>
|
<button id="deselect" class="btn btn-inverse toggable hide"><%= t(:deselect_all) %></button>
|
||||||
<%= link_to t(:delete_), '#', id: "deleteTags", class: "btn btn-danger toggable hide", rel: '' %>
|
<%= 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(:merge), '#', id: "mergerTags", class: "btn btn-success toggable hide", rel: merge_admin_tags_path %>
|
||||||
|
<%= link_to t(:remove_default), '#', id: "removeDefaults", class: "btn btn-info toggable hide", method: :post, remote: true %>
|
||||||
<%= 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 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), '#', class: "btn btn-primary open-slide", data: {title: t('new.tag'), id: 'new'} %>
|
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t('new.tag'), id: 'new'} %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,10 +15,12 @@
|
||||||
<!-- tags -->
|
<!-- tags -->
|
||||||
<div class="tags">
|
<div class="tags">
|
||||||
<div id="tags-list">
|
<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>
|
<% unless @is_module_tag %>
|
||||||
<ul class="tags-groups checkbox-card default-tags">
|
<p class="tag-lead lead muted"><i class="icons-tag"></i> <%= t(:default) %> <span class="badge pull-right"><%= @tags.count %></span></p>
|
||||||
<%= render partial: "tag", collection: @tags %>
|
<ul class="tags-groups checkbox-card default-tags">
|
||||||
</ul>
|
<%= render partial: "tag", collection: @tags %>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
<% @module_apps.each do |mod| %>
|
<% @module_apps.each do |mod| %>
|
||||||
<%
|
<%
|
||||||
@mod = mod
|
@mod = mod
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
<li class="filter-item <%= tag.is_default ? 'default' : '' %>">
|
<li class="filter-item <%= tag.is_default ? 'default' : 'module' %>">
|
||||||
|
<% if defined?(in_module) && tag.is_default && !@is_module_tag %>
|
||||||
<% unless defined?(in_module) && tag.is_default %>
|
<a>
|
||||||
|
<span class="amount">
|
||||||
|
<%= tag.get_module_tagging_count @mod.taggable_model %>
|
||||||
|
</span>
|
||||||
|
<%= tag.show_names_slash %>
|
||||||
|
</a>
|
||||||
|
<% else %>
|
||||||
<p class="card pull-left">
|
<p class="card pull-left">
|
||||||
<input type="checkbox">
|
<input type="checkbox">
|
||||||
</p>
|
</p>
|
||||||
<%= hidden_field_tag "ids[]", tag.id, class: "tag_id" %>
|
<%= hidden_field_tag "ids[]", tag.id, class: "tag_id" %>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if defined?(in_module) && tag.is_default %>
|
|
||||||
<a>
|
|
||||||
<span class="amount"><%= tag.get_module_tagging_count @mod.taggable_model %></span>
|
|
||||||
<%= tag.show_names_slash %>
|
|
||||||
</a>
|
|
||||||
<% else %>
|
|
||||||
<%= link_to '#', class: "open-slide", data: {title: t('editing.tag'), id: tag.id.to_s, form: tag.name_translations} do %>
|
<%= link_to '#', class: "open-slide", data: {title: t('editing.tag'), id: tag.id.to_s, form: tag.name_translations} do %>
|
||||||
<span class="amount"><%= tag.taggings.count %></span>
|
<span class="amount">
|
||||||
|
<%= tag.taggings.count %>
|
||||||
|
</span>
|
||||||
<%= tag.show_names_slash %>
|
<%= tag.show_names_slash %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
<div class="controls" data-toggle="buttons-checkbox">
|
||||||
|
<span id="select_tags">
|
||||||
|
<% module_app.tags.each do |tag| %>
|
||||||
|
<label class="checkbox inline btn <%= 'active' if object.tags.include?(tag) %>">
|
||||||
|
<%= check_box_tag "#{object.class.name.camelize(:lower)}[tags][]", tag.id, object.tags.include?(tag) %> <%= tag.name %>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<button id="add_tag_btn" class="btn" data-toggle="modal" data-target="#tagModal" style="margin-left: <%= module_app.tags.blank? ? "10" : "180" %>px">
|
||||||
|
<i class='icon-plus'></i> <%= t(:new_tag) %>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="modal fade" id="tagModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h4 class="modal-title" id="myModalLabel"><%= t(:new_tag) %></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<% Site.first.in_use_locales.each do |locale| %>
|
||||||
|
<%= label_tag "name-#{locale}", "#{t(:name)} (#{t(locale)})" %>
|
||||||
|
<input class="input-large" id="<%=locale%>" name="tag[name_translations][<%=locale%>]" placeholder="<%=t(:name)%>" type="text">
|
||||||
|
<br/><br/>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><%= t(:close) %></button>
|
||||||
|
<button type="button" class="btn btn-primary" id="add_tag"><%= t(:add) %></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$("#tagModal").hide();
|
||||||
|
|
||||||
|
$("#add_tag").click(function(){
|
||||||
|
createTag();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#tagModal .modal-body").keypress(function(e) {
|
||||||
|
if(e.which == 13) {
|
||||||
|
createTag();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var createTag = function(){
|
||||||
|
$.ajax({
|
||||||
|
url : "<%= create_in_form_admin_module_app_tags_path(:module_app_id=>module_app.id.to_s) %>",
|
||||||
|
type : "post",
|
||||||
|
data: $("input[name^='tag']").serialize(),
|
||||||
|
}).done(function(data){
|
||||||
|
$("#select_tags").append('<label class="checkbox inline btn active">'+
|
||||||
|
'<input id="<%= object.class.name.camelize(:lower) %>_tags_" name="<%= object.class.name.camelize(:lower) %>[tags][]" type="checkbox" value="'+data.id+'" checked>'+data.name+'</label>');
|
||||||
|
$("#add_tag_btn").css("margin-left", "180px");
|
||||||
|
$('#tagModal').modal('hide');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -1,3 +1,5 @@
|
||||||
|
<%= hidden_field_tag 'module_app_id', @module_app.id.to_s %>
|
||||||
|
|
||||||
<% content_for :right_nav do %>
|
<% content_for :right_nav do %>
|
||||||
<div class="searchClear pull-right">
|
<div class="searchClear pull-right">
|
||||||
<input id="filter-input" class="search-query input-medium" type="text" placeholder="<%= t('search.tags') %>" value="">
|
<input id="filter-input" class="search-query input-medium" type="text" placeholder="<%= t('search.tags') %>" value="">
|
||||||
|
@ -19,15 +21,59 @@
|
||||||
<div class="view-page">
|
<div class="view-page">
|
||||||
<div class="nano">
|
<div class="nano">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<%= form_for :tag, url: nil, remote: true do |f| %>
|
<div id="add-tags">
|
||||||
<fieldset>
|
|
||||||
<%= render :partial => "form", :locals => { :f => f } %>
|
<% if @is_module_tag %>
|
||||||
<div class="form-actions">
|
<ul class="nav nav-pills">
|
||||||
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
<li class="active"><a href=".set_new" data-toggle="tab"><%= t(:create_) %></a></li>
|
||||||
<%= f.submit t(:submit), class: 'btn btn-primary btn-small' %>
|
<li id="select_default"><a href=".select_default" data-toggle="tab"><%= t(:use_default) %></a></li>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="tab-content">
|
||||||
|
|
||||||
|
<div class="set_new tab-pane fade active in">
|
||||||
|
<%= form_for :tag, url: nil, remote: true do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<%= 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(:submit), class: 'btn btn-primary btn-small' %>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
|
||||||
<% end %>
|
<% if @is_module_tag %>
|
||||||
|
<div class="select_default tags tab-pane fade">
|
||||||
|
<input id="filter-default-tag" class="search-query" type="text" placeholder="Search Tags" value="">
|
||||||
|
<%= form_tag add_from_default_admin_module_app_tags_path(:module_app_id=>@module_app.id), id: "filter-default-tag", method: :post, remote: true do %>
|
||||||
|
<fieldset>
|
||||||
|
<ul class="add-default-tags-list tags-groups checkbox-card">
|
||||||
|
<% @default_tags.each do |tag| %>
|
||||||
|
<li class="filter-item default">
|
||||||
|
<p class="card pull-left">
|
||||||
|
<input type="checkbox">
|
||||||
|
<%= check_box_tag "ids[]", tag.id, false, class: "tag_id" %>
|
||||||
|
</p>
|
||||||
|
<a>
|
||||||
|
<span class="amount"><%= tag.taggings.count %></span>
|
||||||
|
<%= tag.show_names_slash %>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<div class="form-actions">
|
||||||
|
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||||
|
<%= submit_tag t(:add), class: 'btn btn-primary btn-small' %>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
$("#delete_tags").modal('hide');
|
$("#delete_tags").modal('hide');
|
||||||
$("#tags-merger").modal('hide');
|
$("#tags-merger").modal('hide');
|
||||||
|
$("#remove_defaults").modal('hide');
|
||||||
$("#tags_index").html("<%= j render 'index' %>")
|
$("#tags_index").html("<%= j render 'index' %>")
|
||||||
$.pageslide.close();
|
$.pageslide.close();
|
||||||
openSlide();
|
openSlide();
|
||||||
$('.card').cardCheck({
|
$('.card').cardCheck({
|
||||||
item: $('.card input[type="checkbox"]'),
|
item: $('.card input[type="checkbox"]'),
|
||||||
});
|
});
|
||||||
checkedLength()
|
checkedLength();
|
|
@ -1 +0,0 @@
|
||||||
<%= render 'new' %>
|
|
|
@ -20,7 +20,26 @@ if Page.count == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if User.count==0
|
if User.count==0
|
||||||
|
group = Workgroup.new
|
||||||
|
group.title = "Administrator"
|
||||||
|
group.key = 'admin'
|
||||||
|
group.save
|
||||||
|
|
||||||
|
role = Role.new
|
||||||
|
role.key = 'admin'
|
||||||
|
role.title_translations = {:en=>'Administrator', :zh_tw=>'Administrator'}
|
||||||
|
role.save
|
||||||
|
|
||||||
|
profile = MemberProfile.new
|
||||||
|
profile.first_name_translations = {:en=>'Digital', :zh_tw=>'Digital'}
|
||||||
|
profile.last_name_translations = {:en=>'Ruling', :zh_tw=>'Ruling'}
|
||||||
|
profile.save
|
||||||
|
|
||||||
|
role.member_profiles << profile
|
||||||
|
|
||||||
user = User.new
|
user = User.new
|
||||||
|
user.workgroup = group
|
||||||
|
user.member_profile = profile
|
||||||
user.user_name = "rulingcom"
|
user.user_name = "rulingcom"
|
||||||
user.password = "bjo4xjp6"
|
user.password = "bjo4xjp6"
|
||||||
user.email = "orbit@rulingcom.com"
|
user.email = "orbit@rulingcom.com"
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
OrbitApp.registration "Category", type: 'ModuleApp' do
|
||||||
|
module_label 'module_name.category'
|
||||||
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
|
|
||||||
|
authorizable
|
||||||
|
|
||||||
|
side_bar do
|
||||||
|
head_label_i18n 'module_name.category', icon_class: "icons-flow-cascade"
|
||||||
|
head_link_path "admin_categories_path"
|
||||||
|
active_for_controllers (['admin/categories'])
|
||||||
|
|
||||||
|
# available_for [:admin, :manager]
|
||||||
|
|
||||||
|
# context_link 'all',
|
||||||
|
# link_path: "admin_categorys_path",
|
||||||
|
# priority: 1,
|
||||||
|
# active_for_action: {categorys: :index},
|
||||||
|
# available_for: [:admin, :manager]
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,7 +7,7 @@
|
||||||
side_bar do
|
side_bar do
|
||||||
head_label_i18n 'module_name.tag', icon_class: "icons-tag"
|
head_label_i18n 'module_name.tag', icon_class: "icons-tag"
|
||||||
head_link_path "admin_tags_path"
|
head_link_path "admin_tags_path"
|
||||||
active_for_controllers ({public: ['admin/tags']})
|
active_for_controllers (['admin/tags'])
|
||||||
|
|
||||||
# available_for [:admin, :manager]
|
# available_for [:admin, :manager]
|
||||||
|
|
||||||
|
|
|
@ -667,6 +667,7 @@ en:
|
||||||
|
|
||||||
module_name:
|
module_name:
|
||||||
tag: Tag
|
tag: Tag
|
||||||
|
category: Category
|
||||||
|
|
||||||
datetime_picker:
|
datetime_picker:
|
||||||
date:
|
date:
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
zh_tw:
|
zh_tw:
|
||||||
_locale: 中文
|
_locale: 中文
|
||||||
|
en: 英文
|
||||||
|
zh_tw: 中文
|
||||||
more: "更多"
|
more: "更多"
|
||||||
site_: 網站
|
site_: 網站
|
||||||
site_info: 基本資訊
|
site_info: 基本資訊
|
||||||
|
@ -7,8 +9,10 @@ zh_tw:
|
||||||
site_structure: 網站架構
|
site_structure: 網站架構
|
||||||
sitemap: 網站地圖
|
sitemap: 網站地圖
|
||||||
site_name: 網站名稱
|
site_name: 網站名稱
|
||||||
|
submit: 送出
|
||||||
mobile_settings: 行動設定
|
mobile_settings: 行動設定
|
||||||
modules: 網站模組
|
modules: 網站模組
|
||||||
|
name: 名稱
|
||||||
search_engine: 搜尋引擎
|
search_engine: 搜尋引擎
|
||||||
templates: 網站模版
|
templates: 網站模版
|
||||||
preference: 系統偏好
|
preference: 系統偏好
|
||||||
|
@ -17,8 +21,10 @@ zh_tw:
|
||||||
locale: 位置
|
locale: 位置
|
||||||
login: 登入
|
login: 登入
|
||||||
logout: 登出
|
logout: 登出
|
||||||
|
cancel: 取消
|
||||||
dashboard_: 儀表版
|
dashboard_: 儀表版
|
||||||
desktop: 桌面
|
desktop: 桌面
|
||||||
|
disable: 停用
|
||||||
password: 密碼
|
password: 密碼
|
||||||
all: 全部
|
all: 全部
|
||||||
add: 新增
|
add: 新增
|
||||||
|
@ -60,4 +66,5 @@ zh_tw:
|
||||||
register: 註冊
|
register: 註冊
|
||||||
registered: 已註冊
|
registered: 已註冊
|
||||||
|
|
||||||
|
module_name:
|
||||||
|
category: 類別
|
||||||
|
|
|
@ -51,15 +51,41 @@ Orbit::Application.routes.draw do
|
||||||
post 'toggle'
|
post 'toggle'
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :module_apps
|
resources :module_apps do
|
||||||
|
resources :categories do
|
||||||
|
collection do
|
||||||
|
post 'create_in_form'
|
||||||
|
end
|
||||||
|
member do
|
||||||
|
post 'toggle'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
resources :tags do
|
||||||
|
collection do
|
||||||
|
post 'add_to_default'
|
||||||
|
post 'add_from_default'
|
||||||
|
post 'create_in_form'
|
||||||
|
post 'delete_tags'
|
||||||
|
post 'merge'
|
||||||
|
post 'remove_default'
|
||||||
|
post 'update_included_default'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
get 'authorizations(/:module(/:type(/:id)))' => 'authorizations#index', :as => :authorizations
|
get 'authorizations(/:module(/:type(/:id)))' => 'authorizations#index', :as => :authorizations
|
||||||
|
|
||||||
resources :authorizations
|
resources :authorizations
|
||||||
resources :items
|
resources :items
|
||||||
|
resources :categories do
|
||||||
|
member do
|
||||||
|
post 'toggle'
|
||||||
|
end
|
||||||
|
end
|
||||||
resources :tags do
|
resources :tags do
|
||||||
collection do
|
collection do
|
||||||
post 'add_to_default'
|
post 'add_to_default'
|
||||||
|
post 'add_from_default'
|
||||||
post 'delete_tags'
|
post 'delete_tags'
|
||||||
post 'merge'
|
post 'merge'
|
||||||
post 'remove_default'
|
post 'remove_default'
|
||||||
|
|
|
@ -7,7 +7,7 @@ module ContextLinkRenderer
|
||||||
@request = request
|
@request = request
|
||||||
@params = params
|
@params = params
|
||||||
@current_user = current_user
|
@current_user = current_user
|
||||||
content_tag :li, link_to(content_tag(:span, I18n.t(@label_i18n)), Rails.application.routes.url_helpers.send(@path)), :class => ( active_actions[controller] == action ? 'active' : nil)
|
content_tag :li, link_to(content_tag(:span, I18n.t(@label_i18n)), Rails.application.routes.url_helpers.send(@path, @arg)), :class => ( active_actions[controller] == action ? 'active' : nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -142,6 +142,7 @@ module OrbitApp
|
||||||
@label_i18n = label_i18n
|
@label_i18n = label_i18n
|
||||||
@priority = options[:priority] || 0
|
@priority = options[:priority] || 0
|
||||||
@path = options[:link_path] || ""
|
@path = options[:link_path] || ""
|
||||||
|
@arg = options[:link_arg] || ""
|
||||||
set_available_for_avoiding_sensitive_links(options[:available_for] )
|
set_available_for_avoiding_sensitive_links(options[:available_for] )
|
||||||
@active_for_action = options[:active_for_action] || []
|
@active_for_action = options[:active_for_action] || []
|
||||||
@active_for_app_auth = options[:active_for_app_auth] || []
|
@active_for_app_auth = options[:active_for_app_auth] || []
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 7.4 KiB |
|
@ -0,0 +1,7 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class Admin::CategoriesControllerTest < ActionController::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class Admin::CategoriesHelperTest < ActionView::TestCase
|
||||||
|
end
|
Loading…
Reference in New Issue