From d5c55c9697426bca8e7ac7a3f2373d19217331d1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 9 Aug 2012 15:25:30 +0800 Subject: [PATCH] widget & frontend field --- .../admin/module_apps_controller.rb | 5 + .../admin/page_parts_controller.rb | 11 +- app/controllers/admin/pages_controller.rb | 13 + app/models/page.rb | 20 +- app/models/page_part.rb | 11 +- .../module_apps/reload_frontend_pages.js.erb | 4 +- .../admin/page_parts/_module_widget.html.erb | 15 +- .../admin/page_parts/_widget_fields.html.erb | 12 + .../admin/page_parts/_widget_styles.html.erb | 1 - .../admin/page_parts/reload_widgets.js.erb | 3 +- app/views/admin/pages/_form.html.erb | 12 + .../admin/pages/_frontend_fields.html.erb | 11 + config/list.yml | 25 +- .../front_end/bulletins_controller.rb | 16 +- .../announcement/app/models/bulletin.rb | 2 - .../back_end/bulletins/_form.html.erb | 8 +- .../front_end/bulletins/index.html.erb | 258 +++++++++++++++- .../widget/bulletins/_index.html.erb | 275 ++++++++++++++---- .../announcement/config/routes.rb | 2 +- 19 files changed, 604 insertions(+), 100 deletions(-) create mode 100644 app/views/admin/page_parts/_widget_fields.html.erb delete mode 100644 app/views/admin/page_parts/_widget_styles.html.erb create mode 100644 app/views/admin/pages/_frontend_fields.html.erb diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index 1393bf324..3d0fd8962 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -11,6 +11,11 @@ class Admin::ModuleAppsController < ApplicationController def reload_frontend_pages @module_app = ModuleApp.find(params[:id]) + + @frontend_path = @module_app.widgets.keys[0] if ( !@module_app.widgets.blank? && @module_app.widgets[0].blank? ) + + @frontend_style = @module_app.widgets[@frontend_path] if ( !@frontend_path.blank? ) + case @module_app.key when 'announcement' @categories = BulletinCategory.all diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index d75b54aa1..294715dac 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -49,6 +49,10 @@ class Admin::PagePartsController < ApplicationController def update @part = PagePart.find(params[:id]) + + params[:page_part][:widget_field] = params[:page_part][:widget_field].zip( params[:page_part][:widget_field_type] ) + params[:page_part][:widget_field_type] = nil + if @part.update_attributes(params[:page_part]) set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu') flash.now[:notice] = t('admin.update_success_content') @@ -74,11 +78,12 @@ class Admin::PagePartsController < ApplicationController def reload_widgets @module_app = ModuleApp.find(params[:id]) - @widget_path = @module_app.widgets.keys[0] - @widget_style = @module_app.widgets[@widget_path] + @widget_path = @module_app.widgets.keys[0] if ( @module_app.widgets[0].blank? ) + + @widget_style = @module_app.widgets[@widget_path] if ( !@widget_path.blank? ) + case @module_app.key when 'announcement' - # @widget_style = @module_app.widgets['index'] @categories = BulletinCategory.all @tags = AnnouncementTag.all when 'news' diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 5fc6cb77e..26a297953 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -28,10 +28,19 @@ class Admin::PagesController < ApplicationController def edit @item = Page.find(params[:id]) @apps = ModuleApp.excludes(app_pages: nil).entries + + @module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc) + @designs = Design.all.entries @design = @item.design ? @item.design : @designs.first @app_frontend_urls = @item.module_app.app_pages if @item.module_app + if @item.module_app + @module_app = @item.module_app + + @frontend_path = @item.app_frontend_url ? @item.app_frontend_url : @module_app.widgets.keys[0] + @frontend_style = @module_app.widgets[@frontend_path] if !@frontend_path.blank? && !@module_app.widgets.blank? + case @item.module_app.key when 'announcement' @categories = BulletinCategory.all @@ -45,6 +54,7 @@ class Admin::PagesController < ApplicationController end else @categories = nil + @module_app = @module_apps[0] end end @@ -79,6 +89,9 @@ class Admin::PagesController < ApplicationController @item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id ) end + params[:page][:frontend_field] = params[:page][:frontend_field].zip( params[:page][:frontend_field_type] ) + params[:page][:frontend_field_type] = nil + if @item.update_attributes(params[:page]) flash[:notice] = t('admin.update_success_page') respond_to do |format| diff --git a/app/models/page.rb b/app/models/page.rb index 970df4cfe..9c7a7e304 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -10,6 +10,10 @@ class Page < Item field :tag field :view_count, :type => Integer, :default => 0 + field :frontend_style + field :frontend_field , :type => Array + field :frontend_data_count + belongs_to :design belongs_to :module_app has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy @@ -18,7 +22,7 @@ class Page < Item has_many :page_metas, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :page_parts, :allow_destroy => true - before_save :create_parts, :set_key + before_save :create_parts, :set_key , :delete_empty_frontend_field # embeds_many :custom_images, :class_name => 'Image', as: :design_image @@ -53,4 +57,18 @@ class Page < Item end end + def delete_empty_frontend_field + + if self.frontend_field + self.frontend_field.reject! { |ff| (ff[0].blank? || ff[1].blank?) } + # self.frontend_field.each do | ff | + # if ff[0].blank? || ff[1].blank? + # self.frontend_field.delete("") if self.frontend_field + # self.frontend_field.delete(ff) + # end + # end + end + + end + end diff --git a/app/models/page_part.rb b/app/models/page_part.rb index 4d75dbbf4..8226426cc 100644 --- a/app/models/page_part.rb +++ b/app/models/page_part.rb @@ -10,6 +10,7 @@ class PagePart field :public_r_tag_object_id, :default => nil field :public_r_tag_option, :default => nil field :widget_path + field :widget_style field :widget_field , :type => Array field :widget_data_count @@ -20,7 +21,7 @@ class PagePart belongs_to :page belongs_to :module_app - before_save :set_key + before_save :set_key, :delete_empty_widget_field def i18n_variable @i18n_variable ||= I18nVariable.first(:conditions => {:key => 'i18n_variable', :language_value_id => self.id, :language_value_type => self.class}) rescue nil @@ -36,5 +37,13 @@ class PagePart title.key = 'title' if title && (title.key.blank? rescue true) i18n_variable.key = 'i18n_variable' if i18n_variable && (i18n_variable.key.blank? rescue true) end + + def delete_empty_widget_field + + if self.widget_field + self.widget_field.reject! { |wf| (wf[0].blank? || wf[1].blank?) } + end + # self.widget_field.delete("") if self.widget_field + end end \ No newline at end of file diff --git a/app/views/admin/module_apps/reload_frontend_pages.js.erb b/app/views/admin/module_apps/reload_frontend_pages.js.erb index 2fc90b8eb..863e64b20 100644 --- a/app/views/admin/module_apps/reload_frontend_pages.js.erb +++ b/app/views/admin/module_apps/reload_frontend_pages.js.erb @@ -1,3 +1,5 @@ $('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', @module_app.app_pages) %>"); +$('#app_page_frontend_style').html("<%= escape_javascript(select 'page', 'frontend_style', @module_app.widgets[@frontend_path]) if !@frontend_path.blank? %>"); $('#app_page_category').html("<%= j (select 'page', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, {:include_blank => true}) if @categories %>"); -$('#app_page_tag').html("<%= j (select 'page', 'tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, {:include_blank => true}) if @tags %>"); \ No newline at end of file +$('#app_page_tag').html("<%= j (select 'page', 'tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, {:include_blank => true}) if @tags %>"); +$('#app_page_frontend_field').html("<%= j render '../admin/pages/frontend_fields' %>") \ No newline at end of file diff --git a/app/views/admin/page_parts/_module_widget.html.erb b/app/views/admin/page_parts/_module_widget.html.erb index 279ba62e8..76f06db83 100644 --- a/app/views/admin/page_parts/_module_widget.html.erb +++ b/app/views/admin/page_parts/_module_widget.html.erb @@ -20,7 +20,6 @@ <%= f.select :widget_style, @widget_style, :selected => @part.widget_style %> - <%#= render 'widget_styles' %> : @@ -34,14 +33,14 @@ - - <%= f.label :widget_field %> - <% @module_app.widget_fields.each_with_index do |widget_field, i| %> - <%= i+1 %> - <%= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, (@part.widget_field ? @part.widget_field[i] : nil) ), :include_blank => true %>
- - <% end %> + <%= render 'widget_fields' %> + + <%#= f.label :widget_field %> + <%# @module_app.widget_fields.each_with_index do |widget_field, i| %> + <%#= i+1 %> + <%#= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, (@part.widget_field ? @part.widget_field[i] : nil) ), :include_blank => true %>
+ <%# end %> <%#= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, @part.widget_field.collect{|widget_field| widget_field}), {:multiple => :multiple, :size => 6} %>
diff --git a/app/views/admin/page_parts/_widget_fields.html.erb b/app/views/admin/page_parts/_widget_fields.html.erb new file mode 100644 index 000000000..21196b5bf --- /dev/null +++ b/app/views/admin/page_parts/_widget_fields.html.erb @@ -0,0 +1,12 @@ + + <% if (@module_app && @module_app.widget_fields) %> + + <%= label_tag('widget_field') %> + + <% @module_app.widget_fields.each_with_index do |widget_field, i| %> + <%= i+1 %> + <%= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, (@part[:widget_field][i][0] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) ), :include_blank => true %> + <%= select_tag "page_part[widget_field_type][]", options_for_select(LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}, (@part[:widget_field][i][1] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) ), :include_blank => true %>
+ <% end %> + + <% end %> \ No newline at end of file diff --git a/app/views/admin/page_parts/_widget_styles.html.erb b/app/views/admin/page_parts/_widget_styles.html.erb deleted file mode 100644 index 1f9ef84ff..000000000 --- a/app/views/admin/page_parts/_widget_styles.html.erb +++ /dev/null @@ -1 +0,0 @@ - <%= select 'page_part', 'widget_style', @widget_style, :selected => (@part ? @part[:widget_style] : nil), :include_blank => true if @widget_style && @widget_style.size > 0 %> \ No newline at end of file diff --git a/app/views/admin/page_parts/reload_widgets.js.erb b/app/views/admin/page_parts/reload_widgets.js.erb index 8dca2040d..6d41a9b77 100644 --- a/app/views/admin/page_parts/reload_widgets.js.erb +++ b/app/views/admin/page_parts/reload_widgets.js.erb @@ -1,4 +1,5 @@ $('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| k}) %>") -$('#widget_style_list select').html("<%= j options_for_select(@module_app.widgets[@widget_path]) %>") +$('#widget_style_list select').html("<%= j options_for_select( @module_app.widgets[@widget_path] ) if !@widget_path.blank? %>") +$('#widget_field').html("<%= j render 'widget_fields' %>") $('#widget_category').html("<%= j render 'widget_categories' %>") $('#widget_tag').html("<%= j render 'widget_tags' %>") \ No newline at end of file diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index eff3e4df1..8b429e55b 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -42,15 +42,27 @@ <%= select('page','app_frontend_url', @app_frontend_urls, :selected => @item.app_frontend_url ) rescue ''%> + + <%= select('page','frontend_style', @frontend_style, :selected => @item[:frontend_style], :include_blank => true ) rescue ''%> + <%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%> <%= select('page','tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, :selected => @item[:tag], :include_blank => true ) rescue ''%> + + <%= render 'frontend_fields' %> + +
+ <%= f.label :frontend_data_count, t('admin.frontend_data_count'), :class => 'control-label' %> +
+ <%= f.text_field :frontend_data_count %> +
+
<%= f.label :is_published, "#{t('admin.is_published')} ?", :class => 'control-label' %>
diff --git a/app/views/admin/pages/_frontend_fields.html.erb b/app/views/admin/pages/_frontend_fields.html.erb new file mode 100644 index 000000000..ce042dddb --- /dev/null +++ b/app/views/admin/pages/_frontend_fields.html.erb @@ -0,0 +1,11 @@ + + <% if (@module_app && @module_app.widget_fields) %> + <%= label_tag('frontend_field & frontend_field_type') %> + <% @module_app.widget_fields.each_with_index do |frontend_field, i| %> + <%= i+1 %> + <%= select_tag "page[frontend_field][]", options_for_select(@module_app.widget_fields.collect{|frontend_field| [frontend_field.humanize, frontend_field]}, (@item[:frontend_field][i][0] if (@item && !@item[:frontend_field].blank? && !@item[:frontend_field][i].blank?)) ), :include_blank => true %> + <%= select_tag "page[frontend_field_type][]", options_for_select(LIST[:widget_field_type].collect{|frontend_field| [frontend_field.humanize, frontend_field]}, (@item[:frontend_field][i][1] if (@item && !@item[:frontend_field].blank? && !@item[:frontend_field][i].blank?)) ), :include_blank => true %>
+ <% end %> + <% end %> + + \ No newline at end of file diff --git a/config/list.yml b/config/list.yml index ef95ba314..55bebb77d 100644 --- a/config/list.yml +++ b/config/list.yml @@ -14,4 +14,27 @@ public_r_tags: page_part_kinds: - text - public_r_tag - - module_widget \ No newline at end of file + - module_widget + +widget_field: + - title + - category + - image + - date + - subtitle + - content + - link + - file + +widget_field_type: + - title + - category + - img + - date + - text + - link + - file + - status + - tag + - viewcount + - host \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index 9fd97b9b9..da67c0bb0 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -9,17 +9,27 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController # GET /bulletins.xml def index + + @item = Page.find(params[:page_id]) + if @item.frontend_data_count + @page_num = @item.frontend_data_count + else + @page_num = 10 + end + + @frontend_style = @item.frontend_style + date_now = Time.now if !params[:category_id].blank? - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[: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_main]).per(10) + @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[: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_main]).per(@page_num) @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil elsif !params[:tag_id].blank? @tag = AnnouncementTag.find(params[:tag_id]) rescue nil @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.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_main]).per(10) + @bulletins = @tag.bulletins.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_main]).per(@page_num) else - @bulletins = Bulletin.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_main]).per(10) + @bulletins = Bulletin.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_main]).per(@page_num) end end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index db4f40111..589da3208 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -12,8 +12,6 @@ class Bulletin has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_one :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_and_belongs_to_many :tags, :class_name => "AnnouncementTag" - - field :title2, localize: true field :postdate , :type => DateTime field :deadline , :type => DateTime diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index 6fb50cbee..180cf67a9 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -146,13 +146,7 @@ <%= I18nVariable.from_locale(locale) %> <%= f.text_field locale, :class=>'post-title' %> <% end %> -
- - <%= f.label :title2 %> - <%= f.fields_for :title2_translations do |f| %> - <%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale, :class=>'post-title', :value => (@bulletin.title2_translations[locale] rescue nil) %> - <% end %> +
<%= f.label :subtitle %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb index 4ba18b51e..48d30d1d3 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb @@ -8,26 +8,252 @@

<%= t('announcement.announcement') %>

<% end %> +<% if !@item.frontend_field.blank? %> - - - - - - +<% if @frontend_style == '1' %> + +
+
<%= t('announcement.bulletin.category') %><%= t('announcement.bulletin.title') %><%= t('announcement.bulletin.postdate') %>
+ + + <% @item.frontend_field.each do |ff| %> + + <% end %> + + + <% @bulletins.each do |post| %> + <% @item.frontend_field.each do |ff| %> + + + + <% end %> + <% end %> +
<%= t("announcement.bulletin.#{ff[0]}") if !ff[0].blank? %>
+ + <% if ff[1] == 'title' %> + <%= link_to post.send("#{ff[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %> + <% elsif ff[1] == 'date' %> + <%= display_date(post.send(ff[0])) %> + <% elsif ff[1] == 'category' %> + <%= post.send("#{post.class.to_s.underscore}_#{ff[0]}").i18n_variable[I18n.locale] rescue nil %> + <% elsif ff[1] == 'img' %> +
<%= image_tag(post.image.url) %>
+ <% elsif ff[1] == 'text' %> + <%#= post.send("#{ff[0]}[#{I18n.locale}]").html_safe %> + <%= post.send("#{ff[0]}")[I18n.locale].html_safe %> + <% elsif ff[1] == 'status' %> + <% if post.is_top? %> + <%= t(:top) %> + <% end %> + <% if post.is_hot? %> + <%= t(:hot) %> + <% end %> + <% elsif ff[1] == 'link' %> + <% elsif ff[1] == 'file' %> + <% elsif ff[1] == 'tag' %> + <% elsif ff[1] == 'viewcount' %> + <%= dislpay_view_count(post) %> + <% elsif ff[1] == 'host' %> + <%= User.from_id(post.update_user_id).name rescue ''%> + <% end %> +
+
+
+ +<% elsif @frontend_style == '2' %> + +
+ +
+ +<% elsif @frontend_style == '3' %> + +
+ + +
+ +<% elsif @frontend_style == '4' %> + +
+ + +
+ +<% elsif @frontend_style == '5' %> + +
+
<%= image_tag(@bulletins.first.image.url) %>
+ +
-<% @bulletins.each do |post| %> - - <%= post.bulletin_category.i18n_variable[I18n.locale] rescue nil %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %> - <%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %> - - <%= display_date_time(post.postdate) %> - - <% end %> - +<% else %> + + + + + + + + + <% @bulletins.each do |post| %> + + + + + + + <% end %> + +
<%= t('announcement.bulletin.category') %><%= t('announcement.bulletin.title') %><%= t('announcement.bulletin.postdate') %>
<%= post.bulletin_category.i18n_variable[I18n.locale] rescue nil %><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %> + <%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %> + <%= display_date_time(post.postdate) %>
+ +<% end %> <%= paginate @bulletins, :param_name => :page_main, :params => {:inner => 'false'} %> 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 f6767b1bf..79cbc3aa0 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 @@ -3,41 +3,56 @@

<%= @title %>

<% end %> +<% if !@widget_fields.blank? %> + <% if @widget_style == '1' %> -

========== 1 ==========

-
-
- <% elsif @widget_style == '2' %> -

========== 2 ==========

-
-
<%= image_tag(@bulletins.first.image.url) %>
+ <% 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() %>
+ <% end %> +
+ +<% elsif @widget_style == '3' %> + +
+ + <% if !@category_id.blank? %>
<%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %>
<% else %> @@ -88,5 +157,103 @@ <% end %>
+ +<% elsif @widget_style == '4' %> + +
+ + + <% 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() %>
+ <% end %> + +
+ +<% elsif @widget_style == '5' %> + +
+
<%= image_tag(@bulletins.first.image.url) %>
+ + + <% 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() %>
+ <% end %> +
+ +<% end %> + <% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index 5bcfea223..a9f1c4968 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -39,7 +39,7 @@ Rails.application.routes.draw do # end end namespace :widget do - match "index" => "bulletins#index" + match "bulletins" => "bulletins#index" match "bulletins_and_web_links" => "bulletins#bulletins_and_web_links" match "reload_bulletins" => "bulletins#reload_bulletins" match "reload_web_links" => "bulletins#reload_web_links"