Skip to content

Commit

Permalink
Merge pull request #2062 from MushroomObserver/nimmo-show-location
Browse files Browse the repository at this point in the history
Try to spiff up show location
  • Loading branch information
nimmolo committed Mar 24, 2024
2 parents f7361b5 + 3e6fb6d commit dcffad0
Show file tree
Hide file tree
Showing 29 changed files with 272 additions and 178 deletions.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/mo/_matrix_box.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ h5.rss-heading {
background: rgba($panel-bg, 0.45);
}

.panel .list-group-item {
background: transparent;
}

// .panel-footer {
// background: none;
// }
Expand Down
62 changes: 31 additions & 31 deletions app/helpers/descriptions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ def reader?(desc)
# # Renders something like this:
# <p>EOL Project Draft: Show | Edit | Destroy</p>
#
def show_embedded_description_title(desc, type)
title = description_title(desc)
links = description_mod_links(desc, type)
tag.div do
[tag.span(title, class: "text-lg"),
links.safe_join(" | ")].safe_join(safe_nbsp)
end
end
# Maybe unused presently
# def show_embedded_description_title(desc, type)
# title = description_title(desc)
# links = description_mod_links(desc, type)
# tag.div do
# [tag.span(title, class: "text-lg"),
# links.safe_join(" | ")].safe_join(safe_nbsp)
# end
# end

def description_mod_links(desc, type)
links = []
Expand Down Expand Up @@ -97,29 +98,6 @@ def make_list_links(list, type, fake_default, current = nil)
list
end

# Be sure to preload the ivars @versions and @projects sent as args.
def show_description_details_and_alternates(desc, versions, projects,
review: false)
panel_block(
id: "description_details",
heading: :show_observation_details.l,
heading_links: description_change_links(desc),
footer: review ? show_description_export_and_review(desc) : nil
) do
tag.div(class: "row") do
[
tag.div(class: "col-xs-12 col-md-6") do
show_description_details(desc, versions)
end,
tag.div(class: "col-xs-12 col-md-6") do
show_alt_descriptions(object: desc.parent, projects: projects,
current: desc)
end
].safe_join
end
end
end

# Details of a description for a show_description page.
def show_description_details(description, versions, user = User.current)
parent = description.parent
Expand Down Expand Up @@ -247,6 +225,28 @@ def show_alt_descriptions(object:, projects: nil, current: nil)
html
end

# This is the same as show_alt_descriptions, but in its own panel block.
def show_alt_descriptions_panel(object:, projects: nil, current: nil)
type = object.type_tag

# Add title and maybe "no descriptions", wrapping it all up in paragraph.
list = list_descriptions(object: object, type: type, current: current)
any = list.any?
list << indent + :"show_#{type}_no_descriptions".t unless any
html = list.safe_join(safe_br)

add_list_of_projects(object, type, html, projects) if projects.present?

# Show existing drafts, with link to create new one.
panel_block(
id: "alt_descriptions",
heading: :show_name_descriptions.l,
heading_links: icon_link_to(*create_description_tab(object, type))
) do
html
end
end

# Show list of projects user is a member of.
def add_list_of_projects(object, type, html, projects)
return if projects.blank?
Expand Down
66 changes: 33 additions & 33 deletions app/helpers/link_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def modal_link_to(identifier, name, path, args)

# pass title if it's a plain button (say for collapse) but you want a tooltip
def link_icon(type, title: "")
return "" unless (glyph = link_icon_index[type])
return "" unless (glyph = LINK_ICON_INDEX[type])

text = ""
opts = { class: "glyphicon glyphicon-#{glyph} px-2" }
Expand All @@ -125,38 +125,38 @@ def link_icon(type, title: "")
tag.span(text, **opts)
end

def link_icon_index
{
edit: "edit",
delete: "remove-circle",
add: "plus",
back: "step-backward",
show: "eye-open",
hide: "eye-close",
reuse: "share",
x: "remove",
remove: "remove-circle",
send: "send",
ban: "ban-circle",
minus: "minus-sign",
trash: "trash",
cancel: "remove",
email: "envelope",
question: "question-sign",
list: "list",
clone: "duplicate",
merge: "transfer",
move: "random",
adjust: "resize-vertical",
make_default: "star",
publish: "upload",
deprecate: "ok-circle", # approved name needs to look "approved"
approve: "exclamation-sign", # deprecated name needs to look "deprecated"
synonyms: "random",
tracking: "bullhorn",
manage_lists: "indent-left"
}.freeze
end
# NOTE: Specific to glyphicons
LINK_ICON_INDEX = {
edit: "edit",
delete: "remove-circle",
add: "plus",
back: "step-backward",
show: "eye-open",
hide: "eye-close",
reuse: "share",
x: "remove",
remove: "remove-circle",
send: "send",
ban: "ban-circle",
minus: "minus-sign",
trash: "trash",
cancel: "remove",
email: "envelope",
question: "question-sign",
list: "list",
clone: "duplicate",
merge: "transfer",
move: "random",
adjust: "resize-vertical",
make_default: "star",
publish: "upload",
deprecate: "ok-circle", # approved name needs to look "approved"
approve: "exclamation-sign", # deprecated name needs to look "deprecated"
synonyms: "random",
tracking: "bullhorn",
manage_lists: "indent-left",
observations: "tags"
}.freeze

# button to destroy object
# Used instead of link_to because method: :delete requires jquery_ujs library
Expand Down
61 changes: 46 additions & 15 deletions app/helpers/tabs/locations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,34 @@ def locations_index_tabs(query:)
end

# Composed links because there's interest_icons
def location_show_tabs(location:)
links = [
observations_at_location_tab(location),
def location_show_tabs
[
# observations_at_location_tab(location),
locations_index_tab,
new_location_tab,
edit_location_tab(location)
new_location_tab
# edit_location_tab(location)
]
if in_admin_mode?
links += [
destroy_location_tab(location),
location_reverse_order_tab(location)
]
# if in_admin_mode?
# links += [
# destroy_location_tab(location),
# location_reverse_order_tab(location)
# ]
# end
# links
end

def location_show_heading_links(location:)
links = location_show_tabs(location: location)
icons = []
links.each do |link|
icons << icon_link_to(*link)
end
links
icons
end

def new_location_tab
[:show_location_create.t, add_query_param(new_location_path),
{ class: tab_id(__method__.to_s) }]
{ class: tab_id(__method__.to_s), icon: :add }]
end

def map_locations_tab
Expand All @@ -48,7 +57,7 @@ def location_countries_tab
def edit_location_tab(location)
[:show_location_edit.t,
add_query_param(edit_location_path(location.id)),
{ class: tab_id(__method__.to_s) }]
{ class: tab_id(__method__.to_s), icon: :edit }]
end

def destroy_location_tab(location)
Expand All @@ -58,7 +67,29 @@ def destroy_location_tab(location)
def location_reverse_order_tab(location)
[:show_location_reverse.t,
add_query_param(location_reverse_name_order_path(location.id)),
{ class: tab_id(__method__.to_s) }]
{ class: tab_id(__method__.to_s), icon: :back }]
end

# description tabs:
def location_show_description_tab(location)
return unless location&.description

[:show_name_see_more.l,
add_query_param(location_description_path(location.description.id)),
{ class: tab_id(__method__.to_s), icon: :list }]
end

def location_edit_description_tab(location)
return unless location&.description

[:EDIT.l, edit_location_description_path(location.description.id),
{ class: tab_id(__method__.to_s), icon: :edit }]
end

def location_new_description_tab(location)
[:show_name_create_description.l,
new_location_description_path(location.id),
{ class: tab_id(__method__.to_s), icon: :add }]
end

def location_version_tabs(location:)
Expand All @@ -79,7 +110,7 @@ def locations_index_tab
def observations_at_location_tab(location)
[show_obs_link_title_with_count(location),
add_query_param(observations_path(location: location.id)),
{ class: tab_id(__method__.to_s) }]
{ class: tab_id(__method__.to_s), icon: :observations }]
end

def location_map_title(query:)
Expand Down
10 changes: 5 additions & 5 deletions app/helpers/versions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ module VersionsHelper
#
def show_previous_version(obj, versions)
previous_version = versions&.last(2)&.first
if previous_version
if !previous_version || previous_version&.version == obj.version
current_version_html(obj)
elsif previous_version
previous_version_link(previous_version, obj)
else
initial_version_html(obj)
end
end

Expand Down Expand Up @@ -47,7 +47,7 @@ def show_past_versions(obj, versions, args = {})

def previous_version_link(previous_version, obj)
str = "#{:show_name_previous_version.t} #{previous_version.version}"
initial_version_html(obj) +
current_version_html(obj) +
# FIX THIS: Send the path helper the id and version param.
link_with_query(str,
{ controller: "#{obj.show_controller}/versions",
Expand All @@ -57,7 +57,7 @@ def previous_version_link(previous_version, obj)
safe_br
end

def initial_version_html(obj)
def current_version_html(obj)
:VERSION.t + ": " + obj.version.to_s + safe_br
end

Expand Down
4 changes: 2 additions & 2 deletions app/views/controllers/comments/_object.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
render(partial: "locations/show/location", object: object)

when "LocationDescription"
render(partial: "descriptions/show_description_details")
render(partial: "descriptions/description_details_and_alts_panel")

when "Name"
str = render(partial: "names/show/nomenclature",
Expand All @@ -16,7 +16,7 @@
content_tag(:div, str, class: "name-section m-3")

when "NameDescription"
render(partial: "descriptions/show_description_details")
render(partial: "descriptions/description_details_and_alts_panel")

when "Observation"
render(partial: "observations/show/observation_details",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<%# Top panel for any description, the basic details and alternatives %>
<% review ||= false %>
<%=
panel_block(
id: "description_details_and_alts",
heading: :show_observation_details.l,
heading_links: description_change_links(@description),
footer: review ? show_description_export_and_review(@description) : nil
) do
tag.div(class: "row") do
[
tag.div(class: "col-xs-12 col-md-6") do
show_description_details(@description, @versions)
end,
tag.div(class: "col-xs-12 col-md-6") do
show_alt_descriptions(object: @description.parent, projects: @projects,
current: @description)
end
].safe_join
end
end
%>

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/controllers/locations/descriptions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_pager_for(@description)
@container = :wide
%>
<%= render(partial: "descriptions/show_description_details") %>
<%= render(partial: "descriptions/description_details_and_alts_panel") %>
<%= render(partial: "descriptions/show_description_notes") %>
<%= render(partial: "descriptions/show_description_authors_and_editors") %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ add_tab_set(location_description_version_tabs(description: @description,
<%= show_past_versions(@description, @versions) %>
<%= render(partial: "descriptions/show_description_details") %>
<%= render(partial: "descriptions/description_details_and_alts_panel") %>
<%= show_object_footer(@description, @versions) %>
Loading

0 comments on commit dcffad0

Please sign in to comment.