Fix widget index
This commit is contained in:
parent
a82022c958
commit
f13c21c1b4
|
@ -9,26 +9,29 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
||||||
@part = PagePart.find(params[:part_id])
|
@part = PagePart.find(params[:part_id])
|
||||||
|
|
||||||
if @part.widget_data_count
|
if @part.widget_data_count
|
||||||
@page_num = @part.widget_data_count
|
@page_num = @part.widget_data_count
|
||||||
else
|
else
|
||||||
@page_num = 4
|
@page_num = 4
|
||||||
end
|
end
|
||||||
|
|
||||||
if @part.widget_field
|
num_of_fields = @part.widget_field_name.reject(&:empty?).length
|
||||||
@widget_fields = @part.widget_field
|
widget_field_names = @part.widget_field_name.reject(&:empty?)
|
||||||
else
|
widget_classes = @part.widget_class.reject(&:empty?)
|
||||||
@widget_fields = []
|
@widget_fields = []
|
||||||
end
|
|
||||||
|
if @part.widget_field_name
|
||||||
@title = @part.title_translations[I18n.locale.to_s]
|
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
|
@widget_style = @part.widget_style
|
||||||
|
@category_id = @part.category
|
||||||
@category_id = @part.category
|
|
||||||
|
|
||||||
date_now = Time.now
|
date_now = Time.now
|
||||||
if !@category_id.blank?
|
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)
|
@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)
|
@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
|
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
|
@categories = @module_app.categories.enabled
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
<% # encoding: utf-8 %>
|
<% # encoding: utf-8 %>
|
||||||
<% if @title %>
|
<% if @title %>
|
||||||
<h1 class="h1"><%= @title %></h1>
|
<h2 class="h2"><%= @title %></h2>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if !@widget_fields.blank? %>
|
<% if !@widget_fields.blank? %>
|
||||||
|
|
||||||
<% if @widget_style == '1' %>
|
<% if @widget_style == '1' %>
|
||||||
|
|
||||||
<div class="news news1">
|
<div class="default_widget_typeA">
|
||||||
<table class="newstb" border="0" cellpadding="0" cellspacing="0" >
|
<table class="default_widget_tb" border="0" cellpadding="0" cellspacing="0" >
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% @widget_fields.each do |wf| %>
|
<% @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 %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -52,18 +52,21 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
<% @posts.each do |post| %>
|
||||||
|
<tr>
|
||||||
<% if !@category_id.blank? %>
|
<td><%= display_date(post.postdate) %></td>
|
||||||
<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %></div>
|
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.category_id) %>
|
||||||
<% else %>
|
</td>
|
||||||
<div class="more"><%= link_to t('more'), panel_announcement_front_end_bulletins_path() %></div>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="more"><%= link_to t('announcement.more'), panel_announcement_front_end_bulletins_path() %></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% elsif @widget_style == '2' %>
|
<% elsif @widget_style == '2' %>
|
||||||
|
|
||||||
<div class="news news2">
|
<div class="default_widget_list">
|
||||||
<ul class="newslist">
|
<ul class="newslist">
|
||||||
<% @bulletins.each do |post| %>
|
<% @bulletins.each do |post| %>
|
||||||
<li class="<%= cycle('odd', '')%>">
|
<li class="<%= cycle('odd', '')%>">
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
<%= javascript_include_tag "mobile/jquery.mu.image.resize.js" %>
|
<%= javascript_include_tag "mobile/jquery.mu.image.resize.js" %>
|
||||||
<!-- <script type='text/javascript' src='/assets/lib/jquery.mu.image.resize.degsin.js'></script> -->
|
<!-- <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' %>
|
<%= render 'index' %>
|
||||||
</div>
|
</div>
|
|
@ -37,4 +37,5 @@ zh_tw:
|
||||||
widget:
|
widget:
|
||||||
bulletins_and_web_links: 分眾頁籤
|
bulletins_and_web_links: 分眾頁籤
|
||||||
index: 索引
|
index: 索引
|
||||||
search: 搜尋
|
search: 搜尋
|
||||||
|
more: 更多+
|
Reference in New Issue