app/builders/blacklight/action_builder.rb in blacklight-7.40.0 vs app/builders/blacklight/action_builder.rb in blacklight-8.0.0.beta1
- old
+ new
@@ -25,22 +25,31 @@
callback = opts.fetch(:callback, nil).inspect
validator = opts.fetch(:validator, nil).inspect
klass.class_eval <<EORUBY, __FILE__, __LINE__ + 1
def #{name}
- @response, @documents = action_documents
+ @documents = action_documents
- if request.post? && #{callback} &&
- (#{validator}.blank? || send(#{validator}))
+ if request.post? && #{callback}
+ if #{validator}.blank? || send(#{validator})
- send(#{callback}, @documents)
+ send(#{callback}, @documents)
- flash.now[:success] ||= I18n.t("blacklight.#{name}.success", default: nil)
+ flash[:success] ||= I18n.t("blacklight.#{name}.success", default: nil)
- respond_to do |format|
- format.html do
- return render "#{name}_success" if request.xhr?
- redirect_to action_success_redirect_path
+ respond_to do |format|
+ format.html do
+ return render "#{name}_success", layout: false if request.xhr?
+ redirect_to action_success_redirect_path
+ end
+ end
+ else
+ # Not valid
+ respond_to do |format|
+ format.html do
+ return render layout: false, status: :unprocessable_entity if request.xhr?
+ # Otherwise draw the full page
+ end
end
end
else
respond_to do |format|
format.html do