diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 1a962e443..6d873b81b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -78,6 +78,12 @@ def set_form_variables @project.build_logo_image if @project.logo_image.blank? @project_statuses = ProjectStatus.all + @facilitators_array = Facilitator.joins(:user) + .order(:first_name, :last_name) + .map{|f| [f.name, f.user.id] } + @project.project_users = @project.project_users + .includes(:project) + .sort_by { |pu| pu.user.facilitator&.name.to_s.downcase } end def set_index_variables @@ -97,6 +103,18 @@ def project_params :inactive, :notes, :agency_type, :agency_type_other, :website_url, :project_status_id, :location_id, :windows_type_id, logo_image_attributes: [:id, :file, :_destroy], + sectorable_items_attributes: [ + :id, + :sector_id, + :_destroy, + ], + project_users_attributes: [ + :id, + :user_id, + :inactive, + :title, + :_destroy, + ], addresses_attributes: [ :id, :address_type, diff --git a/app/helpers/sector_helper.rb b/app/helpers/sector_helper.rb new file mode 100644 index 000000000..3c79931db --- /dev/null +++ b/app/helpers/sector_helper.rb @@ -0,0 +1,20 @@ +module SectorHelper + def sector_button(sector, font_size: "text-md") + link_to authenticated_root_path(sector), + class: "group inline-flex items-center gap-2 px-4 py-2 + border border-purple-800 text-purple-500 rounded-lg + hover:bg-purple-800 hover:text-white transition-colors duration-200 + #{font_size} shadow-sm leading-none whitespace-nowrap" do + + # --- Name: stays one line & turns white on hover --- + content_tag( + :span, + sector.name.to_s.truncate(30), + title: sector.name.to_s, + class: "font-semibold text-gray-900 whitespace-nowrap group-hover:text-white" + ) + end + end + + +end diff --git a/app/models/address.rb b/app/models/address.rb index 4006f6a25..d11db6187 100644 --- a/app/models/address.rb +++ b/app/models/address.rb @@ -11,6 +11,6 @@ class Address < ApplicationRecord scope :active, -> { where(inactive: false) } def name - "#{street}, #{city}, #{state} #{zip}" + "#{street_address}, #{city}, #{state} #{zip_code}" end end diff --git a/app/models/project.rb b/app/models/project.rb index 998081331..eb8dcbbab 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -22,6 +22,8 @@ class Project < ApplicationRecord # Nested attributes accepts_nested_attributes_for :logo_image, allow_destroy: true, reject_if: :all_blank accepts_nested_attributes_for :addresses, allow_destroy: true, reject_if: :all_blank + accepts_nested_attributes_for :sectorable_items, allow_destroy: true, reject_if: :all_blank + accepts_nested_attributes_for :project_users, allow_destroy: true, reject_if: :all_blank scope :active, -> { where(inactive: false) } diff --git a/app/views/projects/_address_fields.html.erb b/app/views/projects/_address_fields.html.erb index d84a9c407..afeed9f22 100644 --- a/app/views/projects/_address_fields.html.erb +++ b/app/views/projects/_address_fields.html.erb @@ -1,4 +1,9 @@ -
No facilitators listed.
+ <% end %> ++ <% if @project.sectorable_items.any? %> +
No facilitators listed.
+ No sectors selected. <% end %> -- <% if @project.sectorable_items.any? %> - <%= @project.sectorable_items.joins(:sector).order("sectors.name").map do |item| %> - <% "#{item.sector.name}#{ " (Leader)" if item.is_leader? }" %> - <% end.join(", ") %> - <% else %> - No sectors selected. - <% end %> -
-