From e353afb5ac7fc9b477c31a78b213d647e1e1cf8c Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 17 Apr 2012 15:21:43 +0800 Subject: [PATCH] fix i18n vars in ad_banner --- app/controllers/admin/ad_banners_controller.rb | 7 +++---- app/models/ad_banner.rb | 6 +++++- app/views/admin/ad_banners/_ad_banner_tab.html.erb | 4 ++-- app/views/admin/ad_banners/_ad_image_update.html.erb | 4 ++-- app/views/admin/ad_banners/_preview_block.html.erb | 2 +- app/views/admin/ad_images/_form.html.erb | 7 +++++++ app/views/layouts/_side_bar.html.erb | 6 +++--- config/routes.rb | 6 +++--- 8 files changed, 26 insertions(+), 16 deletions(-) diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index 5ce44a0d..4d2ed213 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -40,14 +40,13 @@ class Admin::AdBannersController < ApplicationController end def realtime_preview - @ad_banner = AdBanner.find(params[:id]).clone - debugger - @ad_banner.update_attributes(params[:ad_banner]) + @ad_banner = AdBanner.find(params[:id]).preview_clone + #@ad_banner.update_attributes(params[:ad_banner]).update_attributes(params[:ad_images]) end def index @ad_banners = AdBanner.all - @active = @ad_banners.first + @active = @ad_banners.first end end \ No newline at end of file diff --git a/app/models/ad_banner.rb b/app/models/ad_banner.rb index 3e09280f..a2ac2096 100644 --- a/app/models/ad_banner.rb +++ b/app/models/ad_banner.rb @@ -13,7 +13,11 @@ class AdBanner FX_TYPES = ["blindX","blindY","blindZ","cover","curtainX","curtainY","fade","fadeZoom","growX","growY","scrollUp","scrollDown","scrollLeft","scrollRight","scrollHorz","scrollVert","shuffle","slideX","slideY","toss","turnUp","turnDown","turnLeft","turnRight","uncover","wipe","zoom"] - + def preview_clone + preview_banner = self.clone + preview_banner.ad_images = self.ad_images + preview_banner + end # def new_ad_images(*attrs) # debugger # a=1 diff --git a/app/views/admin/ad_banners/_ad_banner_tab.html.erb b/app/views/admin/ad_banners/_ad_banner_tab.html.erb index 7bba88c6..001726f4 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -12,8 +12,8 @@
<%= render :partial => "ad_image_update", :collection => ad_banner_tab.ad_images,:as => :ad_image,:locals=>{:ad_banner => ad_banner_tab} %> <%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %> - <%= link_to 'Add AdImage',new_admin_ad_banner_ad_image_path(ad_banner_tab) %> - <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%> + <%= link_to t("admin.ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%> + <%= link_to t("modal.preview"), realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger btn btn-success'%>
<% end -%> diff --git a/app/views/admin/ad_banners/_ad_image_update.html.erb b/app/views/admin/ad_banners/_ad_image_update.html.erb index 34723b7e..583c3316 100644 --- a/app/views/admin/ad_banners/_ad_image_update.html.erb +++ b/app/views/admin/ad_banners/_ad_image_update.html.erb @@ -5,8 +5,8 @@ <%= "#{ad_image.post_date ||'NeedReset' }~#{ad_image.unpost_date || 'NeedReset'}" %>

- <%= link_to 'Edit',edit_admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn btn-primary' %> - <%= link_to 'Del',admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn',:method => :delete,:confirm => t('sure?') %> + <%= link_to t('edit'),edit_admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn btn-primary' %> + <%= link_to t('delete'),admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn',:method => :delete,:confirm => t('sure?') %>

diff --git a/app/views/admin/ad_banners/_preview_block.html.erb b/app/views/admin/ad_banners/_preview_block.html.erb index c2185d04..f71b3cd3 100644 --- a/app/views/admin/ad_banners/_preview_block.html.erb +++ b/app/views/admin/ad_banners/_preview_block.html.erb @@ -23,7 +23,7 @@ diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 03b11b18..21dca2a0 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -4,6 +4,8 @@ <% content_for :page_specific_javascript do %> <%= javascript_include_tag "lib/datepicker" %> <%= javascript_include_tag "lib/date.format" %> + <%= javascript_include_tag "inc/modal-preview" %> + <% end %> @@ -184,5 +186,10 @@ +
+ <%= link_to t("modal.preview"), realtime_preview_admin_ad_banner_path(@ad_image.ad_banner) ,:class=>"preview_trigger btn btn-success" rescue nil%> + + +
\ No newline at end of file diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 38380984..84d89ac4 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -32,9 +32,9 @@ <%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.ad_banner'), admin_ad_banners_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('ad_banners', 'ad_images')) do -%> - <%= content_tag :li, link_to(t('admin.all_ad_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> - <%= content_tag :li, link_to(t('admin.new_ad_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> - <%= content_tag :li, link_to(t('admin.new_ad_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> + <%= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> + <%= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> + <%= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 2716588a..0d440e83 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,13 +26,13 @@ Orbit::Application.routes.draw do resources :ad_banners do - member do - match 'preivew' => 'ad_banners#realtime_preview',:as => :realtime_preview,:via => :put - end collection do match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post end + member do + match 'preivew' => 'ad_banners#realtime_preview',:as => :realtime_preview,:via => :put + end resources :ad_images ,:except => [:show,:index] end resources :dashboards