Skip to content

Loading…

When uploading images directly from /refinery/images/new redirect back t... #1904

Merged
merged 1 commit into from

2 participants

@ugisozols
Refinery member

...o /refinery/images.

I changed the code because when I tried to upload images using direct path /refinery/images/new it would reload the same window and not redirect back to /refinery/images.

I wasn't sure about introducing refinery url helper in js so maybe we should approach this differently.

@parndt parndt commented on the diff
...s/app/controllers/refinery/admin/images_controller.rb
@@ -55,12 +55,10 @@ def create
unless params[:insert]
if @images.all?(&:valid?)
flash.notice = t('uploaded_successfully', :scope => 'refinery.admin.images.form')
- if from_dialog?
- @dialog_successful = true
- render :nothing => true, :layout => true
- else
- redirect_to refinery.admin_images_path
- end
+
+ @dialog_successful = true if from_dialog?
+
+ render :nothing => true, :layout => true
@parndt Refinery member
parndt added a note

what if they're not using a dialogue?

@ugisozols Refinery member

That's the case I was trying to fix. They'll get redirected back to /refinery/images by https://github.com/resolve/refinerycms/pull/1904/files#L0R54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@parndt parndt merged commit f8061d9 into master

1 check failed

Details default The Travis build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 27, 2012
  1. @ugisozols
This page is out of date. Refresh to see the latest.
View
6 images/app/assets/javascript/refinery/images.js.coffee.erb
@@ -19,7 +19,6 @@ class Images
cache_dom: ->
@error_list = $("#error_list")
- @success_list = $("#flash")
@error_explanation = $("#errorExplanation")
@upload_progress = $("#upload_progress")
@@ -44,14 +43,15 @@ class Images
after_upload_all: ->
$(".save-loader").hide()
@upload_progress.hide()
- @success_list.show()
if @errors.length > 0
@render_errors()
else
if getParameterByName("modal") == "true"
window.parent.document.getElementById("dialog_frame").contentDocument.location.reload(true);
- else
+ else if getParameterByName("dialog") == "true"
window.parent.location.reload(true)
+ else
+ window.location = "<%= Refinery::Core::Engine.routes.url_helpers.admin_images_path %>"
validate: (file) ->
max_file_size = <%= Refinery::Images.max_image_size %>
View
10 images/app/controllers/refinery/admin/images_controller.rb
@@ -55,12 +55,10 @@ def create
unless params[:insert]
if @images.all?(&:valid?)
flash.notice = t('uploaded_successfully', :scope => 'refinery.admin.images.form')
- if from_dialog?
- @dialog_successful = true
- render :nothing => true, :layout => true
- else
- redirect_to refinery.admin_images_path
- end
+
+ @dialog_successful = true if from_dialog?
+
+ render :nothing => true, :layout => true
@parndt Refinery member
parndt added a note

what if they're not using a dialogue?

@ugisozols Refinery member

That's the case I was trying to fix. They'll get redirected back to /refinery/images by https://github.com/resolve/refinerycms/pull/1904/files#L0R54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
else
self.new # important for dialogs
render :action => 'new'
Something went wrong with that request. Please try again.