archive and web_resouce for new ui

Conflicts:
	app/assets/stylesheets/lib/main-forms.css
This commit is contained in:
Spen 2013-07-22 14:59:33 +08:00 committed by chris
parent 1ba1703e90
commit 5d3bc07488
30 changed files with 1531 additions and 620 deletions

View File

@ -0,0 +1,511 @@
//Global Variables
$sidebarState = window.localStorage.getItem('sidebarState');
$ua = navigator.userAgent;
$.extend($.support, {
touch: "ontouchend" in document
});
if($.support.touch) {
mouseenterEvent = clickEvent = "touchstart";
} else {
clickEvent = "click";
mouseenterEvent = "mouseenter";
};
!function ($) {
// Focus first element
$.fn.focusFirstField = function(){
$this = this;
$this.find(":text:visible:enabled").filter(function(){
return $(this).parents(":hidden").size() == 0;
}).slice(0,1).focus();
return this;
}
//Checked Toggle
$.fn.togglebox = function () {
var $checked = this;
$checked.each(function() {
if(!$(this).closest('div').hasClass('togglebox')) {
$(this).wrap('<div class="togglebox" />');
$('<label><b></b></label>').insertAfter($(this));
}
})
$checked.each(function(i) {
if($(this).attr('type') == "checkbox") {
if($(this).prop('checked')) {
$(this).parent('.togglebox').addClass('disabled').closest('li').addClass('disabled');
};
$(this).on({
change: function() {
$(this).parent('.togglebox').toggleClass('disabled');
$(this).closest('tr').toggleClass('disable');
}
});
};
if($(this).attr('type') == "radio") {
if(!$(this).prop('checked')) {
$(this).parent('.togglebox').addClass('disabled').closest('li').addClass('disabled');
$(this).closest('tr').addClass('disable');
};
$(this).on({
change: function() {
$checked.each(function(i) {
if(!$(this).parent('.togglebox').hasClass('disabled')) {
$(this).parent('.togglebox').toggleClass('disabled');
$(this).closest('tr').toggleClass('disable');
};
});
$(this).parent('.togglebox').toggleClass('disabled')
$(this).closest('tr').toggleClass('disable');
}
});
};
if($('#sitemap').length) {
$(this).on({
change: function() {
$(this).closest('li').toggleClass('disabled');
if($(this).prop('checked')) {
$(this).attr('checked', 'checked');
$(this).parents('h6')
.siblings('ul')
.find('li')
.addClass('disabled')
.find('h6 .togglebox')
.addClass('disabled')
.find('input[type="checkbox"]')
.prop('checked', true)
.attr('checked', 'checked');
} else {
$(this).removeAttr('checked');
$(this).parents('h6')
.siblings('ul')
.find('li')
.removeClass('disabled')
.find('h6 .togglebox')
.removeClass('disabled')
.find('input[type="checkbox"]')
.prop('checked', false)
.removeAttr('checked');
};
$('.toggle-check').each(function(i) {
var len = $(this).closest('ul').children('li').length,
checLen = $(this).closest('ul').children('li').find('input[checked]').length,
checLen = checLen - $(this).closest('ul').children('li').find('ul').find('input[checked]').length;
if(len == checLen) {
$(this).closest('ul')
.parent('li')
.addClass('disabled')
.children('h6')
.find('.togglebox')
.addClass('disabled')
.find('input[type="checkbox"]')
.prop('checked', true)
.attr('checked', 'checked');
} else {
$(this).closest('ul')
.parent('li')
.removeClass('disabled')
.children('h6')
.find('.togglebox')
.removeClass('disabled')
.find('input[type="checkbox"]')
.prop('checked', false)
.removeAttr('checked');
};
});
},
});
};
});
};
// Search Clear
$.fn.searchClear = function (param){
_defaultSettings = {
inputName: ':input',
inputIcon: 'inputIcon',
clearBtnIcon: 'clearBtnIcon',
liveFilter: false,
};
_set = $.extend(_defaultSettings, param);
$this = this;
$input = this.find(_set.inputName);
$tmp = '<i class="'+_set.inputIcon+'"></i><i class="'+_set.clearBtnIcon+' search-clear"></i>';
$input.wrap('<div class="sc-field" />');
$this.find('.sc-field').prepend($tmp);
$searchClear = $this.find(".search-clear");
function run(e) {
$searchClear.hide();
$($input).each(function() {
if($(this).val().length > 0) {
$(this).prev($searchClear).show();
}else {
$(this).prev($searchClear).hide();
}
$(this).on("blur keyup", function(){
if($(this).val().length > 0) {
$(this).prev($searchClear).show();
}else {
$(this).prev($searchClear).hide();
}
});
if(_set.liveFilter) {
$(this).prevAll($searchClear).on({
click: function(){
$(this).hide();
$(this).next($input).val("");
$('.checkbox-card .mark').removeClass('mark')
},
});
} else {
$(this).prevAll($searchClear).on({
click: function(){
$(this).hide();
$(this).next($input).val("");
},
});
}
});
}
// Checking IE10
// if Windows 8 and IE is ture. remove search clear buttom and fix text input padding-right
if(/Windows NT 6.2/g.test(navigator.userAgent)){
if(/MSIE/g.test(navigator.userAgent)){
$searchClear.remove();
$input.css({
'padding-right': '5px',
});
}else{run()}
}else{run()}
}
// Fixed Nav
fixedNav = function () {
if($('.fixed-nav').length){
var $fixedNav = $('.fixed-nav');
if($sidebarState){
$fixedNav.addClass('open');
}
$fixedNav.on(clickEvent, function() {
if($sidebarState) {
window.localStorage.removeItem('sidebarState');
$fixedNav.removeClass('open');
}else{
window.localStorage.setItem('sidebarState', 1);
$fixedNav.addClass('open');
}
$sidebarState = window.localStorage.getItem('sidebarState')
});
}
};
// Sidebar
sidebarNav = function () {
var $sidebar = $('#sidebar'),
$sidebarMenu = $('#sidebar-menu'),
$scroller = $('.scroller'),
$sidebarNav = $('.sidebar-nav'),
$el = $('.sidebar-nav').children('li'),
$elIndex = null,
$blockList = $('.sub-nav-block-list'),
$block = $('.sub-nav-block'),
$blockIndex = 0,
$arrow = $('.sub-nav-arrow'),
$wrap = $('#main-wrap'),
$wrapLeft = $wrap.css('margin-left'),
$position = 0,
$arrowHeightFormat = $('.position').height()-8;
if($('#sidebar').length>0) {
$wrap.css({'margin-left': 61});
$wrapLeft = 61;
}
if($el.hasClass('active')) {
// Menu defaults active
$elIndex = $el.filter('.active').index();
if($sidebarState && !$sidebarNav.hasClass('no-sub-nav')) {
$block.eq($elIndex).addClass('show');
$blockList.css({'width': 180});
$wrap.css({
'margin-left': 241,
});
}
// Arrow defaults position
$position = $el.eq($elIndex).offset().top-$el.eq($elIndex).height()/2+$arrowHeightFormat-$(document).scrollTop();
$arrow.css({
'top': $position,
});
}
if($.support.touch && !$sidebarNav.hasClass('no-sub-nav')) {
$el.find('a').removeAttr('href');
};
$el.on(mouseenterEvent, function(e) {
$block.siblings().removeClass('show').eq($(this).index()).addClass('show');
$arrow.stop(true, false).animate({
top: ($(this).offset().top-$(this).height()/2)+$arrowHeightFormat-$(document).scrollTop(),
},{
duration: 500,
easing: 'easeInOutBack',
});
if(!$sidebarState || !$el.hasClass('active')) {
$blockList.css({'width': 180});
if($('#pageslide').length) {
if($('#pageslide').is(":hidden")) {
$wrap.css({
'margin-left': $blockList.width()+$sidebarNav.width(),
});
}
}else{
$wrap.css({
'margin-left': $blockList.width()+$sidebarNav.width(),
});
}
// if($('.topnav').length) {
// $('.topnav').css({
// 'left': $blockList.width()+$sidebarNav.width()+20,
// });
// }
if($('.bottomnav').length) {
$('.bottomnav').css({
'left': $blockList.width()+$sidebarNav.width()+20,
});
}
$sidebar.css({
'width': $blockList.width()+$sidebarNav.width(),
});
}
});
if ($sidebarNav.hasClass('no-sub-nav')) {
$sidebar.on('mouseleave', function() {
$arrow.stop(true, false).animate({
'top': $position,
},{
duration: 500,
easing: 'easeInOutBack',
});
})
};
// $el.on('mouseleave', function() {
// $el.hasClass('active') ? $position = $el.eq($elIndex).offset().top-$el.eq($elIndex).height()/2+$arrowHeightFormat-$(document).scrollTop() : 0;
// $(this).hasClass('active') ? '':$(this).children('span').removeClass('hover');
// });
$block.on({
mouseenter: function() {
$blockIndex = $block.filter('.sub-nav-block show').index();
$el.eq($blockIndex).hasClass('active') ? '':$el.eq($blockIndex).children('span').addClass('hover');
},
mouseleave: function() {
$block.removeClass('show');
if(!$sidebarState || !$el.hasClass('active')) {
$blockList.css({'width': 0});
if($('#pageslide').length) {
if($('#pageslide').is(":hidden")) {
$wrap.css({
'margin-left': $wrapLeft,
});
// if($('.topnav').length) {
// if($sidebarState) {
// $('.topnav').css({
// 'left': 261,
// });
// }
// }
}
} else {
$wrap.css({
'margin-left': $blockList.width()+$sidebarNav.width(),
});
}
// if($('.topnav').length) {
// $('.topnav').css({
// 'left': $blockList.width()+$sidebarNav.width()+20,
// });
// }
if($('.bottomnav').length) {
$('.bottomnav').css({
'left': $blockList.width()+$sidebarNav.width()+20,
});
}
$sidebar.css({'width': 61});
}else{
$block.eq($elIndex).addClass('show');
};
if($elIndex === null) {
$position = 0;
} else {
$position = $el.eq($elIndex).offset().top-$el.eq($elIndex).height()/2+$arrowHeightFormat-$(document).scrollTop();
}
$arrow.stop(true, false).animate({
top: $position,
},{
duration: 500,
easing: 'easeInOutBack',
});
}
});
// Touch Start
$wrap.on({
touchstart: function() {
if(!$sidebarState || !$el.hasClass('active')) {
if($block.hasClass('show')) {
$blockIndex = $block.filter('.sub-nav-block show').index();
$block.removeClass('show');
$blockList.css({'width': 0});
$wrap.css({
'margin-left': $wrapLeft,
});
$sidebar.css({'width': 61});
$arrow.stop().animate({
top: $position,
},{
duration: 500,
easing: 'easeInOutBack',
});
$el.eq($blockIndex).hasClass('active') ? '':$el.eq($blockIndex).children('span').removeClass('hover');
}
}
}
});
// Sidebar Nav Drag
if(/MSIE 8.0/g.test($ua)){
$sidebarMenu.addClass('nano')
.css({'position': 'relative', 'top': '0px'})
.children('.scroller')
.addClass('content')
.removeClass('scroller');
$sidebarMenu.nanoScroller({ scrollTop: 0 });
} else {
if($('#sidebar').length) {
var sidebarMenu = new iScroll('sidebar-menu', {
vScrollbar: true,
scrollbarClass: 'myScrollbar',
onBeforeScrollStart: function (e) {
var target = e.target;
clearTimeout(this.hoverTimeout);
while (target.nodeName != "SPAN") target = target.parentNode;
$target = $(target.parentNode).index();
},
touch: function () {
if (this.hoverTarget) {
clearTimeout(this.hoverTimeout);
$('.sub-nav-block').removeClass('show')
$('.sub-nav-block').eq($target).addClass('show')
}
},
});
}
};
};
// Initial State
initialState = function () {
if($('.bottomnav').length) {
var $bottomnavHeight = $('.bottomnav').outerHeight();
$('.wrap-inner').css({
'padding-bottom': $bottomnavHeight,
})
if($sidebarState) {
if(!$('.sidebar-nav').hasClass('no-sub-nav')) {
$('.bottomnav').css({
'left': 261,
});
}
}
}
// if($('.topnav').length) {
// if($sidebarState) {
// $('.topnav').css({
// 'left': 261,
// });
// }
// }
};
}(window.jQuery);
// Open Slide
function openSlide() {
var $openSlide = $('.open-slide'),
$pageslideW;
$(window).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954;
$(window).resize(function() {
$(this).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954;
})
$openSlide.each(function() {
if($(this).hasClass('view-page')) {
$(this).pageslide({ W: $pageslideW, iframe: true});
} else if($('#items').length) {
$(this).pageslide({ W: 324});
} else {
$(this).pageslide();
};
});
$('.bottomnav .open-slide').on('click', function() {
$('.table tr').removeClass('active');
$('.filter-item').removeClass('active')
});
}
function formTip() {
if($('.main-forms').length && $('.add-on').length) {
$('.main-forms .add-on').tooltip();
}
}
// Document Ready
$(function() {
initialState();
$('#login').on('shown', function () {
$(document.body).addClass('modalBlur');
$('#login').focusFirstField();
}).on("hide", function() {
$(document.body).removeClass('modalBlur');
});
$('#orbit-bar .searchClear').searchClear({
inputName: '.search-query',
inputIcon: 'icon-search',
clearBtnIcon: 'icons-cross-3',
});
$('#filter .searchClear').searchClear({
inputName: '.search-query',
inputIcon: 'icon-search',
clearBtnIcon: 'icons-cross-3',
liveFilter: true,
});
$('#member-filter').on('shown', function() {
$(this).find('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
});
if($('#sidebar').length) {
if(!/MSIE 8.0/g.test(navigator.userAgent)){
document.getElementById('sidebar').addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
}
demo_fu1();
}
if($('#pageslide').length) {
openSlide();
}
if($('.tags').length) {
$('#filter-input').fastLiveFilter('#tags-list', '.filter-item', '.tag');
}
if($('#card-list').length) {
$('#filter-input').fastLiveFilter('#card-list', '.filter-item', '.user-name');
}
if($('.toggle-check').length) {
$('.toggle-check').togglebox();
}
formTip()
sidebarNav();
});

View File

@ -1,100 +1,117 @@
/* General style with default layout */ /* General style with default layout */
.o-archives {} .o-archives {}
.o-archives-content {} .o-archives .o-archives-content {}
.o-archives-group { .o-archives .o-archives-group {
margin: 20px 0 0 0; margin: 20px 0 0 0;
padding: 20px 0 0 0; padding: 20px 0 0 0;
border-top: dashed 1px #eee; border-top: dashed 1px #eee;
} }
.o-archives-group:first-child { .o-archives .o-archives-group:first-child {
margin: 0; margin: 0;
padding: 0; padding: 0;
border: 0; border: 0;
} }
.o-archives-category { .o-archives .o-archives-category {
padding-bottom: 16px; padding-bottom: 16px;
margin-bottom: 16px;
border-bottom: solid 2px #ccc; border-bottom: solid 2px #ccc;
font-weight: bold; font-weight: bold;
} }
.o-archives-list {} .o-archives .o-archives-list {}
.o-archives-list ul { .o-archives .o-archives-list ul {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
} }
.o-archives-list li {} .o-archives .o-archives-list li {}
.o-archives-title { .o-archives .o-archives-title {
border-left: solid 8px #eee; border-left: solid 8px #eee;
border-bottom: solid 1px #eee; border-bottom: solid 1px #eee;
padding: 0 0 0 16px; padding: 0 0 0 16px;
line-height: 2em;
} }
.o-archives-list-item {} .o-archives .o-archives-list-item {
.o-archives-list-item ol { padding: 12px 0;
list-style-type: decimal;
} }
.o-archives-list-item li { .o-archives .o-archives-list-item ol {
margin: 0 0 10px 0; list-style-type: disc;
margin: 0;
} }
.o-archives-file {} .o-archives .o-archives-list-item li {
.o-archives-file:hover {} margin: 0 0 8px 0;
.o-archives-file-type { }
display: inline-block; .o-archives .o-archives-file {
vertical-align: middle; font-size: 0.85em;
margin-left: 8px; }
padding: 0 4px; .o-archives .o-archives-file:hover {}
height: 15px; .o-archives .o-archives-file-type {
font-size: 9px; display: inline-block;
text-transform: uppercase; vertical-align: top;
line-height: 15px; margin-left: 8px;
background-color: #999; padding: 0 6px;
color: #FFF; height: 16px;
border-radius: 3px; font-size: 10px;
-webkit-text-size-adjust: none; text-transform: uppercase;
line-height: 16px;
background-color: #666;
color: #fff;
border-radius: 3px;
}
.o-archives .o-archives-hot {
font-size: 11px;
font-weight: normal;
padding: 0 4px;
display: inline-block;
vertical-align: top;
margin: 0 0 0 8px;
background-color: #D83131;
color: #FFF;
} }
/* Tag list */ /* Tag list */
.o-archives-tag-list {} .o-archives .o-archives-tag-list {}
.o-archives-tag-list ul { .o-archives .o-archives-tag-list ul {
margin: 0 -4px; margin: 0 -4px;
padding: 0; padding: 0;
list-style: none; list-style: none;
} }
.o-archives-tag-list ul:after { .o-archives .o-archives-tag-list ul:after {
content: "."; content: ".";
clear: both; clear: both;
display: block; display: block;
height: 0; height: 0;
visibility: hidden; visibility: hidden;
} }
.o-archives-tag-list li { .o-archives .o-archives-tag-list li {
float: left; float: left;
margin: 0 4px 8px 4px; margin: 0 4px 8px 4px;
} }
.o-archives-tag { .o-archives .o-archives-tag {
display: block; display: block;
border: solid 1px #ccc; border: solid 1px #ccc;
padding: 2px 6px; padding: 4px;
font-size: 0.85em;
} }
.o-archives-tag:hover {} .o-archives .o-archives-tag:hover {}
/* Table layout */ /* Table layout */
.o-archives.layout-table {} .o-archives.layout-table {}
.o-archives-search { .o-archives .o-archives-search {
overflow: hidden; overflow: hidden;
margin: 0 0 10px 0; margin: 0 0 10px 0;
} }
.o-archives-search label { .o-archives .o-archives-search label {
display: inline-block; display: inline-block;
margin: 0 8px 0 0; margin: 0 8px 0 0;
} }
.o-archives-search-option { .o-archives .o-archives-search-option {
float: right; float: right;
} }
.o-archives-search-option select { .o-archives .o-archives-search-option select {
width: 80px; width: 80px;
} }
.o-archives-search-keyword {} .o-archives .o-archives-search-keyword {}
.o-archives-search-keyword input[type=submit] { .o-archives .o-archives-search-keyword input[type=submit] {
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
margin: 0 0 0 8px; margin: 0 0 0 8px;
@ -112,6 +129,8 @@ border-radius: 3px;
.o-archives.layout-table .even td {} .o-archives.layout-table .even td {}
.o-archives.layout-table .column-ctrl { .o-archives.layout-table .column-ctrl {
text-align: left; text-align: left;
padding: 8px 4px;
font-size: 0.85em;
} }
.o-archives.layout-table .column-ctrl.col-title { width: 30% } .o-archives.layout-table .column-ctrl.col-title { width: 30% }
.o-archives.layout-table .column-ctrl.col-file {} .o-archives.layout-table .column-ctrl.col-file {}
@ -121,16 +140,18 @@ border-radius: 3px;
font-weight: bold; font-weight: bold;
border: 0; border: 0;
padding: 0; padding: 0;
line-height: 1.2em;
} }
.o-archives.layout-table .o-archives-category { .o-archives.layout-table .o-archives-category {
padding: 0; padding: 0;
margin: 0; margin: 0;
border: 0; border: 0;
font-weight: normal;
} }
.o-archives.layout-table .o-archives-tag { .o-archives.layout-table .o-archives-tag {
display: inline-block; display: inline-block;
margin-bottom: 3px; margin-bottom: 3px;
} }
.o-archives.layout-table .o-archives-category { .o-archives.layout-table .o-archives-list-item {
font-weight: normal; padding: 0;
} }

View File

@ -1,48 +1,66 @@
class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController
# before_filter :for_app_manager,:except => [:index,:show] # before_filter :for_app_manager,:except => [:index,:show]
include OrbitControllerLib::DivisionForDisable # include OrbitControllerLib::DivisionForDisable
before_filter :force_order_for_visitor,:only=>[:index] before_filter :force_order_for_visitor,:only=>[:index]
before_filter :force_order_for_user,:except => [:index] before_filter :force_order_for_user,:except => [:index]
before_filter :for_app_sub_manager,:except => [:index] before_filter :for_app_sub_manager,:except => [:index]
before_filter :only => [ :new,:edit,:update,:create] do |controller| # before_filter :only => [ :new,:edit,:update,:create] do |controller|
controller.get_categorys('ArchiveFileCategory') # controller.get_categorys('ArchiveFileCategory')
# end
before_filter :only => [ :new, :create, :edit, :update ] do |controller|
@categories = get_categories_for_form
end end
def index def index
@tags = get_tags
@categories = get_categories_for_index
@statuses = get_statuses
category_ids = @categories.collect{|t| t.id}
get_categorys("ArchiveFileCategory",params[:archive_file_category_id]) @archive_files = get_sorted_and_filtered("archive_file", :category_id.in => category_ids)
@filter = params[:filter]
new_filter = params[:new_filter]
if @filter && params[:clear]
@filter.delete(params[:type])
elsif @filter && new_filter
if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s)
@filter[new_filter[:type]].delete(new_filter[:id].to_s)
elsif @filter.has_key?(new_filter[:type])
@filter[new_filter[:type]] << new_filter[:id].to_s
else
@filter.merge!({new_filter[:type] => [new_filter[:id].to_s]})
end
elsif new_filter
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
end
@archive_filecategories = get_categories_for_index("ArchiveFileCategory")
@archive_file_category_ids = @archive_file_categories.collect{|t| t.id.to_s} + [nil]
@archive_files = (params[:sort] || @filter) ? get_sorted_and_filtered("archive_file",:archive_file_category_id.in => @archive_file_category_ids) : get_viewable("archive_file",:archive_file_category_id.in => @archive_file_category_ids)
@tags = get_tags
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
format.js { }
format.xml { render :xml => @archive_files } format.xml { render :xml => @archive_files }
format.js
end end
end end
# def index
# get_categorys("ArchiveFileCategory",params[:archive_file_category_id])
# @filter = params[:filter]
# new_filter = params[:new_filter]
# if @filter && params[:clear]
# @filter.delete(params[:type])
# elsif @filter && new_filter
# if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s)
# @filter[new_filter[:type]].delete(new_filter[:id].to_s)
# elsif @filter.has_key?(new_filter[:type])
# @filter[new_filter[:type]] << new_filter[:id].to_s
# else
# @filter.merge!({new_filter[:type] => [new_filter[:id].to_s]})
# end
# elsif new_filter
# @filter = {new_filter[:type] => [new_filter[:id].to_s]}
# end
# @archive_filecategories = get_categories_for_index("ArchiveFileCategory")
# @archive_file_category_ids = @archive_file_categories.collect{|t| t.id.to_s} + [nil]
# @archive_files = (params[:sort] || @filter) ? get_sorted_and_filtered("archive_file",:archive_file_category_id.in => @archive_file_category_ids) : get_viewable("archive_file",:archive_file_category_id.in => @archive_file_category_ids)
# @tags = get_tags
# respond_to do |format|
# format.html # index.html.erb
# format.xml { render :xml => @archive_files }
# format.js
# end
# end
# GET /archive_files/1 # GET /archive_files/1
# GET /archive_files/1.xml # GET /archive_files/1.xml
def show def show
@ -57,7 +75,12 @@ class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController
# GET /archive_files/new # GET /archive_files/new
# GET /archive_files/new.xml # GET /archive_files/new.xml
def new def new
@archive_file = ArchiveFile.new if(session[:in_validate_object].blank?)
@archive_file = ArchiveFile.new
else
@archive_file = session[:in_validate_object]
session[:in_validate_object] = {}
end
@tags = get_tags @tags = get_tags
@ -70,8 +93,11 @@ class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController
# GET /archive_files/1/edit # GET /archive_files/1/edit
def edit def edit
@archive_file = ArchiveFile.find(params[:id]) @archive_file = ArchiveFile.find(params[:id])
if !current_user.admin?
@tags = get_tags redirect_to :action => :index
else
@tags = get_tags
end
end end
# POST /archive_files # POST /archive_files

View File

@ -21,6 +21,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
def index def index
@item = Page.find(params[:page_id]) @item = Page.find(params[:page_id])
@title = @item.title @title = @item.title
@frontend_style = @item.frontend_style
if !@item.frontend_data_count.blank? if !@item.frontend_data_count.blank?
@page_num = @item.frontend_data_count @page_num = @item.frontend_data_count
else else
@ -28,23 +29,69 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
end end
date_now = Time.now date_now = Time.now
@archive_file_categorys = ArchiveFileCategory.all # @archive_file_categorys = ArchiveFileCategory.all
# @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num) # @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num)
if !params[:category_id].blank? && !params[:tag_id].blank? if !params[:category_id].blank?
@archive_files = @archive_files.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num) @archive_file_categorys = @module_app.categories.enabled.any_in(:_id => params[:category_id])
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil @archive_file_category_ids = @module_app.categories.enabled.any_in(:_id => params[:category_id]).collect{|a|a.id}
elsif !params[:category_id].blank?
@archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
else else
@archive_files = ArchiveFile.default_sort(params[:sort]).can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) @archive_file_categorys = @module_app.categories.enabled
@archive_file_category_ids = @module_app.categories.enabled.collect{|a|a.id}
end end
if @frontend_style == "1"
get_categorys if !params[:category_id].blank? && !params[:tag_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids, :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num)
# @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
elsif !params[:category_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num)
# @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids,:tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num)
else
@archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num)
end
elsif @frontend_style == "2"
@archive_file_datas = Array.new
@archive_file_categorys.each do |afcg|
if !params[:category_id].blank? && !params[:tag_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id.in => [afcg.id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort])
elsif !params[:category_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id.in => [afcg.id]).desc( :is_top ).default_sort(params[:sort])
elsif !params[:tag_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id => afcg.id, :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort])
else
@archive_files = ArchiveFile.can_display.where(:category_id => afcg.id).desc( :is_top ).default_sort(params[:sort])
end
archive_file_datas = Array.new
@archive_files.each do |af|
archive_file_multiple_datas = Array.new
af.archive_file_multiples.asc(:sort_number).each do | afile |
archive_file_multiple_datas << {
"file_title" => (!afile.file_title.blank? ? afile.file_title : t('archive.download') ) ,
"url" => afile.file.url,
"icon" => af.get_file_icon(afile.file.url)
} if afile.file.file and afile.choose_lang_display(I18n.locale.to_s)
end
archive_file_datas << { "title" => af.title, "is_hot" => (!af.is_hot.blank? ? '1' : ''), "archive_file_multiples" => archive_file_multiple_datas } if !af.archive_file_multiples.blank? and !archive_file_multiple_datas.blank?
end
@archive_file_datas << { "title" => afcg.title, "archive_files" => archive_file_datas } if !@archive_files.blank?
end
end
# get_categorys
if params[:sort] if params[:sort]
@archive_files = get_sorted_and_filtered('archive_file', nil, @archive_files) @archive_files = get_sorted_and_filtered('archive_file', nil, @archive_files)

View File

@ -28,17 +28,91 @@ class Panel::Archive::Widget::ArchiveFilesController < OrbitWidgetController
date_now = Time.now date_now = Time.now
# if !params[:category_id].blank?
# @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.any_in(:category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num)
# @archive_file_categorys = ArchiveFileCategory.any_in(:_id => params[:category_id]).excludes('disable' => true)
# elsif !params[:tag_id].blank?
# @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num)
# get_categorys
# else
# @archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top).page( params[:page_main] ).per(@page_num)
# get_categorys
# end
# if !params[:category_id].blank? && !params[:tag_id].blank?
# @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
# @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
# elsif !params[:category_id].blank?
# @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:category_id.in => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
# @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
# elsif !params[:tag_id].blank?
# @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
# else
# @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
# end
if !params[:category_id].blank? if !params[:category_id].blank?
@archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.any_in(:archive_file_category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) @archive_file_categorys = @module_app.categories.enabled.any_in(:_id => params[:category_id])
@archive_file_categorys = ArchiveFileCategory.any_in(:_id => params[:category_id]).excludes('disable' => true) @archive_file_category_ids = @module_app.categories.enabled.any_in(:_id => params[:category_id]).collect{|a|a.id}
elsif !params[:tag_id].blank?
@archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num)
get_categorys
else else
@archive_files = ArchiveFile.default_sort(params[:sort]).all.can_display.merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top).page( params[:page_main] ).per(@page_num) @archive_file_categorys = @module_app.categories.enabled
get_categorys @archive_file_category_ids = @module_app.categories.enabled.collect{|a|a.id}
end end
if @widget_style == "1"
if !params[:category_id].blank? && !params[:tag_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids, :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num)
elsif !params[:category_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num)
elsif !params[:tag_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids,:tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num)
else
@archive_files = ArchiveFile.can_display.where(:category_id.in => @archive_file_category_ids).desc( :is_top ).default_sort(params[:sort]).page( params[:page_main] ).per(@page_num)
end
elsif @widget_style == "2"
@archive_file_datas = Array.new
@archive_file_categorys.each do |afcg|
if !params[:category_id].blank? && !params[:tag_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id.in => [afcg.id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).limit(@page_num)
elsif !params[:category_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id.in => [afcg.id]).desc( :is_top ).default_sort(params[:sort]).limit(@page_num)
elsif !params[:tag_id].blank?
@archive_files = ArchiveFile.can_display.where(:category_id => afcg.id, :tagged_ids.in => params[:tag_id]).desc( :is_top ).default_sort(params[:sort]).limit(@page_num)
else
@archive_files = ArchiveFile.can_display.where(:category_id => afcg.id).desc( :is_top ).default_sort(params[:sort]).limit(@page_num)
end
archive_file_datas = Array.new
@archive_files.each do |af|
archive_file_multiple_datas = Array.new
af.archive_file_multiples.asc(:sort_number).each do | afile |
archive_file_multiple_datas << {
"file_title" => (!afile.file_title.blank? ? afile.file_title : t('archive.download') ) ,
"url" => afile.file.url,
"icon" => af.get_file_icon(afile.file.url)
} if afile.file.file and afile.choose_lang_display(I18n.locale.to_s)
end
archive_file_datas << { "title" => af.title, "is_hot" => (!af.is_hot.blank? ? '1' : ''), "archive_file_multiples" => archive_file_multiple_datas } if !af.archive_file_multiples.blank? and !archive_file_multiple_datas.blank?
end
@archive_file_datas << { "title" => afcg.title, "archive_files" => archive_file_datas } if !@archive_files.blank?
end
end
if params[:sort] if params[:sort]
@archive_files = get_sorted_and_filtered('archive_file', nil, @archive_files) @archive_files = get_sorted_and_filtered('archive_file', nil, @archive_files)
end end

View File

@ -1,22 +1,25 @@
# encoding: utf-8 # encoding: utf-8
class ArchiveFile class ArchiveFile
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes include Mongoid::MultiParameterAttributes
include Mongoid::Sortable include Mongoid::Sortable
include Sunspot::Mongo
include OrbitCategory::Categorizable
include OrbitModel::LanguageRestrict
include OrbitModel::Status include OrbitModel::Status
include OrbitModel::TimeFrame
include OrbitTag::Taggable include OrbitTag::Taggable
BelongsToCategory = :archive_file_category # BelongsToCategory = :archive_file_category
PAYMENT_TYPES = @site_valid_locales # PAYMENT_TYPES = @site_valid_locales
field :title, localize: true field :title, localize: true
field :create_user_id field :create_user_id
field :update_user_id field :update_user_id, :class_name => "User"
# belongs_to :archive_file_category # belongs_to :archive_file_category
@ -31,13 +34,14 @@ class ArchiveFile
# searchable do # searchable do
# text :titles do # text :titles do
# title_translations.to_a.collect{|t| t[1]} # title_translations.to_a.collect{|t| t[1]}
# end # end
# boolean :frontend_search do # boolean :frontend_search do
# !is_hidden # !is_hidden
# end # end
# end # end
def self.search( category_id = nil ) def self.search( category_id = nil )
if category_id.to_s.size > 0 if category_id.to_s.size > 0

View File

@ -5,8 +5,7 @@ class ArchiveFileCategory
include Mongoid::Timestamps include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable include OrbitCoreLib::ObjectAuthable
include OrbitCoreLib::ObjectDisable include OrbitCoreLib::ObjectDisable
include Sunspot::Mongo
# include Mongoid::MultiParameterAttributes
APP_NAME = 'Archive' APP_NAME = 'Archive'
ObjectAuthTitlesOptions = %W{submit_new fact_check} ObjectAuthTitlesOptions = %W{submit_new fact_check}
AfterObjectAuthUrl = '/panel/archive/back_end/archive_file_categorys' AfterObjectAuthUrl = '/panel/archive/back_end/archive_file_categorys'
@ -20,21 +19,6 @@ class ArchiveFileCategory
validates :title, :at_least_one => true validates :title, :at_least_one => true
searchable do
text :titles do
title_translations.to_a.collect{|t| t[1]}
end
boolean :frontend_search do
!disable
end
text :files do
archive_files.can_display.collect{|t| t.title_translations.to_a.collect{|t| t[1]}}
end
end
def pp_object def pp_object
title title

View File

@ -1,157 +1,196 @@
<% # encoding: utf-8 %> <% # encoding: utf-8 %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<% end %>
<%= f.error_messages %> <%= f.error_messages %>
<!--Widget start--> <!-- Input Area -->
<div class="input-area">
<div id="sub-wiget"> <!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<% if show_form_status_field(@archive_file) %>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
<% end %>
<li>
<a href="#tag" data-toggle="tab"><%= t(:tags) %></a>
</li>
</ul>
<div id="widget-status" class="widget-box widget-size-300"> <!-- Module -->
<div class="widget-action clear tip" title="Setting the announcement state"> <div class="tab-content module-area">
<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-star"></i>Status</h3>
<div class="widget-content clear">
<div class="controls">
<%= f.check_box :is_top %><%= t('top') %>
<%= f.check_box :is_hot %><%= t('hot') %>
<%= f.check_box :is_hidden %><%= t('hide') %>
</div>
</div>
</div>
<div id="widget-tags" class="widget-box widget-size-300"> <!-- Basic Module -->
<div class="widget-action clear tip" title="Setting"> <div class="tab-pane fade in active" id="basic">
<a class="action"><i class="icon-cog icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-tag"></i>Tags</h3>
<div class="widget-content clear form-horizontal">
<% @tags.each do |tag| %>
<%= check_box_tag 'archive_file[tag_ids][]', tag.id, @archive_file.tag_ids.include?(tag.id)%>
<%= tag.name %>
<% end %>
</div>
</div>
</div> <!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %>
</div>
</div>
<!-- Sort -->
<div class="control-group">
<label class="control-label muted"><%= t(:sort_number) %></label>
<div class="controls">
<%= f.text_field :sort_number %>
</div>
</div>
<!--Wiget End--> </div>
<!--Post Start-->
<div id="post-body"> <!-- Status Module -->
<div id="post-body-content" class="clear"> <% if show_form_status_field(@archive_file) %>
<div class="tab-pane fade" id="status">
<%= f.label :category %> <!-- Status -->
<%= f.select :archive_file_category_id, @archive_file_categorys.collect {|t| [ t.title, t.id ]} %> <div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @archive_file.is_top? %>">
<%= f.check_box :is_top %> <%= t(:top) %>
</label>
<label class="checkbox inline btn <%= 'active' if @archive_file.is_hot? %>">
<%= f.check_box :is_hot %> <%= t(:hot) %>
</label>
<label class="checkbox inline btn <%= 'active' if @archive_file.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
<%= f.label :sort_number %> </div>
<%= f.text_field :sort_number %> <% end %>
<ul class="nav nav-tabs"> <!-- Tag Module -->
<% @site_valid_locales.each_with_index do |locale, i| %> <div class="tab-pane fade" id="tag">
<%# site_valid_locales_default_head.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<div class="tab-content"> <!-- Tag -->
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<% @tags.each do |tag| %>
<label class="checkbox inline btn <%= 'active' if @archive_file.tag_ids.include?(tag.id) %>">
<%= check_box_tag 'archive_file[tag_ids][]', tag.id, @archive_file.tag_ids.include?(tag.id) %> <%= tag.name %>
<%= hidden_field_tag 'archive_file[tag_ids][]', '' %>
</label>
<% end %>
</div>
</div>
<% @site_valid_locales.each_with_index do |locale, i| %> </div>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>"> </div>
<div class="title">
<%= f.label :title %>
<%= f.fields_for :title_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@archive_file.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div> <!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_valid_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a>
</li>
<% end %>
</ul>
<% end %> <!-- Language -->
<div class="tab-content language-area">
</div> <% @site_valid_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<div> <!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:title) %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@archive_file.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<div class="archive_file_multiples_block"> </div>
<table class="table table-condensed"> <% end %>
<thead>
<tr>
<th>排序數</th>
<th>File</th>
<th>File Name</th>
<th class="span2"><%= t('呈現語系')%></th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="4">
<div id='add_archive_file_multiple' class="info_input archive_file_multiples_block">
<%= hidden_field_tag 'archive_file_multiple_field_count', @archive_file.archive_file_multiples.count %>
<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i> ADD/新增</span></a>
</div>
</td>
</tr>
</tfoot> <!-- File -->
<tbody> <div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<% @archive_file.archive_file_multiples.asc(:_id).each_with_index do |archive_file_multiple, i| %> <!-- Exist -->
<%= f.fields_for :archive_file_multiples, archive_file_multiple do |f| %> <% if @archive_file && !@archive_file.archive_file_multiples.blank? %>
<%= render :partial => 'form_file', :object => archive_file_multiple, :locals => {:f => f, :i => i} %> <div class="exist">
<% end %> <% @archive_file.archive_file_multiples.each_with_index do |archive_file_multiple, i| %>
<% end %> <%= f.fields_for :archive_file_multiples, archive_file_multiple do |f| %>
</tbody> <%= render :partial => 'form_file', :object => archive_file_multiple, :locals => {:f => f, :i => i} %>
</table> <% end %>
<% end %>
<hr>
</div>
<% end %>
</div> <!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'archive_file_multiple_field_count', @archive_file.archive_file_multiples.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div> </div>
</div>
</div>
</div>
<!--Post End-->
<div class="form-actions">
<%= hidden_field_tag 'page', params[:page] if !params[:page].blank? %>
<%= hidden_field_tag 'filter', params[:filter] %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= hidden_field_tag 'page', params[:page] if !params[:page].blank? %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% content_for :page_specific_javascript do %> <% content_for :page_specific_javascript do %>
<%= javascript_include_tag "archive_form" %> <script>
<script> $(document).ready(function() {
$('#add_archive_file_multiple a.add').live('click', function(){ $('.main-forms .add-on').tooltip();
var new_id = $(this).prev().attr('value'); $(document).on('click', '#add_file', function(){
var old_id = new RegExp("new_archive_file_multiples", "g"); var new_id = $(this).prev().attr('value');
$(this).prev().attr('value', parseInt(new_id) + 1); var old_id = new RegExp("new_archive_file_multiples", "g");
var new_form_file = $("<%= escape_javascript(add_attribute 'form_file', f, :archive_file_multiples) %>".replace(old_id, new_id)); var on = $('.language-nav li.active').index();
new_form_file.find('input#archive_file_archive_file_multiples_attributes_'+new_id+'_sort_number').val(new_id * 10) var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).parents('table').append(new_form_file); $(this).prev().attr('value', parseInt(new_id) + 1);
}); $(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :archive_file_multiples) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$('.archive_file_multiples_block a.delete').live('click', function(){ $(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
$(this).parents('.list_item').remove(); });
}); $('.main-forms .add-on').tooltip();
});
$('.action a.remove_existing_record').live('click', function(){ $('.for_preview').popover({ html : true });
$(this).next('.should_destroy').attr('value', 1); $(document).on('click', '.delete_file', function(){
$("tr#archive_file_" + $(this).prev().attr('value')).hide(); $(this).parents('.input-prepend').remove();
}); });
$(document).on('click', '.remove_existing_record', function(){
</script> if(confirm("<%= I18n.t(:sure?)%>")){
$(this).next('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
});
</script>
<% end %> <% end %>

View File

@ -1,64 +1,56 @@
<% # encoding: utf-8 %> <div class="fileupload fileupload-new start-line" data-provides="fileupload">
<%= form_file.file.file ? ( link_to t(:view), form_file.file.url, {:class => 'btn', :target => '_blank', :title => t(:view)} ) : '' %>
<div class="input-prepend input-append">
<label>
<span class="add-on btn btn-file" title="<%= t(:file_) %>">
<i class="icons-paperclip"></i>
<%= f.file_field :file %>
</span>
<div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= t(:select_file) %></span>
</div>
</label>
<span class="add-on icons-pencil" title="<%= 'File Name' %>"></span>
<span class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :file_title_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: 'File Name', :value => (form_file.file_title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<tr id="<%= "archive_file_multiple_#{form_file.id}" if !form_file.new_record? %>" class='list_item'> <span class="add-on icon-list-ol" title="<%= t(:sort_number) %>"></span>
<td> <span class="tab-content">
<div class="control-group"> <%= f.text_field :sort_number , :class => "input-mini"%>
<div class="controls"> </span>
<%= f.text_field :sort_number %>
</div>
</div>
</td>
<td>
<div class="control-group">
<div class="controls">
<%= f.file_field :file %>
<%= form_file.file.file ? ( link_to t(:view), form_file.file.url, {:class => 'btn', :target => '_blank', :title => t(:view)} ) : '' %>
</div>
</div>
</td>
<td>
<div class="tab-content"> <span class="add-on btn-group btn" title="<%= t('archive.show_lang') %>">
<%= t('archive.show_lang') %> <span class="caret"></span>
<ul class="dropdown-menu">
<% @site_valid_locales.each do |locale| %>
<li>
<label class="checkbox">
<%= check_box_tag "archive_file[archive_file_multiples_attributes][#{( form_file.new_record? ? 'new_archive_file_multiples' : "#{i}" )}][choose_lang][]", locale, (form_file.choose_lang.nil? ? true : form_file.choose_lang.include?(locale)) %>
<%= I18nVariable.from_locale(locale) %>
</label>
</li>
<% end %>
</ul>
<%= hidden_field_tag 'archive_file[archive_file_multiples_attributes][0][choose_lang][]', '' %>
</span>
<% @site_valid_locales.each_with_index do |locale, i| %> <span class="delete_file add-on btn" title="<%= t(:delete) %>">
<% if form_file.new_record? %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>"> <a class="icon-trash"></a>
<%#= f.fields_for :i18n_variable, (form_file.new_record? ? form_file.build_i18n_variable : form_file.i18n_variable ) do |f| %> <% else %>
<%= f.fields_for :file_title_translations do |f| %> <%= f.hidden_field :id %>
<div class="control-group"> <a class="remove_existing_record icon-remove"></a>
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.from_locale(locale) %></label> <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
<div class="controls"> <% end %>
<%= f.text_field locale, :class=>'post-file_title', :value => (form_file.file_title_translations[locale] rescue nil) %> </span>
</div> </div>
</div> </div>
<% end %>
</div>
<% end %>
</div>
</td>
<td>
<% @site_valid_locales.each do |locale| %>
<%= check_box_tag "archive_file[archive_file_multiples_attributes][#{( form_file.new_record? ? 'new_archive_file_multiples' : "#{i}" )}][choose_lang][]", locale, (form_file.choose_lang.nil? ? true : form_file.choose_lang.include?(locale)) %>
<%= I18nVariable.from_locale(locale) %>
<% end %>
<%= hidden_field_tag 'archive_file[archive_file_multiples_attributes][0][choose_lang][]', '' %>
</td>
<td>
<span class="action">
<% if form_file.new_record? %>
<a class="delete"><i class="icon-remove"></i></a>
<% else %>
<%= f.hidden_field :id %>
<a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
</span>
</td>
</tr>

View File

@ -1,5 +1,5 @@
<h1><%= t('archive.editing_archive') %></h1> <%= form_for @archive_file, url: panel_archive_back_end_archive_file_path(@archive_file), html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= form_for @archive_file, :url => panel_archive_back_end_archive_file_path(@archive_file), :html => {:class => 'clear'} do |f| %> <%= render partial: 'form', locals: {f: f} %>
<%= render :partial => 'form', :locals => {:f => f} %> </fieldset>
<% end %> <% end %>

View File

@ -1,24 +1,48 @@
<%= render 'filter' %> <% set_default_index do
objects @archive_files
filterable
sortable
quick_edit_link type: 'edit',
link: 'edit_panel_archive_back_end_archive_file_path'
quick_edit_link type: 'detail'
quick_edit_link type: 'delete',
link: 'panel_archive_back_end_archive_file_path'
field type: 'status',
db_field: @statuses,
translation: 'status',
hide: 'phone',
sort: 'status',
header_class: 'span2'
field type: 'associated',
associated_value: 'title',
db_field: 'category',
translation: 'category',
hide: 'phone',
sort: 'category',
header_class: 'span2'
field type: 'field',
db_field: 'title',
translation: 'title',
sort: 'title',
link: 'panel_archive_front_end_archive_file_path',
quick_edit: true
field type: 'tags',
db_field: 'tags',
translation: 'tags',
hide: 'all',
sort: 'tags'
filter_field type: 'array',
values: @statuses,
translation: 'status'
filter_field type: 'objects',
values: @categories,
translation: 'category',
object_field: 'title'
filter_field type: 'objects',
values: @tags,
translation: 'tags',
object_field: 'name'
footer link: 'new_panel_archive_back_end_archive_file_path'
end %>
<table class="table main-list"> <%= render 'admin/default_index/index' %>
<thead>
<tr>
<th class="span1"></th>
<th class="span1"></th>
<th class="span1"></th>
<th class="span2"></th>
<th class="span3"></th>
<th class="span2"></th>
</tr>
</thead>
<tbody id="tbody_archive">
<%= render :partial => 'archive_file', :collection => @archive_files %>
</tbody>
</table>
<div class="form-actions form-fixed pagination-right">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:add), new_panel_archive_back_end_archive_file_path, :class => 'btn btn-primary pull-right' if (is_manager? rescue nil) %>
<div id="archive_file_pagination" class="paginationFixed">
<%= paginate @archive_files, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>
</div>
</div>

View File

@ -1,9 +1,5 @@
<%= form_for @archive_file, url: panel_archive_back_end_archive_files_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<%= flash_messages %> <fieldset>
<h1><%= t('archive_file.new_archive') %></h1> <%= render partial: 'form', locals: {f: f} %>
<%= form_for @archive_file, :url => panel_archive_back_end_archive_files_path, :html => {:class => 'clear'} do |f| %> </fieldset>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %> <% end %>
<%#= link_back %>

View File

@ -1,5 +1,6 @@
<% # encoding: utf-8 %> <% # encoding: utf-8 %>
<% if @frontend_style == '1' %>
<div class="o-archives layout-table"> <div class="o-archives layout-table">
@ -15,15 +16,19 @@
<% @archive_files.each_with_index do |post,i| %> <% @archive_files.each_with_index do |post,i| %>
<tr <% if ( (i + 1) % 2 ) == 0 %> class="even" <% end %>> <tr <% if ( (i + 1) % 2 ) == 0 %> class="even" <% end %>>
<td><div class="o-archives-title"><%= post.title %></div></td> <td>
<div class="o-archives-title"><%= post.title %>
<% if !post.is_hot.blank? %><span class="o-archives-hot"><%= t('hot')%></span><% end %>
</div>
</td>
<td> <td>
<div class="o-archives-list-item"> <div class="o-archives-list-item">
<% if !post.archive_file_multiples.blank? %> <% if !post.archive_file_multiples.blank? %>
<ol> <ol>
<% post.archive_file_multiples.asc(:_id).each do | afile | %> <% post.archive_file_multiples.asc(:sort_number).each do | afile | %>
<% if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %> <% if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %>
<li> <li>
<%= link_to afile.file_title, afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} %> <%= link_to (!afile.file_title.blank? ? afile.file_title : t('archive.download') ), afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} if afile.file.file %>
<%= post.get_file_icon(afile.file.url) %> <%= post.get_file_icon(afile.file.url) %>
</li> </li>
<% end %> <% end %>
@ -33,7 +38,7 @@
</div> </div>
</td> </td>
<td><div class="o-archives-category"> <td><div class="o-archives-category">
<%= post.archive_file_category.title %> <%= post.category.title if !post.category.blank? %>
</div></td> </div></td>
</tr> </tr>
<% end %> <% end %>
@ -42,7 +47,44 @@
</table> </table>
</div> </div>
<%= paginate @archive_files, :param_name => :page_main, :params => {:inner => 'false'} %> <%= paginate @archive_files, :param_name => :page_main, :params => {:inner => 'false'} %>
<% elsif @frontend_style == '2' %>
<div class="o-archives">
<div class="o-archives-content">
<% @archive_file_datas.each do |afcpost| %>
<div class="o-archives-group">
<h2 class="o-archives-category h2"><%= afcpost["title"] %></h2>
<div class="o-archives-content">
<div class="o-archives-list">
<ul>
<% afcpost["archive_files"].each do |post| %>
<li>
<h3 class="o-archives-title h3">
<%= post["title"] %>
<% if !post["is_hot"].blank? %><span class="o-archives-hot"><%= t('hot')%></span><% end %>
</h3>
<div class="o-archives-list-item">
<ol>
<% post["archive_file_multiples"].each do | afile | %>
<li>
<%= link_to afile["file_title"], afile["url"], {:target => '_blank', :title => afile["file_title"], :class => "o-archives-file"} %>
<%= afile["icon"] %>
</li>
<% end %>
</ol>
</div>
</li>
<% end %>
</ul>
</div>
</div>
<% end %>
</div>
</div>
<% end %>
<%= stylesheet_link_tag "archive/archives" %> <%= stylesheet_link_tag "archive/archives" %>

View File

@ -13,7 +13,7 @@
<% @archive_file.archive_file_multiples.each do | afile | %> <% @archive_file.archive_file_multiples.each do | afile | %>
<% if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %> <% if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %>
<li> <li>
<%= link_to afile.file_title, afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} %> <%= link_to (!afile.file_title.blank? ? afile.file_title : t('download_') ), afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} if afile.file.file %>
<%= @archive_file.get_file_icon(afile.file.url) %> <%= @archive_file.get_file_icon(afile.file.url) %>
</li> </li>
<% end %> <% end %>

View File

@ -16,7 +16,11 @@
<tbody> <tbody>
<% @archive_files.each_with_index do |post,i| %> <% @archive_files.each_with_index do |post,i| %>
<tr <% if ( (i + 1) % 2 ) == 0 %> class="even" <% end %>> <tr <% if ( (i + 1) % 2 ) == 0 %> class="even" <% end %>>
<td><div class="o-archives-title"><%= post.title %></div></td> <td>
<div class="o-archives-title"><%= post.title %>
<% if !post.is_hot.blank? %><span class="o-archives-hot"><%= t('hot')%></span><% end %>
</div>
</td>
<td> <td>
<div class="o-archives-list-item"> <div class="o-archives-list-item">
<% if !post.archive_file_multiples.blank? %> <% if !post.archive_file_multiples.blank? %>
@ -24,7 +28,7 @@
<% post.archive_file_multiples.asc(:_id).each do | afile | %> <% post.archive_file_multiples.asc(:_id).each do | afile | %>
<% if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %> <% if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %>
<li> <li>
<%= link_to afile.file_title, afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} %> <%= link_to (!afile.file_title.blank? ? afile.file_title : t('archive.download') ), afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} if afile.file.file %>
<%= post.get_file_icon(afile.file.url) %> <%= post.get_file_icon(afile.file.url) %>
</li> </li>
<% end %> <% end %>
@ -34,7 +38,7 @@
</div> </div>
</td> </td>
<td><div class="o-archives-category"> <td><div class="o-archives-category">
<%= post.archive_file_category.title %> <%= post.category.title if !post.category.blank? %>
</div></td> </div></td>
</tr> </tr>
<% end %> <% end %>
@ -42,57 +46,50 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="pull_right">
<% if !params[:category_id].blank? %>
<%= link_to t(:more_plus), panel_archive_front_end_archive_files_path(:category_id => @part.category) %>
<% else %>
<%= link_to t(:more_plus), panel_archive_front_end_archive_files_path %>
<% end %>
</div>
<% elsif @widget_style == '2' %> <% elsif @widget_style == '2' %>
<div class="o-archives"> <div class="o-archives">
<div class="o-archives-content"> <div class="o-archives-content">
<% @archive_file_categorys.each do |afcpost| %> <% @archive_file_datas.each do |afcpost| %>
<div class="o-archives-group"> <div class="o-archives-group">
<% if @category_id.blank? %> <h2 class="o-archives-category h2"><%= afcpost["title"] %></h2>
<h2 class="o-archives-category h2"><%= afcpost.title %></h2>
<% end %>
<div class="o-archives-content"> <div class="o-archives-content">
<div class="o-archives-list"> <div class="o-archives-list">
<ul> <ul>
<% afcpost["archive_files"].each do |post| %>
<% afcpost.archive_files.can_display.desc( :is_top ).each do |post| %>
<li> <li>
<h3 class="o-archives-title h3"><%= post.title %></h3> <h3 class="o-archives-title h3">
<%= post["title"] %>
<% if !post["is_hot"].blank? %><span class="o-archives-hot"><%= t('hot')%></span><% end %>
</h3>
<div class="o-archives-list-item"> <div class="o-archives-list-item">
<% if !post.archive_file_multiples.blank? %>
<ol> <ol>
<% post.archive_file_multiples.asc(:_id).each do | afile | %> <% post["archive_file_multiples"].each do | afile | %>
<% if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %>
<li> <li>
<%= link_to afile.file_title, afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} %> <%= link_to afile["file_title"], afile["url"], {:target => '_blank', :title => afile["file_title"], :class => "o-archives-file"} %>
<%= post.get_file_icon(afile.file.url) %> <%= afile["icon"] %>
</li> </li>
<% end %>
<% end %> <% end %>
</ol> </ol>
<% end %>
</div> </div>
</li> </li>
<% end %> <% end %>
</ul> </ul>
</div> </div>
</div> </div>
<% end %> <% end %>
</div> </div>
</div> </div>
<% end %> <% end %>
<div class="pull_right">
<% if !params[:category_id].blank? %>
<%= link_to t(:more_plus), panel_archive_front_end_archive_files_path(:category_id => @part.category) %>
<% else %>
<%= link_to t(:more_plus), panel_archive_front_end_archive_files_path %>
<% end %>
</div>

View File

@ -1,6 +1,8 @@
en: en:
archive: archive:
show_lang: Language
download: Download
archive: Archive archive: Archive
Title: Title Title: Title
Files: Files Files: Files

View File

@ -1,6 +1,8 @@
zh_tw: zh_tw:
archive: archive:
show_lang: 呈現語系
download: 檔案下載
archive: 檔案室 archive: 檔案室
Title: 標題 Title: 標題
Files: 檔案 Files: 檔案

View File

@ -12,14 +12,16 @@ module Archive
update_info 'some update_info' update_info 'some update_info'
front_end do front_end do
app_page 'archive_files' do app_page 'archive_files' do
frontend_i18n "archive.frontend.archive" frontend_i18n "archive.frontend.archive"
style ["1","2"]
end end
end end
category ["ArchiveFileCategory"] # category ["ArchiveFileCategory"]
authorizable authorizable
categorizable
taggable taggable
widgets do widgets do
@ -35,7 +37,7 @@ module Archive
customize_widget "index" do customize_widget "index" do
widget_i18n "archive.widget.index" widget_i18n "archive.widget.index"
style ["1"] style ["1","2"]
end end
customize_widget "archive_search_block" do customize_widget "archive_search_block" do
@ -50,7 +52,8 @@ module Archive
side_bar do side_bar do
head_label_i18n 'archive.archive',:icon_class=>"icons-archive" head_label_i18n 'archive.archive',:icon_class=>"icons-archive"
available_for [:admin,:guest,:manager,:sub_manager] available_for [:admin,:guest,:manager,:sub_manager]
active_for_controllers ({:private=>['archive_file_categorys','archive_files'],:public=>['panel/archive/back_end/tags']}) # active_for_controllers ({:private=>['archive_file_categorys','archive_files'],:public=>['panel/archive/back_end/tags']})
active_for_controllers ({:private=>['archive_file_categorys','archive_files','module_tags', 'categories']})
active_for_object_auth ['ArchiveFileCategory'] active_for_object_auth ['ArchiveFileCategory']
head_link_path "panel_archive_back_end_archive_files_path" head_link_path "panel_archive_back_end_archive_files_path"
@ -66,19 +69,15 @@ module Archive
:active_for_action=>{:archive_files=>:new}, :active_for_action=>{:archive_files=>:new},
:available_for => [:sub_manager] :available_for => [:sub_manager]
context_link 'categories', context_link 'categories',
:link_path=>"panel_archive_back_end_archive_file_categorys_path" , :link_path=>"admin_module_app_categories_path(get_module_app)" ,
:priority=>3, :priority=>3,
:active_for_action=>{:archive_file_categorys=>:index}, :active_for_category => 'Archive',
:available_for => [:manager] :available_for => [:manager]
context_link 'tags', context_link 'tags',
:link_path=>"admin_module_tags_path(module_app_id: get_module_app)" , :link_path=>"admin_module_tags_path(module_app_id: get_module_app)" ,
:priority=>4, :priority=>4,
:active_for_tag => 'Archive', :active_for_tag => 'Archive',
:available_for => [:manager] :available_for => [:manager]
context_link 'module_authorization',
:link_path=>"admin_authorizations_path(get_module_app.key)",
:priority=>5,
:available_for => [:manager]
end end
end end

View File

@ -1,69 +1,90 @@
/* General style with default layout */ /* General style with default layout */
.o-links {} .o-links {}
.o-links-group { .o-links .o-links-group {
margin: 20px 0 0 0; margin: 20px 0 0 0;
padding: 20px 0 0 0; padding: 20px 0 0 0;
border-top: dashed 1px #EEE; border-top: dashed 1px #EEE;
} }
.o-links-group:first-child { .o-links .o-links-group:first-child {
margin: 0; margin: 0;
padding: 0; padding: 0;
border: 0; border: 0;
} }
.o-links-category { .o-links .o-links-category {
padding-bottom: 16px; padding-bottom: 16px;
border-bottom: solid 2px #CCC; border-bottom: solid 2px #CCC;
font-weight: bold; font-weight: bold;
font-size: 1.2em;
} }
.o-links-content {} .o-links .o-links-content {}
.o-links-content > ul { .o-links .o-links-content > ul {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
} }
.o-links-content > ul > li {} .o-links .o-links-content > ul > li {
.o-links-list {} margin-bottom: 30px;
.o-links-list > ul {} }
.o-links-list > ul > li { .o-links .o-links-list {}
.o-links .o-links-list > ul {}
.o-links .o-links-list > ul > li {
padding: 10px 0 0 0; padding: 10px 0 0 0;
margin: 10px 0 0 0; margin: 10px 0 0 0;
border-top: solid 1px #eee; border-top: solid 1px #eee;
} }
.o-links-list > ul > li:first-child { .o-links .o-links-list > ul > li:first-child {
padding: 0; padding: 0;
margin: 0; margin: 0;
border: 0; border: 0;
} }
.o-links-title {} .o-links .o-links-title {}
.o-links-link { .o-links .o-links-link {
font-weight: bold; font-weight: bold;
} }
.o-links-link:hover {} .o-links .o-links-link:hover {}
.o-links-description {} .o-links .o-links-description {
margin: 12px 0;
font-size: 0.85em;
line-height: 1.5em;
}
.o-links .o-links-hot {
background-color: #D83131;
border-radius: 3px;
color: #FFFFFF;
display: inline-block;
font-size: 11px;
font-weight: normal;
line-height: 20px;
margin: 0 0 0 8px;
padding: 0 4px;
vertical-align: top;
}
/* Tag list */ /* Tag list */
.o-links-tag-list { .o-links .o-links-tag-list {
margin: 0 0 16px 0; margin: 0 0 16px 0;
} }
.o-links-tag-list ul { .o-links .o-links-tag-list ul {
margin: 0 -4px; margin: 0 -4px;
padding: 0; padding: 0;
list-style: none; list-style: none;
} }
.o-links-tag-list ul:after { .o-links .o-links-tag-list ul:after {
content: "."; content: ".";
clear: both; clear: both;
display: block; display: block;
height: 0; height: 0;
visibility: hidden; visibility: hidden;
} }
.o-links-tag-list li { .o-links .o-links-tag-list li {
float: left; float: left;
margin: 0 4px 8px 4px; margin: 0 4px 8px 4px;
} }
.o-links-tag { .o-links .o-links-tag {
display: block; display: block;
border: solid 1px #ccc; border: solid 1px #ccc;
padding: 2px 6px; padding: 4px;
font-size: 0.85em;
} }
.o-links-tag:hover {} .o-links .o-links-tag:hover {}

View File

@ -1,50 +1,68 @@
class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable # include OrbitControllerLib::DivisionForDisable
# before_filter :for_app_manager,:except => [:index,:show] # before_filter :for_app_manager,:except => [:index,:show]
before_filter :force_order_for_visitor,:only=>[:index] before_filter :force_order_for_visitor,:only=>[:index]
before_filter :force_order_for_user,:except => [:index] before_filter :force_order_for_user,:except => [:index]
before_filter :for_app_sub_manager,:except => [:index] before_filter :for_app_sub_manager,:except => [:index]
before_filter :only => [ :new,:edit,:update,:create] do |controller| # before_filter :only => [ :new,:edit,:update,:create] do |controller|
controller.get_categorys('WebLinkCategory') # controller.get_categorys('WebLinkCategory')
# end
before_filter :only => [ :new, :create, :edit, :update ] do |controller|
@categories = get_categories_for_form
end end
def index def index
@tags = get_tags
@categories = get_categories_for_index
@statuses = get_statuses
category_ids = @categories.collect{|t| t.id}
get_categorys("WebLinkCategory",params[:web_link_category_id]) @web_links = get_sorted_and_filtered("web_link", :category_id.in => category_ids)
@filter = params[:filter]
new_filter = params[:new_filter]
if @filter && params[:clear]
@filter.delete(params[:type])
elsif @filter && new_filter
if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s)
@filter[new_filter[:type]].delete(new_filter[:id].to_s)
elsif @filter.has_key?(new_filter[:type])
@filter[new_filter[:type]] << new_filter[:id].to_s
else
@filter.merge!({new_filter[:type] => [new_filter[:id].to_s]})
end
elsif new_filter
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
end
@web_link_categories = get_categories_for_index("WebLinkCategory")
@web_link_category_ids = @web_link_categories.collect{|t| t.id.to_s} + [nil]
# @web_links = WebLink.search(params[:category_id])
#@web_links = (params[:sort] || @filter) ? get_sorted_and_filtered_web_links : WebLink.all.page(params[:page]).per(10)
@web_links = (params[:sort] || @filter) ? get_sorted_and_filtered("web_link",:web_link_category_id.in => @web_link_category_ids) : get_viewable("web_link",:web_link_category_id.in => @web_link_category_ids)
@tags = get_tags
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
format.js { }
format.xml { render :xml => @web_links } format.xml { render :xml => @web_links }
format.js
end end
end end
# def index
# get_categorys("WebLinkCategory",params[:web_link_category_id])
# @filter = params[:filter]
# new_filter = params[:new_filter]
# if @filter && params[:clear]
# @filter.delete(params[:type])
# elsif @filter && new_filter
# if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s)
# @filter[new_filter[:type]].delete(new_filter[:id].to_s)
# elsif @filter.has_key?(new_filter[:type])
# @filter[new_filter[:type]] << new_filter[:id].to_s
# else
# @filter.merge!({new_filter[:type] => [new_filter[:id].to_s]})
# end
# elsif new_filter
# @filter = {new_filter[:type] => [new_filter[:id].to_s]}
# end
# @web_link_categories = get_categories_for_index("WebLinkCategory")
# @web_link_category_ids = @web_link_categories.collect{|t| t.id.to_s} + [nil]
# # @web_links = WebLink.search(params[:category_id])
# #@web_links = (params[:sort] || @filter) ? get_sorted_and_filtered_web_links : WebLink.all.page(params[:page]).per(10)
# @web_links = (params[:sort] || @filter) ? get_sorted_and_filtered("web_link",:web_link_category_id.in => @web_link_category_ids) : get_viewable("web_link",:web_link_category_id.in => @web_link_category_ids)
# @tags = get_tags
# respond_to do |format|
# format.html # index.html.erb
# format.xml { render :xml => @web_links }
# format.js
# end
# end
# GET /web_links/1 # GET /web_links/1
# GET /web_links/1.xml # GET /web_links/1.xml
def show def show
@ -58,7 +76,13 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
# GET /web_links/new # GET /web_links/new
# GET /web_links/new.xml # GET /web_links/new.xml
def new def new
@web_link = WebLink.new if(session[:in_validate_object].blank?)
@web_link = WebLink.new
else
@web_link = session[:in_validate_object]
session[:in_validate_object] = {}
end
@tags = get_tags @tags = get_tags
respond_to do |format| respond_to do |format|
@ -70,7 +94,11 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
# GET /web_links/1/edit # GET /web_links/1/edit
def edit def edit
@web_link = WebLink.find(params[:id]) @web_link = WebLink.find(params[:id])
@tags = get_tags if !current_user.admin?
redirect_to :action => :index
else
@tags = get_tags
end
end end
# POST /web_links # POST /web_links

View File

@ -17,24 +17,45 @@ class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController
if @item.frontend_data_count if @item.frontend_data_count
@page_num = @item.frontend_data_count @page_num = @item.frontend_data_count
else else
@page_num = 0 @page_num = 4
end end
date_now = Time.now date_now = Time.now
@archive_file_categorys = WebLinkCategory.all # @web_link_categorys = get_categories_for_index
if !params[:category_id].blank? if !params[:category_id].blank?
@web_links = WebLink.all.can_display.any_in(:web_link_category_id => params[:category_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) @web_link_categorys = @module_app.categories.enabled.any_in(:_id => params[:category_id])
@web_link_categorys = WebLinkCategory.any_in(:_id => params[:category_id]).excludes('disable' => true)
elsif !params[:tag_id].blank?
@web_links = WebLink.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
get_categorys
else else
@web_links = WebLink.all.can_display.merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) @web_link_categorys = @module_app.categories.enabled
end
@web_link_datas = Array.new
@web_link_categorys.each do |wlcg|
if !params[:category_id].blank? && !params[:tag_id].blank?
@web_links = WebLink.all.can_display.where(:category_id.in => [wlcg.id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at )
elsif !params[:category_id].blank?
@web_links = WebLink.all.can_display.where(:category_id.in => [wlcg.id]).desc( :is_top, :created_at )
elsif !params[:tag_id].blank?
@web_links = WebLink.all.can_display.where(:category_id => wlcg.id, :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at )
else
@web_links = WebLink.all.can_display.where(:category_id => wlcg.id).desc( :is_top, :created_at )
end
web_link_datas = Array.new
@web_links.each do |wl|
web_link_datas << {
"title" => wl.title,
"is_hot" => (!wl.is_hot.blank? ? '1' : ''),
"context" => wl.context,
"url" => wl.url
} if !wl.blank?
end
@web_link_datas << { "title" => wlcg.title, "web_links" => web_link_datas } if !@web_links.blank?
get_categorys
end end
end end

View File

@ -1,4 +1,5 @@
class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
def initialize def initialize
super super
@app_title = 'web_resource' @app_title = 'web_resource'
@ -30,14 +31,38 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
date_now = Time.now date_now = Time.now
if !params[:category_id].blank? if !params[:category_id].blank?
@web_links = WebLink.all.can_display.any_in(:web_link_category_id => params[:category_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) @web_link_categorys = @module_app.categories.enabled.any_in(:_id => params[:category_id])
@web_link_categorys = WebLinkCategory.any_in(:_id => params[:category_id]).excludes('disable' => true)
elsif !params[:tag_id].blank?
@web_links = WebLink.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
get_categorys
else else
@web_links = WebLink.all.can_display.merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) @web_link_categorys = @module_app.categories.enabled
get_categorys end
@web_link_datas = Array.new
@web_link_categorys.each do |wlcg|
if !params[:category_id].blank? && !params[:tag_id].blank?
@web_links = WebLink.all.can_display.where(:category_id.in => [wlcg.id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
elsif !params[:category_id].blank?
@web_links = WebLink.all.can_display.where(:category_id.in => [wlcg.id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
elsif !params[:tag_id].blank?
@web_links = WebLink.all.can_display.where(:category_id => wlcg.id, :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
else
@web_links = WebLink.all.can_display.where(:category_id => wlcg.id).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
end
web_link_datas = Array.new
@web_links.each do |wl|
web_link_datas << {
"title" => wl.title,
"is_hot" => (!wl.is_hot.blank? ? '1' : ''),
"context" => wl.context,
"url" => wl.url
} if !wl.blank?
end
@web_link_datas << { "title" => wlcg.title, "web_links" => web_link_datas } if !@web_links.blank?
end end
end end

View File

@ -1,12 +1,14 @@
# encoding: utf-8 # encoding: utf-8
class WebLink class WebLink
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes include Mongoid::MultiParameterAttributes
include Sunspot::Mongo
include OrbitCategory::Categorizable
include OrbitModel::LanguageRestrict include OrbitModel::LanguageRestrict
include OrbitModel::Status include OrbitModel::Status
include OrbitModel::TimeFrame
include OrbitTag::Taggable include OrbitTag::Taggable
field :title, localize: true field :title, localize: true
@ -14,9 +16,9 @@ class WebLink
field :url, localize: true field :url, localize: true
field :create_user_id field :create_user_id
field :update_user_id field :update_user_id, :class_name => "User"
belongs_to :web_link_category # belongs_to :web_link_category
before_save :clean_tags before_save :clean_tags

View File

@ -1,112 +1,152 @@
<div id= "poststuff">
<% # encoding: utf-8 %> <% # encoding: utf-8 %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<% end %>
<%= f.error_messages %> <%= f.error_messages %>
<!--Widget start--> <!-- Input Area -->
<div class="input-area">
<div id="sub-wiget"> <!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<% if show_form_status_field(@web_link) %>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
<% end %>
<li>
<a href="#tag" data-toggle="tab"><%= t(:tags) %></a>
</li>
</ul>
<div id="widget-status" class="widget-box widget-size-300"> <!-- Module -->
<div class="widget-action clear tip" title="Setting the announcement state"> <div class="tab-content module-area">
<a class="action"><i class="icon-exclamation-sign icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-star"></i><%= t(:status) %></h3>
<div class="widget-content clear">
<div class="controls">
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_top %>
<%= t('top') %>
<% end -%>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_hot %>
<%= t('hot') %>
<% end -%>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_hidden %>
<%= t('hide') %>
<% end -%>
</div>
</div>
</div>
<div id="widget-tags" class="widget-box widget-size-300"> <!-- Basic Module -->
<div class="widget-action clear tip" title="Setting"> <div class="tab-pane fade in active" id="basic">
<a class="action"><i class="icon-cog icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-tag"></i><%= t('nccu.tags') %></h3>
<div class="widget-content clear form-horizontal">
<% @tags.each do |tag| %>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'web_link[tag_ids][]', tag.id, @web_link.tag_ids.include?(tag.id)%>
<%= tag.name %>
<%= hidden_field_tag 'web_link[tag_ids][]', '' %>
<% end %>
<% end %>
</div>
</div>
</div> <!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %>
</div>
</div>
</div>
<!-- Status Module -->
<% if show_form_status_field(@web_link) %>
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @web_link.is_top? %>">
<%= f.check_box :is_top %> <%= t(:top) %>
</label>
<label class="checkbox inline btn <%= 'active' if @web_link.is_hot? %>">
<%= f.check_box :is_hot %> <%= t(:hot) %>
</label>
<label class="checkbox inline btn <%= 'active' if @web_link.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
<% end %>
<!-- Tag Module -->
<div class="tab-pane fade" id="tag">
<!-- Tag -->
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<% @tags.each do |tag| %>
<label class="checkbox inline btn <%= 'active' if @web_link.tag_ids.include?(tag.id) %>">
<%= check_box_tag 'web_link[tag_ids][]', tag.id, @web_link.tag_ids.include?(tag.id) %> <%= tag.name %>
<%= hidden_field_tag 'web_link[tag_ids][]', '' %>
</label>
<% end %>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_valid_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:title) %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@web_link.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- Context-->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:description) %></label>
<div class="controls">
<%= f.fields_for :context_translations do |f| %>
<%= f.text_area locale, rows: 5, class: "input-block-level", value: (@web_link.context_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- Url-->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:url) %></label>
<div class="controls">
<%= f.fields_for :url_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t(:url), value: (@web_link.url_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
<!--Wiget End--> </div>
<!--Post Start-->
<div id="post-body"> </div>
<div id="post-body-content" class="clear">
<!-- Form Actions -->
<%= f.label :category ,t(:category)%> <div class="form-actions">
<%= f.select :web_link_category_id, @web_link_categorys.collect {|t| [ t.title, t.id ]} %> <%= hidden_field_tag 'page', params[:page] if !params[:page].blank? %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<ul class="nav nav-tabs"> <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
<% @site_valid_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<div class="tab-content">
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title">
<%= f.label :name , t('nccu.link_name') %>
<%= f.fields_for :title_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@web_link.title_translations[locale] rescue nil) %>
<% end %>
</div>
<div class="title">
<%= f.label :describe, t(:description) %>
<%= f.fields_for :context_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :value => (@web_link.context_translations[locale] rescue nil) %>
<% end %>
</div>
<div class="title">
<%= f.label :url , t(:url) %>
<%= f.fields_for :url_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@web_link.url_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<% end %>
</div>
</div>
<!--Post End-->
</div>
<div class="form-actions">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
</div> </div>

View File

@ -1,5 +1,5 @@
<h1><%= t('web_link.editing_web_resource') %></h1> <%= form_for @web_link, url: panel_web_resource_back_end_web_link_path(@web_link), html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= form_for @web_link, :url => panel_web_resource_back_end_web_link_path(@web_link), :html => {:class => 'clear'} do |f| %> <%= render partial: 'form', locals: {f: f} %>
<%= render :partial => 'form', :locals => {:f => f} %> </fieldset>
<% end %> <% end %>

View File

@ -1,22 +1,49 @@
<%= render 'filter' %> <% set_default_index do
<table class="table main-list"> objects @web_links
<thead> filterable
<tr> sortable
<th class="span1"></th> quick_edit_link type: 'edit',
<th class="span1"></th> link: 'edit_panel_web_resource_back_end_web_link_path'
<th class="span2"></th> quick_edit_link type: 'detail'
<th class="span3"></th> quick_edit_link type: 'delete',
<th class="span2"></th> link: 'panel_web_resource_back_end_web_link_path'
</tr> field type: 'status',
</thead> db_field: @statuses,
<tbody id="tbody_web_links" class="sort-holder"> translation: 'status',
<%= render :partial => 'web_link', :collection => @web_links %> hide: 'phone',
</tbody> sort: 'status',
</table> header_class: 'span2'
field type: 'associated',
associated_value: 'title',
db_field: 'category',
translation: 'category',
hide: 'phone',
sort: 'category',
header_class: 'span2'
field type: 'field',
db_field: 'title',
translation: 'title',
sort: 'title',
link: 'panel_web_resource_front_end_web_link_path',
quick_edit: true,
header_class: 'span5'
field type: 'tags',
db_field: 'tags',
translation: 'tags',
hide: 'all',
sort: 'tags'
filter_field type: 'array',
values: @statuses,
translation: 'status'
filter_field type: 'objects',
values: @categories,
translation: 'category',
object_field: 'title'
filter_field type: 'objects',
values: @tags,
translation: 'tags',
object_field: 'name'
footer link: 'new_panel_web_resource_back_end_web_link_path'
end %>
<div class="form-actions form-fixed pagination-right"> <%= render 'admin/default_index/index' %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:add), new_panel_web_resource_back_end_web_link_path, :class => 'btn btn-primary pull-right' if (is_manager? rescue nil) %>
<div id="web_link_pagination" class="paginationFixed">
<%= paginate @web_links, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>
</div>
</div>

View File

@ -1,10 +1,5 @@
<%= form_for @web_link, url: panel_web_resource_back_end_web_links_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<%= flash_messages %> <fieldset>
<div id="poststuff"> <%= render partial: 'form', locals: {f: f} %>
<h1><%= t('web_link.new_web_resource') %></h1> </fieldset>
<%= form_for @web_link, :url => panel_web_resource_back_end_web_links_path, :html => {:class => 'clear'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %> <% end %>
</div>
<%#= link_back %>

View File

@ -4,17 +4,18 @@
<div class="o-links-content"> <div class="o-links-content">
<ul> <ul>
<% @web_link_categorys.each do |wlcg| %> <% @web_link_datas.each do |wlcg| %>
<% if wlcg.web_links.count > 0 %>
<li> <li>
<h3 class="o-links-category"><%= wlcg.title rescue nil%></h3> <h3 class="o-links-category"><%= wlcg["title"] rescue nil%></h3>
<div class="o-links-list"> <div class="o-links-list">
<ul> <ul>
<% wlcg.web_links.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num).each do |post| %> <% wlcg["web_links"].each do |post| %>
<li> <li>
<%= link_to post.title, post.url, {:target => '_blank', :title => post.title, :class=>"o-links-title"} %> <%= link_to post["title"], post["url"], {:target => '_blank', :title => post["title"], :class=>"o-links-title"} %>
<div class="o-links-description"><%= post.context %></div> <% if !post["is_hot"].blank? %><span class="o-links-hot"><%= t('hot')%></span><% end %>
<div class="o-links-description"><%= post["context"] %></div>
</li> </li>
<% end %> <% end %>
@ -23,12 +24,11 @@
</li> </li>
<% end %> <% end %>
<% end %>
</ul> </ul>
</div> </div>
</div> </div>
<%= paginate @web_links, :param_name => :page_main, :params => {:inner => false}%> <%#= paginate @web_links, :param_name => :page_main, :params => {:inner => false}%>
<%= stylesheet_link_tag "web_resource/links" %> <%= stylesheet_link_tag "web_resource/links" %>

View File

@ -2,17 +2,18 @@
<div class="o-links-content"> <div class="o-links-content">
<ul> <ul>
<% @web_link_categorys.each do |wlcg| %> <% @web_link_datas.each do |wlcg| %>
<% if wlcg.web_links.count > 0 %>
<li> <li>
<h3 class="o-links-category"><%= wlcg.title rescue nil%></h3> <h3 class="o-links-category"><%= wlcg["title"] rescue nil%></h3>
<div class="o-links-list"> <div class="o-links-list">
<ul> <ul>
<% wlcg.web_links.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num).each do |post| %> <% wlcg["web_links"].each do |post| %>
<li> <li>
<%= link_to post.title, post.url, {:target => '_blank', :title => post.title, :class=>"o-links-title"} %> <%= link_to post["title"], post["url"], {:target => '_blank', :title => post["title"], :class=>"o-links-title"} %>
<div class="o-links-description"><%= post.context %></div> <% if !post["is_hot"].blank? %><span class="o-links-hot"><%= t('hot')%></span><% end %>
<div class="o-links-description"><%= post["context"] %></div>
</li> </li>
<% end %> <% end %>
@ -21,7 +22,6 @@
</li> </li>
<% end %> <% end %>
<% end %>
</ul> </ul>
</div> </div>

View File

@ -16,9 +16,8 @@ module WebResource
end end
end end
taggable
authorizable authorizable
categorizable
taggable taggable
widgets do widgets do
@ -38,7 +37,7 @@ module WebResource
side_bar do side_bar do
head_label_i18n 'link',:icon_class=>"icons-link" head_label_i18n 'link',:icon_class=>"icons-link"
available_for [:admin,:guest,:manager,:sub_manager] available_for [:admin,:guest,:manager,:sub_manager]
active_for_controllers ({:private=>['web_links', 'web_link_categorys']}) active_for_controllers ({:private=>['web_links', 'web_link_categorys','module_tags', 'categories']})
active_for_object_auth ['WebLinkCategory'] active_for_object_auth ['WebLinkCategory']
head_link_path "panel_web_resource_back_end_web_links_path" head_link_path "panel_web_resource_back_end_web_links_path"
@ -54,11 +53,10 @@ module WebResource
:priority=>2, :priority=>2,
:active_for_action=>{:web_links=>:new}, :active_for_action=>{:web_links=>:new},
:available_for => [:sub_manager] :available_for => [:sub_manager]
context_link 'categories', context_link 'categories',
:link_path=>"panel_web_resource_back_end_web_link_categorys_path" , :link_path=>"admin_module_app_categories_path(get_module_app)" ,
:priority=>3, :priority=>3,
:active_for_action=>{:web_link_categorys=>:index}, :active_for_category => 'WebResource',
:available_for => [:manager] :available_for => [:manager]
context_link 'tags', context_link 'tags',
@ -66,12 +64,6 @@ module WebResource
:priority=>4, :priority=>4,
:active_for_tag => 'WebResource', :active_for_tag => 'WebResource',
:available_for => [:manager] :available_for => [:manager]
context_link 'module_authorization',
:link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'WebResource'}))",
:priority=>6,
:active_for_app_auth => 'web_resource',
:available_for => [:admin]
end end
end end
end end