app/controllers/refinery/admin/images_controller.rb in refinerycms-images-2.0.10 vs app/controllers/refinery/admin/images_controller.rb in refinerycms-images-2.1.0
- old
+ new
@@ -27,11 +27,11 @@
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?))
+ find_all_images(({extra_condition[0] => extra_condition[1]} if extra_condition.present?))
search_all_images if searching?
paginate_images
render :action => "insert"
@@ -68,13 +68,50 @@
else
# if all uploaded images are ok redirect page back to dialog, else show current page with error
if @images.all?(&:valid?)
@image_id = @image.id if @image.persisted?
@image = nil
+ end
- self.insert
+ self.insert
+ end
+ end
+
+ def update
+ attributes_before_assignment = @image.attributes
+ @image.attributes = params[:image]
+ if @image.valid? && @image.save
+ flash.notice = t(
+ 'refinery.crudify.updated',
+ :what => "'#{@image.title}'"
+ )
+
+ unless from_dialog?
+ unless params[:continue_editing] =~ /true|on|1/
+ redirect_back_or_default refinery.admin_images_path
+ else
+ unless request.xhr?
+ redirect_to :back
+ else
+ render :partial => '/refinery/message'
+ end
+ end
+ else
+ self.index
+ @dialog_successful = true
+ render :index
end
+ else
+ @thumbnail = Image.find params[:id]
+ unless request.xhr?
+ render :action => 'edit'
+ else
+ render :partial => '/refinery/admin/error_messages', :locals => {
+ :object => @image,
+ :include_object_name => true
+ }
+ end
end
end
protected
@@ -82,10 +119,11 @@
@app_dialog = params[:app_dialog].present?
@field = params[:field]
@update_image = params[:update_image]
@thumbnail = params[:thumbnail]
@callback = params[:callback]
+ @multiple = params[:multiple]
@conditions = params[:conditions]
end
def change_list_mode_if_specified
if action_name == 'index' && params[:view].present? && Refinery::Images.image_views.include?(params[:view].to_sym)
@@ -97,13 +135,9 @@
@images = @images.paginate(:page => params[:page], :per_page => Image.per_page(from_dialog?, !@app_dialog))
end
def restrict_controller
super unless action_name == 'insert'
- end
-
- def store_current_location!
- super unless action_name == 'insert' or from_dialog?
end
end
end
end