diff --git a/app/views/organizations/_affiliation_fields.html.erb b/app/views/organizations/_affiliation_fields.html.erb index c687886a6..9c545c151 100644 --- a/app/views/organizations/_affiliation_fields.html.erb +++ b/app/views/organizations/_affiliation_fields.html.erb @@ -1,83 +1,96 @@ <% if allowed_to?(:manage?, Organization) %> <% expired = f.object.inactive? || (f.object.end_date.present? && f.object.end_date < Date.current) %>
-
id="<%= dom_id(f.object) %>"<% end %> data-inactive-toggle-target="row"> -
- <% if f.object.persisted? && f.object.person.present? %> - - <% show_email = f.object.person.profile_show_email? || allowed_to?(:manage?, Person) %> - <%= person_profile_button(f.object.person, truncate_at: 30, subtitle: (f.object.person.preferred_email if show_email)) %> - <%= f.hidden_field :person_id %> - <% else %> - <%= f.input :person_id, - include_blank: true, - required: true, - input_html: { - data: { - controller: "remote-select", - remote_select_model_value: "person" - } - }, - label: "Person" - %> - <% end %> -
- -
- <%= f.input :title, - as: :text, - input_html: { - rows: 1, - value: f.object&.title || "Facilitator", - style: "height: 42px; min-height: 42px;", - data: { - inactive_toggle_target: "title", - action: "affiliation-dates#recalculate inactive-toggle#updateBorder" - } - } %> -
+
+
+ <% if f.object.persisted? && f.object.person.present? %> + + <% show_email = f.object.person.profile_show_email? || allowed_to?(:manage?, Person) %> + <%= person_profile_button(f.object.person, truncate_at: 25, subtitle: (f.object.person.preferred_email if show_email)) %> + <%= f.hidden_field :person_id %> + <% else %> + +
+ <%= f.input :person_id, + include_blank: true, + required: true, + wrapper_html: { class: "mb-0 h-full" }, + input_html: { + class: "h-full border-0", + data: { + controller: "remote-select", + remote_select_model_value: "person" + } + }, + label: false + %> +
+ <% end %> +
-
- <%= f.input :start_date, - as: :string, - label: "Start", - input_html: { - type: "date", - value: (f.object.start_date || (Date.current unless f.object.persisted?))&.strftime("%Y-%m-%d"), - class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", - data: { action: "change->affiliation-dates#recalculate" } - } %> -
+
+ <%= f.input :title, + as: :text, + wrapper_html: { class: "mb-0" }, + input_html: { + rows: 1, + value: f.object&.title || "Facilitator", + style: "height: 56px; min-height: 56px; padding-top: 14px;", + data: { + inactive_toggle_target: "title", + action: "affiliation-dates#recalculate inactive-toggle#updateBorder" + } + } %> +
-
- <%= f.input :end_date, - as: :string, - label: "End", - input_html: { - type: "date", - value: f.object.end_date&.strftime("%Y-%m-%d"), - class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", - data: { - inactive_toggle_target: "endDate", - action: "change->inactive-toggle#toggle change->affiliation-dates#recalculate" - } - } %> -
+
+ <%= f.input :start_date, + as: :string, + label: "Start", + wrapper_html: { class: "mb-0" }, + input_html: { + type: "date", + value: (f.object.start_date || (Date.current unless f.object.persisted?))&.strftime("%Y-%m-%d"), + class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", + style: "height: 56px;", + data: { action: "change->affiliation-dates#recalculate" } + } %> +
-
- - <%= f.check_box :primary_contact, - checked: f.object.primary_contact? || !f.object.persisted?, - class: "h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" %> -
+
+ <%= f.input :end_date, + as: :string, + label: "End", + wrapper_html: { class: "mb-0" }, + input_html: { + type: "date", + value: f.object.end_date&.strftime("%Y-%m-%d"), + class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", + style: "height: 56px;", + data: { + inactive_toggle_target: "endDate", + action: "change->inactive-toggle#toggle change->affiliation-dates#recalculate" + } + } %> +
-
- <%= link_to_remove_association "Remove", - f, - class: "text-sm text-gray-400 hover:text-red-600 underline whitespace-nowrap admin-only bg-blue-100 rounded px-2 py-1" %> +
+ +
+ <%= f.check_box :primary_contact, + checked: f.object.primary_contact? || !f.object.persisted?, + class: "h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" %> +
+
+ <%= link_to_remove_association "Remove", + f, + class: "text-sm text-gray-400 hover:text-red-600 underline whitespace-nowrap" %> +
+
diff --git a/app/views/organizations/_form.html.erb b/app/views/organizations/_form.html.erb index 9a7c54400..08156bb25 100644 --- a/app/views/organizations/_form.html.erb +++ b/app/views/organizations/_form.html.erb @@ -102,56 +102,7 @@
- <% org_earliest_aff = f.object.persisted? ? f.object.affiliations.minimum(:start_date) : nil %> - <% org_aff_ended = f.object.persisted? && f.object.affiliations.any? && !f.object.affiliations.active.exists? %> - <% org_latest_end = f.object.persisted? ? f.object.affiliations.maximum(:end_date) : nil %> - <% org_end_date = org_aff_ended ? org_latest_end : f.object.end_date %>
- <% if allowed_to?(:manage?, Organization) %> -
-
- - -
- <% if org_aff_ended || (f.object.end_date.present? && !has_affiliations) %><% end %><%= (org_earliest_aff || f.object.start_date)&.strftime('%b %Y') || "—" %><%= " – #{org_end_date.strftime('%b %Y')}" if org_end_date.present? %> - <% if has_affiliations && org_earliest_aff.nil? %> - - <% elsif f.object.start_date.present? && org_earliest_aff.present? && f.object.start_date.beginning_of_month != org_earliest_aff.beginning_of_month %> -

Organization start_date: <%= f.object.start_date.strftime("%b %Y") %>

- <% end %> -
-
- <% unless has_affiliations %> - <%= f.input :start_date, - label: false, - as: :string, - input_html: { - type: 'date', - value: f.object.start_date&.strftime('%Y-%m-%d'), - class: "block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500 mt-2" - } %> - <% end %> -
- <% end %> -
<%= f.input :agency_type, label: "Organization Type", @@ -301,8 +252,68 @@
+ <% org_earliest_aff = f.object.persisted? ? f.object.affiliations.minimum(:start_date) : nil %> + <% org_aff_ended = f.object.persisted? && f.object.affiliations.any? && !f.object.affiliations.active.exists? %> + <% org_latest_end = f.object.persisted? ? f.object.affiliations.maximum(:end_date) : nil %> + <% org_end_date = org_aff_ended ? org_latest_end : f.object.end_date %> + <% org_decorated = f.object.decorate %> + <% org_fac_start = org_decorated.facilitator_since_date %> + <% org_fac_ended = org_decorated.facilitation_end_date %> +
+
+ + +
+ <% if org_aff_ended || (f.object.end_date.present? && !has_affiliations) %><% end %><%= (org_earliest_aff || f.object.start_date)&.strftime('%b %Y') || "—" %><%= " – #{org_end_date.strftime('%b %Y')}" if org_end_date.present? %> + <% if has_affiliations && org_earliest_aff.nil? %> + + <% elsif f.object.start_date.present? && org_earliest_aff.present? && f.object.start_date.beginning_of_month != org_earliest_aff.beginning_of_month %> +

Organization start_date: <%= f.object.start_date.strftime("%b %Y") %>

+ <% end %> +
+ <% unless has_affiliations %> + <%= f.input :start_date, + label: false, + as: :string, + input_html: { + type: 'date', + value: f.object.start_date&.strftime('%Y-%m-%d'), + class: "block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500 mt-2" + } %> + <% end %> +
+
+ + +
+ <% if org_fac_ended %><% end %><%= org_fac_start&.strftime("%b %Y") || "—" %><%= " – #{org_fac_ended.strftime('%b %Y')}" if org_fac_ended %> +
+
+
<% if allowed_to?(:manage?, Organization) %> -
+
<%= f.fields_for :affiliations do |affiliation_form| %>
<%= render "affiliation_fields", @@ -311,7 +322,7 @@ <% end %>
-
<%= link_to_add_association "➕ Add Affiliation", +
<%= link_to_add_association "➕ Add Affiliation", f, :affiliations, class: "btn btn-secondary-outline" %>
diff --git a/app/views/people/_affiliation_fields.html.erb b/app/views/people/_affiliation_fields.html.erb index 06e801e29..c2cf55bfb 100644 --- a/app/views/people/_affiliation_fields.html.erb +++ b/app/views/people/_affiliation_fields.html.erb @@ -1,85 +1,95 @@ <% if allowed_to?(:manage?, Person) %> <% expired = f.object.inactive? || (f.object.end_date.present? && f.object.end_date < Date.current) %>
-
-
- <% if f.object.persisted? && f.object.organization.present? %> - - <%= organization_profile_button(f.object.organization, truncate_at: 30) %> - <%= f.hidden_field :organization_id %> - <% else %> - <%= f.input :organization_id, - include_blank: true, - required: true, - input_html: { - data: { - controller: "remote-select", - remote_select_model_value: "organization" - } - }, - error: "Organization can't be blank", - prompt: "Search by name", - label: "Organization", - label_html: { class: "block text-sm font-medium text-gray-700 mb-1 " } %> - <% end %> -
+
+
+ <% if f.object.persisted? && f.object.organization.present? %> + + <%= organization_profile_button(f.object.organization, truncate_at: 25) %> + <%= f.hidden_field :organization_id %> + <% else %> + +
+ <%= f.input :organization_id, + include_blank: true, + required: true, + wrapper_html: { class: "mb-0 h-full" }, + input_html: { + class: "h-full border-0", + data: { + controller: "remote-select", + remote_select_model_value: "organization" + } + }, + error: "Organization can't be blank", + prompt: "Search by name", + label: false %> +
+ <% end %> +
-
-
+
<%= f.input :title, as: :text, + wrapper_html: { class: "mb-0" }, input_html: { rows: 1, value: f.object.title || "Facilitator", - style: "height: 42px; min-height: 42px;", + style: "height: 56px; min-height: 56px; padding-top: 14px;", data: { inactive_toggle_target: "title", action: "affiliation-dates#recalculate inactive-toggle#updateBorder" } } %>
-
- -
- <%= f.input :start_date, - as: :string, - label: "Start", - input_html: { - type: "date", - value: (f.object.start_date || (Date.current unless f.object.persisted?))&.strftime("%Y-%m-%d"), - class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", - data: { action: "change->affiliation-dates#recalculate" } - } %> -
-
- <%= f.input :end_date, - as: :string, - label: "End", - input_html: { - type: "date", - value: f.object.end_date&.strftime("%Y-%m-%d"), - class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", - data: { - inactive_toggle_target: "endDate", - action: "change->inactive-toggle#toggle change->affiliation-dates#recalculate" - } - } %> -
+
+ <%= f.input :start_date, + as: :string, + label: "Start", + wrapper_html: { class: "mb-0" }, + input_html: { + type: "date", + value: (f.object.start_date || (Date.current unless f.object.persisted?))&.strftime("%Y-%m-%d"), + class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", + style: "height: 56px;", + data: { action: "change->affiliation-dates#recalculate" } + } %> +
-
- - <%= f.check_box :primary_contact, - checked: f.object.primary_contact? || !f.object.persisted?, - class: "h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" %> -
+
+ <%= f.input :end_date, + as: :string, + label: "End", + wrapper_html: { class: "mb-0" }, + input_html: { + type: "date", + value: f.object.end_date&.strftime("%Y-%m-%d"), + class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", + style: "height: 56px;", + data: { + inactive_toggle_target: "endDate", + action: "change->inactive-toggle#toggle change->affiliation-dates#recalculate" + } + } %> +
-
- <%= link_to_remove_association "Remove", - f, - class: "text-sm text-gray-400 hover:text-red-600 underline whitespace-nowrap admin-only bg-blue-100 rounded px-2 py-1" %> +
+ +
+ <%= f.check_box :primary_contact, + checked: f.object.primary_contact? || !f.object.persisted?, + class: "h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" %> +
+
+ <%= link_to_remove_association "Remove", + f, + class: "text-sm text-gray-400 hover:text-red-600 underline whitespace-nowrap" %> +
+
diff --git a/app/views/people/_form.html.erb b/app/views/people/_form.html.erb index 0d1fd615a..535a7f45f 100644 --- a/app/views/people/_form.html.erb +++ b/app/views/people/_form.html.erb @@ -13,102 +13,47 @@
<%= f.input :first_name, input_html: { value: f.object.first_name || @user&.first_name } %><%= f.input :legal_first_name, label: "Legal First Name", hint: "If different from first name" %><%= f.input :last_name, input_html: { value: f.object.last_name || @user&.last_name } %><%= f.input :pronouns %>
- <% person = f.object.respond_to?(:object) ? f.object.object : f.object %> - <% decorated = person.decorate %> -

Important dates

-
-
-
- - -
- <% if decorated.affiliation_end_date %><% end %><%= decorated.affiliated_since_date&.strftime("%b %Y") || "—" %><%= " – #{decorated.affiliation_end_date.strftime('%b %Y')}" if decorated.affiliation_end_date %> - <% if decorated.affiliated_since_date.nil? && person.affiliations.exists? %> - - <% elsif decorated.member_since_earlier_than_all_affiliations? %> -

⚠ Earlier date on file: <%= person.member_since.strftime("%b %Y") %>

- <% elsif decorated.member_since_differs_from_all_affiliations? %> -

Different date on file: <%= person.member_since.strftime("%b %Y") %>

- <% end %> -
-
-
- - -
- <% if decorated.facilitation_end_date %><% end %><%= decorated.facilitator_since_date&.strftime("%b %Y") || "—" %><%= " – #{decorated.facilitation_end_date.strftime('%b %Y')}" if decorated.facilitation_end_date %> - <% if decorated.member_since_earlier_than_facilitator_affiliations? %> -

⚠ Earlier date on file: <%= person.member_since.strftime("%b %Y") %>

- <% elsif decorated.member_since_differs_from_facilitator_affiliations? %> -

Different date on file: <%= person.member_since.strftime("%b %Y") %>

- <% end %> -
-
-
- <%= f.input :date_of_birth, - label: "Birthday", - as: :date, - discard_year: true, - order: [:month, :day], - prompt: { month: "Select Month", day: "Select Day" }, - wrapper_html: { class: "flex flex-wrap gap-2 items-end" }, - label_html: { class: "w-full" }, - input_html: { - class: "flex-1 rounded-md border-gray-300 shadow-sm - focus:border-blue-500 focus:ring focus:ring-blue-200 focus:ring-opacity-50" - } %> +
+

Emails

+ +
+
+ <% if f.object.user %> +
+ + <%= f.object.user&.email %> + +

+ Only + <% if allowed_to?(:edit?, f.object.user) %> + <%= link_to "editable by admins", + edit_user_path(f.object.user), + class: "underline" %> + <% else %> + editable by admins + <% end %> +

+
+ <% else %> + <%= f.input :email, label: "Primary email" %> + <% end %> + + <%= f.input :email_type, + label: "Primary email type", + as: :select, + collection: Person::CONTACT_TYPES.compact.map { |type| [type.to_s.humanize, type] }, + selected: f.object.email_type || f.object.user&.email_type, + include_blank: true %> + + <%= f.input :email_2, label: "Secondary email" %> + + <%= f.input :email_2_type, + label: "Secondary email type", + as: :select, + collection: Person::CONTACT_TYPES.compact.map { |type| [type.to_s.humanize, type] }, + include_blank: true %>
- <% if allowed_to?(:manage?, Person) && params[:admin].present? %> -
- <%= f.input :member_since, - as: :date, - discard_day: true, - start_year: 1991, - end_year: Time.current.year, - prompt: { month: "Select Month", year: "Select Year" }, - order: [:month, :year], - label: "Member since (override)", - hint: "Pick January if you only know the year", - wrapper_html: { class: "flex flex-wrap gap-2 items-end" }, - label_html: { class: "w-full" }, - hint_html: { class: "w-full" }, - input_html: { - class: "flex-1 rounded-md border-gray-300 shadow-sm admin-only bg-blue-100 border-blue-200 - focus:border-blue-500 focus:ring focus:ring-blue-200 focus:ring-opacity-50" - } %> -
- <% end %>
@@ -117,49 +62,6 @@
<%= render "shared/form_image_field", f: f, field_name: :avatar %>
-
-

Emails

- -
-
- <% if f.object.user %> -
- - <%= f.object.user&.email %> - -

- Only - <% if allowed_to?(:edit?, f.object.user) %> - <%= link_to "editable by admins", - edit_user_path(f.object.user), - class: "underline" %> - <% else %> - editable by admins - <% end %> -

-
- <% else %> - <%= f.input :email, label: "Primary email" %> - <% end %> - - <%= f.input :email_type, - label: "Primary email type", - as: :select, - collection: Person::CONTACT_TYPES.compact.map { |type| [type.to_s.humanize, type] }, - selected: f.object.email_type || f.object.user&.email_type, - include_blank: true %> - - <%= f.input :email_2, label: "Secondary email" %> - - <%= f.input :email_2_type, - label: "Secondary email type", - as: :select, - collection: Person::CONTACT_TYPES.compact.map { |type| [type.to_s.humanize, type] }, - include_blank: true %> -
-
-
-
@@ -255,12 +157,92 @@ <% end %> + <% person = f.object.respond_to?(:object) ? f.object.object : f.object %> + <% decorated = person.decorate %>
Affiliations (only editable by admins)
-
+
+ <% if allowed_to?(:manage?, Person) && params[:admin].present? %> +
+ <%= f.input :member_since, + as: :date, + discard_day: true, + start_year: 1991, + end_year: Time.current.year, + prompt: { month: "Select Month", year: "Select Year" }, + order: [:month, :year], + label: "Member since (override)", + hint: "Pick January if you only know the year", + wrapper_html: { class: "flex flex-wrap gap-2 items-end" }, + label_html: { class: "w-full" }, + hint_html: { class: "w-full" }, + input_html: { + class: "flex-1 rounded-md border-gray-300 shadow-sm admin-only bg-blue-100 border-blue-200 + focus:border-blue-500 focus:ring focus:ring-blue-200 focus:ring-opacity-50" + } %> +
+ <% end %> +
+
+ + +
+ <% if decorated.affiliation_end_date %><% end %><%= decorated.affiliated_since_date&.strftime("%b %Y") || "—" %><%= " – #{decorated.affiliation_end_date.strftime('%b %Y')}" if decorated.affiliation_end_date %> + <% if decorated.affiliated_since_date.nil? && person.affiliations.exists? %> + + <% elsif decorated.member_since_earlier_than_all_affiliations? %> +

⚠ Earlier date on file: <%= person.member_since.strftime("%b %Y") %>

+ <% elsif decorated.member_since_differs_from_all_affiliations? %> +

Different date on file: <%= person.member_since.strftime("%b %Y") %>

+ <% end %> +
+
+
+ + +
+ <% if decorated.facilitation_end_date %><% end %><%= decorated.facilitator_since_date&.strftime("%b %Y") || "—" %><%= " – #{decorated.facilitation_end_date.strftime('%b %Y')}" if decorated.facilitation_end_date %> + <% if decorated.member_since_earlier_than_facilitator_affiliations? %> +

⚠ Earlier date on file: <%= person.member_since.strftime("%b %Y") %>

+ <% elsif decorated.member_since_differs_from_facilitator_affiliations? %> +

Different date on file: <%= person.member_since.strftime("%b %Y") %>

+ <% end %> +
+
+
<% if allowed_to?(:manage?, Person) %>
<%= f.fields_for :affiliations do |affiliation_form| %> @@ -287,21 +269,33 @@
-
- <%= f.input :bio, - as: :text, - input_html: { - rows: 2, - maxlength: 1650, - class: "w-full rounded-md border-gray-300 shadow-sm - focus:border-blue-500 focus:ring focus:ring-blue-200 focus:ring-opacity-50" - }, - hint: "Maximum 250 characters" %>
- - - <% if f.object.user %> - <%= f.fields_for :user do |user_form| %> -
+ <%= f.input :bio, + as: :text, + input_html: { + rows: 2, + maxlength: 1650, + class: "w-full rounded-md border-gray-300 shadow-sm + focus:border-blue-500 focus:ring focus:ring-blue-200 focus:ring-opacity-50" + }, + hint: "Maximum 250 characters" %> + +
+
+ <%= f.input :date_of_birth, + label: "Birthday", + as: :date, + discard_year: true, + order: [:month, :day], + prompt: { month: "Month", day: "Day" }, + wrapper_html: { class: "flex flex-wrap gap-2 items-end" }, + label_html: { class: "w-full" }, + input_html: { + class: "flex-1 rounded-md border-gray-300 shadow-sm + focus:border-blue-500 focus:ring focus:ring-blue-200 focus:ring-opacity-50" + } %> +
+ <% if f.object.user %> + <%= f.fields_for :user do |user_form| %> <%= user_form.input :time_zone, as: :select, collection: us_time_zone_fundamentals, @@ -310,13 +304,13 @@ hint: "Event times and other dates will be shown in this timezone.", input_html: { class: "w-full" }, wrapper_html: { class: "w-full max-w-md" } %> -
+ <% end %> <% end %> - <% end %> +
- Social media links: + Social media links
@@ -332,7 +326,7 @@
- Profile display preferences: + Profile display preferences