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
This commit is contained in:
saurabhbhatia 2013-08-09 09:24:26 +08:00
parent e14cb3c74c
commit 7c64e8c637
14 changed files with 180 additions and 156 deletions

View File

@ -10,28 +10,27 @@ class Admin::AdImagesController < Admin::AdBannersController
end end
def index def index
@ad_banner = AdBanner.find params[:ad_banner_id] #@ad_banner = AdBanner.find params[:ad_banner_id]
@ad_images = @ad_banner.ad_images.all.page(params[:page]).per(10) #@ad_images = @ad_banner.ad_images.all.page(params[:page]).per(10)
@ad_images = AdImage.all.page(params[:page]).per(10)
end end
def edit def edit
@ad_banner = AdBanner.find params[:ad_banner_id] #@ad_banner = AdBanner.find params[:ad_banner_id]
@ad_image = @ad_banner.ad_images.find params[:id] @ad_image = AdImage.find(params[:id])
@tags = get_tags @tags = get_tags
end end
def update 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.update_attributes(params[:ad_image])
@ad_image.to_save = true redirect_to admin_ad_images_path
@ad_image.save!
redirect_to admin_ad_banner_path @ad_banner
end end
def new def new
ad_banner = AdBanner.find params[:ad_banner_id] #ad_banner = AdBanner.find params[:ad_banner_id]
@ad_image =ad_banner.ad_images.build #@ad_image =ad_banner.ad_images.build
@ad_image = AdImage.new
@ad_image.post_date = Date.today @ad_image.post_date = Date.today
@ad_image.unpost_date = Date.today + 30 @ad_image.unpost_date = Date.today + 30
@tags = get_tags @tags = get_tags
@ -39,23 +38,23 @@ class Admin::AdImagesController < Admin::AdBannersController
end end
def create def create
@ad_banner = AdBanner.find params[:ad_banner][:id] # @ad_banner = AdBanner.find params[:ad_banner][:id]
ad_image = AdImage.new params[:ad_image] @ad_image = AdImage.new params[:ad_image]
ad_image.to_save = true #@ad_image.to_save = true
@ad_banner.ad_images << ad_image #@ad_banner.ad_images << ad_image
if @ad_banner.save! if @ad_image.save
redirect_to admin_ad_banner_path @ad_banner redirect_to admin_ad_images_path
end end
end end
def destroy def destroy
@ad_banner = AdBanner.find params[:ad_banner_id] #@ad_banner = AdBanner.find params[:ad_banner_id]
@ad_image = @ad_banner.ad_images.find params[:id] @ad_image = AdImage.find params[:id]
if @ad_image.destroy if @ad_image.destroy
flash[:notice] = t('ad.success_destroy_ad_image') flash[:notice] = t('ad.success_destroy_ad_image')
redirect_to admin_ad_banner_path @ad_banner redirect_to admin_ad_images_path
end end
end end

View File

@ -0,0 +1,25 @@
<div class="content">
<%= form_for(:ad_banner, :url => admin_ad_banner_path(:ad_banner), :remote => true) do |f| %>
<fieldset>
<legend>Ad Banner</legend>
<label>Banner Name</label>
<%= f.text_field :title, :class=>"input-large", :placeholder=>"Banner Name" %>
<span class="help-block">Banner Name only english</span>
<label for="timeout">Ste</label>
<%= f.text_field :transition_sec, :class => 'input-large', :placeholder => 'Time' %>
<span class="help-block">Please enter the number of seconds</span>
<label>Best Size</label>
<%= f.text_field :best_size, :class=>"input-large", :placeholder=>"Banner Size" %>
<span class="help-block">Best Size EX:120x30 </span>
<label>Effect</label>
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
<div class="preview">
<%= image_tag "slideshow_preview_A.png", :width=>220 %>
<%= image_tag "slideshow_preview_B.png", :width=>220 %>
</div>
<span class="help-block">Effect</span>
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:create_), class: 'btn btn-primary btn-small' %>
</fieldset>
<% end %>
</div>

View File

@ -0,0 +1,41 @@
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t('ad_banner.title') %></th>
<th class="span1"><%= t('ad_banner.transition_msec') %></th>
<th class="span1"><%= t('ad_banner.ad_fx') %></th>
</tr>
</thead>
<tbody id="tbody_locations" class="sort-holder">
<% @ad_banners.each do |ad_banner| %>
<tr class="with_action">
<td><%= ad_banner.title %>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if is_admin?%>
<li><%= link_to t(:edit), edit_admin_ad_banner_path(ad_banner)%></li>
<li><%= link_to 'Destroy', admin_ad_banner_path(ad_banner), method: :delete , :confirm => t(:sure?) %></li>
<% end %>
</ul>
</div>
</td>
<td><%= ad_banner.transition_msec %></td>
<td><%= ad_banner.ad_fx%></td>
</tr>
<% end %>
</tbody>
</table>
<%if is_manager? %>
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add_new), "#add-banner", :class => "btn btn-primary open-slide"%>
</div>
</div>
<div id="add-banner" class="nano" style="display:none">
<%= render 'new' %>
</div>
<% end %>

View File

@ -1,25 +1 @@
<div class="content"> <%= render 'edit'%>
<%= form_for(:ad_banner, :url => admin_ad_banners_path, :remote => true) do |f| %>
<fieldset>
<legend>Ad Banner</legend>
<label>Banner Name</label>
<%= f.text_field :title, :class=>"input-large", :placeholder=>"Banner Name" %>
<span class="help-block">Banner Name only english</span>
<label for="timeout">Ste</label>
<%= f.text_field :transition_sec, :class => 'input-large', :placeholder => 'Time' %>
<span class="help-block">Please enter the number of seconds</span>
<label>Best Size</label>
<%= f.text_field :best_size, :class=>"input-large", :placeholder=>"Banner Size" %>
<span class="help-block">Best Size EX:120x30 </span>
<label>Effect</label>
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
<div class="preview">
<%= image_tag "slideshow_preview_A.png", :width=>220 %>
<%= image_tag "slideshow_preview_B.png", :width=>220 %>
</div>
<span class="help-block">Effect</span>
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:create_), class: 'btn btn-primary btn-small' %>
</fieldset>
<% end %>
</div>

View File

@ -0,0 +1 @@
$('#view-page .content').html("<%= j render 'edit' %>");

View File

@ -1,51 +1,9 @@
<% set_default_index do <% content_for :right_nav do %>
objects @ad_banners <div class="searchClear pull-right">
<input id="filter-input" class="search-query input-medium" type="text" placeholder="<%= t('search.tags') %>" value="">
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' %>
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add_new), "#add-banner", :class => "btn btn-primary open-slide"%>
</div> </div>
</div> <% end %>
<div id="add-banner" class="nano" style="display:none"> <div id="tags_index">
<%= render 'new' %> <%= render 'index' %>
</div> </div>

View File

@ -0,0 +1,3 @@
$("#categories_index").html("<%= j render 'index' %>")
$.pageslide.close();
openSlide();

View File

@ -1,6 +1,6 @@
<%= flash_messages %> <%= 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 } %> <%= render :partial => "form", :locals => { :f => f } %>

View File

@ -1,39 +1,48 @@
<% set_default_index do <table class="table main-list">
objects @ad_images <thead>
<tr>
<th class="span1"><%= t('ad_image.image') %></th>
<th class="span1"><%= t('ad_image.post_date') %></th>
<th class="span1"><%= t('ad_image.unpost_date') %></th>
<th class="span1"><%= t('ad_image.context') %></th>
<th class="span1"><%= t('ad_image.out_link') %></th>
</tr>
</thead>
<tbody id="tbody_locations" class="sort-holder">
<% @ad_images.each do |ad_image| %>
<tr class="with_action">
<td><%= image_tag ad_image.file.thumb %>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if is_admin?%>
<li><%= link_to t(:edit), edit_admin_ad_image_path(ad_image)%></li>
<li><%= link_to 'Destroy', admin_ad_image_path(ad_image), method: :delete , :confirm => t(:sure?) %></li>
quick_edit_link type: 'edit', <% end %>
link: 'edit_admin_ad_banner_ad_image_path' </ul>
quick_edit_link type: 'detail' </div>
quick_edit_link type: 'delete', </td>
link: 'admin_ad_banner_ad_image_path' <td><%= ad_image.post_date %></td>
<td><%= ad_image.unpost_date %></td>
<td><%= ad_image.context %></td>
<td><%=link_to "#{ad_image.out_link}", ad_image.out_link %></td>
</tr>
<% end %>
</tbody>
</table>
<%if is_manager? %>
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add_new), "#add-banner", :class => "btn btn-primary open-slide"%>
</div>
<div class="pagination pagination-centered">
<%= paginate @ad_images unless @ad_images.blank? %>
</div>
</div>
field db_field: 'file', <div id="add-banner" class="nano" style="display:none">
translation: 'image' <%= render 'new' %>
</div>
field db_field: 'post_date', <% end %>
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' %>

View File

@ -1,6 +1,5 @@
<%= flash_messages %> <%= flash_messages %>
<%= form_for @ad_image, :url => admin_create_ad_image_path, :html => { :class => 'form' ,:multipart => true} do |f| %>
<%= form_for @ad_image, :url => create_ad_image_admin_ad_banners_path, :html => { :class => 'form' ,:multipart => true} do |f| %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>

View File

@ -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/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 match 'ad_banners/:id/rename' => 'ad_banners#rename',:as => :rename_ad_banner,:via => :post
resources :ad_banners do match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get
collection do match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post
match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get resources :ad_images ,:except => [:show]
match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post
end resources :ad_banners #do
resources :ad_images ,:except => [:show] # collection do
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
# end
# resources :ad_images ,:except => [:show]
#end
match 'authorizations/add_roles/:module(/:type(/:id))' => 'authorizations#add_roles', :as => :add_roles_authorizations 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 match 'authorizations/add_users/:module(/:type(/:id))' => 'authorizations#add_users', :as => :add_users_authorizations

View File

@ -1,4 +1,8 @@
en: en:
module_name: ad_banner:
ad_banner: Ad Banner ad_banner: Ad Banner
banner: Banner
all: All
categories: Categories
add: Add

View File

@ -1,4 +1,8 @@
zh_tw: zh_tw:
module_name: ad_banner:
ad_banner: 廣告輪播 ad_banner: 廣告輪播
banner: 橫幅
all: 全部
categories: 類別
add: 新增

View File

@ -42,23 +42,24 @@ module AdBanner
head_link_path "admin_ad_banners_path" head_link_path "admin_ad_banners_path"
context_link 'ad_banner.banner', context_link 'ad_banner.all',
:link_path=>"admin_ad_banners_path" , :link_path=>"admin_ad_images_path" ,
:priority=>1, :priority=>1,
:active_for_action=>{'admin/ad_banners'=>:index}, :active_for_action=>{'admin/ad_banners'=>:index},
:available_for => [:manager] :available_for => [:manager]
context_link 'tags', context_link 'ad_banner.add',
:link_path=>"admin_module_tags_path(module_app_id: get_module_app)" , :link_path=>"new_admin_ad_image_path" ,
:priority=>4, :priority=>1,
:active_for_tag => 'Announcement', :active_for_action=>{'admin/ad_banners'=>:index},
:available_for => [:manager]
context_link 'ad_banner.banner',
:link_path=>"admin_ad_banners_path" ,
:priority=>3,
:active_for_action=>{'admin/ad_banners'=>:index},
:available_for => [:manager] :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]
end end
end end
end end