Skip to content

Commit

Permalink
Move the answer notification to the plan view
Browse files Browse the repository at this point in the history
  • Loading branch information
ahukkanen committed Feb 8, 2024
1 parent cc30275 commit 1e41ec3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 25 deletions.
10 changes: 6 additions & 4 deletions app/cells/decidim/plans/plan_notification/show.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<div class="callout callout--icon <%= status_class %>">
<div class="callout callout--icon <%= status_class %> margin-bottom-2">
<div class="callout__title">
<div class="callout__icon">
<%= icon(icon_key, role: "img", "aria-hidden": true) %>
</div>
<p class="h6"><%= title %></p>
</div>
<div class="callout__content">
<%== decidim_sanitize description %>
</div>
<% if has_answer_text? %>
<div class="callout__content">
<%== decidim_sanitize description %>
</div>
<% end %>
</div>
7 changes: 5 additions & 2 deletions app/cells/decidim/plans/plan_notification_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class PlanNotificationCell < Decidim::CardMCell

def show
return unless model.answered?
return if answer_text.blank?

render
end
Expand Down Expand Up @@ -54,12 +53,16 @@ def title
end

def description
translated_attribute model.answer
answer_text
end

def answer_text
@answer_text ||= translated_attribute(model.answer)
end

def has_answer_text?
strip_tags(answer_text).strip.present?
end
end
end
end
2 changes: 2 additions & 0 deletions app/cells/decidim/plans/plan_view/show.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

<%= cell("decidim/plans/plan_add_authors", plan) %>
<% end %>

<%== plan_notification %>
</div>
<div class="row">
<div class="columns medium-8">
Expand Down
17 changes: 17 additions & 0 deletions app/cells/decidim/plans/plan_view_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ def collaborator_requests
render :collaborator_requests
end

def plan_notification(data = {})
context = data[:context] || {}
data = data.merge(
context: context.merge(current_component: current_component)
)

cell(
layout_manifest.notification_layout,
plan,
data
)
end

private

def plan
Expand Down Expand Up @@ -180,6 +193,10 @@ def current_locale
I18n.locale.to_s
end

def layout_manifest
@layout_manifest ||= Decidim::Plans.layouts.find(current_component.settings.layout)
end

def routes_proxy
@routes_proxy ||= EngineRouter.main_proxy(current_component)
end
Expand Down
13 changes: 0 additions & 13 deletions app/helpers/decidim/plans/plan_layout_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ def render_plan_view(plan, data = {})
data
)
end

def render_plan_notification(plan, data = {})
context = data[:context] || {}
data = data.merge(
context: context.merge(current_component: current_component)
)

cell(
layout_manifest.notification_layout,
plan,
data
)
end
end
end
end
6 changes: 0 additions & 6 deletions app/views/decidim/plans/plans/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<% if @plan.answered? %>
<% content_for :notification do %>
<%= render_plan_notification(@plan) %>
<% end %>
<% end %>

<% add_decidim_meta_tags({
title: present(@plan).title,
url: plan_url(@plan.id)
Expand Down

0 comments on commit 1e41ec3

Please sign in to comment.