Skip to content

Commit

Permalink
Add non-JS flash messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Lubosky committed Jul 27, 2023
1 parent 444e579 commit 0b855cd
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/controllers/admin/admins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def create
authorize @resource, :create?

@resource.save

render_flash_message_for(@resource)

location = @resource.persisted? ? admin_admins_path : nil
respond_with :admin, @resource, location: location
end
Expand All @@ -32,13 +35,17 @@ def update
@resource.update_without_password(resource_params)
end

render_flash_message_for(@resource)

respond_with :admin, @resource, location: admin_admins_path
end

def destroy
authorize @resource, :destroy?
@resource.soft_delete!

render_flash_message_for(@resource)

respond_with :admin, @resource, location: admin_admins_path
end

Expand Down
7 changes: 7 additions & 0 deletions app/controllers/admin/assessors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def create

@resource.save
location = @resource.persisted? ? admin_assessors_path : nil

render_flash_message_for(@resource)

respond_with :admin, @resource, location: location
end

Expand All @@ -32,13 +35,17 @@ def update
@resource.update_without_password(resource_params)
end

render_flash_message_for(@resource)

respond_with :admin, @resource, location: admin_assessors_path
end

def destroy
authorize @resource, :destroy?
@resource.soft_delete!

render_flash_message_for(@resource)

respond_with :admin, @resource, location: admin_assessors_path
end

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/admin/custom_emails_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ def create
@form = CustomEmailForm.new(custom_email_form_attributes)
if @form.valid?
CustomEmailWorker.perform_async(custom_email_form_attributes)
render_flash_message_for(@form)
redirect_to admin_custom_email_path, notice: "Email was successfully scheduled"
else
render_flash_message_for(@form)
render :show
end
end
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/admin/judges_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def create

@resource.save
location = @resource.persisted? ? admin_judges_path : nil

render_flash_message_for(@resource)

respond_with :admin, @resource, location: location
end

Expand All @@ -32,13 +35,17 @@ def update
@resource.update_without_password(resource_params)
end

render_flash_message_for(@resource)

respond_with :admin, @resource, location: admin_judges_path
end

def destroy
authorize @resource, :destroy?
@resource.soft_delete!

render_flash_message_for(@resource)

respond_with :admin, @resource, location: admin_judges_path
end

Expand Down
5 changes: 5 additions & 0 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def create

@resource.save
location = @resource.persisted? ? admin_users_path : nil

render_flash_message_for(@resource)

respond_with :admin, @resource, location: location
end

Expand All @@ -39,6 +42,8 @@ def update
@resource.update_without_password(resource_params)
end

render_flash_message_for(@resource)

respond_with :admin, @resource, location: admin_users_path
end

Expand Down
5 changes: 4 additions & 1 deletion app/controllers/concerns/admin_shortlisted_docs_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def create

respond_to do |format|
format.html do
render_flash_message_for(attachment)
redirect_to [namespace_name, form_answer]
end

Expand All @@ -30,7 +31,8 @@ def create
else
respond_to do |format|
format.html do
redirect_to [namespace_name, form_answer], alert: attachment.errors.full_messages.join(", ")
render_flash_message_for(attachment)
redirect_to [namespace_name, form_answer]
end

format.js do
Expand All @@ -55,6 +57,7 @@ def destroy
if request.xhr? || request.format.js?
head :ok
else
render_flash_message_for(resource)
redirect_to [namespace_name, form_answer]
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def create

respond_to do |format|
format.html do
render_flash_message_for(resource)

redirect_to [namespace_name, form_answer], alert: render_errors
end

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/concerns/draft_notes_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def create

respond_to do |format|
format.html do
render_flash_message_for(resource)
redirect_to [namespace_name, form_answer]
end

Expand All @@ -28,6 +29,7 @@ def update

respond_to do |format|
format.html do
render_flash_message_for(resource)
redirect_to [namespace_name, form_answer]
end

Expand Down

0 comments on commit 0b855cd

Please sign in to comment.