From 2a14c8bad496f8e496b5e8b7cc64ba56b5e26eaa Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Thu, 3 May 2012 14:57:10 +0800 Subject: [PATCH] Announcement preivew --- app/controllers/application_controller.rb | 4 +- app/controllers/pages_controller.rb | 6 +- app/helpers/application_helper.rb | 4 +- app/views/admin/ad_banners/index.html.erb | 2 +- app/views/admin/module_apps/edit.html.erb | 18 ++--- lib/parsers/parser_front_end.rb | 7 +- .../back_end/approvals_controller.rb | 7 ++ .../front_end/bulletins_controller.rb | 14 +++- .../approvals/_modal_approve.html.erb | 68 +++++++++++++++++++ .../approvals/preview_and_approve.js.erb | 5 ++ .../back_end/bulletins/_bulletin.html.erb | 2 +- .../back_end/bulletins/_form.html.erb | 22 ------ .../back_end/bulletins/index.html.erb | 2 + .../announcement/config/locales/en.yml | 1 + .../announcement/config/locales/zh_tw.yml | 1 + .../announcement/config/routes.rb | 6 +- 16 files changed, 124 insertions(+), 45 deletions(-) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/preview_and_approve.js.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ab01ea6bd..a57b4d705 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -96,9 +96,9 @@ class ApplicationController < ActionController::Base end # Render the page - def render_page(id = nil) + def render_page(param) if @item - render :text => process_page(@item, id), :layout => 'page_layout' + render :text => process_page(@item, param[:id],param), :layout => 'page_layout' else render :text => '404 Not Found' end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 4860ea2e8..fab5b6a03 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -19,7 +19,7 @@ class PagesController < ApplicationController if @item && @item.is_published case @item._type when 'Page' - render_page(params[:id]) + render_page(params) when 'Link' redirect_to "http://#{@item[:url]}" end @@ -40,7 +40,9 @@ class PagesController < ApplicationController end def show_from_link - redirect_to "/#{@item.full_name}?id=#{params[:id]}" + # debugger + # a=1 + redirect_to "/#{@item.full_name}?id=#{params[:id]}&preview=#{params[:preview]}" end def load_orbit_bar diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6e76b1a27..ab8d163f6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -116,8 +116,8 @@ module ApplicationHelper ' active' if (@filter[type].include?(id.to_s) rescue nil) end - def process_page(page, id) - parse_page_noko(page, id) + def process_page(page, id,params) + parse_page_noko(page, id,params) end def page_metas(page) diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index d70afab39..47a9ec4d3 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -1,7 +1,7 @@ <% content_for :page_specific_css do -%> <%#= stylesheet_link_tag "admin/ad_banner_preview" %> <% end -%> -<% content_for :page_specific_css do -%> +<% content_for :page_specific_javascript do -%> <%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> <%= javascript_include_tag "inc/modal-preview" %> <% end -%> diff --git a/app/views/admin/module_apps/edit.html.erb b/app/views/admin/module_apps/edit.html.erb index 52142feac..7fb64d170 100644 --- a/app/views/admin/module_apps/edit.html.erb +++ b/app/views/admin/module_apps/edit.html.erb @@ -17,17 +17,17 @@
-
<%= t("admin.user_role.auth.sub_manager") %> - <% @module_app.sub_managers.each do |manager| %> -
<%= manager.user.name %> <%= get_auth_by(manager) %><%= link_to '[X]',remove_sub_manager_admin_module_app_path(@module_app,manager),:method => :delete if if_permit_to_delete(:sub_manager) && manager.user != current_user %>
- <% end %> +
<%#= t("admin.user_role.auth.sub_manager") %> + <%# @module_app.sub_managers.each do |manager| %> +
<%#= manager.user.name %> <%#= get_auth_by(manager) %><%#= link_to '[X]',remove_sub_manager_admin_module_app_path(@module_app,manager),:method => :delete if if_permit_to_delete(:sub_manager) && manager.user != current_user %>
+ <%# end %>
- <%= form_tag(assign_sub_manager_admin_module_app_path) do %> - <%= collection_select(:sub_manager,:id, User.all, :id, :name, :prompt => true,:disabled => !if_permit_to_assign(:sub_manager))%> - <%= submit_tag t("admin.user_role.auth.add_sub_manager") %> - <% end %> + <%#= form_tag(assign_sub_manager_admin_module_app_path) do %> + <%#= collection_select(:sub_manager,:id, User.all, :id, :name, :prompt => true,:disabled => !if_permit_to_assign(:sub_manager))%> + <%#= submit_tag t("admin.user_role.auth.add_sub_manager") %> + <%# end %>
-<%= render :partial => "admin/components/user_role_management", :locals => { :object => @module_app ,:auth=> @module_app.app_auth ,:submit_url=> admin_module_app_app_auths_path(@module_app),:ploy_route_ary=>['remove',:admin,@module_app,@module_app.app_auth] } %> +<%#= render :partial => "admin/components/user_role_management", :locals => { :object => @module_app ,:auth=> @module_app.app_auth ,:submit_url=> admin_module_app_app_auths_path(@module_app),:ploy_route_ary=>['remove',:admin,@module_app,@module_app.app_auth] } %> diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index dfec0dd9a..ff69a72b9 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -21,10 +21,10 @@ module ParserFrontEnd require 'nokogiri' - def parse_page_noko(page, id = nil) + def parse_page_noko(page, id = nil,params) body = Nokogiri::HTML(page.design.layout.body) parse_menu(body, page) - public_r_tags = parse_contents(body, page, id) + public_r_tags = parse_contents(body, page, id,params[:preview]) parse_images(body, page) public_r_tags.each do |tag| @@ -35,7 +35,7 @@ module ParserFrontEnd end # page_contents - def parse_contents(body, page, id) + def parse_contents(body, page, id,preview = false) public_r_tags = [] body.css('.page_content').each do |content| ret = '' @@ -44,6 +44,7 @@ module ParserFrontEnd ret << "/#{id}" if id ret << "?inner=true&page_id=#{page.id}" ret << "&category_id=#{page.category}" if page[:category] + ret << "&preview=true" if preview ret << "'>" else part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb index 4338fdd13..566b07426 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb @@ -3,6 +3,13 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle before_filter :is_admin? include AdminHelper # layout 'admin' + def preview_and_approve + @bulletin = Bulletin.find params[:bulletin_id] + end + + def approve + + end def setting @bulletin_categorys = BulletinCategory.all 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 8438c8e0f..26739b62b 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 @@ -23,10 +23,20 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController end def show - @bulletin = Bulletin.can_display.where(_id: params[:id]).first - get_categorys + if params[:preview] == "true" + preview_content + else + @bulletin = Bulletin.can_display.where(_id: params[:id]).first + get_categorys + end + end + def preview_content + @bulletin = Bulletin.find params[:id] + get_categorys + render :show + end protected diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb new file mode 100644 index 000000000..8f65e341c --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb @@ -0,0 +1,68 @@ + <% if bulletin -%> + + + + + +<% end -%> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/preview_and_approve.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/preview_and_approve.js.erb new file mode 100644 index 000000000..d0e4649dd --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/preview_and_approve.js.erb @@ -0,0 +1,5 @@ +$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_approve',:locals => {:bulletin => @bulletin})) %>"); +var start_modal_with_id = "bulletin-<%=@bulletin.id%>"; +$("#"+start_modal_with_id).css("width","1050px"); +$("#"+start_modal_with_id).css("height","768px"); +$("#"+start_modal_with_id).css("margin","-270px 0 0 -550px"); \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb index 5fb1fcaab..db22e5019 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb @@ -54,7 +54,7 @@ <% end -%> <% if show_approval_link(bulletin) %> -
  • <%= link_to t('announcement.bulletin.approval'), edit_panel_announcement_back_end_bulletin_path(bulletin) %>
  • <%#= #TODO add ancher so user can quick access into that part %> +
  • <%= link_to t('announcement.bulletin.approval'), panel_announcement_back_end_bulletin_approval_preview_path(bulletin),:class => 'preview_trigger' %>
  • <%#= #TODO add ancher so user can quick access into that part %> <% end %> 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 df86f2211..d9771e831 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 @@ -105,28 +105,6 @@ -

    Audit

    -
    - - <% if is_manager? || @bulletin.bulletin_category.authed_users('fact_check').include?(current_user) || current_user.admin? %> -
    - <%= f.label :approval_stat, t('announcement.bulletin.approval_stat') %> - <%= content_tag :label,:class => "radio inline" do -%> - <%= f.radio_button :is_checked, true , {:class => 'privacy'} %> - <%= t('announcement.bulletin.approval_pass') %> - <% end -%> - <%= content_tag :label,:class => "radio inline" do -%> - <%= f.radio_button :is_checked, false, (!@bulletin.is_checked ? {:checked => true, :class => 'privacy'} : {})%> - <%= t('announcement.bulletin.approval_not_pass') %> - <% end -%> -
    - <%= label :is_checked_false, t('announcement.bulletin.approval_not_pass_reason') %> - <%= f.text_field :not_checked_reason %> -
    - -
    - <% end %> -
    <% elsif current_user.admin? %> <%= f.hidden_field :is_checked,:value => true%> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb index 54c0ab7a9..4220edf45 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb @@ -23,5 +23,7 @@ <% content_for :page_specific_javascript do %> <%= javascript_include_tag "bulletin_form" %> + <%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> + <%= javascript_include_tag "inc/modal-preview" %> <% end %> diff --git a/vendor/built_in_modules/announcement/config/locales/en.yml b/vendor/built_in_modules/announcement/config/locales/en.yml index 16353b6ac..f88490e44 100644 --- a/vendor/built_in_modules/announcement/config/locales/en.yml +++ b/vendor/built_in_modules/announcement/config/locales/en.yml @@ -81,6 +81,7 @@ en: approval_setting_window_title: 'Unit' approval_user_list: 'Approval Users' cate_auth: Category Authorization + submit_approval: Submit approval # admin: # action: Action # add_language: Add language 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 bf0d0be6b..d0b6d73ed 100644 --- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml @@ -63,6 +63,7 @@ zh_tw: approval_setting_window_title: '單位' approval_user_list: '審核者' cate_auth: '分類授權' + submit_approval: '提交審核' bulletin: last_modified: 最後修改於 diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index 0de9877a1..f2c5092f7 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -7,6 +7,8 @@ Rails.application.routes.draw do match 'approval_setting' => "approvals#update_setting" ,:as => :approval_setting,:via => :post match 'approval_setting' => "approvals#user_list" ,:as => :approval_user_list,:via => :put resources :bulletins do + match "approve/:bulletin_id" => "approvals#preview_and_approve",:as => :approval_preview,:via => :put + match "approve/:bulletin_id" => "approvals#approve",:as => :approve,:via => :post match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add match "link_quick_edit/:bulletin_id" => "bulletins#link_quick_edit" ,:as => :link_quick_edit member do @@ -32,7 +34,9 @@ Rails.application.routes.draw do resources :tags end namespace :front_end do - resources :bulletins + resources :bulletins # do + # match "preview" => "bulletins#preview_content",:as => :get_preview_content + # end end namespace :widget do match "bulletins" => "bulletins#index"