diff --git a/app/helpers/proposals_dashboard_helper.rb b/app/helpers/proposals_dashboard_helper.rb index 336e05ee9..adaa21a50 100644 --- a/app/helpers/proposals_dashboard_helper.rb +++ b/app/helpers/proposals_dashboard_helper.rb @@ -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) diff --git a/app/views/dashboard/_proposed_action.html.erb b/app/views/dashboard/_proposed_action.html.erb index c51a26ca7..e055e5a98 100644 --- a/app/views/dashboard/_proposed_action.html.erb +++ b/app/views/dashboard/_proposed_action.html.erb @@ -23,12 +23,21 @@ <% end %> <% if proposed_action.description.present? %> - - <%= t("dashboard.recommended_actions.show_description") %> - -
+ <% if proposed_action_long_description?(proposed_action) %> +
+ <%= proposed_action_description(proposed_action) %> +
+ + <%= t("dashboard.recommended_actions.show_description") %> + +
+ <%= proposed_action.description.html_safe %> +
+ <% else %> <%= proposed_action.description.html_safe %> -
+ <% end %> <% end %> <% proposed_action.links.each do |link| %> diff --git a/spec/features/dashboard/dashboard_spec.rb b/spec/features/dashboard/dashboard_spec.rb index f9ba0da34..9f484acf2 100644 --- a/spec/features/dashboard/dashboard_spec.rb +++ b/spec/features/dashboard/dashboard_spec.rb @@ -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)