diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 0b6b7eae5..9e7d03037 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -1,40 +1,25 @@ { "permissions": { "allow": [ - "Bash(bundle exec brakeman:*)", - "Bash(bundle exec rails routes:*)", - "Bash(bundle exec rails runner:*)", "Bash(bundle exec rspec:*)", - "Bash(bundle exec rubocop:*)", + "Bash(bundle exec rails runner:*)", "Bash(RAILS_ENV=test bundle exec rails runner:*)", "Bash(RAILS_ENV=test bundle exec rspec:*)", + "Bash(git stash:*)", "Bash(git add:*)", - "Bash(git apply:*)", - "Bash(git checkout:*)", "Bash(git commit:*)", - "Bash(git diff:*)", - "Bash(git pull:*)", "Bash(git push:*)", - "Bash(git reset:*)", - "Bash(git stash:*)", + "Bash(git diff:*)", "Bash(bin/rails db:migrate:*)", + "Bash(for i in 1 2 3)", + "Bash(do bundle exec rspec spec/system/stories_spec.rb:71 --format progress)", + "Bash(done)", "Bash(bin/rails runner:*)", - "Bash(chmod:*)", - "Bash(mysql -u root:*)", "Bash(git -C /Users/maebeale/programming/awbw branch --show-current)", "Bash(bundle exec rails routes:*)", "Bash(bundle exec rubocop:*)", "Bash(git -C /Users/maebeale/programming/awbw diff --name-only main...HEAD)", - "Bash(git log:*)", - - "Bash(git fetch:*)", - "Bash(git rebase:*)", - "Bash(grep:*)" - - "Bash(bin/rails generate:*)", - "Bash(bin/rails db:schema:dump:*)", - "Bash(RAILS_ENV=test bin/rails:*)" - + "Bash(git merge:*)" ] } } diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index eebf0d0ec..4c2b8a6ae 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -95,10 +95,19 @@ def set_form_variables @organization_statuses = OrganizationStatus.all @sectors_collection = Sector.published.order(:name).pluck(:name, :id) @current_sector_ids = @organization.sectorable_items.map(&:sector_id) - @people_array = authorized_scope(Person.joins(:user)) - .order(:first_name, :last_name) - .pluck(:first_name, :last_name, :id) - .map { |fn, ln, id| [ "#{fn} #{ln}", id ] } + # Build array of [display_name, id] for person selection dropdown + # Email priority matches Person#preferred_email: user.email > person.email > person.email_2 + @people_array = authorized_scope(Person.left_joins(:user)) + .order(:first_name, :last_name) + .pluck( + :first_name, + :last_name, + :id, + Arel.sql("COALESCE(users.email, people.email, people.email_2)") + ) + .map { |fn, ln, id, email| + [ "#{fn} #{ln}#{" (#{email})" if email.present?}", id ] + } if @organization.persisted? && @organization.errors.empty? affiliations = @organization.affiliations diff --git a/app/models/person.rb b/app/models/person.rb index 90e43da50..6c7a9a46c 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -149,6 +149,10 @@ def primary_organization .first&.organization end + def preferred_email + user&.email.presence || email.presence || email_2.presence + end + private def strip_whitespace diff --git a/app/views/people/index.html.erb b/app/views/people/index.html.erb index ae00bed5d..55e2ecf08 100644 --- a/app/views/people/index.html.erb +++ b/app/views/people/index.html.erb @@ -33,7 +33,7 @@ <% cache [person, current_user.super_user?] do %>