From c887cb73669c330b37d9246bcb612617cea8ea60 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 21 Sep 2017 17:35:21 +0200 Subject: [PATCH 01/10] improves html markup on communities and topics views --- app/views/communities/show.html.erb | 21 ++++---- app/views/topics/_comments.html.erb | 4 +- app/views/topics/_form.html.erb | 10 ++-- app/views/topics/_informative_text.html.erb | 10 ++-- app/views/topics/_recommendations.html.erb | 18 +++---- app/views/topics/_topic.html.erb | 12 +---- app/views/topics/edit.html.erb | 7 +-- app/views/topics/new.html.erb | 9 ++-- app/views/topics/show.html.erb | 58 ++++++++++++++------- 9 files changed, 77 insertions(+), 72 deletions(-) diff --git a/app/views/communities/show.html.erb b/app/views/communities/show.html.erb index 8190ff6b6..59fa73646 100644 --- a/app/views/communities/show.html.erb +++ b/app/views/communities/show.html.erb @@ -3,20 +3,21 @@
- <%= back_link_to community_back_link_path(@community) %> -

<%= community_text(@community) %>

-

<%= community_title(@community) %>

-

<%= community_description(@community) %>

+ <%= community_text(@community) %> +

<%= link_to community_title(@community), community_back_link_path(@community) %>

+
+ +
+

<%= community_description(@community) %>

- -
- <%= render 'participants' %> diff --git a/app/views/topics/_comments.html.erb b/app/views/topics/_comments.html.erb index 03568ed48..db22c8097 100644 --- a/app/views/topics/_comments.html.erb +++ b/app/views/topics/_comments.html.erb @@ -13,12 +13,12 @@ <% if user_signed_in? %> <%= render 'comments/form', {commentable: @topic, parent_id: nil, toggeable: false} %> <% else %> -
+
<%= t("topics.show.login_to_comment", signin: link_to(t("votes.signin"), new_user_session_path), signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %> -
+ <% end %> diff --git a/app/views/topics/_form.html.erb b/app/views/topics/_form.html.erb index b0f3dcd28..a03458216 100644 --- a/app/views/topics/_form.html.erb +++ b/app/views/topics/_form.html.erb @@ -3,19 +3,15 @@ <%= render 'shared/errors', resource: @topic %>
-
<%= f.label :title, t("community.topic.form.topic_title") %> <%= f.text_field :title, label: false %> -
-
+ <%= f.label :description, t("community.topic.form.topic_description") %> - <%= f.text_area :description, label: false %> -
-
+ <%= f.text_area :description, label: false, rows: "5" %> + <%= f.submit(class: "button", value: t("community.topic.form.#{action_name}.submit_button")) %>
-
<% end %> diff --git a/app/views/topics/_informative_text.html.erb b/app/views/topics/_informative_text.html.erb index aeb5ad773..6a8475d8f 100644 --- a/app/views/topics/_informative_text.html.erb +++ b/app/views/topics/_informative_text.html.erb @@ -1,11 +1,13 @@ -

<%= t("community.show.create_first_community_topic.first_theme") %>

+

<%= t("community.show.create_first_community_topic.first_theme") %>

<% if user_signed_in? %> - <%= t("community.show.create_first_community_topic.first_theme_not_logged_in") %> +
+ <%= t("community.show.create_first_community_topic.first_theme_not_logged_in") %> +
<% else %>
<%= t("community.show.create_first_community_topic.sub_first_theme", - link: link_to(t("community.show.create_first_community_topic.sign_link", - org_name: setting['org_name']), new_user_session_path)).html_safe %> + sign_in: link_to(t("community.show.create_first_community_topic.sign_in"), new_user_session_path), + sign_up: link_to(t("community.show.create_first_community_topic.sign_up"), new_user_registration_path)).html_safe %>
<% end %> diff --git a/app/views/topics/_recommendations.html.erb b/app/views/topics/_recommendations.html.erb index 022b7eb93..ff86b877b 100644 --- a/app/views/topics/_recommendations.html.erb +++ b/app/views/topics/_recommendations.html.erb @@ -1,13 +1,7 @@ -
+

<%= t("community.topic.sidebar.recommendations_title") %>

- - -

<%= t("community.topic.sidebar.recommendations_title") %>

- - - -
+ diff --git a/app/views/topics/_topic.html.erb b/app/views/topics/_topic.html.erb index fe225d501..4082bf3f7 100644 --- a/app/views/topics/_topic.html.erb +++ b/app/views/topics/_topic.html.erb @@ -1,6 +1,6 @@
- -
+ +

<%= link_to topic.title, community_topic_path(@community, topic) %>

@@ -14,12 +14,4 @@

- -
- <% if topic.author == current_user %> - <%= link_to t("community.show.topic.edit_button"), edit_community_topic_path(@community.id, topic), class: 'button small hollow' %> - <%= link_to t("community.show.topic.destroy_button"), community_topic_path(@community.id, topic), method: :delete, class: 'button hollow alert small' %> - <% end %> -
-
diff --git a/app/views/topics/edit.html.erb b/app/views/topics/edit.html.erb index 15c026ca8..e305acd13 100644 --- a/app/views/topics/edit.html.erb +++ b/app/views/topics/edit.html.erb @@ -1,4 +1,4 @@ -
+
<%= back_link_to community_path(@community) %> @@ -6,6 +6,7 @@ <%= render "form" %>
- <%= render "recommendations" %> - +
+ <%= render "recommendations" %> +
diff --git a/app/views/topics/new.html.erb b/app/views/topics/new.html.erb index c1f1c42da..8f9d541e2 100644 --- a/app/views/topics/new.html.erb +++ b/app/views/topics/new.html.erb @@ -1,11 +1,12 @@ -
- +
+
<%= back_link_to community_path(@community) %>

<%= t("community.topic.create") %>

<%= render 'form' %>
- <%= render "recommendations" %> - +
+ <%= render "recommendations" %> +
diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 914839bdd..7640578e9 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -1,27 +1,47 @@ -
-
+
+
+
- <%= back_link_to community_path(@community) %> -
+ <%= back_link_to community_path(@community), t("community.show.back", + community: community_text(@community), + proposal: community_title(@community)) %> -

<%= community_text(@community) %> <%= community_title(@community) %>

-

<%= @topic.title %>

-
-

<%= @topic.description %>

- <%= render '/shared/author_info', resource: @topic %> +

<%= @topic.title %>

-  •  - <%= l @topic.created_at.to_date %> -  •  -   -
+
+ <%= render '/shared/author_info', resource: @topic %> -
- <%= render "topics/filter_subnav" %> -
- <%= render "topics/comments" %> +  •  + <%= l @topic.created_at.to_date %> +  •  +   + <%= link_to t("community.show.topic.comments", count: @topic.comments_count), + community_topic_path(@community, @topic, anchor: "comments") %>
+
+

<%= @topic.description %>

+
+ + <% if @topic.author == current_user %> + + <% end %> +
+ + +
+ <%= render "topics/filter_subnav" %> +
+ <%= render "topics/comments" %>
-
From 0fa59401e49784327503b730d6ed527bd8f67613 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 21 Sep 2017 17:39:32 +0200 Subject: [PATCH 02/10] improves i18n for community --- app/views/topics/_form.html.erb | 2 +- config/locales/en/community.yml | 18 ++++++++++-------- config/locales/es/community.yml | 18 ++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/app/views/topics/_form.html.erb b/app/views/topics/_form.html.erb index a03458216..0011df486 100644 --- a/app/views/topics/_form.html.erb +++ b/app/views/topics/_form.html.erb @@ -7,7 +7,7 @@ <%= f.label :title, t("community.topic.form.topic_title") %> <%= f.text_field :title, label: false %> - <%= f.label :description, t("community.topic.form.topic_description") %> + <%= f.label :description, t("community.topic.form.topic_text") %> <%= f.text_area :description, label: false, rows: "5" %> <%= f.submit(class: "button", value: t("community.topic.form.#{action_name}.submit_button")) %> diff --git a/config/locales/en/community.yml b/config/locales/en/community.yml index 068c98998..c4c679edb 100644 --- a/config/locales/en/community.yml +++ b/config/locales/en/community.yml @@ -14,29 +14,31 @@ en: proposal: Participate in the community of this proposal. An active community can help to improve the content of the proposal and boost its dissemination to get more support. investment: Participate in the community of this budget investment. An active community can help to improve the content of the budget investment and boost its dissemination to get more support. create_first_community_topic: - first_theme_not_logged_in: No issue yet available, participate creating the first one. Click on the create new topic button. + first_theme_not_logged_in: No issue available, participate creating the first one. first_theme: Create the first community topic - sub_first_theme: To create a theme you have to %{link} - sign_link: "access %{org_name}" + sub_first_theme: "To create a theme you must to %{sign_in} o %{sign_up}." + sign_in: "sign in" + sign_up: "sign up" tab: participants: Participants sidebar: participate: Participate new_topic: Create topic - disabled_info_title: You need to be logged to create a new topic topic: - edit_button: Edit - destroy_button: Destroy + edit: Edit topic + destroy: Destroy topic comments: one: 1 comment other: "%{count} comments" zero: No comments + author: Author + back: Back to %{community} %{proposal} topic: create: Create a topic edit: Edit Topic form: - topic_title: Topic Title - topic_description: Description + topic_title: Topic title + topic_text: Topic text new: submit_button: Create topic edit: diff --git a/config/locales/es/community.yml b/config/locales/es/community.yml index 8013c116c..f0f61b037 100644 --- a/config/locales/es/community.yml +++ b/config/locales/es/community.yml @@ -14,29 +14,31 @@ es: proposal: Participa en la comunidad de esta propuesta. Una comunidad activa puede ayudar a mejorar el contenido de la propuesta así como a dinamizar su difusión para conseguir más apoyos. investment: Participa en la comunidad de este proyecto de inversión. Una comunidad activa puede ayudar a mejorar el contenido del proyecto de inversión así como a dinamizar su difusión para conseguir más apoyos. create_first_community_topic: - first_theme_not_logged_in: Aún no hay ningun tema disponible, participa creando el primero. Haz click en el botón crear nuevo tema. + first_theme_not_logged_in: No hay ningún tema disponible, participa creando el primero. first_theme: Crea el primer tema de la comunidad - sub_first_theme: Para crear un tema tienes que %{link} - sign_link: "acceder a %{org_name}" + sub_first_theme: "Para crear un tema debes %{sign_in} o %{sign_up}." + sign_in: "iniciar sesión" + sign_up: "registrarte" tab: participants: Participantes sidebar: participate: Participa new_topic: Crea un tema - disabled_info_title: Necesitas estar logueado para crear un nuevo tema topic: - edit_button: Editar - destroy_button: Eliminar + edit: Editar tema + destroy: Eliminar tema comments: one: 1 Comentario other: "%{count} Comentarios" zero: Sin comentarios + author: Autor + back: Volver a %{community} %{proposal} topic: create: Crear un tema edit: Editar tema form: - topic_title: Titulo del tema - topic_description: Descripción + topic_title: Título del tema + topic_description: Texto del tema new: submit_button: Crear tema edit: From 363f2a59acc153df6511e7ea6fc907bcb7595fff Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 21 Sep 2017 17:39:55 +0200 Subject: [PATCH 03/10] improves styles for community --- app/assets/stylesheets/layout.scss | 6 +++++- app/assets/stylesheets/pages.scss | 3 +-- app/assets/stylesheets/participation.scss | 6 +----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 9ecf74442..ffcd1e7f9 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -278,7 +278,7 @@ a { .icon-angle-left { clear: both; color: $text-medium; - float: left; + display: inline-block; } .tabs-content { @@ -324,6 +324,10 @@ a { vertical-align: top; } +.uppercase { + text-transform: uppercase; +} + // 02. Header // ---------- diff --git a/app/assets/stylesheets/pages.scss b/app/assets/stylesheets/pages.scss index 7114b01d6..d3db7e9b2 100644 --- a/app/assets/stylesheets/pages.scss +++ b/app/assets/stylesheets/pages.scss @@ -44,8 +44,7 @@ // 03. Content // ---------------------- -.more-info-content, -.communities-show { +.more-info-content { h3 { color: $brand; diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 3d90ee128..8f85040fd 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -249,9 +249,7 @@ .proposal-form, .budget-investment-form, .spending-proposal-form, -.document-form, -.topic-new, -.topic-form { +.document-form { .icon-debates, .icon-proposals, @@ -300,8 +298,6 @@ } .proposal-form, -.topic-form, -.topic-new, .document-form { .recommendations li::before { From c400c83fa2d2812977238be698c48fdc5f1350f4 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 21 Sep 2017 17:41:35 +0200 Subject: [PATCH 04/10] removes unnecessary methods on topics helper --- app/helpers/topics_helper.rb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb index 1d5f1964f..488eed517 100644 --- a/app/helpers/topics_helper.rb +++ b/app/helpers/topics_helper.rb @@ -1,11 +1,2 @@ module TopicsHelper - - def disabled_create_topic - "disabled" unless current_user - end - - def disabled_info_title - t("community.show.sidebar.disabled_info_title") unless current_user - end - end From 2948251fc293fc69757911c88542929cc470cd3e Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 21 Sep 2017 18:31:30 +0200 Subject: [PATCH 05/10] updates specs --- spec/features/communities_spec.rb | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/spec/features/communities_spec.rb b/spec/features/communities_spec.rb index 2909f416e..7cd3d814c 100644 --- a/spec/features/communities_spec.rb +++ b/spec/features/communities_spec.rb @@ -27,15 +27,6 @@ feature 'Communities' do expect(page).not_to have_selector(".button.disabled", text: "Create topic") end - scenario 'Should display disabled create topic button when user is not logged' do - proposal = create(:proposal) - community = proposal.community - - visit community_path(community) - - expect(page).to have_selector(".button.disabled", text: "Create topic") - end - scenario 'Should display without_topics_text and participants when there are not topics' do proposal = create(:proposal) community = proposal.community @@ -100,7 +91,7 @@ feature 'Communities' do expect(topic2.title).to appear_before(topic1.title) end - scenario 'Should display topic edit button when author is logged' do + scenario 'Should display topic edit button on topic show when author is logged' do proposal = create(:proposal) community = proposal.community user = create(:user) @@ -108,15 +99,11 @@ feature 'Communities' do topic2 = create(:topic, community: community) login_as(user) - visit community_path(community) + visit community_topic_path(community, topic1) + expect(page).to have_link("Edit topic", href: edit_community_topic_path(community, topic1)) - within "#topic_#{topic1.id}" do - expect(page).to have_link("Edit", href: edit_community_topic_path(community, topic1)) - end - - within "#topic_#{topic2.id}" do - expect(page).not_to have_link("Edit", href: edit_community_topic_path(community, topic2)) - end + visit community_topic_path(community, topic2) + expect(page).not_to have_link("Edit topic", href: edit_community_topic_path(community, topic2)) end scenario 'Should display participant when there is topics' do From 04e9ef62302940f6289ffa3ab245f32b337d39cc Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 6 Dec 2017 21:05:35 +0100 Subject: [PATCH 06/10] fixes i18n for new topic form --- config/locales/en/community.yml | 4 ++-- config/locales/es/community.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/locales/en/community.yml b/config/locales/en/community.yml index a0a1e53ae..d7a892aa8 100644 --- a/config/locales/en/community.yml +++ b/config/locales/en/community.yml @@ -37,8 +37,8 @@ en: create: Create a topic edit: Edit Topic form: - topic_title: Topic title - topic_text: Topic text + topic_title: Title + topic_text: Initial text new: submit_button: Create topic edit: diff --git a/config/locales/es/community.yml b/config/locales/es/community.yml index ccb8f3cfa..f08a4918a 100644 --- a/config/locales/es/community.yml +++ b/config/locales/es/community.yml @@ -37,8 +37,8 @@ es: create: Crear un tema edit: Editar tema form: - topic_title: Título del tema - topic_description: Texto del tema + topic_title: Título + topic_text: Texto inicial new: submit_button: Crear tema edit: From 8bfaee72676300fe3b7413163c10c38c5db5198f Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 13 Dec 2017 14:21:20 +0100 Subject: [PATCH 07/10] Fix missing parenthesis on i18n.l method call --- app/views/topics/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 7640578e9..30e6ad44a 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -12,7 +12,7 @@ <%= render '/shared/author_info', resource: @topic %>  •  - <%= l @topic.created_at.to_date %> + <%= l(@topic.created_at.to_date) %>  •    <%= link_to t("community.show.topic.comments", count: @topic.comments_count), From 8c9585480bcca6a8647f3cdfc64a4d351343e91c Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 13 Dec 2017 14:40:38 +0100 Subject: [PATCH 08/10] Remove no longer needed topics helper module file --- app/helpers/topics_helper.rb | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 app/helpers/topics_helper.rb diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb deleted file mode 100644 index 488eed517..000000000 --- a/app/helpers/topics_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module TopicsHelper -end From 831ca1dd6740c22b92ca6720ecf4bc520c3dc422 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Dec 2017 13:50:42 +0100 Subject: [PATCH 09/10] Redirect anonymous user to sign in on create topic link --- app/helpers/communities_helper.rb | 3 +++ app/views/communities/show.html.erb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/helpers/communities_helper.rb b/app/helpers/communities_helper.rb index 22bc76617..744749a68 100644 --- a/app/helpers/communities_helper.rb +++ b/app/helpers/communities_helper.rb @@ -32,4 +32,7 @@ module CommunitiesHelper community.from_proposal? ? t("community.sidebar.description.proposal") : t("community.sidebar.description.investment") end + def create_topic_link(community) + current_user.present? ? new_community_topic_path(community.id) : new_user_session_path + end end diff --git a/app/views/communities/show.html.erb b/app/views/communities/show.html.erb index 59fa73646..4da0369b9 100644 --- a/app/views/communities/show.html.erb +++ b/app/views/communities/show.html.erb @@ -17,7 +17,7 @@
@@ -30,7 +30,7 @@
From a71ad644c52ce1784f6227c75f7949a0b18f5b23 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Dec 2017 13:51:10 +0100 Subject: [PATCH 10/10] Fix community topics specs --- spec/features/communities_spec.rb | 1 - spec/features/topics_specs.rb | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/spec/features/communities_spec.rb b/spec/features/communities_spec.rb index 7cd3d814c..725364074 100644 --- a/spec/features/communities_spec.rb +++ b/spec/features/communities_spec.rb @@ -24,7 +24,6 @@ feature 'Communities' do expect(page).to have_content proposal.title expect(page).to have_content "Participate in the community of this proposal" expect(page).to have_link("Create topic", href: new_community_topic_path(community)) - expect(page).not_to have_selector(".button.disabled", text: "Create topic") end scenario 'Should display without_topics_text and participants when there are not topics' do diff --git a/spec/features/topics_specs.rb b/spec/features/topics_specs.rb index 0ba674844..a4c8c8ff9 100644 --- a/spec/features/topics_specs.rb +++ b/spec/features/topics_specs.rb @@ -4,13 +4,16 @@ feature 'Topics' do context 'New' do - scenario 'Should display disabled button to new topic page without user logged', :js do + scenario 'Create new topic link should redirect to sign up for anonymous users', :js do proposal = create(:proposal) community = proposal.community + logout visit community_path(community) + click_link "Create topic" - expect(page).to have_selector(".button.expanded.disabled") + expect(page).to have_content "Sign in with:" + expect(current_path).to eq(new_user_session_path) end scenario 'Can access to new topic page with user logged', :js do @@ -34,8 +37,8 @@ feature 'Topics' do click_link "Create topic" - expect(page).to have_content "Topic Title" - expect(page).to have_content "Description" + expect(page).to have_content "Title" + expect(page).to have_content "Initial text" expect(page).to have_content "Recommendations to create a topic" expect(page).to have_content "Do not write the topic title or whole sentences in capital letters. On the internet that is considered shouting. And no one likes to be yelled at." expect(page).to have_content "Any topic or comment that implies an illegal action will be eliminated, also those that intend to sabotage the spaces of the subject, everything else is allowed." @@ -128,9 +131,9 @@ feature 'Topics' do user = create(:user) topic = create(:topic, community: community, author: user) login_as(user) - visit community_path(community) + visit community_topic_path(community, topic) - click_link "Destroy" + click_link "Destroy topic" expect(page).to have_content "Topic deleted successfully." expect(page).not_to have_content topic.title