From ff03db3c14c2c615a972d8eb211ed9dd35e3ab06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Salvador=20P=C3=A9rez=20Garc=C3=ADa?= Date: Mon, 11 Jun 2018 19:53:48 +0200 Subject: [PATCH] Fixes #153 Preview proposal after its creation --- app/views/proposals/_preview.html.erb | 225 ++++++++++++++++++++++++++ app/views/proposals/created.html.erb | 2 + app/views/proposals/show.html.erb | 108 +------------ 3 files changed, 228 insertions(+), 107 deletions(-) create mode 100644 app/views/proposals/_preview.html.erb diff --git a/app/views/proposals/_preview.html.erb b/app/views/proposals/_preview.html.erb new file mode 100644 index 000000000..d0aca601d --- /dev/null +++ b/app/views/proposals/_preview.html.erb @@ -0,0 +1,225 @@ +<% provide :title do %><%= @proposal.title %><% end %> +<% content_for :meta_description do %><%= @proposal.summary %><% end %> +<% provide :social_media_meta_tags do %> +<%= render "shared/social_media_meta_tags", + social_url: proposal_url(@proposal), + social_title: @proposal.title, + social_description: @proposal.summary, + twitter_image_url: (@proposal.image.present? ? @proposal.image_url(:thumb) : nil), + og_image_url: (@proposal.image.present? ? @proposal.image_url(:thumb) : nil) %> +<% end %> +<% content_for :canonical do %> + <%= render "shared/canonical", href: proposal_url(@proposal) %> +<% end %> + +<% cache_if !preview, [locale_and_user_status(@proposal), @proposal, @proposal.author, Flag.flagged?(current_user, @proposal), @proposal_votes] do %> +
+
+
+ <%= back_link_to proposals_path unless preview %> + +

<%= @proposal.title %>

+ <% if @proposal.retired? %> +
+ + <%= t("proposals.show.retired_warning") %>
+ <%= link_to t("proposals.show.retired_warning_link_to_explanation"), "#retired_explanation" %> +
+
+ <% elsif @proposal.conflictive? %> +
+ <%= t("proposals.show.flag") %> +
+ <% end %> + +
+ <%= render '/shared/author_info', resource: @proposal %> + +  •  + <%= l @proposal.created_at.to_date %> +  •  +   + <%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %> + + <% if current_user %> +  •  + + <%= render 'proposals/flag_actions', proposal: @proposal %> + + <% end %> + +
+ + <%= render_image(@proposal.image, :large, true) if @proposal.image.present? %> + +
+

+ <%= t("proposals.show.code") %> + <%= @proposal.code %> +

+ +
<%= @proposal.summary %>
+ + <% if @proposal.video_url.present? %> +
+
+
+
+
+ <% end %> + + <%= safe_html_with_links @proposal.description %> + + <% if feature?(:map) && map_location_available?(@proposal.map_location) %> +
+ <%= render_map(@proposal.map_location, "proposal", false, nil) %> +
+ <% end %> + + <% if @proposal.external_url.present? %> + + <% end %> + + <% if @proposal.video_url.present? %> + + + <% end %> + +

<%= @proposal.question %>

+ + <% if @proposal.retired? %> +
+

<%= t('proposals.show.retired') %>: <%= t("proposals.retire_options.#{@proposal.retired_reason}") unless @proposal.retired_reason == 'other' %>

+ <%= simple_format text_with_links(@proposal.retired_explanation), {}, sanitize: false %> +
+ <% end %> + + <% if feature?(:allow_attached_documents) %> + <%= render 'documents/documents', + documents: @proposal.documents, + max_documents_allowed: Proposal.max_documents_allowed %> + <% end %> + + <%= render 'shared/tags', taggable: @proposal %> + + <%= render 'shared/geozone', geozonable: @proposal %> + + <%= render 'relationable/related_content', relationable: @proposal %> + +
+ <%= render 'proposals/actions', proposal: @proposal %> +
+
+ + +
+
+<% end %> + +<% unless preview %> +
+
+ <%= render "proposals/filter_subnav" %> +
+
+ +
+ + + <%= render "proposals/notifications" %> +
+<% end %> diff --git a/app/views/proposals/created.html.erb b/app/views/proposals/created.html.erb index 7ea3caf73..79384727f 100644 --- a/app/views/proposals/created.html.erb +++ b/app/views/proposals/created.html.erb @@ -10,3 +10,5 @@ + +<%= render 'preview', preview: true %> diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index 63143ec52..92e9a2d58 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -1,109 +1,3 @@ -<% provide :title do %><%= @proposal.title %><% end %> -<% content_for :meta_description do %><%= @proposal.summary %><% end %> -<% provide :social_media_meta_tags do %> - <%= render "shared/social_media_meta_tags", - social_url: proposal_url(@proposal), - social_title: @proposal.title, - social_description: @proposal.summary, - twitter_image_url: (@proposal.image.present? ? @proposal.image_url(:thumb) : nil), - og_image_url: (@proposal.image.present? ? @proposal.image_url(:thumb) : nil) %> -<% end %> -<% content_for :canonical do %> - <%= render "shared/canonical", href: proposal_url(@proposal) %> -<% end %> - -<% cache [locale_and_user_status(@proposal), - @proposal, - @proposal.author, - Flag.flagged?(current_user, @proposal), - @proposal_votes] do %> -
-
-
- <%= back_link_to proposals_path %> - -

<%= @proposal.title %>

- <% if @proposal.retired? %> -
- - <%= t("proposals.show.retired_warning") %>
- <%= link_to t("proposals.show.retired_warning_link_to_explanation"), - "#retired_explanation" %> -
-
- <% elsif @proposal.conflictive? %> -
- <%= t("proposals.show.flag") %> -
- <% end %> - -
- <%= render '/shared/author_info', resource: @proposal %> - -  •  - <%= l @proposal.created_at.to_date %> -  •  -   - <%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %> - - <% if current_user %> -  •  - - <%= render 'proposals/flag_actions', proposal: @proposal %> - - <% end %> - -
- - <%= render_image(@proposal.image, :large, true) if @proposal.image.present? %> - -
-

- <%= t("proposals.show.code") %> - <%= @proposal.code %> -

- -
<%= @proposal.summary %>
- - <% if @proposal.video_url.present? %> -
-
-
-
-
- <% end %> - - <%= safe_html_with_links @proposal.description %> - - <% if feature?(:map) && map_location_available?(@proposal.map_location) %> -
- <%= render_map(@proposal.map_location, "proposal", false, nil) %> -
- <% end %> - - <% if @proposal.external_url.present? %> - - <% end %> - - <% if @proposal.video_url.present? %> - - - <% end %> - -

<%= @proposal.question %>

- <% if @proposal.retired? %>

@@ -113,7 +7,7 @@ <%= simple_format text_with_links(@proposal.retired_explanation), {}, sanitize: false %>

<% end %> - +d <% if feature?(:allow_attached_documents) %> <%= render 'documents/documents', documents: @proposal.documents,