Skip to content

Commit 5fc7317

Browse files
authored
revert affiliation fields files (#1486)
1 parent c453cad commit 5fc7317

2 files changed

Lines changed: 132 additions & 155 deletions

File tree

app/views/organizations/_affiliation_fields.html.erb

Lines changed: 70 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,83 @@
11
<% if allowed_to?(:manage?, Organization) %>
22
<% expired = f.object.inactive? || (f.object.end_date.present? && f.object.end_date < Date.current) %>
33
<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' %>"
55
style="border-left: 4px solid <%= f.object.facilitator? ? '#e879f9' : '#d1d5db' %>"
66
<% if f.object.persisted? %>id="<%= dom_id(f.object) %>"<% end %>
77
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>
3442

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>
4954

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>
6369

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>
8076

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" %>
9481
</div>
9582
</div>
9683
</div>

app/views/people/_affiliation_fields.html.erb

Lines changed: 62 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,85 @@
11
<% if allowed_to?(:manage?, Person) %>
22
<% expired = f.object.inactive? || (f.object.end_date.present? && f.object.end_date < Date.current) %>
33
<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' %>"
55
style="border-left: 4px solid <%= f.object.facilitator? ? '#e879f9' : '#d1d5db' %>"
66
data-inactive-toggle-target="row">
7-
<div class="flex gap-x-4 items-start">
8-
<div class="shrink-0" style="width: 280px;" data-inactive-toggle-target="profileButton">
9-
<% if f.object.persisted? && f.object.organization.present? %>
10-
<label class="block font-medium text-gray-700 mb-1">Organization</label>
11-
<%= organization_profile_button(f.object.organization, truncate_at: 25) %>
12-
<%= f.hidden_field :organization_id %>
13-
<% else %>
14-
<label class="block font-medium text-gray-700 mb-1">Organization <abbr>*</abbr></label>
15-
<div class="rounded-md border border-gray-300 shadow-sm overflow-hidden" style="height: 56px;">
16-
<%= f.input :organization_id,
17-
include_blank: true,
18-
required: true,
19-
wrapper_html: { class: "mb-0 h-full" },
20-
input_html: {
21-
class: "h-full border-0",
22-
data: {
23-
controller: "remote-select",
24-
remote_select_model_value: "organization"
25-
}
26-
},
27-
error: "Organization can't be blank",
28-
prompt: "Search by name",
29-
label: false %>
30-
</div>
31-
<% end %>
32-
</div>
7+
<div style="width: 350px; min-width: 350px; flex-shrink: 0;" data-inactive-toggle-target="profileButton">
8+
<% if f.object.persisted? && f.object.organization.present? %>
9+
<label class="block text-sm font-medium text-gray-700 mb-1">Organization</label>
10+
<%= organization_profile_button(f.object.organization, truncate_at: 30) %>
11+
<%= f.hidden_field :organization_id %>
12+
<% else %>
13+
<%= f.input :organization_id,
14+
include_blank: true,
15+
required: true,
16+
input_html: {
17+
data: {
18+
controller: "remote-select",
19+
remote_select_model_value: "organization"
20+
}
21+
},
22+
error: "Organization can't be blank",
23+
prompt: "Search by name",
24+
label: "Organization",
25+
label_html: { class: "block text-sm font-medium text-gray-700 mb-1 " } %>
26+
<% end %>
27+
</div>
3328

34-
<div class="flex-1" style="min-width: 150px;">
29+
<div class="w-full sm:w-auto" style="min-width: 200px;">
30+
<div class="pt-1">
3531
<%= f.input :title,
3632
as: :text,
37-
wrapper_html: { class: "mb-0" },
3833
input_html: {
3934
rows: 1,
4035
value: f.object.title || "Facilitator",
41-
style: "height: 56px; min-height: 56px; padding-top: 14px;",
36+
style: "height: 42px; min-height: 42px;",
4237
data: {
4338
inactive_toggle_target: "title",
4439
action: "affiliation-dates#recalculate inactive-toggle#updateBorder"
4540
}
4641
} %>
4742
</div>
43+
</div>
4844

49-
<div class="shrink-0">
50-
<%= f.input :start_date,
51-
as: :string,
52-
label: "Start",
53-
wrapper_html: { class: "mb-0" },
54-
input_html: {
55-
type: "date",
56-
value: (f.object.start_date || (Date.current unless f.object.persisted?))&.strftime("%Y-%m-%d"),
57-
class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm",
58-
style: "height: 56px;",
59-
data: { action: "change->affiliation-dates#recalculate" }
60-
} %>
61-
</div>
45+
<div class="w-full sm:w-auto">
46+
<%= f.input :start_date,
47+
as: :string,
48+
label: "Start",
49+
input_html: {
50+
type: "date",
51+
value: (f.object.start_date || (Date.current unless f.object.persisted?))&.strftime("%Y-%m-%d"),
52+
class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm",
53+
data: { action: "change->affiliation-dates#recalculate" }
54+
} %>
55+
</div>
6256

63-
<div class="shrink-0">
64-
<%= f.input :end_date,
65-
as: :string,
66-
label: "End",
67-
wrapper_html: { class: "mb-0" },
68-
input_html: {
69-
type: "date",
70-
value: f.object.end_date&.strftime("%Y-%m-%d"),
71-
class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm",
72-
style: "height: 56px;",
73-
data: {
74-
inactive_toggle_target: "endDate",
75-
action: "change->inactive-toggle#toggle change->affiliation-dates#recalculate"
76-
}
77-
} %>
78-
</div>
57+
<div class="w-full sm:w-auto">
58+
<%= f.input :end_date,
59+
as: :string,
60+
label: "End",
61+
input_html: {
62+
type: "date",
63+
value: f.object.end_date&.strftime("%Y-%m-%d"),
64+
class: "rounded-md border-gray-300 focus:ring-blue-500 focus:border-blue-500 text-sm",
65+
data: {
66+
inactive_toggle_target: "endDate",
67+
action: "change->inactive-toggle#toggle change->affiliation-dates#recalculate"
68+
}
69+
} %>
70+
</div>
7971

80-
<div class="shrink-0 whitespace-nowrap">
81-
<label class="block font-medium text-gray-700 mb-1">Primary org contact</label>
82-
<div class="pt-2">
83-
<%= f.check_box :primary_contact,
84-
checked: f.object.primary_contact? || !f.object.persisted?,
85-
class: "h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" %>
86-
</div>
87-
<div class="-mb-2 text-right">
88-
<%= link_to_remove_association "Remove",
89-
f,
90-
class: "text-sm text-gray-400 hover:text-red-600 underline whitespace-nowrap" %>
91-
</div>
92-
</div>
72+
<div class="w-full sm:w-auto pb-3">
73+
<label class="block text-sm font-medium text-gray-700 mb-1">Primary contact</label>
74+
<%= f.check_box :primary_contact,
75+
checked: f.object.primary_contact? || !f.object.persisted?,
76+
class: "h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" %>
77+
</div>
78+
79+
<div class="w-full text-right admin-only">
80+
<%= link_to_remove_association "Remove",
81+
f,
82+
class: "text-sm text-gray-400 hover:text-red-600 underline whitespace-nowrap admin-only bg-blue-100 rounded px-2 py-1" %>
9383
</div>
9484
</div>
9585
</div>

0 commit comments

Comments
 (0)