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 d273264 commit 2d38a98
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 39 deletions.
37 changes: 37 additions & 0 deletions app/views/decidim/ideas/ideas/_idea_attributes.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<div class="attributes">
<h2 class="resource__aside__title"><%= t(".title") %></h2>

<div class="attributes__item">
<h3 class="attributes__item__name"><%= t(".attributes.id") %></h3>
<div class="attributes__item__value"><%= idea.id %></div>
</div>
<% if has_visible_area_scope?(idea) %>
<div class="attributes__item">
<h3 class="attributes__item__name"><%= t(".attributes.area") %></h3>
<div class="attributes__item__value"><%= translated_attribute(idea.area_scope.name) %></div>
</div>
<% end %>
<% if idea.category.present? %>
<div class="attributes__item">
<h3 class="attributes__item__name"><%= t(".attributes.category") %></h3>
<div class="attributes__item__value">
<% if idea.category.parent %>
<%= translated_attribute(idea.category.parent.name) %> -
<% end %>
<%= translated_attribute(idea.category.name) %>
</div>
</div>
<% end %>
<% if idea.published? %>
<div class="attributes__item">
<h3 class="attributes__item__name"><%= t(".attributes.published_at") %></h3>
<div class="attributes__item__value"><%= l(idea.published_at.to_date, format: :decidim_short) %></div>
</div>
<% end %>
<% if component_settings.geocoding_enabled? && idea.address.present? %>
<div class="attributes__item">
<h3 class="attributes__item__name"><%= t(".attributes.address") %></h3>
<div class="attributes__item__value"><%= idea.address %></div>
</div>
<% end %>
</div>
2 changes: 1 addition & 1 deletion app/views/decidim/ideas/ideas/_idea_controls.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="resource-control-panel margin-top-3">
<div class="title h3"><%= t ".manage_idea" %></div>
<h2 class="resource__aside__title"><%= t ".manage_idea" %></h2>

<div class="resource-controls">
<% if allowed_to?(:edit, :idea, idea: idea) %>
Expand Down
57 changes: 19 additions & 38 deletions app/views/decidim/ideas/ideas/_idea_full.html.erb
Original file line number Diff line number Diff line change
@@ -1,58 +1,38 @@
<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><%= present(idea).title(links: true, html_escape: true) %></h1>

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

<% if component_settings.geocoding_enabled? && idea.address.present? %>
<div class="resource__info__item"><%= idea.address %></div>
<% end %>
</div>

<% if idea.respond_to?(:tags) && idea.tags.any? %>
<div class="resource__tags">
<%= cell("decidim/tags/tags", idea) %>
</div>
<% end %>

<% if idea.image && idea.image.main_url %>
<%= image_tag idea.image.main_url, class:"resource-image", alt: strip_tags(translated_attribute(idea.image.title)) %>
<%= image_tag idea.image.main_url, class:"resource__image", alt: strip_tags(translated_attribute(idea.image.title)) %>
<% elsif category_image_path(idea.category) %>
<%= image_tag category_image_path(idea.category), class:"resource-image", alt: strip_tags(present(idea).title(html_escape: true)) %>
<%= image_tag category_image_path(idea.category), class:"resource__image", alt: strip_tags(present(idea).title(html_escape: true)) %>
<% else %>
<%= image_tag asset_pack_path("media/images/idea-default.jpg"), class:"resource-image", alt: strip_tags(present(idea).title(html_escape: true)) %>
<%= image_tag asset_pack_path("media/images/idea-default.jpg"), class:"resource__image", alt: strip_tags(present(idea).title(html_escape: true)) %>
<% end %>
</div>
</div>

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

<% if show_actions && allowed_to?(:withdraw, :idea, idea: idea) %>
<div class="row">
<div class="columns">
<%= render partial: "idea_controls", locals: { idea: idea } %>
</div>
<div class="margin-bottom-3">
<%= render partial: "idea_controls", locals: { idea: idea } %>
</div>
<% end %>

<%= render partial: "idea_attributes", locals: { idea: idea } %>
</div>
</div>
</div>
Expand All @@ -61,6 +41,7 @@
<div class="row">
<div class="columns small-12 medium-8">
<div class="resource__main resource__content static__content">
<h2><%= t(".subtitle") %></h2>
<%= render_idea_body(idea) %>

<% if idea.answered? && idea.published_state? %>
Expand All @@ -73,14 +54,14 @@
</div>
</div>
<% end %>
</div>

<div class="resource__details">
<%= attachments_for idea %>
<div class="resource__details margin-top-3">
<%= attachments_for idea %>

<%# = linked_resources_for idea, :results, "included_ideas" %>
<%# = linked_resources_for idea, :projects, "included_ideas" %>
<%# = linked_resources_for idea, :ideas, "copied_from_component" %>
<%# = linked_resources_for idea, :results, "included_ideas" %>
<%# = linked_resources_for idea, :projects, "included_ideas" %>
<%# = linked_resources_for idea, :ideas, "copied_from_component" %>
</div>
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,14 @@ en:
show_areas_info_text: Check which neighborhood belong to different major districts
show_categories_info_text: Check what the themes consist of
show_terms_info_text: Show criteria
idea_attributes:
attributes:
address: Location
area: Area
category: Theme
id: Number (ID)
published_at: Publish time
title: Information
index:
description: Explore ideas from others on the map and the idea cards. You can also make your own ideas heard!
draft_idea_title: You have an idea draft!
Expand Down Expand Up @@ -547,6 +555,7 @@ en:
comments: Comments
edit_idea: Edit idea
show_versions: Show version history
subtitle: Idea
ideas:
empty: There are no ideas yet
empty_filters: There isn't any idea with this criteria
Expand Down
9 changes: 9 additions & 0 deletions config/locales/fi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,14 @@ fi:
show_areas_info_text: Tarkista, mitkä kaupunginosat kuuluvat eri suurpiireihin
show_categories_info_text: Katso, mitä teemat pitävät sisällään
show_terms_info_text: Tutustu kriteereihin
idea_attributes:
attributes:
address: Sijainti
area: Alue
category: Teema
id: Numero (ID)
published_at: Julkaisuaika
title: Tiedot
index:
description: Tutustu muiden ideoihin kartalta ja ideakorteista. Voit myös itse tuoda ajatuksesi kuuluviin!
draft_idea_title: Sinulla on keskeneräinen idea!
Expand Down Expand Up @@ -547,6 +555,7 @@ fi:
comments: Kommentit
edit_idea: Muokkaa ideaa
show_versions: Näytä versiohistoria
subtitle: Idea
ideas:
empty: Ei vielä ideoita
empty_filters: Ideoita ei löytynyt valituilla hakuehdoilla
Expand Down
9 changes: 9 additions & 0 deletions config/locales/sv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,14 @@ sv:
show_areas_info_text: Kontrollera vilken stadsdel som tillhör olika stordistrikt
show_categories_info_text: Kontrollera vad teman består av
show_terms_info_text: Visa kriterier
idea_attributes:
attributes:
address: Plats
area: Område
category: Tema
id: Nummer (ID)
published_at: Publiceringstiden
title: Information
index:
description: Utforska idéer från andra på kartan och idékorten. Du kan också göra dina egna idéer hörda!
draft_idea_title: Du har ett idéutkast!
Expand Down Expand Up @@ -547,6 +555,7 @@ sv:
comments: Kommentarer
edit_idea: Redigera idé
show_versions: Visa versionshistorik
subtitle: Idén
ideas:
empty: Det finns inga idéer ännu
empty_filters: Det finns ingen idé med dessa kriterier
Expand Down

0 comments on commit 2d38a98

Please sign in to comment.