Skip to content

Commit

Permalink
Improve usability of organisation select on batch_invitations/new
Browse files Browse the repository at this point in the history
This makes it easier to select the organisation for a batch of users
by excluding closed organisations and sorting the remaining ones
alphabetically. We did something similar in #2426 and #2417 - there's
enough subtle differences in those two select boxes (indicating a
current organisation and adding a "None" option respectively) that I
haven't attempted to extract the duplication. I think the new scopes
are self-explanatory enough that I'm happy to keep them inline in this
view.
  • Loading branch information
chrislo committed Oct 11, 2023
1 parent dd376e4 commit 330d660
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/batch_invitations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
id: "batch_invitation_organisation_id",
name: "batch_invitation[organisation_id]",
label: "Organisation",
options: policy_scope(Organisation).map { |organisation| { text: organisation.name_with_abbreviation, value: organisation.id } }
options: policy_scope(Organisation).not_closed.order(:name).map { |organisation| { text: organisation.name_with_abbreviation, value: organisation.id } }
} %>

<% end %>
Expand Down
8 changes: 8 additions & 0 deletions test/controllers/batch_invitations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def users_csv(filename = "users.csv")

assert_select "#batch_invitation_organisation_id option", organisation.name
end

should "exclude closed organisations from select" do
create(:organisation)
create(:organisation, closed: true)
get :new

assert_select "#batch_invitation_organisation_id option", 1
end
end

context "POST create" do
Expand Down

0 comments on commit 330d660

Please sign in to comment.