Fix widget index

This commit is contained in:
Bernie Chiu 2013-12-11 17:14:11 +08:00 committed by saurabhbhatia
parent a82022c958
commit f13c21c1b4
4 changed files with 50 additions and 32 deletions

View File

@ -9,26 +9,29 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
def index
@part = PagePart.find(params[:part_id])
if @part.widget_data_count
@page_num = @part.widget_data_count
else
@page_num = 4
end
if @part.widget_field
@widget_fields = @part.widget_field
else
@widget_fields = []
end
@title = @part.title_translations[I18n.locale.to_s]
@part = PagePart.find(params[:part_id])
if @part.widget_data_count
@page_num = @part.widget_data_count
else
@page_num = 4
end
num_of_fields = @part.widget_field_name.reject(&:empty?).length
widget_field_names = @part.widget_field_name.reject(&:empty?)
widget_classes = @part.widget_class.reject(&:empty?)
@widget_fields = []
if @part.widget_field_name
num_of_fields.times do |index|
@widget_fields << [widget_field_names[index], widget_classes[index]]
end
end
@title = @part.title_translations[I18n.locale.to_s]
@widget_style = @part.widget_style
@category_id = @part.category
@category_id = @part.category
date_now = Time.now
if !@category_id.blank?
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id => @category_id).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
@ -39,6 +42,17 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num)
end
if !params[:category_id].blank? && !params[:tag_id].blank?
@posts = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
# @posts = Bulletin.available_for_lang(I18n.locale).can_display.where(:category_id.in=>params[:category_id],:tagged_ids.in=>params[:tag_id])
elsif !params[:category_id].blank?
@posts = Bulletin.all.available_for_lang(I18n.locale).can_display.where(:category_id.in => params[:category_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
elsif !params[:tag_id].blank?
@posts = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
else
@posts = Bulletin.all.available_for_lang(I18n.locale).can_display.desc( :is_top, :postdate).page( params[:page_main]).per(@page_num)
end
@categories = @module_app.categories.enabled
end

View File

@ -1,18 +1,18 @@
<% # encoding: utf-8 %>
<% if @title %>
<h1 class="h1"><%= @title %></h1>
<h2 class="h2"><%= @title %></h2>
<% end %>
<% if !@widget_fields.blank? %>
<% if @widget_style == '1' %>
<div class="news news1">
<table class="newstb" border="0" cellpadding="0" cellspacing="0" >
<div class="default_widget_typeA">
<table class="default_widget_tb" border="0" cellpadding="0" cellspacing="0" >
<thead>
<tr>
<% @widget_fields.each do |wf| %>
<th><span class="<%= wf[1] %>"><%= t("announcement.bulletin.#{wf[0]}") if !wf[0].blank? %></span></th>
<th><span class="<%= wf[1] %>"><%= t("announcement.default_widget.#{wf[0]}") if !wf[0].blank? %></span></th>
<% end %>
</tr>
</thead>
@ -52,18 +52,21 @@
<% end %>
</tr>
<% end %>
</table>
<% if !@category_id.blank? %>
<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div>
<% else %>
<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path() %></div>
<% @posts.each do |post| %>
<tr>
<td><%= display_date(post.postdate) %></td>
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.category_id) %>
</td>
</tr>
<% end %>
</table>
<div class="more"><%= link_to t('announcement.more'), panel_announcement_front_end_bulletins_path() %></div>
</div>
<% elsif @widget_style == '2' %>
<div class="news news2">
<div class="default_widget_list">
<ul class="newslist">
<% @bulletins.each do |post| %>
<li class="<%= cycle('odd', '')%>">

View File

@ -2,6 +2,6 @@
<%= javascript_include_tag "mobile/jquery.mu.image.resize.js" %>
<!-- <script type='text/javascript' src='/assets/lib/jquery.mu.image.resize.degsin.js'></script> -->
<div id="bulletin_widget">
<div id="default_widget_typeA">
<%= render 'index' %>
</div>

View File

@ -37,4 +37,5 @@ zh_tw:
widget:
bulletins_and_web_links: 分眾頁籤
index: 索引
search: 搜尋
search: 搜尋
more: 更多+