From 7c64e8c637fb347a331647ee854612f32d0459d5 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Fri, 9 Aug 2013 09:24:26 +0800 Subject: [PATCH] Updated AdBanner index page and Ad Image index page, and edit pages Conflicts: vendor/built_in_modules/ad_banner/config/locales/en.yml vendor/built_in_modules/ad_banner/init.rb --- app/controllers/admin/ad_images_controller.rb | 39 +++++---- app/views/admin/ad_banners/_edit.html.erb | 25 ++++++ app/views/admin/ad_banners/_index.html.erb | 41 ++++++++++ app/views/admin/ad_banners/edit.html.erb | 26 +----- app/views/admin/ad_banners/edit.js.erb | 1 + app/views/admin/ad_banners/index.html.erb | 56 ++----------- app/views/admin/ad_banners/index.js.erb | 3 + app/views/admin/ad_images/edit.html.erb | 2 +- app/views/admin/ad_images/index.html.erb | 81 ++++++++++--------- app/views/admin/ad_images/new.html.erb | 3 +- config/routes.rb | 18 +++-- .../ad_banner/config/locales/en.yml | 8 +- .../ad_banner/config/locales/zh_tw.yml | 8 +- vendor/built_in_modules/ad_banner/init.rb | 25 +++--- 14 files changed, 180 insertions(+), 156 deletions(-) create mode 100644 app/views/admin/ad_banners/_edit.html.erb create mode 100644 app/views/admin/ad_banners/_index.html.erb create mode 100644 app/views/admin/ad_banners/edit.js.erb create mode 100644 app/views/admin/ad_banners/index.js.erb diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index 78caf3aa..2571fcaa 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -10,28 +10,27 @@ class Admin::AdImagesController < Admin::AdBannersController end def index - @ad_banner = AdBanner.find params[:ad_banner_id] - @ad_images = @ad_banner.ad_images.all.page(params[:page]).per(10) + #@ad_banner = AdBanner.find params[:ad_banner_id] + #@ad_images = @ad_banner.ad_images.all.page(params[:page]).per(10) + @ad_images = AdImage.all.page(params[:page]).per(10) end def edit - @ad_banner = AdBanner.find params[:ad_banner_id] - @ad_image = @ad_banner.ad_images.find params[:id] + #@ad_banner = AdBanner.find params[:ad_banner_id] + @ad_image = AdImage.find(params[:id]) @tags = get_tags end def update - @ad_banner = AdBanner.find params[:ad_banner_id] - @ad_image = AdImage.find params[:id] + @ad_image = AdImage.find(params[:id]) @ad_image.update_attributes(params[:ad_image]) - @ad_image.to_save = true - @ad_image.save! - redirect_to admin_ad_banner_path @ad_banner + redirect_to admin_ad_images_path end def new - ad_banner = AdBanner.find params[:ad_banner_id] - @ad_image =ad_banner.ad_images.build + #ad_banner = AdBanner.find params[:ad_banner_id] + #@ad_image =ad_banner.ad_images.build + @ad_image = AdImage.new @ad_image.post_date = Date.today @ad_image.unpost_date = Date.today + 30 @tags = get_tags @@ -39,23 +38,23 @@ class Admin::AdImagesController < Admin::AdBannersController end def create - @ad_banner = AdBanner.find params[:ad_banner][:id] - ad_image = AdImage.new params[:ad_image] - ad_image.to_save = true - @ad_banner.ad_images << ad_image + # @ad_banner = AdBanner.find params[:ad_banner][:id] + @ad_image = AdImage.new params[:ad_image] + #@ad_image.to_save = true + #@ad_banner.ad_images << ad_image - if @ad_banner.save! - redirect_to admin_ad_banner_path @ad_banner + if @ad_image.save + redirect_to admin_ad_images_path end end def destroy - @ad_banner = AdBanner.find params[:ad_banner_id] - @ad_image = @ad_banner.ad_images.find params[:id] + #@ad_banner = AdBanner.find params[:ad_banner_id] + @ad_image = AdImage.find params[:id] if @ad_image.destroy flash[:notice] = t('ad.success_destroy_ad_image') - redirect_to admin_ad_banner_path @ad_banner + redirect_to admin_ad_images_path end end diff --git a/app/views/admin/ad_banners/_edit.html.erb b/app/views/admin/ad_banners/_edit.html.erb new file mode 100644 index 00000000..88e88231 --- /dev/null +++ b/app/views/admin/ad_banners/_edit.html.erb @@ -0,0 +1,25 @@ +
+ <%= form_for(:ad_banner, :url => admin_ad_banner_path(:ad_banner), :remote => true) do |f| %> +
+ Ad Banner + + <%= f.text_field :title, :class=>"input-large", :placeholder=>"Banner Name" %> + Banner Name only english + + <%= f.text_field :transition_sec, :class => 'input-large', :placeholder => 'Time' %> + Please enter the number of seconds + + <%= f.text_field :best_size, :class=>"input-large", :placeholder=>"Banner Size" %> + Best Size EX:120x30 + + <%= f.select :ad_fx ,AdBanner::FX_TYPES %> +
+ <%= image_tag "slideshow_preview_A.png", :width=>220 %> + <%= image_tag "slideshow_preview_B.png", :width=>220 %> +
+ Effect + <%= t(:cancel) %> +<%= f.submit t(:create_), class: 'btn btn-primary btn-small' %> +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/admin/ad_banners/_index.html.erb b/app/views/admin/ad_banners/_index.html.erb new file mode 100644 index 00000000..c6072cfe --- /dev/null +++ b/app/views/admin/ad_banners/_index.html.erb @@ -0,0 +1,41 @@ + + + + + + + + + + <% @ad_banners.each do |ad_banner| %> + + + + + + <% end %> + +
<%= t('ad_banner.title') %><%= t('ad_banner.transition_msec') %><%= t('ad_banner.ad_fx') %>
<%= ad_banner.title %> +
+ +
+
<%= ad_banner.transition_msec %><%= ad_banner.ad_fx%>
+<%if is_manager? %> + +
+
+ <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add_new), "#add-banner", :class => "btn btn-primary open-slide"%> +
+
+ + + +<% end %> diff --git a/app/views/admin/ad_banners/edit.html.erb b/app/views/admin/ad_banners/edit.html.erb index a74ab0ab..5f11ce38 100644 --- a/app/views/admin/ad_banners/edit.html.erb +++ b/app/views/admin/ad_banners/edit.html.erb @@ -1,25 +1 @@ -
- <%= form_for(:ad_banner, :url => admin_ad_banners_path, :remote => true) do |f| %> -
- Ad Banner - - <%= f.text_field :title, :class=>"input-large", :placeholder=>"Banner Name" %> - Banner Name only english - - <%= f.text_field :transition_sec, :class => 'input-large', :placeholder => 'Time' %> - Please enter the number of seconds - - <%= f.text_field :best_size, :class=>"input-large", :placeholder=>"Banner Size" %> - Best Size EX:120x30 - - <%= f.select :ad_fx ,AdBanner::FX_TYPES %> -
- <%= image_tag "slideshow_preview_A.png", :width=>220 %> - <%= image_tag "slideshow_preview_B.png", :width=>220 %> -
- Effect - <%= t(:cancel) %> -<%= f.submit t(:create_), class: 'btn btn-primary btn-small' %> -
- <% end %> -
\ No newline at end of file +<%= render 'edit'%> \ No newline at end of file diff --git a/app/views/admin/ad_banners/edit.js.erb b/app/views/admin/ad_banners/edit.js.erb new file mode 100644 index 00000000..30d88e18 --- /dev/null +++ b/app/views/admin/ad_banners/edit.js.erb @@ -0,0 +1 @@ +$('#view-page .content').html("<%= j render 'edit' %>"); \ No newline at end of file diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index 5a27d13f..cf8c645e 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -1,51 +1,9 @@ -<% set_default_index do -objects @ad_banners - - -quick_edit_link type: 'edit', -link: 'edit_admin_ad_banner_path' -quick_edit_link type: 'detail' -quick_edit_link type: "add image", -link: 'new_admin_ad_banner_ad_image_path' -quick_edit_link type: "Images", -link: 'admin_ad_banner_ad_images_path' - -field type: 'field', -db_field: 'title', -translation: 'title', -sort: 'title', -link: 'admin_ad_banner_path', -quick_edit: true, -header_class: 'span5' - -field type: 'field', -db_field: 'ad_fx', -translation: 'ad_fx', -sort: 'ad_fx', -link: 'admin_ad_banner_path', -quick_edit: true, -header_class: 'span5' - -field db_field: 'best_size', -translation: 'best_size', -header_class: 'span5' - - -filter_field type: 'objects', -values: @tags, -translation: 'tags', -object_field: 'name' - -end %> -<%= render 'admin/default_index/index' %> - - -
-
- <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add_new), "#add-banner", :class => "btn btn-primary open-slide"%> +<% content_for :right_nav do %> +
+
-
+<% end %> - +
+ <%= render 'index' %> +
\ No newline at end of file diff --git a/app/views/admin/ad_banners/index.js.erb b/app/views/admin/ad_banners/index.js.erb new file mode 100644 index 00000000..641d1fa7 --- /dev/null +++ b/app/views/admin/ad_banners/index.js.erb @@ -0,0 +1,3 @@ +$("#categories_index").html("<%= j render 'index' %>") +$.pageslide.close(); +openSlide(); \ No newline at end of file diff --git a/app/views/admin/ad_images/edit.html.erb b/app/views/admin/ad_images/edit.html.erb index 5fbf198c..a3852f4f 100644 --- a/app/views/admin/ad_images/edit.html.erb +++ b/app/views/admin/ad_images/edit.html.erb @@ -1,6 +1,6 @@ <%= flash_messages %> -<%= form_for @ad_image, :url => admin_ad_banner_ad_image_path, :html => { :class => 'form' } do |f| %> +<%= form_for @ad_image, :url => admin_ad_image_path, :html => { :class => 'form' } do |f| %> <%= render :partial => "form", :locals => { :f => f } %> diff --git a/app/views/admin/ad_images/index.html.erb b/app/views/admin/ad_images/index.html.erb index 565ccfc1..4222a281 100644 --- a/app/views/admin/ad_images/index.html.erb +++ b/app/views/admin/ad_images/index.html.erb @@ -1,39 +1,48 @@ -<% set_default_index do -objects @ad_images + + + + + + + + + + + + <% @ad_images.each do |ad_image| %> + + + + + + + + <% end %> + +
<%= t('ad_image.image') %><%= t('ad_image.post_date') %><%= t('ad_image.unpost_date') %><%= t('ad_image.context') %><%= t('ad_image.out_link') %>
<%= image_tag ad_image.file.thumb %> +
+ +
+
<%= ad_image.post_date %><%= ad_image.unpost_date %><%= ad_image.context %><%=link_to "#{ad_image.out_link}", ad_image.out_link %>
+<%if is_manager? %> + +
+
+ <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add_new), "#add-banner", :class => "btn btn-primary open-slide"%> +
+ +
-field db_field: 'file', -translation: 'image' + -field db_field: 'post_date', - translation: 'start_date', - hide: 'phone', - sort: 'start_date' - -field db_field: 'unpost_date', - translation: 'end_date', - hide: 'phone', - sort: 'end_date' - -field db_field: 'unpost_date', - translation: 'end_date', - hide: 'phone', - sort: 'end_date' - -field db_field: 'context', - translation: 'content', - hide: 'phone' - -field db_field: 'out_link', - translation: 'link', - hide: 'phone' - -footer link: 'new_admin_ad_banner_ad_image_path' - -end %> -<%= render 'admin/default_index/index' %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/ad_images/new.html.erb b/app/views/admin/ad_images/new.html.erb index 99379faa..e6345f06 100644 --- a/app/views/admin/ad_images/new.html.erb +++ b/app/views/admin/ad_images/new.html.erb @@ -1,6 +1,5 @@ <%= flash_messages %> - -<%= form_for @ad_image, :url => create_ad_image_admin_ad_banners_path, :html => { :class => 'form' ,:multipart => true} do |f| %> +<%= form_for @ad_image, :url => admin_create_ad_image_path, :html => { :class => 'form' ,:multipart => true} do |f| %> <%= render :partial => "form", :locals => { :f => f } %> diff --git a/config/routes.rb b/config/routes.rb index caf5e2d7..ea57ffb6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -45,13 +45,17 @@ Orbit::Application.routes.draw do match 'ad_banners/:id/preview' => 'ad_banners#realtime_preview',:as => :realtime_preview_ad_banner,:via => :put match 'ad_banners/:id/rename' => 'ad_banners#rename',:as => :rename_ad_banner,:via => :post - resources :ad_banners do - 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 - resources :ad_images ,:except => [:show] - end + 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 + resources :ad_images ,:except => [:show] + + resources :ad_banners #do + # 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 + # resources :ad_images ,:except => [:show] + #end match 'authorizations/add_roles/:module(/:type(/:id))' => 'authorizations#add_roles', :as => :add_roles_authorizations match 'authorizations/add_users/:module(/:type(/:id))' => 'authorizations#add_users', :as => :add_users_authorizations diff --git a/vendor/built_in_modules/ad_banner/config/locales/en.yml b/vendor/built_in_modules/ad_banner/config/locales/en.yml index 09482d11..45ad11d6 100644 --- a/vendor/built_in_modules/ad_banner/config/locales/en.yml +++ b/vendor/built_in_modules/ad_banner/config/locales/en.yml @@ -1,4 +1,8 @@ en: - module_name: - ad_banner: Ad Banner \ No newline at end of file + ad_banner: + ad_banner: Ad Banner + banner: Banner + all: All + categories: Categories + add: Add \ No newline at end of file diff --git a/vendor/built_in_modules/ad_banner/config/locales/zh_tw.yml b/vendor/built_in_modules/ad_banner/config/locales/zh_tw.yml index 72c778cd..86426ff4 100644 --- a/vendor/built_in_modules/ad_banner/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/ad_banner/config/locales/zh_tw.yml @@ -1,4 +1,8 @@ zh_tw: - module_name: - ad_banner: 廣告輪播 \ No newline at end of file + ad_banner: + ad_banner: 廣告輪播 + banner: 橫幅 + all: 全部 + categories: 類別 + add: 新增 diff --git a/vendor/built_in_modules/ad_banner/init.rb b/vendor/built_in_modules/ad_banner/init.rb index 24034416..12fd9f81 100644 --- a/vendor/built_in_modules/ad_banner/init.rb +++ b/vendor/built_in_modules/ad_banner/init.rb @@ -42,23 +42,24 @@ module AdBanner head_link_path "admin_ad_banners_path" - context_link 'ad_banner.banner', - :link_path=>"admin_ad_banners_path" , + context_link 'ad_banner.all', + :link_path=>"admin_ad_images_path" , :priority=>1, :active_for_action=>{'admin/ad_banners'=>:index}, :available_for => [:manager] - - context_link 'tags', - :link_path=>"admin_module_tags_path(module_app_id: get_module_app)" , - :priority=>4, - :active_for_tag => 'Announcement', + + context_link 'ad_banner.add', + :link_path=>"new_admin_ad_image_path" , + :priority=>1, + :active_for_action=>{'admin/ad_banners'=>:index}, :available_for => [:manager] - context_link 'module_authorization', - :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'AdBanner'}))", - :priority=>6, - :active_for_app_auth => 'ad_banners', - :available_for => [:admin] + context_link 'ad_banner.banner', + :link_path=>"admin_ad_banners_path" , + :priority=>3, + :active_for_action=>{'admin/ad_banners'=>:index}, + :available_for => [:manager] + end end end