From 9cc1e95cb16f3888a352c732b478c6a2d7663b31 Mon Sep 17 00:00:00 2001 From: Spen Date: Thu, 18 Jul 2013 14:52:57 +0800 Subject: [PATCH] announcement add new widget bulletins_and_links Conflicts: vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_bulletins.html.erb --- .../announcement/bulletins_and_web_links.css | 78 +++++++++++++++++++ .../widget/bulletins_controller.rb | 69 +++++++++++++++- .../widget/bulletins/_bulletins.html.erb | 6 +- .../widget/bulletins/_tag.html.erb | 2 +- .../widget/bulletins/_web_links.html.erb | 4 +- .../bulletins_and_web_links.html.erb | 36 +++++++++ .../bulletins/bulletins_and_web_links.js.erb | 3 + .../announcement/config/locales/en.yml | 2 +- .../announcement/config/locales/zh_tw.yml | 2 +- vendor/built_in_modules/announcement/init.rb | 5 ++ 10 files changed, 195 insertions(+), 12 deletions(-) create mode 100644 vendor/built_in_modules/announcement/app/assets/stylesheets/announcement/bulletins_and_web_links.css create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.js.erb diff --git a/vendor/built_in_modules/announcement/app/assets/stylesheets/announcement/bulletins_and_web_links.css b/vendor/built_in_modules/announcement/app/assets/stylesheets/announcement/bulletins_and_web_links.css new file mode 100644 index 00000000..ecd28219 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/assets/stylesheets/announcement/bulletins_and_web_links.css @@ -0,0 +1,78 @@ + +.mega_tab_block { + clear: both; + position: relative; +} + +.mega_tab_block h3 { + font: 22px/100% 'arial',sans-serif; + margin: 0 0 10px; + padding: 0; +} + +.mega_tab_block .pagination { + float: left; + height: auto; + margin: 10px 0 0; + width: auto; +} +.mega_tab_block .pagination a { + background: none repeat scroll 0 0 #EEEEEE; + display: block; + float: left; + margin: 0 5px 0 0; + padding: 10px; +} + + +.tag_block { + clear: both; + margin: 0 0 20px; + position: relative; +} +.mega_tab_block .tag_list { + background: none repeat scroll 0 0 #EEEEEE; + margin: 0; + overflow: hidden; + padding: 0 0 0 5px; +} +.mega_tab_block .tag_list li { + float: left; + list-style: none outside none; +} +.mega_tab_block .tag_list li a { + background: none repeat scroll 0 0 #DDDDDD; + float: left; + margin: 0 5px 0 0; + padding: 10px; +} + +.news_block { + clear: both; + margin: 0 0 20px; + overflow: hidden; + position: relative; +} +.mega_tab_block .news_list { + margin: 0; + padding: 0; +} +.mega_tab_block .news_list li { + list-style: none outside none; + padding: 5px 0; +} + + +.links_block { + clear: both; + overflow: hidden; + position: relative; +} +.mega_tab_block .links_list { + margin: 0; + padding: 0; +} +.mega_tab_block .links_list li { + list-style: none outside none; + padding: 5px 0; +} \ No newline at end of file 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 2867205e..45bb60cc 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 @@ -66,14 +66,75 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController end + def bulletins_and_web_links + + @part = PagePart.find(params[:part_id]) if !params[:part_id].blank? + + @title = @part.title_translations[I18n.locale.to_s] + + if !@part.blank? and @part.widget_data_count + @page_num = @part.widget_data_count + else + @page_num = 5 + end + + date_now = Time.now + + if !params[:tag_id].blank? + @tags = Tag.any_in(:_id => params[:tag_id]).asc(:created_at) + elsif params[:tag_id].blank? and !@part.tag.blank? + @tags = Tag.any_in(:_id => @part.tag).asc(:created_at) + else + @ModuleApp_b = ModuleApp.first(:conditions => {:key=>'announcement'}) + @tags = Tag.where(:module_tag_id => @ModuleApp_b.id).asc(:created_at) + end + + @selected_tag = Tag.find(params[:id]).first rescue @tags[0] + + @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => @selected_tag.id.to_s, :is_hidden => false).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) rescue nil + + if @part.widget_style == 'bulletins_and_web_links' + @ModuleApp_w = ModuleApp.first(:conditions => {:key=>'web_resource'}) + @link_selected_tag = Tag.first(:conditions => {:name => @selected_tag.name, :module_tag_id => @ModuleApp_w.id}) + @web_links = WebLink.where(:tagged_ids => @link_selected_tag.id.to_s, :is_hidden => false).desc(:is_top,:created_at).available_for_lang(I18n.locale).page(params[:page]).per(@page_num) rescue nil + end + + end + def reload_bulletins - @selected_tag = Tag.find(params[:tag_id]) - @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort).page(params[:page]).per(5) rescue nil + + @part = PagePart.find(params[:part_id]) if !params[:part_id].blank? + + @title = @part.title_translations[I18n.locale.to_s] + + if !@part.blank? and @part.widget_data_count + @page_num = @part.widget_data_count + else + @page_num = 5 + end + + date_now = Time.now + + @selected_tag = Tag.find(params[:tag_id]).first + @bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => @selected_tag.id.to_s, :is_hidden => false).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) rescue nil end def reload_web_links - @selected_tag = Tag.find(params[:tag_id]) - @web_links = WebLink.where(:name => @selected_tag.name).where(:is_hidden => false).desc(:is_top, sort).available_for_lang(I18n.locale).page(params[:page]).per(5) rescue nil + + @part = PagePart.find(params[:part_id]) if !params[:part_id].blank? + + if !@part.blank? and @part.widget_data_count + @page_num = @part.widget_data_count + else + @page_num = 5 + end + + date_now = Time.now + + @selected_tag = Tag.find(params[:tag_id]).first + @ModuleApp = ModuleApp.first(:conditions => {:key=>'web_resource'}) + @link_selected_tag = Tag.first(:conditions => {:name => @selected_tag.name, :module_tag_id => @ModuleApp.id}) + @web_links = WebLink.where(:tagged_ids => @link_selected_tag.id.to_s, :is_hidden => false).desc(:is_top,:created_at).available_for_lang(I18n.locale).page(params[:page]).per(@page_num) rescue nil end def bulletins_side_bar diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_bulletins.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_bulletins.html.erb index 97067fb3..c1e9407e 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_bulletins.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_bulletins.html.erb @@ -1,10 +1,10 @@ <% @bulletins.each do |bulletin| %>
  • - <%= link_to bulletin.title, panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category_id , :tag_id => @selected_tag.id ) %> + <%= link_to bulletin.title, panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category_id, :part_id => params[:part_id] , :tag_id => @selected_tag.id ) %>
  • <% end %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_tag.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_tag.html.erb index 6188bfe9..e7b87179 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_tag.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_tag.html.erb @@ -1,3 +1,3 @@
  • - <%= link_to tag.name, panel_announcement_widget_bulletins_and_web_links_path(:id => tag.id), :remote => true, :class => ('active' if tag.eql?(@selected_tag)) %> + <%= link_to tag.name, panel_announcement_widget_bulletins_and_web_links_path(:inner=>true, :id => [tag.id], :part_id=>params[:part_id]), :remote => true, :class => ('active' if tag.eql?(@selected_tag)) %>
  • \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb index a1b8f4db..928326c0 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb @@ -5,6 +5,6 @@ <% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb new file mode 100644 index 00000000..483042ee --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb @@ -0,0 +1,36 @@ +
    + +
    + +
    + +
    +

    + <%#= link_to t("announcement.bulletins"), panel_announcement_front_end_bulletins_path, :class => 'more' %> + <%= link_to @title, panel_announcement_front_end_bulletins_path, :class => 'more' %> +

    + +
    + + <% if @part.widget_style == 'bulletins_and_web_links' %> + + + + <% end %> + +
    + +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "news_link" %> +<% end %> + +<%= stylesheet_link_tag "announcement/bulletins_and_web_links" %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.js.erb new file mode 100644 index 00000000..9439ce4d --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.js.erb @@ -0,0 +1,3 @@ +$('#bulletins_web_links_tags').html("<%= j render :partial => 'tag', :collection => @tags %>") +$('#bulletins_web_links_bulletins').html("<%= j render 'bulletins' if @bulletins %>") +$('#bulletins_web_links_web_links').html("<%= j render 'web_links' if @web_links %>") \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/config/locales/en.yml b/vendor/built_in_modules/announcement/config/locales/en.yml index 00c74079..6f204af9 100644 --- a/vendor/built_in_modules/announcement/config/locales/en.yml +++ b/vendor/built_in_modules/announcement/config/locales/en.yml @@ -32,6 +32,6 @@ en: update_bulletin_category_success: Update Category Successfully url: URL widget: - bulletins_and_web_links: Bulletins and Web Resources + bulletins_and_web_links: Differential Nav. index: Index search: Search diff --git a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml index 04d1fe25..21ca4e8c 100644 --- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml @@ -34,6 +34,6 @@ zh_tw: update_bulletin_category_success: 更新類別成功 url: 連結位置 widget: - bulletins_and_web_links: 索引 + bulletins_and_web_links: 分眾頁籤 index: 索引 search: 搜尋 \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/init.rb b/vendor/built_in_modules/announcement/init.rb index 001176ef..0c55fda3 100644 --- a/vendor/built_in_modules/announcement/init.rb +++ b/vendor/built_in_modules/announcement/init.rb @@ -53,6 +53,11 @@ module Announcement widget_i18n "announcement.widget.search" end + customize_widget "bulletins_and_web_links" do + widget_i18n "announcement.widget.bulletins_and_web_links" + style ["bulletins_and_links","bulletins_only"] + end + # item "index","announcement.widget.index",:default_template=>true,:fields=>["title","category","postdate"] # item "bulletins_and_web_links","announcement.widget.bulletins_and_web_links" end