diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 6d728cc..b08c28c 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -511,6 +511,19 @@ hr { color: #7a8189; } +.schedule-item__location a, +.plan-item__location a { + color: inherit; + text-decoration: underline; + text-decoration-thickness: 1px; + text-underline-offset: 2px; +} + +.schedule-item__location a:hover, +.plan-item__location a:hover { + color: #C41C1C; +} + .schedule-item__description { font-size: 0.9375rem; color: #404040; @@ -701,6 +714,18 @@ hr { } } +.field-grid-2 { + display: grid; + grid-template-columns: 1fr; + gap: 1rem; +} + +@media (min-width: 640px) { + .field-grid-2 { + grid-template-columns: 1fr 1fr; + } +} + .travel-row { display: flex; flex-direction: column; diff --git a/app/controllers/admin/schedule_items_controller.rb b/app/controllers/admin/schedule_items_controller.rb index 62ac073..9814a2b 100644 --- a/app/controllers/admin/schedule_items_controller.rb +++ b/app/controllers/admin/schedule_items_controller.rb @@ -48,7 +48,7 @@ def set_schedule_item def schedule_item_params attrs = params.require(:schedule_item).permit( :day, :time_label, :sort_time, :title, :host, - :location, :description, :kind, :flexible, :is_public, + :location, :map_url, :description, :kind, :flexible, :is_public, :embassy_mode, :embassy_capacity ) unless attrs[:kind] == "embassy" diff --git a/app/controllers/schedule_items_controller.rb b/app/controllers/schedule_items_controller.rb index c8eb1a1..9d8aa90 100644 --- a/app/controllers/schedule_items_controller.rb +++ b/app/controllers/schedule_items_controller.rb @@ -67,7 +67,7 @@ def set_schedule_item # :created_by_id — forced by association scope (current_user.created_schedule_items) def schedule_item_params params.require(:schedule_item).permit( - :day, :time_label, :title, :location, :description, :flexible, :is_public + :day, :time_label, :title, :location, :map_url, :description, :flexible, :is_public ) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4d52eaa..bb162c0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -9,4 +9,17 @@ def sort_link(label, key) href = "#{request.path}?#{params.to_query}" link_to text, href, class: active ? "sort-active" : nil end + + # Renders a schedule item's location as a link to its map URL when one is + # set, otherwise as plain text. Returns nil when the item has no location. + def location_or_map_link(item) + return nil if item.location.blank? + if item.map_url.present? + link_to item.location, item.map_url, + target: "_blank", + rel: "noopener noreferrer" + else + item.location + end + end end diff --git a/app/views/admin/schedule_items/_form.html.erb b/app/views/admin/schedule_items/_form.html.erb index 3da7acc..da2de51 100644 --- a/app/views/admin/schedule_items/_form.html.erb +++ b/app/views/admin/schedule_items/_form.html.erb @@ -66,6 +66,15 @@ <%= f.text_field :location, class: "input" %> +
+ Optional. Paste a Google Maps short URL. If set, the venue name becomes a link on the schedule. +
+<%= item.location %>
+<%= location_or_map_link(item) %>
<% end %> <% if item.description.present? %> diff --git a/app/views/schedule/_session_item.html.erb b/app/views/schedule/_session_item.html.erb index da8cc22..ec8e7b0 100644 --- a/app/views/schedule/_session_item.html.erb +++ b/app/views/schedule/_session_item.html.erb @@ -62,7 +62,7 @@ <% end %> <% if item.location.present? %> -<%= item.location %>
+<%= location_or_map_link(item) %>
<% end %> <% if item.description.present? %> diff --git a/app/views/schedule_items/_form.html.erb b/app/views/schedule_items/_form.html.erb index 79805fe..4d83ab8 100644 --- a/app/views/schedule_items/_form.html.erb +++ b/app/views/schedule_items/_form.html.erb @@ -16,20 +16,27 @@ submit the intended day without an extra dropdown. %> <%= f.hidden_field :day %> -