Class: Admin::ImagesController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::ImagesController
- Includes:
- ImagesHelper
- Defined in:
- app/controllers/admin/images_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#insert ⇒ Object
This renders the image insert dialog.
- #new ⇒ Object
Methods included from ImagesHelper
#change_list_mode_if_specified, #current_image_view, #image_views, #images_paginator, #other_image_views
Instance Method Details
#create ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/admin/images_controller.rb', line 41 def create @images = [] begin unless params[:image].present? and params[:image][:image].is_a?(Array) @images << (@image = Image.create(params[:image])) else params[:image][:image].each do |image| @images << (@image = Image.create(:image => image)) end end rescue Dragonfly::FunctionManager::UnableToHandle logger.warn($!.) @image = Image.new end unless params[:insert] if @images.all?{|i| i.valid?} flash.notice = t('created', :scope => 'refinery.crudify', :what => "'#{@images.collect{|i| i.title}.join("', '")}'") unless from_dialog? redirect_to :action => 'index' else render :text => "<script>parent.window.location = '#{admin_images_url}';</script>" end else self.new # important for dialogs render :action => 'new' end else # if all uploaded images are ok redirect page back to dialog, else show current page with error if @images.all?{|i| i.valid?} @image_id = @image.id if @image.persisted? @image = nil redirect_to request.query_parameters.merge(:action => 'insert') else self.insert end end end |
#insert ⇒ Object
This renders the image insert dialog
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/admin/images_controller.rb', line 20 def insert self.new if @image.nil? @url_override = admin_images_path(request.query_parameters.merge(:insert => true)) if params[:conditions].present? extra_condition = params[:conditions].split(',') extra_condition[1] = true if extra_condition[1] == "true" extra_condition[1] = false if extra_condition[1] == "false" extra_condition[1] = nil if extra_condition[1] == "nil" end find_all_images(({extra_condition[0].to_sym => extra_condition[1]} if extra_condition.present?)) search_all_images if searching? paginate_images render :action => "insert" end |
#new ⇒ Object
13 14 15 16 17 |
# File 'app/controllers/admin/images_controller.rb', line 13 def new @image = Image.new if @image.nil? @url_override = admin_images_path(:dialog => from_dialog?) end |