Add truncate to proposed action description
The show description link only appears if the description is longer than defined length.
This commit is contained in:
@@ -88,6 +88,14 @@ module ProposalsDashboardHelper
|
||||
t("dashboard.resource.request_resource")
|
||||
end
|
||||
|
||||
def proposed_action_description(proposed_action)
|
||||
raw proposed_action.description.truncate(200)
|
||||
end
|
||||
|
||||
def proposed_action_long_description?(proposed_action)
|
||||
proposed_action.description.length > 200
|
||||
end
|
||||
|
||||
def is_new_action_since_last_login?(proposed_action, new_actions_since_last_login)
|
||||
if new_actions_since_last_login.present?
|
||||
new_actions_since_last_login.include?(proposed_action.id)
|
||||
|
||||
@@ -23,12 +23,21 @@
|
||||
<% end %>
|
||||
|
||||
<% if proposed_action.description.present? %>
|
||||
<a data-toggle="proposed_action_description_<%= dom_id(proposed_action) %>">
|
||||
<small><%= t("dashboard.recommended_actions.show_description") %></small>
|
||||
</a>
|
||||
<div id="proposed_action_description_<%= dom_id(proposed_action) %>" class="hide" data-toggler=".hide">
|
||||
<% if proposed_action_long_description?(proposed_action) %>
|
||||
<div id="truncated_description_<%= dom_id(proposed_action) %>"
|
||||
data-toggler=".hide">
|
||||
<%= proposed_action_description(proposed_action) %>
|
||||
</div>
|
||||
<a data-toggle="proposed_action_description_<%= dom_id(proposed_action) %>
|
||||
truncated_description_<%= dom_id(proposed_action) %>">
|
||||
<small><%= t("dashboard.recommended_actions.show_description") %></small>
|
||||
</a>
|
||||
<div id="proposed_action_description_<%= dom_id(proposed_action) %>" class="hide" data-toggler=".hide">
|
||||
<%= proposed_action.description.html_safe %>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= proposed_action.description.html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% proposed_action.links.each do |link| %>
|
||||
|
||||
@@ -56,6 +56,22 @@ feature "Proposal's dashboard" do
|
||||
expect(page).to have_content(action.title)
|
||||
end
|
||||
|
||||
scenario "Dashboard progress show proposed actions truncated description" do
|
||||
action = create(:dashboard_action, :proposed_action, :active, description: "One short action")
|
||||
action_long = create(:dashboard_action, :proposed_action, :active,
|
||||
description: "This is a really very long description for a proposed "\
|
||||
"action on progress dashboard section, so this description "\
|
||||
"should be appear truncated and shows the show description "\
|
||||
"link to show the complete description to the users.")
|
||||
|
||||
visit progress_proposal_dashboard_path(proposal)
|
||||
|
||||
expect(page).to have_content(action.description)
|
||||
expect(page).to have_content("This is a really very long description for a proposed")
|
||||
expect(page).to have_selector("#truncated_description_dashboard_action_#{action_long.id}")
|
||||
expect(page).to have_selector("a", text: "Show description")
|
||||
end
|
||||
|
||||
scenario "Dashboard progress do not display from the fourth proposed actions", js: true do
|
||||
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||
action_5 = create(:dashboard_action, :proposed_action, :active)
|
||||
|
||||
Reference in New Issue
Block a user