Skip to content

Commit

Permalink
Migrate to the new layout
Browse files Browse the repository at this point in the history
  • Loading branch information
ahukkanen committed Sep 29, 2023
1 parent f4ab32b commit 56190a8
Show file tree
Hide file tree
Showing 18 changed files with 343 additions and 275 deletions.
21 changes: 21 additions & 0 deletions app/cells/decidim/ideas/idea_l/data.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="card__info">
<% if has_visible_area_scope?(model) %>
<div class="card__info__item">
<%= translated_attribute(area_scope.name) %>
</div>
<% end %>

<div class="card__info__item">
#<%= model.id %>
</div>

<div class="card__info__item">
<%= creation_date_status %>
</div>

<% if has_category? %>
<div class="card__info__item">
<%= category %>
</div>
<% end %>
</div>
29 changes: 29 additions & 0 deletions app/cells/decidim/ideas/idea_l/inner.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<%= card_wrapper do %>
<div class="card__inner">
<div class="card__main">
<div class="card__content">
<h2 class="h4"><%= title %></h2>

<%= render :tags %>

<div class="card__text">
<div class="card__text--paragraph">
<%= description %>
</div>
</div>
</div>
</div>
<div class="card__aside">
<%= render :image %>
</div>
</div>

<div class="card__footer">
<div class="card__main">
<%= render :data %>
</div>
<div class="card__aside">
<%= render :status %>
</div>
</div>
<% end %>
3 changes: 3 additions & 0 deletions app/cells/decidim/ideas/idea_l/show.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div id="<%= dom_id(model) %>">
<%= render :inner %>
</div>
26 changes: 26 additions & 0 deletions app/cells/decidim/ideas/idea_l_cell.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

require "cell/partial"

module Decidim
module Ideas
# This cell renders an idea with its L-size card.
class IdeaLCell < Decidim::Ideas::IdeaMCell
def card_classes
classes = super
classes = classes.split unless classes.is_a?(Array)
(classes + ["card--full"]).join(" ")
end

private

def resource_image_variant
:thumbnail_box
end

def category_image_variant
:card_box
end
end
end
end
2 changes: 1 addition & 1 deletion app/cells/decidim/ideas/idea_m/tags.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<span class="label <%= state_classes %>"><%= badge_name%></span>
<% end %>

<%= cell "decidim/tags/tags", model, context: { extra_classes: ["tags--idea"] } %>
<%# = cell "decidim/tags/tags", model, context: { extra_classes: ["tags--idea"] } %>
</div>
9 changes: 9 additions & 0 deletions app/helpers/decidim/ideas/ideas_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ def ideas_map(geocoded_ideas)
map_options[:center_coordinates] = map_center.split(",").map(&:to_f) if map_center

dynamic_map_for(map_options) do
# These snippets need to be added AFTER the other map scripts have
# been added which is why they cannot be within the block. Otherwise
# e.g. the markercluser would not be available when the plans map is
# loaded.
unless snippets.any?(:plans_map_scripts)
snippets.add(:plans_map_scripts, javascript_pack_tag("decidim_ideas_map"))
snippets.add(:foot, snippets.for(:plans_map_scripts))
end

yield
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/decidim/ideas/ideas/_count.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= t(".ideas_count", count: @ideas.total_count) %>
<p class="show-for-sr"><%= t(".ideas_count", count: @ideas.total_count) %></p>
79 changes: 26 additions & 53 deletions app/views/decidim/ideas/ideas/_filters.html.erb
Original file line number Diff line number Diff line change
@@ -1,77 +1,50 @@
<%
main_row_column_class = begin
if display_answer_filter? && display_scope_filter? && display_category_filter?
"columns mediumlarge-6 large-3"
else
"columns mediumlarge-6 large-4"
end
end
%>

<%= filter_form_for filter do |form| %>
<div class="row columns">
<div class="filters__section filters__section--title">
<p class="h3"><%= t(".title") %></p>
</div>
</div>

<% if current_user %>
<div class="row">
<div class="columns mediumlarge-6 large-8">
<%= form.collection_radio_buttons :activity, activity_filter_values, :first, :last, legend_title: t(".activity"), data: { disable_dynamic_change: true } %>
</div>
</div>
<% end %>
<p class="show-for-sr"><%= t(".title") %></p>

<div class="row">
<div class="<%= main_row_column_class %>">
<div class="filters__section text_filter">
<fieldset>
<legend class="mini-title"><%= t(".search") %></legend>
<%= form.search_field :search_text_cont, label: false, placeholder: t(".search"), title: t(".search"), "aria-label": t(".search"), data: { disable_dynamic_change: true } %>
</fieldset>
</div>
</div>
<div class="row medium-unstack">
<% if display_answer_filter? %>
<div class="<%= main_row_column_class %>">
<div class="filters__section with_any_state_filter">
<fieldset>
<legend class="mini-title"><%= t(".state") %></legend>
<%= form.select(:with_any_state, filter_ideas_state_values, { label: false, include_blank: t(".all_states") }, "aria-label": t(".state"), data: { disable_dynamic_change: true }) %>
</fieldset>
<div class="columns">
<div class="filters__control area_scope_id_filter">
<%= form.select(:with_any_state, filter_ideas_state_values, { label: t(".state"), include_blank: t(".all_states") }, "aria-label": t(".state"), data: { disable_dynamic_change: true }) %>
</div>
</div>
<% end %>
<% if display_scope_filter? %>
<div class="<%= main_row_column_class %>">
<div class="filters__section area_scope_id_filter">
<fieldset>
<legend class="mini-title"><%= t(".area_scope") %></legend>
<%= area_scopes_picker_field(form, :with_any_area_scope, root: false, options: { label: false, include_blank: t(".all_area_scopes") }, html_options: { "aria-label": t(".area_scope"), data: { disable_dynamic_change: true } }) %>
</fieldset>
<div class="columns">
<div class="filters__control area_scope_id_filter">
<%= area_scopes_picker_field(form, :with_any_area_scope, root: false, options: { label: t(".area_scope"), include_blank: t(".all_area_scopes") }, html_options: { "aria-label": t(".area_scope"), data: { disable_dynamic_change: true } }) %>
</div>
</div>
<% end %>
<% if display_category_filter? %>
<div class="<%= main_row_column_class %>">
<div class="filters__section with_category_filter">
<fieldset>
<legend class="mini-title"><%= t(".category") %></legend>
<%= form.select(:with_category, filter_ideas_categories_values, { label: false, include_blank: t(".all_categories") }, "aria-label": t(".category"), data: { disable_dynamic_change: true }) %>
</fieldset>
<div class="columns">
<div class="filters__control area_scope_id_filter">
<%= form.select(:with_category, filter_ideas_categories_values, { label: t(".category"), include_blank: t(".all_categories") }, "aria-label": t(".category"), data: { disable_dynamic_change: true }) %>
</div>
</div>
<% end %>

<div class="columns">
<div class="filters__control area_scope_id_filter">
<%= form.search_field :search_text_cont, label: t(".keyword"), placeholder: t(".keyword"), title: t(".keyword"), "aria-label": t(".search"), data: { disable_dynamic_change: true } %>
</div>
</div>
</div>

<% if current_user %>
<%= form.collection_radio_buttons :activity, activity_filter_values, :first, :last, legend_title: t(".activity"), data: { disable_dynamic_change: true } %>
<% end %>


<%= hidden_field_tag :order, order, id: nil, class: "order_filter" %>

<div class="row columns">
<div class="filters__section">
<button type="submit" class="button primary" aria-label="<%= t(".search") %>" aria-controls="projects-count projects" data-close>
<div class="filters__actions">
<button type="submit" class="button button--icon" aria-label="<%= t(".search") %>" aria-controls="projects-count projects" data-close>
<%= t(".search") %>
<%= icon("magnifying-glass", role: "img", "aria-hidden": true) %>
</button>
<button type="reset" class="button clear"><%= t ".reset" %></button>
<button type="reset" class="button clear text-lg"><%= t ".reset" %></button>
</div>
</div>
<% end %>
3 changes: 2 additions & 1 deletion app/views/decidim/ideas/ideas/_idea.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<%= card_for idea, from: idea %>
<%# = card_for idea, from: idea %>
<%= cell("decidim/ideas/idea_l", idea) %>
88 changes: 46 additions & 42 deletions app/views/decidim/ideas/ideas/_idea_actions.html.erb
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
<ul class="actionbox-links">
<% if show_actions %>
<li>
<%= cell("decidim/favorites/favorite_button", idea, button_class: "link action-link", disable_tooltip: true) %>
</li>
<li>
<button type="button" class="link action-link" data-open="socialShare" aria-haspopup="true">
<%= icon "share", role: "img", "aria-hidden": true %>
<span class="link-text"><%= t ".share" %></span>
</button>
</li>
<li>
<%= link_to "#comments", class: "action-link" do %>
<%= icon "comment-square", role: "img", "aria-hidden": true %>
<span class="link-text"><%= t ".show_comments" %></span>
<% end %>
</li>
<% end %>
<% if component_settings.geocoding_enabled? && idea.latitude.present? && idea.longitude.present? %>
<li>
<%= link_to idea_map_link(idea), class: "action-link", target: "_blank" do %>
<%= icon "map-marker", role: "img", "aria-hidden": true %>
<span class="link-text"><%= t ".show_on_map" %></span>
<% end %>
</li>
<% end %>
<% if false %>
<li>
<button type="button" class="link action-link">
<%= icon "print", role: "img", "aria-hidden": true %>
<span class="link-text"><%= t ".print" %></span>
</button>
</li>
<% end %>
<% if show_actions %>
<li>
<button type="button" class="link action-link" data-open="<%= current_user.present? ? "flagModal" : "loginModal" %>" aria-controls="<%= current_user.present? ? "flagModal" : "loginModal" %>" aria-haspopup="true">
<%= icon "flag", role: "img", "aria-hidden": true %>
<% if show_actions %>
<div class="actions-panel bg-secondary">
<%= cell("decidim/favorites/favorite_button", idea, button_class: "link action-link", disable_tooltip: true) %>
</div>
<% end %>

<% if component_settings.geocoding_enabled? && idea.latitude.present? && idea.longitude.present? %>
<div class="actions-panel bg-secondary">
<%= link_to idea_map_link(idea), class: "action-link", target: "_blank", data: { external_link_spacer: "" } do %>
<span class="link-text"><%= t ".show_on_map" %></span>
<%= icon "map-marker", role: "img", "aria-hidden": true %>
<% end %>
</div>
<% end %>

<% if show_actions %>
<div class="actions-panel bg-secondary">
<%= link_to "#comments", class: "action-link" do %>
<span class="link-text"><%= t ".show_comments" %></span>
<%= icon "comment-square", role: "img", "aria-hidden": true %>
<% end %>
</div>

<div class="actions-panel bg-secondary">
<button type="button" class="link action-link" data-open="<%= current_user.present? ? "flagModal" : "loginModal" %>" aria-controls="<%= current_user.present? ? "flagModal" : "loginModal" %>" aria-haspopup="dialog">
<span class="link-text"><%= t ".flag" %></span>
<%= icon "flag", role: "img", "aria-hidden": true %>
</button>
</li>
<% end %>
</ul>
</div>

<%= cell("decidim/flag_modal", idea) %>
<% end %>

<% if show_actions %>
<div class="actions-panel bg-secondary">
<button type="button" class="link action-link" data-open="socialShare" aria-controls="socialShare" aria-haspopup="dialog">
<span class="link-text"><%= t ".share" %></span>
<%= icon "share", role: "img", "aria-hidden": true %>
</button>
</div>

<%= render partial: "share_modal" %>
<%= cell("decidim/flag_modal", idea) %>
<% end %>

<% if false %>
<div class="actions-panel bg-secondary">
<button type="button" class="link action-link">
<%= icon "print", role: "img", "aria-hidden": true %>
<span class="link-text"><%= t ".print" %></span>
</button>
</div>
<% end %>
20 changes: 8 additions & 12 deletions app/views/decidim/ideas/ideas/_idea_controls.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
<div class="resource-control-panel text-center">
<div class="resource-control-panel margin-top-3">
<div class="title h3"><%= t ".manage_idea" %></div>

<% if allowed_to?(:edit, :idea, idea: idea) %>
<div class="lead">
<p><%= t("decidim.ideas.ideas.preview.idea_edit_before_minutes", count: component_settings.idea_edit_before_minutes) %></p>
</div>
<% end %>

<div class="resource-controls">
<% if allowed_to?(:edit, :idea, idea: idea) && idea.amendable? %>
<% if allowed_to?(:edit, :idea, idea: idea) %>
<div class="resource-control">
<%= link_to t(".edit_idea"), edit_idea_path(idea), class: "button primary large hollow" %>
<%= link_to t(".edit_idea"), edit_idea_path(idea) %>
</div>
<% elsif idea.emendation? %>
<% elsif idea.emendation? && idea.amendable? && amendments_enabled? && current_component.current_settings.amendment_creation_enabled && can_participate_in_private_space? %>
<div class="resource-control">
<%= amend_button_for idea %>
<%= action_authorized_link_to :amend, new_amend_path, resource: model, data: { "redirect_url" => new_amend_path }, id: "amend-button" do %>
<%= t("button", scope: "decidim.amendments.amendable", model_name: nil) %>
<% end %>
</div>
<% end %>
<div class="resource-control">
<%= action_authorized_link_to :withdraw, withdraw_idea_path(idea), method: :put, class: "button primary large hollow", data: { confirm: t(".withdraw_confirmation_html") } do %>
<%= action_authorized_link_to :withdraw, withdraw_idea_path(idea), method: :put, data: { confirm: t(".withdraw_confirmation_html") } do %>
<%= t(".withdraw_idea") %>
<% end %>
</div>
Expand Down
Loading

0 comments on commit 56190a8

Please sign in to comment.