Skip to content

Commit

Permalink
Update Administrate template overrides.
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvarner committed Sep 4, 2024
1 parent 61cb21e commit 70a6cf0
Show file tree
Hide file tree
Showing 20 changed files with 175 additions and 463 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ RUN bundle install
COPY . .

EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]
RUN chmod +x ./entrypoint.sh
ENTRYPOINT [ "./entrypoint.sh" ]
6 changes: 6 additions & 0 deletions app/controllers/landings_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

class LandingsController < ApplicationController
def index; end
# empty
end
11 changes: 4 additions & 7 deletions app/views/admin/entities/_collection.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ to display a collection of resources in an HTML table.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
%>

<table aria-labelledby="<%= table_title %>">
<thead>
<tr>
Expand All @@ -29,10 +28,10 @@ to display a collection of resources in an HTML table.
scope="col"
role="columnheader"
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
<%= link_to(sanitized_order_params(page, collection_field_name).merge(
<%= link_to(sanitized_order_params(page, collection_field_name).merge(
collection_presenter.order_params_for(attr_name, key: collection_field_name)
)) do %>
<%= t(
<%= t(
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
default: resource_class.human_attribute_name(attr_name),
).titleize %>
Expand All @@ -55,17 +54,16 @@ to display a collection of resources in an HTML table.
) %>
</tr>
</thead>

<tbody>
<% resources.each do |resource| %>
<tr class="js-table-row"
<% if show_action? :show, resource %>
<% if accessible_action? :show, resource %>
<%= %(tabindex=0 role=link data-url=#{polymorphic_path([namespace, resource])}) %>
<% end %>
>
<% collection_presenter.attributes_for(resource).each do |attribute| %>
<td class="cell-data cell-data--<%= attribute.html_class %>">
<% if show_action? :show, resource -%>
<% if accessible_action? :show, resource -%>
<a href="<%= polymorphic_path([namespace, resource]) -%>"
tabindex="-1"
class="action-show"
Expand All @@ -77,7 +75,6 @@ to display a collection of resources in an HTML table.
<% end -%>
</td>
<% end %>

<%= render(
"collection_item_actions",
collection_presenter: collection_presenter,
Expand Down
16 changes: 8 additions & 8 deletions app/views/admin/entities/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ and renders all form fields for a resource's editable attributes.
resource_name: display_resource_name(page.resource_name, singular: true)
) %>
</h2>

<ul>
<% page.resource.errors.full_messages.each do |message| %>
<li class="flash-error"><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="entity-form">
<div class="field-unit field-unit--string field-unit--optional">
<div class="field-unit__label">
Expand All @@ -49,12 +47,14 @@ and renders all form fields for a resource's editable attributes.
<%= page.resource.legacy_pk %>
</div>
</div>
<% page.attributes(controller.action_name).each do |attribute| -%>
<% next unless page.resource.allowed_attributes.include? attribute.name.to_sym %>
<% next if attribute.name == 'e_type' %>
<div class="field-unit field-unit--<%= attribute.html_class %> field-unit--<%= requireness(attribute) %>">
<%= render_field attribute, f: f %>
</div>
<% page.attributes(controller.action_name).each do |title, attributes| -%>
<% attributes.each do |attribute| %>
<% next unless page.resource.allowed_attributes.include? attribute.name.to_sym %>
<% next if attribute.name == 'e_type' %>
<div class="field-unit field-unit--<%= attribute.html_class %> field-unit--<%= requireness(attribute) %>">
<%= render_field attribute, f: f %>
</div>
<% end -%>
<% end -%>
<input type="hidden" name="entity[e_type]" value=<%= page.resource.e_type %> autocomplete="off">
<div class="form-actions">
Expand Down
6 changes: 1 addition & 5 deletions app/views/admin/entities/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,19 @@ It displays a header, and renders the `_form` partial to do the heavy lifting.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
%>

<% content_for(:title) { t("administrate.actions.edit_resource", name: '') } %>

<header class="main-content__header" role="banner">
<h1 class="main-content__page-title">
<%= content_for(:title) %>
</h1>

<div>
<%= link_to(
t("administrate.actions.show_resource", name: ''),
[namespace, page.resource],
class: "button",
) if valid_action?(:show) && show_action?(:show, page.resource) %>
) if valid_action?(:show) && accessible_action?(:show, page.resource) %>
</div>
</header>

<section class="main-content__body">
<%= render "form", page: page %>
</section>
134 changes: 60 additions & 74 deletions app/views/admin/entities/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,139 +15,125 @@ as well as a link to its edit page.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
%>

<style>
.label {
font-weight: 400;
}

.section-head {
background: gray;
padding: 0.5rem;
color: white;
margin-bottom: 0.5rem;
}

.attribute-data--select {
text-transform: capitalize;
}

table a {
color: #1976d2;
text-decoration: underline;
}

h2 {
font-size: 2rem;
}

table {
max-width: 50vw;
}

th:first-child {
padding-left: 0;
width: 0;
}
.label {
font-weight: 400;
}

.section-head {
background: gray;
padding: 0.5rem;
color: white;
margin-bottom: 0.5rem;
}

.attribute-data--select {
text-transform: capitalize;
}

table a {
color: #1976d2;
text-decoration: underline;
}

h2 {
font-size: 2rem;
}

table {
max-width: 50vw;
}

th:first-child {
padding-left: 0;
width: 0;
}
</style>

<% content_for(:title) { t("administrate.actions.show_resource", name: '') } %>

<header class="main-content__header" role="banner">
<h1 class="main-content__page-title">
<%= content_for(:title) %>
</h1>

<div>
<%= link_to(
t("administrate.actions.edit_resource", name: ''),
[:edit, namespace, page.resource],
class: "button",
) if valid_action?(:edit) && show_action?(:edit, page.resource) %>
) if valid_action?(:edit) && accessible_action?(:edit, page.resource) %>
</div>
</header>

<section class="main-content__body">
<h1 class="section-head">Short Display</h1>
<%= render inline: page.resource.short_display %>
</section>

<hr />

<section class="main-content__body">
<h1 class="section-head">Full Display</h1>
<h2><%= page.resource.e_type.titleize %>: <span class="label"><%= render inline: page.resource.label %></span></h2>
<%= render inline: page.resource.full_display %>
</section>

<section class="main-content__body">
<dl>
<% page.attributes.each do |attribute| %>
<% next unless page.resource.allowed_attributes.include? attribute.name.to_sym %>
<% next unless page.resource.allowed_attributes.include? attribute.name.to_sym %>
<dt class="attribute-label" id="<%= attribute.name %>">
<%= t(
<%= t(
"helpers.label.#{resource_name}.#{attribute.name}",
default: page.resource.class.human_attribute_name(attribute.name),
) %>
</dt>

<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute, page: page %></dd>
<% end %>
</dl>
</section>

<section class="main-content__body">
<dl>
<dt class="attribute-label">Mentions</dt>
<dd class="attribute-data">
<% page.resource.letters.each do |letter| %>
<a href="<%= "/admin/letters/#{letter.id}" -%>"><%= letter.label %></a><br>
<% end %>
</dd>
<dd class="attribute-data">
<% page.resource.letters.each do |letter| %>
<a href="<%= "/admin/letters/#{letter.id}" -%>"><%= letter.label %></a><br>
<% end %>
</dd>
</dl>
</section>

<section class="main-content__body">
<dl>
<dt class="attribute-label">Letters Received</dt>
<dd class="attribute-data">
<% page.resource.letters_received.each do |letter| %>
<a href="<%= "/admin/letters/#{letter.id}" -%>"><%= letter.label %></a><br>
<% end %>
</dd>
<dd class="attribute-data">
<% page.resource.letters_received.each do |letter| %>
<a href="<%= "/admin/letters/#{letter.id}" -%>"><%= letter.label %></a><br>
<% end %>
</dd>
</dl>
</section>

<section class="main-content__body">
<dl>
<dt class="attribute-label">Letters Sent to Place</dt>
<dd class="attribute-data">
<% page.resource.letters_sent_to.each do |letter| %>
<a href="<%= "/admin/letters/#{letter.id}" -%>"><%= letter.label %></a><br>
<% end %>
</dd>
<dd class="attribute-data">
<% page.resource.letters_sent_to.each do |letter| %>
<a href="<%= "/admin/letters/#{letter.id}" -%>"><%= letter.label %></a><br>
<% end %>
</dd>
</dl>
</section>

<section class="main-content__body">
<dl>
<dt class="attribute-label">Letters Sent from Place</dt>
<dd class="attribute-data">
<% page.resource.letters_sent_from.each do |letter| %>
<a href="<%= "/admin/letters/#{letter.id}" -%>"><%= letter.label %></a><br>
<% end %>
</dd>
<dd class="attribute-data">
<% page.resource.letters_sent_from.each do |letter| %>
<a href="<%= "/admin/letters/#{letter.id}" -%>"><%= letter.label %></a><br>
<% end %>
</dd>
</dl>
</section>

<section class="main-content__body">
<dl>
<dt class="attribute-label">Letters Sent</dt>
<dd class="attribute-data">
<% page.resource.letters_sent.each do |letter| %>
<a href="<%= "/admin/letters/#{letter.id}" -%>"><%= letter.label %></a><br>
<% end %>
</dd>
<dd class="attribute-data">
<% page.resource.letters_sent.each do |letter| %>
<a href="<%= "/admin/letters/#{letter.id}" -%>"><%= letter.label %></a><br>
<% end %>
</dd>
</dl>
</section>
11 changes: 4 additions & 7 deletions app/views/admin/letters/_collection.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ to display a collection of resources in an HTML table.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
%>

<table aria-labelledby="<%= table_title %>">
<thead>
<tr>
Expand All @@ -29,10 +28,10 @@ to display a collection of resources in an HTML table.
scope="col"
role="columnheader"
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
<%= link_to(sanitized_order_params(page, collection_field_name).merge(
<%= link_to(sanitized_order_params(page, collection_field_name).merge(
collection_presenter.order_params_for(attr_name, key: collection_field_name)
)) do %>
<%= t(
<%= t(
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
default: resource_class.human_attribute_name(attr_name),
).titleize %>
Expand All @@ -55,17 +54,16 @@ to display a collection of resources in an HTML table.
) %>
</tr>
</thead>

<tbody>
<% resources.each do |resource| %>
<tr class="js-table-row"
<% if show_action? :show, resource %>
<% if accessible_action? :show, resource %>
<%= %(tabindex=0 role=link data-url=#{polymorphic_path([namespace, resource])}) %>
<% end %>
>
<% collection_presenter.attributes_for(resource).each do |attribute| %>
<td class="cell-data cell-data--<%= attribute.html_class %>">
<% if show_action? :show, resource -%>
<% if accessible_action? :show, resource -%>
<a href="<%= polymorphic_path([namespace, resource]) -%>"
tabindex="-1"
class="action-show"
Expand All @@ -81,7 +79,6 @@ to display a collection of resources in an HTML table.
<% end -%>
</td>
<% end %>

<%= render(
"collection_item_actions",
collection_presenter: collection_presenter,
Expand Down
Loading

0 comments on commit 70a6cf0

Please sign in to comment.