From 2e2647af42b760edb7446b77549d88d972745629 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Fri, 23 Mar 2012 11:18:29 +0800 Subject: [PATCH 01/59] change layout from old admin to new_admin. not complete code --- .../admin/ad_banners_controller.rb | 2 +- app/views/admin/ad_banners/index.html.erb | 50 ++++++++----------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index 19d81057..614a75fa 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -1,5 +1,5 @@ class Admin::AdBannersController < ApplicationController - layout "admin" + layout "new_admin" before_filter :authenticate_user! before_filter :is_admin? diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index e109830e..f16f01a9 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -1,47 +1,41 @@ -<% content_for :secondary do %> -
-

<%= t('admin.setup_ad_banners') %>

- -
-<% end -%> <%= flash_messages %> -
-

<%= t('admin.list_ad_banners') %>

- + + + +
- - - - - - - + + + + + + + <% @ad_banners.each do |ad_banner| %> - + + + - - - - + <% end %>
<%= t('admin.title') %><%= t('admin.picture_position') %><%= t('admin.post_date') %><%= t('admin.unpost_date') %><%= t('admin.context') %><%= t('admin.direct_to_after_click') %><%= t('admin.now_display?') %><%= t('admin.location') %><%= t('admin.title') %> <%= t('admin.title') %><%= t('admin.start_date')%><%= t('admin.end_date') %><%= t('admin.style') %>
<%= ad_banner.title %> <%= ad_banner.picture_position %><%= link_to ad_banner.title,edit_admin_ad_banner_path(ad_banner) %> <%= ad_banner.post_date %> <%= ad_banner.unpost_date.nil?? t('form.date_unlimited'): ad_banner.unpost_date %><%= ad_banner.context %><%= ad_banner.direct_to_after_click %><%= ad_banner.display? %> - <%= link_to t(:show), admin_ad_banner_path(ad_banner), :class => 'show' %> - <%= link_to t(:edit), edit_admin_ad_banner_path(ad_banner), :class => 'edit' %> - <%= link_to t(:delete), admin_ad_banner_path(ad_banner), :confirm => t('sure?'), :method => :delete, :class => 'delete' %> - <%= ad_banner.ad_fx %>
-
<%= link_to t('admin.new_ad_banner'), new_admin_ad_banner_path, :class => 'new' %> From 1451c3ac1d70e873a91fc45e07c2b837d2adde6d Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 27 Mar 2012 15:34:21 +0800 Subject: [PATCH 02/59] changing to new admin_layout --- app/views/admin/ad_banners/_ad_banner.html.erb | 11 +++++++++++ .../back_end/bulletin_links_controller-複製.rb | 14 -------------- 2 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 app/views/admin/ad_banners/_ad_banner.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-複製.rb diff --git a/app/views/admin/ad_banners/_ad_banner.html.erb b/app/views/admin/ad_banners/_ad_banner.html.erb new file mode 100644 index 00000000..787a03ed --- /dev/null +++ b/app/views/admin/ad_banners/_ad_banner.html.erb @@ -0,0 +1,11 @@ + + + <%= location %> + + > + + <%= link_to (ad_image.picture_intro || t("untitled")),'' %> + <%= start_date %> + <%= end_date.nil?? t('form.date_unlimited'): end_date %> + <%= style %> + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-複製.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-複製.rb deleted file mode 100644 index 04a75fa6..00000000 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-複製.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Panel::Announcement::BackEnd::BulletinLinksController < ApplicationController - - layout 'new_admin' - - def index - @bulletin_links = BulletinLink.all - - respond_to do |format| - format.html # index.html.erb - # format.xml { render :xml => @bulletins } - format.js - end - -end From c645c1b5df37a64ceab35b6d9c70dc99470d3e9a Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 28 Mar 2012 10:51:14 +0800 Subject: [PATCH 03/59] Remove extra code in bulletin form --- .../back_end/bulletins/_form.html.erb | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) 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 0ba87a70..2ecadbf8 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 @@ -1,25 +1,10 @@ <% # encoding: utf-8 %> - <%= f.error_messages %> - <%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %> - - <% if is_manager? || @bulletin.bulletin_category.authed_users('fact_check').include?(current_user) || current_user.admin?%> -
- <%= label :fact_check_stat, t('announcement.bulletin.fact_check_stat') %> - <%= f.radio_button :is_checked, true%> - <%= label :is_checked_true, t('announcement.bulletin.fact_check_pass') %> - <%= f.radio_button :is_checked, false, (@bulletin.is_checked.nil?? {:checked => true} : {}) %> - <%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass') %> - - <%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass_reason') %> - <%= f.text_field :not_checked_reason %> -
- <% end %> <%= f.error_messages %>
- <% if params[:action] != 'new' %> + <% if params[:action] != 'new' %>
From 649f343e6f574c6a002220060d7672f0e5386a54 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 28 Mar 2012 11:17:59 +0800 Subject: [PATCH 04/59] Ray's fix for margin-top --- app/assets/javascripts/orbit-1.0.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/orbit-1.0.js b/app/assets/javascripts/orbit-1.0.js index cbb6e0b8..d91e3533 100644 --- a/app/assets/javascripts/orbit-1.0.js +++ b/app/assets/javascripts/orbit-1.0.js @@ -99,7 +99,11 @@ function mainTablePosition() { var $height = $('#main-wrap > .subnav').height() var $table = $('#main-wrap > .table') //alert ($table.height()) - $table.stop().animate({marginTop:$height-17},500) + $height = $height-17; + if($height<0){ + $height = 0; + } + $table.stop().animate({marginTop:$height},500) //$table.css({marginTop : $height}) } $(window).scroll(function () { From d6e4da6dad3f82e708cee7baf8793361c239c643 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 28 Mar 2012 11:17:59 +0800 Subject: [PATCH 05/59] Ray's fix for margin-top --- app/assets/javascripts/orbit-1.0.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/orbit-1.0.js b/app/assets/javascripts/orbit-1.0.js index cbb6e0b8..d91e3533 100644 --- a/app/assets/javascripts/orbit-1.0.js +++ b/app/assets/javascripts/orbit-1.0.js @@ -99,7 +99,11 @@ function mainTablePosition() { var $height = $('#main-wrap > .subnav').height() var $table = $('#main-wrap > .table') //alert ($table.height()) - $table.stop().animate({marginTop:$height-17},500) + $height = $height-17; + if($height<0){ + $height = 0; + } + $table.stop().animate({marginTop:$height},500) //$table.css({marginTop : $height}) } $(window).scroll(function () { From e7fdcfffa0b8e04690eb2a185979980b1d1527ec Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 28 Mar 2012 12:12:23 +0800 Subject: [PATCH 06/59] Fix sidebar --- app/views/layouts/_side_bar.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index baeef6c4..e2f757db 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -9,7 +9,7 @@ <%= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> <%= content_tag :li, link_to(t('admin.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %> <%= content_tag :li, link_to(t('admin.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('tags', 'index') %> - <%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('tags', 'index') if is_manager? %> + <%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('tags', 'index') if (is_manager? rescue nil) %> <% end -%> <% end -%> From 25c24c03f9bf4d8a88a8c79935d5029cbe6b4a81 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 28 Mar 2012 19:40:12 +0800 Subject: [PATCH 07/59] Add pagination to bulletin index and remove ajax to make it simple --- app/assets/javascripts/orbit-1.0.js | 5 --- .../back_end/bulletins_controller.rb | 26 +++++++------ .../back_end/bulletins/_bulletins.html.erb | 36 ------------------ .../back_end/bulletins/_filter.html.erb | 37 ++++++++----------- .../back_end/bulletins/index.html.erb | 2 + .../back_end/bulletins/index.js.erb | 1 - 6 files changed, 32 insertions(+), 75 deletions(-) delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.js.erb diff --git a/app/assets/javascripts/orbit-1.0.js b/app/assets/javascripts/orbit-1.0.js index d91e3533..ffd16e82 100644 --- a/app/assets/javascripts/orbit-1.0.js +++ b/app/assets/javascripts/orbit-1.0.js @@ -39,11 +39,6 @@ $(document).ready(function(){ break; } }); - - $(document).on('click', '.sort-header > .sort', function() { - $.getScript($(this).attr('rel')); - }); - var $role = $('.select-role'); var method =$('.privacy:eq(1)').attr('checked'); diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 648c8d55..3642fe4f 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -8,19 +8,19 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # @bulletins = Bulletin.desc("postdate desc") get_categorys(params[:bulletin_category_id]) get_tags - + # @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id] # @bulletins = Bulletin.search(params[:search], params[:category_id]) # @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]]) - @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all.desc("postdate") + @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all.desc("postdate").page(params[:page]).per(10) @bulletin_categories = BulletinCategory.all - + @bulletin_link = BulletinLink.new - @link_url = panel_announcement_back_end_bulletins_path + @link_url = panel_announcement_back_end_bulletins_path @bulletin_file = BulletinFile.new - @file_url = panel_announcement_back_end_bulletins_path + @file_url = panel_announcement_back_end_bulletins_path respond_to do |format| format.html # index.html.erb @@ -299,7 +299,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController bulletins = Bulletin.all case params[:sort] when 'postdate', 'deadline' - bulletins.order_by([params[:sort], params[:direction]]) + bulletins.order_by([params[:sort], params[:direction]]).page(params[:page]).per(10) when 'category' category_ids = bulletins.distinct(:bulletin_category_id) categories = BulletinCategory.find(category_ids) rescue nil @@ -308,7 +308,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController categories.each { |category| h[category.i18n_variable[I18n.locale]] = category.id } sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! sorted_categorys = sorted.collect {|a| bulletins.where(:bulletin_category_id => a[1]).entries } - sorted_categorys.flatten + sorted_categorys.flatten! + Kaminari.paginate_array(sorted_categorys).page(params[:page]).per(10) else nil end @@ -316,9 +317,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController h = Hash.new bulletins.each { |bulletin| h[bulletin.title[I18n.locale]] = bulletin } sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! - sorted.collect {|a| a[1] } + sorted_titles = sorted.collect {|a| a[1] } + Kaminari.paginate_array(sorted_titles).page(params[:page]).per(10) when 'status' - bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction]) + bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction]).page(params[:page]).per(10) when 'update_user_id' user_ids = bulletins.distinct(:update_user_id) users = User.find(user_ids) rescue nil @@ -327,7 +329,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController users.each { |user| h[user.name] = user.id } sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! sorted_users = sorted.collect {|a| bulletins.where(:update_user_id => a[1]).entries } - sorted_users.flatten + sorted_users.flatten! + Kaminari.paginate_array(sorted_users).page(params[:page]).per(10) else nil end @@ -335,7 +338,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController a = Array.new AnnouncementTag.all.order_by(I18n.locale, params[:direction]).each { |tag| a << tag.bulletins } a.flatten! - a.uniq + a.uniq! + Kaminari.paginate_array(a).page(params[:page]).per(10) end end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb index 979f3f4a..81daae8b 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb @@ -1,39 +1,3 @@ - diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter.html.erb index 09222a36..f8ea5418 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter.html.erb @@ -1,4 +1,4 @@ -