|
1 | 1 | <% if allowed_to?(:manage?, Organization) %> |
2 | 2 | <% expired = f.object.inactive? || (f.object.end_date.present? && f.object.end_date < Date.current) %> |
3 | 3 | <div data-controller="inactive-toggle"> |
4 | | - <div class="nested-fields mb-4 rounded-lg border px-3 pt-3 pb-1 <%= expired ? 'bg-gray-100 border-gray-300 opacity-60' : 'bg-white border-gray-200' %>" |
| 4 | + <div class="nested-fields flex flex-wrap gap-x-4 gap-y-1 items-end mb-4 rounded-lg border p-3 <%= expired ? 'bg-gray-100 border-gray-300 opacity-60' : 'bg-white border-gray-200' %>" |
5 | 5 | style="border-left: 4px solid <%= f.object.facilitator? ? '#e879f9' : '#d1d5db' %>" |
6 | 6 | <% if f.object.persisted? %>id="<%= dom_id(f.object) %>"<% end %> |
7 | 7 | data-inactive-toggle-target="row"> |
8 | | - <div class="flex gap-x-4 items-start"> |
9 | | - <div class="shrink-0" style="width: 280px;" data-inactive-toggle-target="profileButton"> |
10 | | - <% if f.object.persisted? && f.object.person.present? %> |
11 | | - <label class="block font-medium text-gray-700 mb-1">Person</label> |
12 | | - <% show_email = f.object.person.profile_show_email? || allowed_to?(:manage?, Person) %> |
13 | | - <%= person_profile_button(f.object.person, truncate_at: 25, subtitle: (f.object.person.preferred_email if show_email)) %> |
14 | | - <%= f.hidden_field :person_id %> |
15 | | - <% else %> |
16 | | - <label class="block font-medium text-gray-700 mb-1">Person <abbr>*</abbr></label> |
17 | | - <div class="rounded-md border border-gray-300 shadow-sm overflow-hidden" style="height: 56px;"> |
18 | | - <%= f.input :person_id, |
19 | | - include_blank: true, |
20 | | - required: true, |
21 | | - wrapper_html: { class: "mb-0 h-full" }, |
22 | | - input_html: { |
23 | | - class: "h-full border-0", |
24 | | - data: { |
25 | | - controller: "remote-select", |
26 | | - remote_select_model_value: "person" |
27 | | - } |
28 | | - }, |
29 | | - label: false |
30 | | - %> |
31 | | - </div> |
32 | | - <% end %> |
33 | | - </div> |
| 8 | + <div style="width: 350px; min-width: 350px; flex-shrink: 0;" data-inactive-toggle-target="profileButton"> |
| 9 | + <% if f.object.persisted? && f.object.person.present? %> |
| 10 | + <label class="block text-sm font-medium text-gray-700 mb-1">Person</label> |
| 11 | + <% show_email = f.object.person.profile_show_email? || allowed_to?(:manage?, Person) %> |
| 12 | + <%= person_profile_button(f.object.person, truncate_at: 30, subtitle: (f.object.person.preferred_email if show_email)) %> |
| 13 | + <%= f.hidden_field :person_id %> |
| 14 | + <% else %> |
| 15 | + <%= f.input :person_id, |
| 16 | + include_blank: true, |
| 17 | + required: true, |
| 18 | + input_html: { |
| 19 | + data: { |
| 20 | + controller: "remote-select", |
| 21 | + remote_select_model_value: "person" |
| 22 | + } |
| 23 | + }, |
| 24 | + label: "Person" |
| 25 | + %> |
| 26 | + <% end %> |
| 27 | + </div> |
| 28 | + |
| 29 | + <div class="w-full sm:w-auto" style="min-width: 200px;"> |
| 30 | + <%= f.input :title, |
| 31 | + as: :text, |
| 32 | + input_html: { |
| 33 | + rows: 1, |
| 34 | + value: f.object&.title || "Facilitator", |
| 35 | + style: "height: 42px; min-height: 42px;", |
| 36 | + data: { |
| 37 | + inactive_toggle_target: "title", |
| 38 | + action: "affiliation-dates#recalculate inactive-toggle#updateBorder" |
| 39 | + } |
| 40 | + } %> |
| 41 | + </div> |
34 | 42 |
|
35 | | - <div class="flex-1" style="min-width: 150px;"> |
36 | | - <%= f.input :title, |
37 | | - as: :text, |
38 | | - wrapper_html: { class: "mb-0" }, |
39 | | - input_html: { |
40 | | - rows: 1, |
41 | | - value: f.object&.title || "Facilitator", |
42 | | - style: "height: 56px; min-height: 56px; padding-top: 14px;", |
43 | | - data: { |
44 | | - inactive_toggle_target: "title", |
45 | | - action: "affiliation-dates#recalculate inactive-toggle#updateBorder" |
46 | | - } |
47 | | - } %> |
48 | | - </div> |
| 43 | + <div class="w-full sm:w-auto"> |
| 44 | + <%= f.input :start_date, |
| 45 | + as: :string, |
| 46 | + label: "Start", |
| 47 | + input_html: { |
| 48 | + type: "date", |
| 49 | + value: (f.object.start_date || (Date.current unless f.object.persisted?))&.strftime("%Y-%m-%d"), |
| 50 | + class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", |
| 51 | + data: { action: "change->affiliation-dates#recalculate" } |
| 52 | + } %> |
| 53 | + </div> |
49 | 54 |
|
50 | | - <div class="shrink-0"> |
51 | | - <%= f.input :start_date, |
52 | | - as: :string, |
53 | | - label: "Start", |
54 | | - wrapper_html: { class: "mb-0" }, |
55 | | - input_html: { |
56 | | - type: "date", |
57 | | - value: (f.object.start_date || (Date.current unless f.object.persisted?))&.strftime("%Y-%m-%d"), |
58 | | - class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", |
59 | | - style: "height: 56px;", |
60 | | - data: { action: "change->affiliation-dates#recalculate" } |
61 | | - } %> |
62 | | - </div> |
| 55 | + <div class="w-full sm:w-auto"> |
| 56 | + <%= f.input :end_date, |
| 57 | + as: :string, |
| 58 | + label: "End", |
| 59 | + input_html: { |
| 60 | + type: "date", |
| 61 | + value: f.object.end_date&.strftime("%Y-%m-%d"), |
| 62 | + class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", |
| 63 | + data: { |
| 64 | + inactive_toggle_target: "endDate", |
| 65 | + action: "change->inactive-toggle#toggle change->affiliation-dates#recalculate" |
| 66 | + } |
| 67 | + } %> |
| 68 | + </div> |
63 | 69 |
|
64 | | - <div class="shrink-0"> |
65 | | - <%= f.input :end_date, |
66 | | - as: :string, |
67 | | - label: "End", |
68 | | - wrapper_html: { class: "mb-0" }, |
69 | | - input_html: { |
70 | | - type: "date", |
71 | | - value: f.object.end_date&.strftime("%Y-%m-%d"), |
72 | | - class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm", |
73 | | - style: "height: 56px;", |
74 | | - data: { |
75 | | - inactive_toggle_target: "endDate", |
76 | | - action: "change->inactive-toggle#toggle change->affiliation-dates#recalculate" |
77 | | - } |
78 | | - } %> |
79 | | - </div> |
| 70 | + <div class="w-full sm:w-auto pb-3"> |
| 71 | + <label class="block text-sm font-medium text-gray-700 mb-1">Primary contact</label> |
| 72 | + <%= f.check_box :primary_contact, |
| 73 | + checked: f.object.primary_contact? || !f.object.persisted?, |
| 74 | + class: "h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" %> |
| 75 | + </div> |
80 | 76 |
|
81 | | - <div class="shrink-0 whitespace-nowrap"> |
82 | | - <label class="block font-medium text-gray-700 mb-1">Primary org contact</label> |
83 | | - <div class="pt-2"> |
84 | | - <%= f.check_box :primary_contact, |
85 | | - checked: f.object.primary_contact? || !f.object.persisted?, |
86 | | - class: "h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" %> |
87 | | - </div> |
88 | | - <div class="-mb-2 text-right"> |
89 | | - <%= link_to_remove_association "Remove", |
90 | | - f, |
91 | | - class: "text-sm text-gray-400 hover:text-red-600 underline whitespace-nowrap" %> |
92 | | - </div> |
93 | | - </div> |
| 77 | + <div class="w-full text-right admin-only"> |
| 78 | + <%= link_to_remove_association "Remove", |
| 79 | + f, |
| 80 | + class: "text-sm text-gray-400 hover:text-red-600 underline whitespace-nowrap admin-only bg-blue-100 rounded px-2 py-1" %> |
94 | 81 | </div> |
95 | 82 | </div> |
96 | 83 | </div> |
|
0 commit comments