Skip to content

Commit

Permalink
Move resource details to the sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
ahukkanen committed Feb 14, 2024
1 parent 0ad3cdd commit 9ed5ab3
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
<%= cell("decidim/favorites/favorite_button", result, button_class: "link action-link", disable_tooltip: true) %>
</div>

<% if result.locations.any? %>
<div class="actions-panel bg-secondary">
<a href="#result_map" class="action-link">
<span class="link-text"><%= t ".show_on_map" %></span>
<%= icon "map-marker", role: "img", "aria-hidden": true %>
</a>
</div>
<% end %>

<div class="actions-panel bg-secondary">
<%= link_to "#comments", class: "action-link" do %>
<span class="link-text"><%= t ".show_comments" %></span>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<div class="attributes">
<h2 class="resource__aside__title"><%= t(".title") %></h2>

<% if result.reference.present? %>
<div class="attributes__item">
<h3 class="attributes__item__name"><%= t(".attributes.reference") %></h3>
<div class="attributes__item__value"><%= result.reference %></div>
</div>
<% end %>
<% if root_result.scope %>
<div class="attributes__item">
<h3 class="attributes__item__name">
<% if root_result.scope.parent %>
<%= translated_attribute root_result.scope.parent.name %>
<% else %>
<%= t(".attributes.scope") %>
<% end %>
</h3>
<div class="attributes__item__value">
<%= translated_attribute(root_result.scope.name) %>
</div>
</div>
<% end %>
<% if root_result.category.present? %>
<div class="attributes__item">
<h3 class="attributes__item__name"><%= t(".attributes.category") %></h3>
<div class="attributes__item__value">
<% if result.category.parent %>
<%= translated_attribute(root_result.category.parent.name) %> -
<% end %>
<%= translated_attribute(root_result.category.name) %>
</div>
</div>
<% end %>
<% if result.published? %>
<div class="attributes__item">
<h3 class="attributes__item__name"><%= t(".attributes.published_at") %></h3>
<div class="attributes__item__value"><%= l(result.published_at.to_date, format: :decidim_short) %></div>
</div>
<% end %>

<%= render partial: "result_attributes_extra", locals: { result: result, root_result: root_result } %>

<% result.result_all_details.each do |detail| %>
<% description = translated_attribute(detail.description_for(result)) %>
<% if description.present? %>
<div class="attributes__item">
<h3 class="attributes__item__name"><%= translated_attribute(detail.title) %></h3>
<div class="attributes__item__value"><%= description %></div>
</div>
<% end %>
<% end %>

<% if result.locations.any? %>
<div class="attributes__item">
<h3 class="attributes__item__name"><%= t(".attributes.location") %></h3>
<div class="attributes__item__value"><%= result.locations.map(&:address).join(", ") %></div>
</div>
<% end %>
</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%
# This file can be used to add extra attributes to the details section that will
# display under the default attributes and above the dynamic attributes.
#
# 1. Copy this file to views/decidim/results/_result_attributes_extra.html.erb
# 2. Do the desired changes there.
%>
37 changes: 14 additions & 23 deletions app/views/decidim/accountability/results/_show_parent.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<%
root_result = result
root_result = root_result.parent while root_result.parent
%>

<div class="row column back-link">
<%= link_to results_path, class: "action-link" do %>
<%= icon "arrow-left", role: "img", "aria-hidden": true %>
Expand All @@ -8,38 +13,24 @@
<div class="row column resource">
<div class="row">
<div class="columns small-12 medium-8">
<div class="resource__main static__content">
<div class="resource__main static__content margin-bottom-0">
<h1><%= translated_attribute result.title %></h1>

<div class="resource__info">
<% if result.scope %>
<div class="resource__info__item"><%= translated_attribute(result.scope.name) %></div>
<% end %>
<div class="resource__info__item">#<%= result.id %></div>
<% if result.published? %>
<div class="resource__info__item"><%= l(result.published_at.to_date, format: :decidim_short) %></div>
<% end %>
<% if result.category.present? %>
<div class="resource__info__item">
<% if result.category.parent %>
<%= translated_attribute(result.category.parent.name) %> -
<% end %>
<%= translated_attribute(result.category.name) %>
</div>
<% end %>
</div>

<% if result.main_image && result.main_image.attached? %>
<%= image_tag result.attached_uploader(:main_image).path, alt: translated_attribute(result.title), class: "resource-image" %>
<%= image_tag result.attached_uploader(:main_image).path, alt: translated_attribute(result.title), class: "resource__image" %>
<% end %>
</div>
</div>

<div class="columns small-12 medium-4">
<div class="resource__aside resource__actions">
<%= render partial: "result_actions", locals: { result: result } %>
<div class="resource__aside">
<div class="resource__actions">
<%= render partial: "result_actions", locals: { result: result } %>
</div>

<%= render partial: "result_attributes", locals: { result: @result, root_result: root_result } %>

<%= render partial: "stats_box", locals: { geocoded_results: geocoded_result } %>
<%= render partial: "stats_box", locals: { result: @result, root_result: root_result, geocoded_results: geocoded_result } %>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<h2><%= t(".subtitle") %></h2>

<p><%== translated_attribute result.summary %></p>

<div class="description">
Expand Down
72 changes: 0 additions & 72 deletions app/views/decidim/accountability/results/_stats_box.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<%
root_result = result
root_result = root_result.parent while root_result.parent
%>
<% if component_settings.display_progress_enabled? && result.progress.present? %>
<%= result_progress_info(root_result) do %>
<div class="progress-label">
Expand All @@ -19,71 +15,3 @@ root_result = root_result.parent while root_result.parent
</p>
<% end %>
<% end %>

<% if result.result_all_details.any? || !root_result.scope.nil? || !result.category.nil? || result.locations.any? %>
<%= result_detail_info(root_result) do %>
<% result.result_all_details.each do |detail| %>
<div class="definition-data__item result_detail">
<span class="definition-data__icon">
<%= result_detail_icon(result, detail) %>
</span>
<span class="definition-data__info">
<% if translated_attribute(detail.description_for(result)).empty? %>
<span class="definition-data__title"><%= translated_attribute detail.title %></span>
<% else %>
<span class="definition-data__title with_description"><%= translated_attribute detail.title %></span>
<span class="definition-data__description"><%= translated_attribute detail.description_for(result) %></span>
<% end %>
</span>
</div>
<% end %>

<% if root_result.scope %>
<div class="definition-data__item result_detail">
<span class="definition-data__icon">
<%= result_detail_icon(result) %>
</span>
<span class="definition-data__info">
<% if root_result.scope.parent %>
<span class="definition-data__title with_description"><%= translated_attribute root_result.scope.parent.name %></span>
<% else %>
<span class="definition-data__title with_description"><%= t("results.show.stats.scope", scope: "decidim.accountability") %></span>
<% end %>
<span class="definition-data__description"><%= translated_attribute root_result.scope.name %></span>
</span>
</div>
<% end %>

<% if root_result.category %>
<div class="definition-data__item result_detail">
<span class="definition-data__icon">
<%= result_detail_icon(result) %>
</span>
<span class="definition-data__info">
<span class="definition-data__title with_description"><%= t("results.show.stats.category", scope: "decidim.accountability") %></span>
<span class="definition-data__description"><%= translated_attribute root_result.category.name %></span>
</span>
</div>
<% end %>

<% if result.locations.any? %>
<div class="definition-data__item result_detail">
<span class="definition-data__icon">
<%= accountability_icon("map-marker") %>
</span>
<span class="definition-data__info">
<span class="definition-data__title with_description"><%= t ".location" %></span>
<span class="definition-data__description">
<%= result.locations.map(&:address).join(", ") %>
<% if geocoded_result.any? %>
<br>
<a href="#result_map"><%= t(".show_on_map") %></a>
<% end %>
</span>
</span>
</div>
<% end %>
<% end %>
<% end %>

<%= resource_reference(result) %>
15 changes: 13 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ en:
result_actions:
share: Share project
show_comments: Show project comments
show_on_map: Show on a map
result_attributes:
attributes:
category: Theme
id: Number (ID)
location: Location
published_at: Publish time
reference: Reference
scope: Area
title: Information
show:
stats:
scope: Scope
Expand All @@ -119,10 +129,11 @@ en:
back_to_list: Show other projects
locations: Project on a map
subresults: Sub projects
show_result_body:
description: Project description
subtitle: Project
stats_box:
average_progress: Average progress on all projects %{progress}.
location: Location
show_on_map: Show on a map
timeline:
title: Implementation timeline
accountability_simple:
Expand Down
15 changes: 13 additions & 2 deletions config/locales/fi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ fi:
result_actions:
share: Jaa hanke
show_comments: Katso hankkeen kommentit
show_on_map: Näytä kartalla
result_attributes:
attributes:
category: Teema
id: Numero (ID)
location: Sijainti
published_at: Julkaisuaika
reference: Viite
scope: Alue
title: Tiedot
show:
stats:
scope: Teema
Expand All @@ -119,10 +129,11 @@ fi:
back_to_list: Näytä muut hankkeet
locations: Hanke kartalla
subresults: Alihankkeet
show_result_body:
description: Hankkeen kuvaus
subtitle: Hanke
stats_box:
average_progress: Kaikkien hankkeiden edistymisen keskiarvo %{progress}.
location: Sijainti
show_on_map: Näytä kartalla
timeline:
title: Toteutuksen aikajana
accountability_simple:
Expand Down
15 changes: 13 additions & 2 deletions config/locales/sv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ sv:
result_actions:
share: Dela projekt
show_comments: Visa projektets kommentarer
show_on_map: Visa på kartan
result_attributes:
attributes:
category: Tema
id: Nummer (ID)
location: Plats
published_at: Publiceringstiden
reference: Referens
scope: Område
title: Information
show:
stats:
scope: Tema
Expand All @@ -119,10 +129,11 @@ sv:
back_to_list: Visa andra projekt
locations: Projekt på kartan
subresults: Delprojekt
show_result_body:
description: Projekt beskrivning
subtitle: Projekt
stats_box:
average_progress: Genomsnittlig framsteg på alla projekt %{progress}.
location: Plats
show_on_map: Visa på kartan
timeline:
title: Implementeringstidslinje
accountability_simple:
Expand Down

0 comments on commit 9ed5ab3

Please sign in to comment.