Skip to content

Commit

Permalink
Adjust site show layout
Browse files Browse the repository at this point in the history
To accomodate inline editing.
  • Loading branch information
joeroe committed Nov 20, 2023
1 parent 880c643 commit 136258b
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 73 deletions.
59 changes: 21 additions & 38 deletions app/views/sites/_site_details.html.erb
Original file line number Diff line number Diff line change
@@ -1,47 +1,30 @@
<dl class="row gx-5">
<dl>

<div class="col-lg">
<!-- Site metadata -->
<dt><small>Canonical name</small></dt>
<dd class="font-monospace"><%= site.name %></dd>

<div class="row">
<dt class="col-sm-3">Canonical name</dt>
<dd class="col-sm-9 text-end"><%= site.name %></dd>
<dt><small>Other names</small></dt>
<dd class="font-monospace"><%= na_value %></dd>

<dt class="col-sm-3">Other names</dt>
<dd class="col-sm-9 text-end"><!-- not yet implemented --><%= na_value %></dd>
<dt><small><%= "Site type".pluralize(site.site_types.count) %></small></dt>
<dd class="font-monospace">
<% if site.site_types.any? %>
<%= site.site_types.collect(&:name).to_sentence.humanize %>
<% else %>
<%= na_value %>
<% end %>
</dd>

<dt class="col-sm-3"><%= "Site type".pluralize(site.site_types.count) %></dt>
<dd class="col-sm-9 text-end">
<% if site.site_types.any? %>
<%= site.site_types.collect(&:name).to_sentence.humanize %>
<% else %>
<%= na_value %>
<% end %>
</dd>
<dt><small>Country</small></dt>
<dd class="font-monospace"><%= render "sites/country", site: site %></dd>

<dt class="col-sm-3"><%= "Reference".pluralize(site.references.count) %></dt>
<dd class="col-sm-9 text-end">
<%# render "references/citations", references: site.references %>
</dd>
<dt><small>Coordinates</small></dt>
<dd class="font-monospace"><%= site.coordinates.present? ? site.coordinates : na_value %></dd>

</div>

</div>

<div class="col-lg">
<!-- Location data -->

<div class="row">
<dt class="col-sm-3">Country</dt>
<dd class="col-sm-9 text-end"><%= render "sites/country", site: site %></dd>
</div>

<div class="row">
<dt class="col-sm-3">Coordinates</dt>
<dd class="col-sm-9 font-monospace text-end"><%= site.coordinates.present? ? site.coordinates : na_value %></dd>
</div>

</div>
<dt><small><%= "Reference".pluralize(site.references.count) %></small></dt>
<dd class="font-monospace">
<%= render "references/citations", references: site.references %>
</dd>

</dl>

78 changes: 43 additions & 35 deletions app/views/sites/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,42 @@

<section id="site-details" class="bg-body">
<div class="container my-5">
<div class="d-flex">
<h2>
<%= xr_icon Site, {}, style: "width: auto; height: 2rem" %>
<%= Site.label.humanize %> details
</h2>
<% if can? :edit, Site %>
<div class="ms-auto">
<%= link_to edit_icon,
edit_site_path,
class: "btn btn-sm btn-outline-primary",
data: { "turbo_frame": "remote_modal" } %>
</div>
<% end %>
</div>
<%= render "site_details", site: @site %>
<% if can? :edit, Site %>
<div class="text-end my-3">
<%= link_to(edit_site_path, class: "btn btn-sm btn-primary", data: { "turbo_frame": "remote_modal" }) do %>
<%= edit_icon %> Edit site details
<% end %>
</div>
<% end %>
</div>
</section>

<section id="site-xrons" class="bg-body">
<% unless @c14s.nil? %>
<div id="site-c14s" class="container my-5">
<h2>
<%= xr_icon C14, {}, style: "height: 2rem" %>
<%= C14.label.humanize.pluralize %>
<small class="text-muted">(<%= @pagy_c14s.count %>)</small>
</h2>
<turbo-frame id="site-c14s-table">
<div id="sites-c14s-toolbar" class="d-flex">
<div class="ms-auto">
<%= link_to bs_icon("download"),
c14s_path(format: :csv, c14: { sample: { contexts: { site_id: @site.id } } }),
class: "btn btn-sm btn-outline-primary",
title: "Download CSV" %>
</div>
<div id="sites-c14s-toolbar" class="d-flex">
<h2>
<%= xr_icon C14, {}, style: "width: auto; height: 2rem" %>
<%= C14.label.humanize.pluralize %>
<small class="text-muted">(<%= @pagy_c14s.count %>)</small>
</h2>
<div class="ms-auto">
<%= link_to bs_icon("download"),
c14s_path(format: :csv, c14: { sample: { contexts: { site_id: @site.id } } }),
class: "btn btn-sm btn-outline-primary",
title: "Download CSV" %>
</div>
</div>

<turbo-frame id="site-c14s-table">
<%= render "c14s/table", c14s: @c14s %>
<% unless @pagy_c14s.pages <= 1 %>
<%== pagy_bootstrap_nav(@pagy_c14s) %>
Expand All @@ -64,20 +72,20 @@

<% unless @typos.nil? %>
<div id="site-typos" class="container my-5">
<h2>
<%= xr_icon Typo, {}, style: "height: 2rem" %>
<%= Typo.label.humanize.pluralize %>
<small class="text-muted">(<%= @pagy_typos.count %>)</small>
</h2>
<turbo-frame id="site-typos-table">
<div id="sites-typos-toolbar" class="d-flex">
<div class="ms-auto">
<%= link_to bs_icon("download"),
typos_path(format: :csv, typo: { sample: { contexts: { site_id: @site.id } } }),
class: "btn btn-sm btn-outline-primary",
title: "Download CSV" %>
</div>
<div id="sites-typos-toolbar" class="d-flex">
<h2>
<%= xr_icon Typo, {}, style: "width: auto; height: 2rem" %>
<%= Typo.label.humanize.pluralize %>
<small class="text-muted">(<%= @pagy_typos.count %>)</small>
</h2>
<div class="ms-auto">
<%= link_to bs_icon("download"),
typos_path(format: :csv, typo: { sample: { contexts: { site_id: @site.id } } }),
class: "btn btn-sm btn-outline-primary",
title: "Download CSV" %>
</div>
</div>
<turbo-frame id="site-typos-table">
<%= render "typos/table", typos: @typos %>
<% unless @pagy_typos.pages <= 1 %>
<%== pagy_bootstrap_nav(@pagy_typos) %>
Expand All @@ -92,9 +100,9 @@
<section id="references" class="bg-body">
<div class="container my-5">
<h2>
<%= xr_icon Reference, {}, style: "height: 2rem" %>
<%= xr_icon Reference, {}, style: "width: auto; height: 2rem" %>
<%= Reference.label.humanize.pluralize %>
<small class="text-muted">(<%# @site.recursive_references.count %>)</small>
<!-- <small class="text-muted">(<%# @site.recursive_references.count %>)</small>-->
</h2>
<%= render "references/bibliography",
references: @site.recursive_references %>
Expand Down

0 comments on commit 136258b

Please sign in to comment.