diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb index 05d17589..9a9df527 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb @@ -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 diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb index 0276b853..cf660e4a 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb @@ -1,18 +1,18 @@ <% # encoding: utf-8 %> <% if @title %> -

<%= @title %>

+

<%= @title %>

<% end %> <% if !@widget_fields.blank? %> <% if @widget_style == '1' %> -
- +
+
<% @widget_fields.each do |wf| %> - + <% end %> @@ -52,18 +52,21 @@ <% end %> <% end %> -
<%= t("announcement.bulletin.#{wf[0]}") if !wf[0].blank? %><%= t("announcement.default_widget.#{wf[0]}") if !wf[0].blank? %>
- - <% if !@category_id.blank? %> -
<%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %>
- <% else %> -
<%= link_to t('more'), panel_announcement_front_end_bulletins_path() %>
+ <% @posts.each do |post| %> + + <%= display_date(post.postdate) %> + <%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.category_id) %> + + <% end %> + + +
<%= link_to t('announcement.more'), panel_announcement_front_end_bulletins_path() %>
<% elsif @widget_style == '2' %> -
+