Skip to content

Commit

Permalink
Merge pull request #3007 from sparc-request/filter-protocols-default-…
Browse files Browse the repository at this point in the history
…radio-fix

GM - Filter protocols default radio fix
  • Loading branch information
amcates committed Oct 24, 2022
2 parents 6f982ed + a9e4a04 commit 280b6b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions app/controllers/dashboard/protocols_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class Dashboard::ProtocolsController < Dashboard::BaseController
before_action :bypass_rmid_validations?, only: [:update, :edit]

def index
@existing_request = params[:existing_request]
admin_orgs = current_user.authorized_admin_organizations
@admin = admin_orgs.any?

@default_filter_params = { show_archived: 0 }

# if we are performing a search, check if user is looking for an old protocol
Expand All @@ -46,12 +46,13 @@ def index
end

# if we are an admin we want to default to admin organizations
# but show "All Protocols" if coming from SPARC proper
if @admin
@organizations = Dashboard::IdentityOrganizations.new(current_user.id).admin_organizations_with_protocols
@default_filter_params[:admin_filter] = "for_admin #{current_user.id}"
@default_filter_params[:admin_filter] = @existing_request ? "for_all" : "for_admin #{current_user.id}"
else
@organizations = Dashboard::IdentityOrganizations.new(current_user.id).general_user_organizations_with_protocols
@default_filter_params[:admin_filter] = "for_identity #{current_user.id}"
@default_filter_params[:admin_filter] = @existing_request ? "for_all" : "for_identity #{current_user.id}"
end

@filterrific =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
.form-group.row.mb-0
= f.label "admin_filter_for_all", t('dashboard.protocol_filters.all_protocols'), class: 'col-6 col-form-label pr-0'
.col-5.d-flex.align-items-center.justify-content-center
= f.radio_button :admin_filter, "for_all", checked: "checked"
= f.radio_button :admin_filter, "for_all"
.card-footer.flex-wrap
= f.submit t('actions.filter'), class: 'btn btn-block btn-primary mb-2'
.col-lg-6.col-12.pl-0.pr-1
Expand Down
2 changes: 1 addition & 1 deletion app/views/service_requests/add_service.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ConfirmSwal.fire(
service_id: "<%= params[:service_id] %>"
confirmed: "true"
else if result.dismiss == 'cancel'
window.location = "<%= dashboard_root_path %>"
window.location = "<%= dashboard_root_path(existing_request: "true") %>"
<% elsif @duplicate_service %>
AlertSwal.fire(
icon: 'error'
Expand Down

0 comments on commit 280b6b6

Please sign in to comment.