From a2e9aa2e0bb2f682d41e8e08f4f341c69355c8cd Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Mon, 5 Aug 2013 18:30:35 +0800 Subject: [PATCH] Updated ADBanner with fixes on index page, ADImage with fixes Conflicts: app/views/admin/ad_banners/index.html.erb app/views/admin/ad_images/_form.html.erb vendor/built_in_modules/ad_banner/init.rb --- .../javascripts/lib/jquery.pageslide.js | 2 +- .../admin/ad_banners_controller.rb | 20 +- app/controllers/admin/ad_images_controller.rb | 7 + app/models/ad_banner.rb | 1 + app/models/ad_image.rb | 1 + app/views/admin/ad_banners/_new.html.erb | 25 ++ app/views/admin/ad_banners/edit.html.erb | 25 ++ app/views/admin/ad_banners/index.html.erb | 79 ++-- app/views/admin/ad_banners/new.html.erb | 1 + app/views/admin/ad_banners/new.js.erb | 1 + app/views/admin/ad_images/_form.html.erb | 361 ++++++++++++------ app/views/admin/ad_images/index.html.erb | 31 ++ config/routes.rb | 2 +- vendor/built_in_modules/ad_banner/init.rb | 15 +- 14 files changed, 414 insertions(+), 157 deletions(-) create mode 100644 app/views/admin/ad_banners/_new.html.erb create mode 100644 app/views/admin/ad_banners/edit.html.erb create mode 100644 app/views/admin/ad_banners/new.js.erb create mode 100644 app/views/admin/ad_images/index.html.erb diff --git a/app/assets/javascripts/lib/jquery.pageslide.js b/app/assets/javascripts/lib/jquery.pageslide.js index e9b049bb4..2455bb514 100644 --- a/app/assets/javascripts/lib/jquery.pageslide.js +++ b/app/assets/javascripts/lib/jquery.pageslide.js @@ -242,7 +242,7 @@ bodyAnimateIn['margin-left'] = '-=' + slideWidth; slideAnimateIn['left'] = '-=' + slideWidth; if($pageslide.find('.preview').length) { - $pageslide.find('.preview').cycle('destroy'); + // $pageslide.find('.preview').cycle('destroy'); $pageslide.find('.preview img').removeAttr('style'); } break; diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index cae3f19c7..37ac3fac6 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -1,10 +1,10 @@ class Admin::AdBannersController < OrbitBackendController - before_filter :force_order_for_visitor,:only=>[:index] - before_filter :force_order_for_user,:except => [:index] - before_filter :for_app_sub_manager,:except => [:index] + before_filter :force_order_for_visitor,:only=>[:index, :show] + before_filter :force_order_for_user,:except => [:index, :show] + before_filter :for_app_sub_manager,:except => [:index, :show] before_filter :for_app_manager,:except => [:index,:show,:update,:realtime_preview] - + def rename @ad_banner = AdBanner.find(params[:id]) @@ -24,17 +24,18 @@ class Admin::AdBannersController < OrbitBackendController end def new - @ad_banners = AdBanner.all - render :action => 'index',:params => 'new' + @ad_banner = AdBanner.new + render layout: false end def create @ad_banner = AdBanner.new(params[:ad_banner]) if @ad_banner.save @active = @ad_banner - respond_to do |format| - format.js {render 'new_created_node'} - end + redirect_to admin_ad_banners_url + #respond_to do |format| + # format.js {render 'new_created_node'} + #end else render 'create_error_msg' end @@ -42,7 +43,6 @@ class Admin::AdBannersController < OrbitBackendController def edit @ad_banner = AdBanner.find(params[:id]) - end def update diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index fc25c5d51..78caf3aa5 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -9,9 +9,15 @@ class Admin::AdImagesController < Admin::AdBannersController @app_title = "ad_banner" end + def index + @ad_banner = AdBanner.find params[:ad_banner_id] + @ad_images = @ad_banner.ad_images.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] + @tags = get_tags end def update @@ -28,6 +34,7 @@ class Admin::AdImagesController < Admin::AdBannersController @ad_image =ad_banner.ad_images.build @ad_image.post_date = Date.today @ad_image.unpost_date = Date.today + 30 + @tags = get_tags #render :action => 'new',:url=> {:ad_banner_id => params.has_key?(:ad_banner_id)? params[:ad_banner_id],nil} end diff --git a/app/models/ad_banner.rb b/app/models/ad_banner.rb index dcae4aea9..b5b275dc7 100644 --- a/app/models/ad_banner.rb +++ b/app/models/ad_banner.rb @@ -3,6 +3,7 @@ class AdBanner include Mongoid::Timestamps include Mongoid::MultiParameterAttributes include OrbitCoreLib::ObjectAuthable + include OrbitTag::Taggable field :title field :transition_msec,type: Integer diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index 4d5227c98..ac34a5959 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -1,6 +1,7 @@ class AdImage include Mongoid::Document include Mongoid::Timestamps + include OrbitTag::Taggable mount_uploader :file, ImageUploader diff --git a/app/views/admin/ad_banners/_new.html.erb b/app/views/admin/ad_banners/_new.html.erb new file mode 100644 index 000000000..e8d0ba138 --- /dev/null +++ b/app/views/admin/ad_banners/_new.html.erb @@ -0,0 +1,25 @@ +
+ <%= form_for(:ad_banner, :url => admin_ad_banners_path) 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/edit.html.erb b/app/views/admin/ad_banners/edit.html.erb new file mode 100644 index 000000000..a74ab0ab8 --- /dev/null +++ b/app/views/admin/ad_banners/edit.html.erb @@ -0,0 +1,25 @@ +
+ <%= 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 diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index 9b2550d55..5a27d13f1 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -1,34 +1,51 @@ -<% content_for :page_specific_css do -%> - <%#= stylesheet_link_tag "admin/ad_banner_preview" %> -<% end -%> -<% content_for :page_specific_javascript do -%> - <%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> - <%= javascript_include_tag "inc/modal-preview" %> - <%= javascript_include_tag "lib/contenteditable" %> - -<% end -%> +<% set_default_index do +objects @ad_banners -
- - -
- <%= render :partial => 'ad_banner_tab',:collection => @ad_banners %> -
- <%= render :partial => "modal_ad_banner_form"%> - +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"%> +
+
+ + diff --git a/app/views/admin/ad_banners/new.html.erb b/app/views/admin/ad_banners/new.html.erb index e69de29bb..e3355a939 100644 --- a/app/views/admin/ad_banners/new.html.erb +++ b/app/views/admin/ad_banners/new.html.erb @@ -0,0 +1 @@ +<%= render 'new' %> \ No newline at end of file diff --git a/app/views/admin/ad_banners/new.js.erb b/app/views/admin/ad_banners/new.js.erb new file mode 100644 index 000000000..5ecf8f163 --- /dev/null +++ b/app/views/admin/ad_banners/new.js.erb @@ -0,0 +1 @@ +$('#view-page .content').html("<%= j render 'new' %>"); \ No newline at end of file diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 884c08c0a..a65f06af6 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -1,121 +1,256 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> <% content_for :page_specific_javascript do %> - <%= javascript_include_tag "inc/modal-preview" %> - <%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> - <%= javascript_include_tag "inc/jquery.imagesloaded.js" %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/modal-preview" %> + <%= javascript_include_tag "lib/file-type" %> <% end %> + +
+
-
- - -
-
-
- -
-

<%= t(:date_) %>

-
- <%= f.datetime_picker :post_date, :picker_type => 'date', :label => t(:start_date) %> - <%= f.datetime_picker :unpost_date, :picker_type => 'date', :label => t(:end_date) %> -
-
- -
-
- + + +
+ + + + + + +
+ + +
+ + +
+ +
+ <%= select_tag 'ad_banner[id]',options_from_collection_for_select(AdBanner.all, "id", "title",params[:ad_banner_id]) , :class=>"input-medium" %> +
+
+ + + +
+ +
+ <%= f.datetime_picker :post_date, :no_label => true %> +
+
+ + +
+ +
+ <%= f.datetime_picker :unpost_date, :no_label => true %> +
+
+ +
+ + +
+ + +
+ +
+ + + +
+
+ +
+ +
+ + +
+ +
+ <% @tags.each do |tag| %> + + <% end %>
-

<%= t(:picture) %>

-
-
-
- - <%= image_tag @ad_image.file rescue ''%> +
+ +
+ + +
+ + +
+ +
+ <%= f.select :link_open ,AdImage::LINK_OPEN_TYPES%> +
+
+ +
+ + +
+ + +
+ +
+ <%= f.text_field :weight ,:class=> 'span3',:placeholder=> t('ad.chinese_1') %> + Please enter the number +
+
+ +
+ + + + + +
+ + +
+ +
+ +
+
+ <% if @ad_image.file %> + <%= image_tag @ad_image.file %> + <% else %> + <%= image_tag "http://www.placehold.it/50x50/EFEFEF/AAAAAA" %> + <%end%> +
+
+ + <%= t(:select_image) %> + <%= t(:change) %> + <%= f.file_field :file %> + + <%= t(:cancel) %> +
+ +
+
+
+
+ +
+ +
+ + + + + +
+ + <% @site_valid_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+ <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@ad_image.title_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+
+ <%= f.fields_for :text_translations do |f| %> + <%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@ad_image.text_translations[locale] rescue nil) %> + <% end %>
- <% if !@ad_image.ad_banner.best_size.empty?%> - <%= t("ad.widget_info_for_ad_image_size",:best_size=> @ad_image.ad_banner.best_size) %> - - <% end -%> -
- - -
- -
-
-
-
- -
-
- -
-

<%= t(:type) %>

-
- <%= f.select :link_open ,AdImage::LINK_OPEN_TYPES%> -
-
- -
-
- -
-

<%= t(:frequency) %>

-
- <%= f.text_field :weight ,:class=> 'span3',:placeholder=> t('ad.chinese_1') %> -
-
- - +
+
-
- - -
-
- -
- <%= select_tag 'ad_banner[id]',options_from_collection_for_select(AdBanner.all, "id", "title",params[:ad_banner_id]) , :class=>"input-medium" %> - <% @site_valid_locales.each do |locale|%> - <%= content_tag :div,:class => "tab-pane #{active_when_current_locale_eq locale}",:id=>"#{locale}" do%> -
- <%= f.fields_for :title_translations do |f| %> - <%= f.text_field locale, :class=>"ad_image-title post-title", :placeholder => t('ad.chinese_3'), :value => (@ad_image.title_translations[locale] rescue nil) %> - <% end %> -
-
-
- <%= f.fields_for :context_translations, @ad_image.context do |f| %> - <%= f.text_area locale, :style => "width:100%", :class => "tinymce_textarea post-title", :value => (@ad_image.context_translations[locale] rescue nil) %> - <% end %> -
+
- <% end %> - <% end %> -
- -
-
-
- <%#= link_to t(:preview), admin_realtime_preview_ad_banner_path(@ad_image.ad_banner.title) ,:class=>"preview_trigger btn btn-success" rescue nil%> - <%= f.submit t("submit"),:class=>"btn btn-primary" %> - <%= f.submit t("cancel"),:class=>"btn ",:type => 'reset' %> -
-
- - -
+ <% end %> + + + +
+ + +
+ +
+ +
+ <%= f.submit t("submit"),:class=>"btn btn-primary" %> + <%= f.submit t("cancel"),:class=>"btn ",:type => 'reset' %> + +
+ +
+ \ No newline at end of file diff --git a/app/views/admin/ad_images/index.html.erb b/app/views/admin/ad_images/index.html.erb new file mode 100644 index 000000000..fba4a32b3 --- /dev/null +++ b/app/views/admin/ad_images/index.html.erb @@ -0,0 +1,31 @@ +<% set_default_index do +objects @ad_images + +quick_edit_link type: 'edit', +link: 'edit_admin_ad_banner_ad_image_path' +quick_edit_link type: 'detail' +quick_edit_link type: 'delete', +link: 'admin_ad_banner_ad_image_path' + +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' + +footer link: 'new_admin_ad_banner_ad_image_path' + +end %> +<%= render 'admin/default_index/index' %> diff --git a/config/routes.rb b/config/routes.rb index 5f2e8bff4..caf5e2d7d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -50,7 +50,7 @@ Orbit::Application.routes.draw 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,:index] + resources :ad_images ,:except => [:show] end match 'authorizations/add_roles/:module(/:type(/:id))' => 'authorizations#add_roles', :as => :add_roles_authorizations diff --git a/vendor/built_in_modules/ad_banner/init.rb b/vendor/built_in_modules/ad_banner/init.rb index c19c7d27c..240344168 100644 --- a/vendor/built_in_modules/ad_banner/init.rb +++ b/vendor/built_in_modules/ad_banner/init.rb @@ -10,7 +10,8 @@ module AdBanner intro "I am intro" update_info 'some update_info' - authorizable + + taggable # front_end do # app_page 'bulletins' @@ -41,6 +42,18 @@ module AdBanner head_link_path "admin_ad_banners_path" + context_link 'ad_banner.banner', + :link_path=>"admin_ad_banners_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', + :available_for => [:manager] + context_link 'module_authorization', :link_path=>"admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: 'AdBanner'}))", :priority=>6,