From 01bb0b9c6b50ac6dd883286f270312ce5123f49a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 18:00:49 +0200 Subject: [PATCH 01/44] Move translation interface to views root shared folder As we are going to call this partial from any application view it will have more sense to place it at `app/views/shared`. --- .../shared/_common_globalize_locales.html.erb | 20 ----------- .../admin/shared/_globalize_locales.html.erb | 3 -- .../shared/_common_globalize_locales.html.erb | 35 +++++++++++++++++++ app/views/shared/_globalize_locales.html.erb | 3 ++ 4 files changed, 38 insertions(+), 23 deletions(-) delete mode 100644 app/views/admin/shared/_common_globalize_locales.html.erb delete mode 100644 app/views/admin/shared/_globalize_locales.html.erb create mode 100644 app/views/shared/_common_globalize_locales.html.erb create mode 100644 app/views/shared/_globalize_locales.html.erb diff --git a/app/views/admin/shared/_common_globalize_locales.html.erb b/app/views/admin/shared/_common_globalize_locales.html.erb deleted file mode 100644 index 085cad58a..000000000 --- a/app/views/admin/shared/_common_globalize_locales.html.erb +++ /dev/null @@ -1,20 +0,0 @@ -
- <% I18n.available_locales.each do |locale| %> -
- <%= link_to t("admin.translations.remove_language"), "#", - id: "js_delete_#{locale}", - style: display_translation_style(resource, locale), - class: "delete js-delete-language", - data: { locale: locale } %> -
- <% end %> - - <%= render "admin/shared/globalize_tabs", resource: resource, display_style: display_style %> - -
- <%= select_tag :translation_locale, - options_for_locale_select, - prompt: t("admin.translations.add_language"), - class: "js-globalize-locale" %> -
-
diff --git a/app/views/admin/shared/_globalize_locales.html.erb b/app/views/admin/shared/_globalize_locales.html.erb deleted file mode 100644 index 1dd35e79e..000000000 --- a/app/views/admin/shared/_globalize_locales.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= render "admin/shared/common_globalize_locales", - resource: resource, - display_style: lambda { |locale| enable_translation_style(resource, locale) } %> diff --git a/app/views/shared/_common_globalize_locales.html.erb b/app/views/shared/_common_globalize_locales.html.erb new file mode 100644 index 000000000..3b6362bb2 --- /dev/null +++ b/app/views/shared/_common_globalize_locales.html.erb @@ -0,0 +1,35 @@ +
" + data-one-languages-description="<%= t("shared.translations.languages_in_use", count: 1) %>" + data-other-languages-description="<%= t("shared.translations.languages_in_use", count: 2) %>"> +
+ + +
<%= active_languages_text(resource) %>
+
+
+ <%= select_tag :select_language, + active_languages(resource), + prompt: "Choose language", + class: "js-select-language" %> + +
+ <% if manage_languages %> + <% I18n.available_locales.each do |locale| %> + <%= link_to t("admin.translations.remove_language"), "#", + style: display_destroy_locale_style(resource, locale), + class: "delete js-delete-language js-delete-#{locale}", + data: { locale: locale } %> + <% end %> + <% end %> +
+
+
+ <% if manage_languages %> + <%= select_tag :add_language, + options_for_locale_select, + prompt: t("admin.translations.add_language"), + class: "js-add-language" %> + <% end %> +
+
diff --git a/app/views/shared/_globalize_locales.html.erb b/app/views/shared/_globalize_locales.html.erb new file mode 100644 index 000000000..e6b982cba --- /dev/null +++ b/app/views/shared/_globalize_locales.html.erb @@ -0,0 +1,3 @@ + <%= render "shared/common_globalize_locales", + resource: resource, + display_style: lambda { |locale| enable_translation_style(resource, locale) } %> From 140c37fcc06006ccd488ae0aadedbc192cef4c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 18:01:10 +0200 Subject: [PATCH 02/44] Render translation interface only when feature setting is active --- app/views/shared/_globalize_locales.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/shared/_globalize_locales.html.erb b/app/views/shared/_globalize_locales.html.erb index e6b982cba..a43961ab5 100644 --- a/app/views/shared/_globalize_locales.html.erb +++ b/app/views/shared/_globalize_locales.html.erb @@ -1,3 +1,5 @@ +<% if translations_interface_enabled? %> <%= render "shared/common_globalize_locales", resource: resource, display_style: lambda { |locale| enable_translation_style(resource, locale) } %> +<% end %> From 146c09adb753038b2592bee8f0e14fb0f2da0ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 18:08:59 +0200 Subject: [PATCH 03/44] Update references to new translation interface --- app/views/admin/admin_notifications/_form.html.erb | 2 +- app/views/admin/banners/_form.html.erb | 2 +- app/views/admin/budget_groups/_form.html.erb | 2 +- app/views/admin/budget_headings/_form.html.erb | 2 +- app/views/admin/budget_investments/edit.html.erb | 2 +- app/views/admin/budget_phases/_form.html.erb | 2 +- app/views/admin/budgets/_form.html.erb | 2 +- app/views/admin/legislation/draft_versions/_form.html.erb | 2 +- app/views/admin/legislation/homepages/_form.html.erb | 2 +- app/views/admin/legislation/milestones/_summary_form.html.erb | 2 +- app/views/admin/legislation/processes/_form.html.erb | 2 +- app/views/admin/legislation/questions/_form.html.erb | 2 +- app/views/admin/poll/active_polls/_form.html.erb | 2 +- app/views/admin/poll/polls/_form.html.erb | 2 +- app/views/admin/poll/questions/_form.html.erb | 2 +- app/views/admin/poll/questions/answers/_form.html.erb | 2 +- .../information_texts/_globalize_locales.html.erb | 2 +- app/views/admin/site_customization/pages/_form.html.erb | 2 +- app/views/admin/widget/cards/_form.html.erb | 2 +- app/views/budgets/investments/_form.html.erb | 2 +- app/views/debates/_form.html.erb | 2 +- app/views/proposals/_form.html.erb | 2 +- app/views/proposals/retire_form.html.erb | 2 +- app/views/tracking/milestones/_form.html.erb | 2 +- app/views/tracking/progress_bars/_form.html.erb | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/app/views/admin/admin_notifications/_form.html.erb b/app/views/admin/admin_notifications/_form.html.erb index 0048c93a5..d0ef97efe 100644 --- a/app/views/admin/admin_notifications/_form.html.erb +++ b/app/views/admin/admin_notifications/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @admin_notification %> +<%= render "shared/globalize_locales", resource: @admin_notification %> <%= translatable_form_for [:admin, @admin_notification] do |f| %> <%= render "shared/errors", resource: @admin_notification %> diff --git a/app/views/admin/banners/_form.html.erb b/app/views/admin/banners/_form.html.erb index dc01b2918..4bb19e227 100644 --- a/app/views/admin/banners/_form.html.erb +++ b/app/views/admin/banners/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @banner %> +<%= render "shared/globalize_locales", resource: @banner %> <%= translatable_form_for [:admin, @banner] do |f| %> diff --git a/app/views/admin/budget_groups/_form.html.erb b/app/views/admin/budget_groups/_form.html.erb index 06a185ae9..5dc71c1e6 100644 --- a/app/views/admin/budget_groups/_form.html.erb +++ b/app/views/admin/budget_groups/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @group %> +<%= render "shared/globalize_locales", resource: @group %>
<%= translatable_form_for [:admin, @budget, @group], url: path do |f| %> diff --git a/app/views/admin/budget_headings/_form.html.erb b/app/views/admin/budget_headings/_form.html.erb index 4fe3b75da..5ef142d1a 100644 --- a/app/views/admin/budget_headings/_form.html.erb +++ b/app/views/admin/budget_headings/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @heading %> +<%= render "shared/globalize_locales", resource: @heading %>
diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb index 8b94f5cac..e1f48f0c9 100644 --- a/app/views/admin/budget_investments/edit.html.erb +++ b/app/views/admin/budget_investments/edit.html.erb @@ -2,7 +2,7 @@ <%= t("shared.back") %> <% end %> -<%= render "admin/shared/globalize_locales", resource: @investment %> +<%= render "shared/globalize_locales", resource: @investment %> <%= translatable_form_for @investment, url: admin_budget_budget_investment_path(@budget, @investment) do |f| %> diff --git a/app/views/admin/budget_phases/_form.html.erb b/app/views/admin/budget_phases/_form.html.erb index 05b4139be..6327ff4c6 100644 --- a/app/views/admin/budget_phases/_form.html.erb +++ b/app/views/admin/budget_phases/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @phase %> +<%= render "shared/globalize_locales", resource: @phase %> <%= translatable_form_for [:admin, @phase.budget, @phase] do |f| %> diff --git a/app/views/admin/budgets/_form.html.erb b/app/views/admin/budgets/_form.html.erb index b552821e1..d20e39009 100644 --- a/app/views/admin/budgets/_form.html.erb +++ b/app/views/admin/budgets/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @budget %> +<%= render "shared/globalize_locales", resource: @budget %> <%= translatable_form_for [:admin, @budget] do |f| %> diff --git a/app/views/admin/legislation/draft_versions/_form.html.erb b/app/views/admin/legislation/draft_versions/_form.html.erb index 754b420ca..21831f0f2 100644 --- a/app/views/admin/legislation/draft_versions/_form.html.erb +++ b/app/views/admin/legislation/draft_versions/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @draft_version %> +<%= render "shared/globalize_locales", resource: @draft_version %> <%= translatable_form_for [:admin, @process, @draft_version], url: url, html: {data: {watch_changes: true}} do |f| %> diff --git a/app/views/admin/legislation/homepages/_form.html.erb b/app/views/admin/legislation/homepages/_form.html.erb index d5e276aa2..56f892095 100644 --- a/app/views/admin/legislation/homepages/_form.html.erb +++ b/app/views/admin/legislation/homepages/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_tabs", +<%= render "shared/globalize_locales", resource: @process, display_style: lambda { |locale| enable_translation_style(@process, locale) } %> diff --git a/app/views/admin/legislation/milestones/_summary_form.html.erb b/app/views/admin/legislation/milestones/_summary_form.html.erb index 952926572..a82273ea5 100644 --- a/app/views/admin/legislation/milestones/_summary_form.html.erb +++ b/app/views/admin/legislation/milestones/_summary_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_tabs", +<%= render "shared/globalize_locales", resource: @process, display_style: lambda { |locale| enable_translation_style(@process, locale) } %> diff --git a/app/views/admin/legislation/processes/_form.html.erb b/app/views/admin/legislation/processes/_form.html.erb index eb9b1d6d2..1e06c552c 100644 --- a/app/views/admin/legislation/processes/_form.html.erb +++ b/app/views/admin/legislation/processes/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @process %> +<%= render "shared/globalize_locales", resource: @process %> <%= translatable_form_for [:admin, @process], html: {data: {watch_changes: true}} do |f| %> diff --git a/app/views/admin/legislation/questions/_form.html.erb b/app/views/admin/legislation/questions/_form.html.erb index daccb3dfe..e191b26d4 100644 --- a/app/views/admin/legislation/questions/_form.html.erb +++ b/app/views/admin/legislation/questions/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @question %> +<%= render "shared/globalize_locales", resource: @question %> <%= translatable_form_for [:admin, @process, @question], url: url, html: {data: {watch_changes: true}} do |f| %> diff --git a/app/views/admin/poll/active_polls/_form.html.erb b/app/views/admin/poll/active_polls/_form.html.erb index 4e7fc766e..678445643 100644 --- a/app/views/admin/poll/active_polls/_form.html.erb +++ b/app/views/admin/poll/active_polls/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @active_poll %> +<%= render "shared/globalize_locales", resource: @active_poll %> <%= translatable_form_for(@active_poll, url: form_url) do |f| %> diff --git a/app/views/admin/poll/polls/_form.html.erb b/app/views/admin/poll/polls/_form.html.erb index 98c1d8d2f..2c8c9f1d6 100644 --- a/app/views/admin/poll/polls/_form.html.erb +++ b/app/views/admin/poll/polls/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @poll %> +<%= render "shared/globalize_locales", resource: @poll %> <%= translatable_form_for [:admin, @poll] do |f| %> <%= render "shared/errors", resource: @poll %> diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index c7aadadf8..ccaa0de00 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @question %> +<%= render "shared/globalize_locales", resource: @question %> <%= translatable_form_for(@question, url: form_url) do |f| %> diff --git a/app/views/admin/poll/questions/answers/_form.html.erb b/app/views/admin/poll/questions/answers/_form.html.erb index 06194cd96..5700e5076 100644 --- a/app/views/admin/poll/questions/answers/_form.html.erb +++ b/app/views/admin/poll/questions/answers/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @answer %> +<%= render "shared/globalize_locales", resource: @answer %> <%= translatable_form_for(@answer, url: form_url) do |f| %> diff --git a/app/views/admin/site_customization/information_texts/_globalize_locales.html.erb b/app/views/admin/site_customization/information_texts/_globalize_locales.html.erb index ebb900379..61969d2f0 100644 --- a/app/views/admin/site_customization/information_texts/_globalize_locales.html.erb +++ b/app/views/admin/site_customization/information_texts/_globalize_locales.html.erb @@ -1,3 +1,3 @@ -<%= render "admin/shared/common_globalize_locales", +<%= render "shared/common_globalize_locales", resource: nil, display_style: lambda { |locale| site_customization_display_translation_style(locale) } %> diff --git a/app/views/admin/site_customization/pages/_form.html.erb b/app/views/admin/site_customization/pages/_form.html.erb index 90075a24b..a32965341 100644 --- a/app/views/admin/site_customization/pages/_form.html.erb +++ b/app/views/admin/site_customization/pages/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @page %> +<%= render "shared/globalize_locales", resource: @page %> <%= translatable_form_for [:admin, @page], html: {class: "edit_page", data: {watch_changes: true}} do |f| %> <% if @page.errors.any? %> diff --git a/app/views/admin/widget/cards/_form.html.erb b/app/views/admin/widget/cards/_form.html.erb index 413be15d1..f16789f5a 100644 --- a/app/views/admin/widget/cards/_form.html.erb +++ b/app/views/admin/widget/cards/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @card %> +<%= render "shared/globalize_locales", resource: @card %> <%= translatable_form_for [:admin, @card] do |f| %> diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index dbf9cdb9e..e3f0f009d 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @investment %> +<%= render "shared/globalize_locales", resource: @investment %> <%= translatable_form_for(@investment, url: form_url, method: :post, html: { multipart: true }) do |f| %> diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb index b4b3c71e4..2c0271901 100644 --- a/app/views/debates/_form.html.erb +++ b/app/views/debates/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @debate %> +<%= render "shared/globalize_locales", resource: @debate %> <%= translatable_form_for(@debate) do |f| %> diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb index faeada8d6..7f05f4b28 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @proposal %> +<%= render "shared/globalize_locales", resource: @proposal %> <%= translatable_form_for(@proposal, url: form_url) do |f| %> diff --git a/app/views/proposals/retire_form.html.erb b/app/views/proposals/retire_form.html.erb index 9a73c9782..0a54ecd92 100644 --- a/app/views/proposals/retire_form.html.erb +++ b/app/views/proposals/retire_form.html.erb @@ -10,7 +10,7 @@ <%= t("proposals.retire_form.warning") %>
- <%= render "admin/shared/globalize_locales", resource: @proposal %> + <%= render "shared/globalize_locales", resource: @proposal %> <%= translatable_form_for(@proposal, url: retire_proposal_path(@proposal)) do |f| %> <%= render "shared/errors", resource: @proposal %> diff --git a/app/views/tracking/milestones/_form.html.erb b/app/views/tracking/milestones/_form.html.erb index f9a86d376..bd948b661 100644 --- a/app/views/tracking/milestones/_form.html.erb +++ b/app/views/tracking/milestones/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @milestone %> +<%= render "shared/globalize_locales", resource: @milestone %> <%= translatable_form_for [:tracking, *resource_hierarchy_for(@milestone)] do |f| %> diff --git a/app/views/tracking/progress_bars/_form.html.erb b/app/views/tracking/progress_bars/_form.html.erb index 07720485e..992ef65d9 100644 --- a/app/views/tracking/progress_bars/_form.html.erb +++ b/app/views/tracking/progress_bars/_form.html.erb @@ -1,4 +1,4 @@ -<%= render "admin/shared/globalize_locales", resource: @progress_bar %> +<%= render "shared/globalize_locales", resource: @progress_bar %> <%= translatable_form_for [:tracking, *resource_hierarchy_for(@progress_bar)] do |f| %> From 6183f14d9dc0f6b2abea6a0d093d7dd76f59e652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 18:10:42 +0200 Subject: [PATCH 04/44] Move translations interface after heading selector Co-Authored-By: alessandro --- app/views/budgets/investments/_form.html.erb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index e3f0f009d..b80f0a963 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -1,5 +1,3 @@ -<%= render "shared/globalize_locales", resource: @investment %> - <%= translatable_form_for(@investment, url: form_url, method: :post, html: { multipart: true }) do |f| %> <%= render "shared/errors", resource: @investment %> @@ -8,6 +6,11 @@
<%= f.select :heading_id, budget_heading_select_options(@budget), {include_blank: true, } %>
+
+
+ <%= render "shared/globalize_locales", resource: @investment %> +
+
<%= f.translatable_fields do |translations_form| %>
From a6e8fecc16ead4798fe439389ea803d6ec11cdd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 18:18:20 +0200 Subject: [PATCH 05/44] Highlight translation interface and translatable form fields Only when translations interface is enabled. Co-Authored-By: alessandro --- app/assets/stylesheets/layout.scss | 13 +++++++++++++ app/helpers/translatable_form_helper.rb | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index b7d5a9647..f29c0653b 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1080,6 +1080,19 @@ form { } } +.translatable-fields { + + &.highlight { + display: inline-block; + padding-top: $line-height; + width: 100%; + } +} + +.translation-locale { + padding-top: $line-height; +} + // 07. Callout // ----------- diff --git a/app/helpers/translatable_form_helper.rb b/app/helpers/translatable_form_helper.rb index 934ab19b0..b4c80757f 100644 --- a/app/helpers/translatable_form_helper.rb +++ b/app/helpers/translatable_form_helper.rb @@ -14,6 +14,10 @@ module TranslatableFormHelper (controller.class.parents & [Admin, Management, Valuation]).any? end + def highlight_translation_html_class + "highlight" if translations_interface_enabled? + end + class TranslatableFormBuilder < FoundationRailsHelper::FormBuilder attr_accessor :translations @@ -66,9 +70,13 @@ module TranslatableFormHelper end end + def highlight_translation_html_class + @template.highlight_translation_html_class + end + def translations_options(resource, locale) { - class: "translatable-fields js-globalize-attribute", + class: "translatable-fields js-globalize-attribute #{highlight_translation_html_class}", style: @template.display_translation_style(resource.globalized_model, locale), data: { locale: locale } } From 3ef8ef8c9c7148c64b3c6c73cfd51aa4fccfee5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Wed, 5 Jun 2019 16:01:33 +0200 Subject: [PATCH 06/44] Add class to set padding-top to any element --- app/assets/stylesheets/layout.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index f29c0653b..c65fbe03c 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -197,6 +197,10 @@ a { padding-top: $line-height; } +.padding-top { + padding-top: $line-height; +} + .light { background: $light; } From db70594fca7f5c222fd214dfa074c95c4244c3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 18:20:33 +0200 Subject: [PATCH 07/44] Add `column` class to keep proper alignment of forms When translations interface is enabled we also want to keep proper alignment between translatable and not translatable fields. Co-Authored-By: alessandro --- app/views/budgets/investments/_form.html.erb | 2 +- app/views/debates/_form.html.erb | 3 +-- app/views/proposals/_form.html.erb | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index b80f0a963..39266eb5a 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -2,7 +2,7 @@ <%= render "shared/errors", resource: @investment %> -
+
<%= f.select :heading_id, budget_heading_select_options(@budget), {include_blank: true, } %>
diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb index 2c0271901..33f60dd91 100644 --- a/app/views/debates/_form.html.erb +++ b/app/views/debates/_form.html.erb @@ -4,8 +4,7 @@ <%= render "shared/errors", resource: @debate %> -
- +
<%= f.translatable_fields do |translations_form| %>
<%= translations_form.text_field :title, diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb index 7f05f4b28..92505e408 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -4,7 +4,7 @@ <%= render "shared/errors", resource: @proposal %> -
+
<%= f.translatable_fields do |translations_form| %>
<%= translations_form.text_field :title, From 9fd77d40423ce4846c1866ba78597657043f07ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 19:17:55 +0200 Subject: [PATCH 08/44] Add `languages in use` description New interface now shows a description to ensure the user knows how many languages are currently in use. --- app/helpers/globalize_helper.rb | 56 ++++++++++++++++++- .../shared/_common_globalize_locales.html.erb | 18 +++--- config/locales/en/general.yml | 8 +++ config/locales/es/general.yml | 8 +++ spec/shared/features/edit_translatable.rb | 24 ++++++++ spec/shared/features/new_translatable.rb | 24 ++++++++ 6 files changed, 125 insertions(+), 13 deletions(-) diff --git a/app/helpers/globalize_helper.rb b/app/helpers/globalize_helper.rb index 92d02b63e..f6780eb7a 100644 --- a/app/helpers/globalize_helper.rb +++ b/app/helpers/globalize_helper.rb @@ -4,9 +4,59 @@ module GlobalizeHelper options_for_select(locale_options, nil) end - def locale_options - I18n.available_locales.map do |locale| - [name_for_locale(locale), locale] + def available_locales(resource) + I18n.available_locales.select{ |locale| enabled_locale?(resource, locale) }.map do |locale| + [name_for_locale(locale), locale , { data: { locale: locale } }] + end + end + + def enabled_locale?(resource, locale) + return site_customization_enable_translation?(locale) if resource.blank? + + if resource.translations.empty? + locale == I18n.locale + else + resource.locales_not_marked_for_destruction.include?(locale) + end + end + + def first_available_locale(resource) + return first_i18n_content_translation_locale if resource.blank? + + if translations_for_locale?(resource, I18n.locale) + I18n.locale + elsif resource.translations.any? + resource.translations.first.locale + else + I18n.locale + end + end + + def first_i18n_content_translation_locale + if I18nContentTranslation.existing_languages.count == 0 || + I18nContentTranslation.existing_languages.include?(I18n.locale) + I18n.locale + else + I18nContentTranslation.existing_languages.first + end + end + + def translations_for_locale?(resource, locale) + resource.present? && resource.translations.any? && + resource.locales_not_marked_for_destruction.include?(locale) + end + + def selected_languages_description(resource) + t("shared.translations.languages_in_use_html", count: active_languages_count(resource)) + end + + def active_languages_count(resource) + if resource.blank? + languages_count + elsif resource.locales_not_marked_for_destruction.size > 0 + resource.locales_not_marked_for_destruction.size + else + 1 end end diff --git a/app/views/shared/_common_globalize_locales.html.erb b/app/views/shared/_common_globalize_locales.html.erb index 3b6362bb2..c114135c3 100644 --- a/app/views/shared/_common_globalize_locales.html.erb +++ b/app/views/shared/_common_globalize_locales.html.erb @@ -1,15 +1,13 @@
" - data-one-languages-description="<%= t("shared.translations.languages_in_use", count: 1) %>" - data-other-languages-description="<%= t("shared.translations.languages_in_use", count: 2) %>"> + data-zero-languages-description="<%= t("shared.translations.languages_in_use_html", count: 0) %>" + data-one-languages-description="<%= t("shared.translations.languages_in_use_html", count: 1) %>" + data-other-languages-description="<%= t("shared.translations.languages_in_use_html", count: 2) %>">
- - -
<%= active_languages_text(resource) %>
-
-
+ + <%= selected_languages_description(resource) %> + <%= select_tag :select_language, - active_languages(resource), + options_for_select_language(resource), prompt: "Choose language", class: "js-select-language" %> @@ -27,7 +25,7 @@
<% if manage_languages %> <%= select_tag :add_language, - options_for_locale_select, + options_for_add_language, prompt: t("admin.translations.add_language"), class: "js-add-language" %> <% end %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index db88d478b..db5333dd6 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -825,6 +825,14 @@ en: legislation_process: "Download legislation processes" budget: "Download budgets" investments: "Download projects" + translations: + select_language_prompt: Choose language + remove_language: Remove language + add_language: Add language + languages_in_use_html: + zero: "0 languages in use" + one: "1 language in use" + other: "%{count} languages in use" social: facebook: "%{org} Facebook" twitter: "%{org} Twitter" diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 5555ef968..1671150ea 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -822,6 +822,14 @@ es: legislation_process: "Descargar procesos legislativos" budget: "Descargar presupuestos" investments: "Descargar proyectos" + translations: + select_language_prompt: Seleccionar idioma + remove_language: Eliminar idioma + add_language: Añadir idioma + languages_in_use_html: + zero: "0 idiomas en uso" + one: "1 idioma en uso" + other: "%{count} idiomas en uso" social: facebook: "Facebook de %{org}" twitter: "Twitter de %{org}" diff --git a/spec/shared/features/edit_translatable.rb b/spec/shared/features/edit_translatable.rb index ed19ad63c..3690d54ae 100644 --- a/spec/shared/features/edit_translatable.rb +++ b/spec/shared/features/edit_translatable.rb @@ -335,6 +335,30 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t expect_page_to_have_translatable_field fields.sample, :fr, with: "" end + + context "Languages in use" do + scenario "Show default description" do + visit path + + expect(page).to have_content "2 languages in use" + end + + scenario "Increase description count after add new language", :js do + visit path + + select "Français", from: :add_language + + expect(page).to have_content "3 languages in use" + end + + scenario "Decrease description count after remove a language", :js do + visit path + + click_link "Remove language" + + expect(page).to have_content "1 language in use" + end + end end end diff --git a/spec/shared/features/new_translatable.rb b/spec/shared/features/new_translatable.rb index 56fb6a028..2d30308b9 100644 --- a/spec/shared/features/new_translatable.rb +++ b/spec/shared/features/new_translatable.rb @@ -154,6 +154,30 @@ shared_examples "new_translatable" do |factory_name, path_name, input_fields, te expect(page).not_to have_link "English" end + + context "Languages in use" do + scenario "Show default description" do + visit new_translatable_path + + expect(page).to have_content "1 language in use" + end + + scenario "Increase description count after add new language", :js do + visit new_translatable_path + + select "Español", from: :add_language + + expect(page).to have_content "2 languages in use" + end + + scenario "Decrease description count after remove a language", :js do + visit new_translatable_path + + click_link "Remove language" + + expect(page).to have_content "0 languages in use" + end + end end end From 4d15815843725f1699fcc9534cd7bce20e0bda65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 19:20:48 +0200 Subject: [PATCH 09/44] Add reusable methods to common actions translations module Because we do this same expectation from a lot of specs. --- spec/support/common_actions/translations.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/support/common_actions/translations.rb b/spec/support/common_actions/translations.rb index e45ae346a..768e60059 100644 --- a/spec/support/common_actions/translations.rb +++ b/spec/support/common_actions/translations.rb @@ -60,4 +60,16 @@ module Translations def front_end_path_to_visit?(path) path[/admin|managment|valuation/].blank? end + + def expect_to_have_language(language) + expect(page).to have_select :select_language, with_options: [language] + end + + def expect_not_to_have_language(language) + expect(page).not_to have_select :select_language, with_options: [language] + end + + def expect_to_have_language_selected(language) + expect(page).to have_select :select_language, selected: language + end end From 05562c190f0f05e829cb4b3cdbec4111fa6b6d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 19:24:25 +0200 Subject: [PATCH 10/44] Adapt translations CS to new translation interface markup Now we are using different html markup to render new translation interface in a responsiveness way so we had to adapt CS to cover new behavior. --- app/assets/javascripts/globalize.js.coffee | 75 ++++++++++++++-------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/globalize.js.coffee b/app/assets/javascripts/globalize.js.coffee index 1238402a2..1f45eed86 100644 --- a/app/assets/javascripts/globalize.js.coffee +++ b/app/assets/javascripts/globalize.js.coffee @@ -2,36 +2,43 @@ App.Globalize = display_locale: (locale) -> App.Globalize.enable_locale(locale) - $(".js-globalize-locale-link").each -> - if $(this).data("locale") == locale - $(this).show() - App.Globalize.highlight_locale($(this)) - $(".js-globalize-locale option:selected").removeAttr("selected") - return + App.Globalize.add_language(locale) + $(".js-add-language option:selected").removeAttr("selected") display_translations: (locale) -> + $(".js-select-language option[value=#{locale}]").prop("selected", true) $(".js-globalize-attribute").each -> if $(this).data("locale") == locale $(this).show() else $(this).hide() $(".js-delete-language").hide() - $("#js_delete_#{locale}").show() + $(".js-delete-" + locale).show() - highlight_locale: (element) -> - $(".js-globalize-locale-link").removeClass("is-active") - element.addClass("is-active") + add_language: (locale) -> + language_option = $(".js-add-language [value=#{locale}]") + if $(".js-select-language option[value=#{locale}]").length == 0 + option = new Option(language_option.text(), language_option.val()) + $(".js-select-language").append(option) + $(".js-select-language option[value=#{locale}]").prop("selected", true) remove_language: (locale) -> $(".js-globalize-attribute[data-locale=#{locale}]").each -> $(this).val("").hide() - if CKEDITOR.instances[$(this).attr("id")] - CKEDITOR.instances[$(this).attr("id")].setData("") - $(".js-globalize-locale-link[data-locale=#{locale}]").hide() - next = $(".js-globalize-locale-link:visible").first() - App.Globalize.highlight_locale(next) - App.Globalize.display_translations(next.data("locale")) + App.Globalize.resetEditor(this) + + $(".js-select-language option[value=#{locale}]").remove() + next = $(".js-select-language option:not([value=''])").first() + App.Globalize.display_translations(next.val()) App.Globalize.disable_locale(locale) + App.Globalize.update_description() + + if $(".js-select-language option").length == 1 + $(".js-select-language option").prop("selected", true) + + resetEditor: (element) -> + if CKEDITOR.instances[$(element).attr("id")] + CKEDITOR.instances[$(element).attr("id")].setData("") enable_locale: (locale) -> App.Globalize.destroy_locale_field(locale).val(false) @@ -43,8 +50,8 @@ App.Globalize = enabled_locales: -> $.map( - $(".js-globalize-locale-link:visible"), - (element) -> $(element).data("locale") + $(".js-select-language:first option:not([value=''])"), + (element) -> $(element).val() ) destroy_locale_field: (locale) -> @@ -54,20 +61,34 @@ App.Globalize = $("#enabled_translations_#{locale}") refresh_visible_translations: -> - locale = $(".js-globalize-locale-link.is-active").data("locale") + locale = $(".js-select-language").val() App.Globalize.display_translations(locale) + update_description: -> + count = App.Globalize.enabled_locales().length + description = App.Globalize.language_description(count) + $(".js-languages-description").html(description) + $(".js-languages-count").text(count) + + language_description: (count) -> + switch count + when 0 then $(".globalize-languages").data("zero-languages-description") + when 1 then $(".globalize-languages").data("one-languages-description") + else $(".globalize-languages").data("other-languages-description") + initialize: -> - $(".js-globalize-locale").on "change", -> - App.Globalize.display_translations($(this).val()) - App.Globalize.display_locale($(this).val()) - - $(".js-globalize-locale-link").on "click", -> - locale = $(this).data("locale") + $(".js-add-language").on "change", -> + locale = $(this).val() App.Globalize.display_translations(locale) - App.Globalize.highlight_locale($(this)) + App.Globalize.display_locale(locale) + App.Globalize.update_description() - $(".js-delete-language").on "click", -> + $(".js-select-language").on "change", -> + locale = $(this).val() + App.Globalize.display_translations(locale) + + $(".js-delete-language").on "click", (e) -> + e.preventDefault() locale = $(this).data("locale") $(this).hide() App.Globalize.remove_language(locale) From 5ada9754488a3772f587dca46e6a92050deaa333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 19:26:35 +0200 Subject: [PATCH 11/44] Adapt globalize helper methods to new translation interface markup --- app/helpers/globalize_helper.rb | 54 +++++++++++++++++---------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/app/helpers/globalize_helper.rb b/app/helpers/globalize_helper.rb index f6780eb7a..96f1d3fbd 100644 --- a/app/helpers/globalize_helper.rb +++ b/app/helpers/globalize_helper.rb @@ -1,7 +1,7 @@ module GlobalizeHelper - def options_for_locale_select - options_for_select(locale_options, nil) + def options_for_select_language(resource) + options_for_select(available_locales(resource), first_available_locale(resource)) end def available_locales(resource) @@ -60,8 +60,12 @@ module GlobalizeHelper end end + def display_translation_style(resource, locale) + "display: none;" unless display_translation?(resource, locale) + end + def display_translation?(resource, locale) - if !resource || resource.translations.blank? || + if !resource || resource.translations.empty? || resource.locales_not_marked_for_destruction.include?(I18n.locale) locale == I18n.locale else @@ -69,38 +73,36 @@ module GlobalizeHelper end end - def display_translation_style(resource, locale) - "display: none;" unless display_translation?(resource, locale) + def display_destroy_locale_style(resource, locale) + "display: none;" unless display_destroy_locale_link?(resource, locale) + end + + def display_destroy_locale_link?(resource, locale) + first_available_locale(resource) == locale + end + + def options_for_add_language + options_for_select(all_language_options, nil) + end + + def all_language_options + I18n.available_locales.map do |locale| + [name_for_locale(locale), locale] + end + end + + def can_manipulate_languages? + params[:controller] != "admin/legislation/milestones" && + params[:controller] != "admin/legislation/homepages" end def translation_enabled_tag(locale, enabled) hidden_field_tag("enabled_translations[#{locale}]", (enabled ? 1 : 0)) end - def enable_translation_style(resource, locale) - "display: none;" unless enable_locale?(resource, locale) - end - - def enable_locale?(resource, locale) - if resource.translations.any? - resource.locales_not_marked_for_destruction.include?(locale) - else - locale == I18n.locale - end - end - - def highlight_class(resource, locale) - "is-active" if display_translation?(resource, locale) - end - def globalize(locale, &block) Globalize.with_locale(locale) do yield end end - - def same_locale?(locale1, locale2) - locale1 == locale2 - end - end From 721710be79ee16fd6b3b5b4269fa0d1ddd551e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 19:31:36 +0200 Subject: [PATCH 12/44] Fix script to manage visibility of progress bar translations After markup changes we need to update DOM selector used to hide/show translations. --- app/assets/javascripts/forms.js.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/forms.js.coffee b/app/assets/javascripts/forms.js.coffee index 34ea71916..2a987245c 100644 --- a/app/assets/javascripts/forms.js.coffee +++ b/app/assets/javascripts/forms.js.coffee @@ -44,10 +44,10 @@ App.Forms = if this.value == "primary" title_field.hide() - $("#globalize_locales").hide() + $(".globalize-languages").hide() else title_field.show() - $("#globalize_locales").show() + $(".globalize-languages").show() $("[name='progress_bar[kind]']").change() From f7417d6479f8dfc04b4dcb286a1478af4217576d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 19:32:22 +0200 Subject: [PATCH 13/44] Adapt specs to new translations interface markup --- spec/features/admin/banners_spec.rb | 7 +++---- spec/features/admin/budget_groups_spec.rb | 4 ++-- spec/features/admin/budget_headings_spec.rb | 4 ++-- spec/features/admin/budgets_spec.rb | 4 ++-- .../admin/legislation/draft_versions_spec.rb | 2 +- spec/features/admin/legislation/questions_spec.rb | 10 +++++----- .../site_customization/information_texts_spec.rb | 13 +++++++------ 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/spec/features/admin/banners_spec.rb b/spec/features/admin/banners_spec.rb index c5b8b376c..f5cc25106 100644 --- a/spec/features/admin/banners_spec.rb +++ b/spec/features/admin/banners_spec.rb @@ -113,10 +113,10 @@ describe "Admin banners magement" do scenario "Publish a banner with a translation different than the current locale", :js do visit new_admin_banner_path - expect(page).to have_link "English" + expect_to_have_language_selected "English" click_link "Remove language" - select "Français", from: "translation_locale" + select "Français", from: "add_language" fill_in "Title", with: "En Français" fill_in "Description", with: "Link en Français" @@ -132,8 +132,7 @@ describe "Admin banners magement" do click_button "Save changes" click_link "Edit banner" - expect(page).to have_link "Français" - expect(page).not_to have_link "English" + expect_to_have_language_selected "Français" expect(page).to have_field "Title", with: "En Français" end diff --git a/spec/features/admin/budget_groups_spec.rb b/spec/features/admin/budget_groups_spec.rb index 92ba4de94..176a4eac6 100644 --- a/spec/features/admin/budget_groups_spec.rb +++ b/spec/features/admin/budget_groups_spec.rb @@ -188,7 +188,7 @@ describe "Admin budget groups" do visit edit_admin_budget_group_path(budget, group) - select "Español", from: "translation_locale" + select "Español", from: :add_language fill_in "Group name", with: "Spanish name" click_button "Save group" @@ -197,7 +197,7 @@ describe "Admin budget groups" do visit edit_admin_budget_group_path(budget, group) - click_link "English" + select "English", from: :select_language fill_in "Group name", with: "New English Name" click_button "Save group" diff --git a/spec/features/admin/budget_headings_spec.rb b/spec/features/admin/budget_headings_spec.rb index 2245ebbd7..ec15027ae 100644 --- a/spec/features/admin/budget_headings_spec.rb +++ b/spec/features/admin/budget_headings_spec.rb @@ -212,7 +212,7 @@ describe "Admin budget headings" do visit edit_admin_budget_group_heading_path(budget, group, heading) - select "Español", from: "translation_locale" + select "Español", from: :add_language fill_in "Heading name", with: "Spanish name" click_button "Save heading" @@ -221,7 +221,7 @@ describe "Admin budget headings" do visit edit_admin_budget_group_heading_path(budget, group, heading) - click_link "English" + select "English", from: :select_language fill_in "Heading name", with: "New English Name" click_button "Save heading" diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 2b214314c..b13d46a8a 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -227,7 +227,7 @@ describe "Admin budgets" do visit edit_admin_budget_path(budget) - select "Español", from: "translation_locale" + select "Español", from: :add_language fill_in "Name", with: "Spanish name" click_button "Update Budget" @@ -236,7 +236,7 @@ describe "Admin budgets" do visit edit_admin_budget_path(budget) - click_link "English" + select "English", from: :select_language fill_in "Name", with: "New English Name" click_button "Update Budget" diff --git a/spec/features/admin/legislation/draft_versions_spec.rb b/spec/features/admin/legislation/draft_versions_spec.rb index 701b0b776..6f3dfc744 100644 --- a/spec/features/admin/legislation/draft_versions_spec.rb +++ b/spec/features/admin/legislation/draft_versions_spec.rb @@ -63,7 +63,7 @@ describe "Admin legislation draft versions" do fill_in "Changes", with: "Version 3 changes" fill_in "Text", with: "Version 3 body" - within(".end") do + within("form .end") do click_button "Create version" end diff --git a/spec/features/admin/legislation/questions_spec.rb b/spec/features/admin/legislation/questions_spec.rb index c4ac2da26..06a03a64c 100644 --- a/spec/features/admin/legislation/questions_spec.rb +++ b/spec/features/admin/legislation/questions_spec.rb @@ -173,7 +173,7 @@ describe "Admin legislation questions" do find("#nested_question_options input").set("Option 1") - click_link "Español" + select "Español", from: :select_language find("#nested_question_options input").set("Opción 1") @@ -182,7 +182,7 @@ describe "Admin legislation questions" do expect(page).to have_field(field_en[:id], with: "Option 1") - click_link "Español" + select "Español", from: :select_language expect(page).to have_field(field_es[:id], with: "Opción 1") end @@ -190,13 +190,13 @@ describe "Admin legislation questions" do scenario "Add new question option after changing active locale", :js do visit edit_question_url - click_link "Español" + select "Español", from: :select_language click_on "Add option" find("#nested_question_options input").set("Opción 1") - click_link "English" + select "English", from: :select_language find("#nested_question_options input").set("Option 1") @@ -206,7 +206,7 @@ describe "Admin legislation questions" do expect(page).to have_field(field_en[:id], with: "Option 1") - click_link "Español" + select "Español", from: :select_language expect(page).to have_field(field_es[:id], with: "Opción 1") end diff --git a/spec/features/admin/site_customization/information_texts_spec.rb b/spec/features/admin/site_customization/information_texts_spec.rb index 2d73e67c8..542040580 100644 --- a/spec/features/admin/site_customization/information_texts_spec.rb +++ b/spec/features/admin/site_customization/information_texts_spec.rb @@ -68,7 +68,7 @@ describe "Admin custom information texts" do visit admin_site_customization_information_texts_path - select "Français", from: "translation_locale" + select "Français", from: :add_language fill_in "contents[content_#{key}]values[value_fr]", with: "Aide personalise sur les débats" click_button "Save" @@ -76,8 +76,8 @@ describe "Admin custom information texts" do expect(page).to have_content "Translation updated successfully" visit admin_site_customization_information_texts_path + select "Français", from: :select_language - select "Français", from: "translation_locale" expect(page).to have_content "Aide personalise sur les débats" expect(page).not_to have_content "Aide sur les débats" end @@ -87,14 +87,14 @@ describe "Admin custom information texts" do visit admin_site_customization_information_texts_path(tab: "proposals") - select "Français", from: "translation_locale" + select "Français", from: :select_language fill_in "contents_content_#{key}values_value_fr", with: "Titre personalise de la proposition" click_button "Save" expect(page).to have_content "Translation updated successfully" visit admin_site_customization_information_texts_path(tab: "proposals") - click_link "Français" + select "Français", from: :select_language expect(page).to have_content "Titre personalise de la proposition" expect(page).not_to have_content "Titre de la proposition" @@ -113,14 +113,15 @@ describe "Admin custom information texts" do visit admin_site_customization_information_texts_path(tab: "debates") - click_link "Español" + select "Español", from: :select_language click_link "Remove language" click_button "Save" expect(page).not_to have_link "Español" visit admin_site_customization_information_texts_path(tab: "debates") - click_link "English" + select "English", from: :select_language + expect(page).to have_content "Start a new debate" expect(page).to have_content "Custom debate title" From faed5857c3f4c7bd64539380cff8b610c368c34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 20:14:09 +0200 Subject: [PATCH 14/44] Adapt specs to new translation interface As translatable translations already exists in these specs it has more sense to me to use select_language intead of adding an already existing language. Anyway both versions behaves the same and specs pass. --- spec/shared/features/edit_translatable.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/shared/features/edit_translatable.rb b/spec/shared/features/edit_translatable.rb index 3690d54ae..6aff7408d 100644 --- a/spec/shared/features/edit_translatable.rb +++ b/spec/shared/features/edit_translatable.rb @@ -72,9 +72,9 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t translatable.update(attributes) visit path - select "English", from: :translation_locale + select "English", from: :select_language click_link "Remove language" - select "Español", from: :translation_locale + select "Español", from: :select_language click_link "Remove language" click_button update_button_text @@ -91,9 +91,9 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t translatable.update(attributes) visit path - select "English", from: :translation_locale + select "English", from: :select_language click_link "Remove language" - select "Español", from: :translation_locale + select "Español", from: :select_language click_link "Remove language" click_button update_button_text visit budgets_path @@ -111,9 +111,9 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t translatable.update(attributes) visit path - select "English", from: :translation_locale + select "English", from: :select_language click_link "Remove language" - select "Español", from: :translation_locale + select "Español", from: :select_language click_link "Remove language" click_button update_button_text visit polls_path From c0b4bb67ebe2a4e79ab0efe56feb1c20e4c3988a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 20:26:16 +0200 Subject: [PATCH 15/44] Adapt shared specs to new translations interface --- spec/shared/features/edit_translatable.rb | 67 +++++++++++------------ spec/shared/features/new_translatable.rb | 16 +++--- 2 files changed, 39 insertions(+), 44 deletions(-) diff --git a/spec/shared/features/edit_translatable.rb b/spec/shared/features/edit_translatable.rb index 6aff7408d..64cb30fd4 100644 --- a/spec/shared/features/edit_translatable.rb +++ b/spec/shared/features/edit_translatable.rb @@ -126,7 +126,7 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t scenario "Add a translation", :js do visit path - select "Français", from: "translation_locale" + select "Français", from: :add_language fields.each { |field| fill_in_field field, :fr, with: text_for(field, :fr) } click_button update_button_text @@ -135,10 +135,10 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t expect_page_to_have_translatable_field field, :en, with: text_for(field, :en) - click_link "Español" + select "Español", from: :select_language expect_page_to_have_translatable_field field, :es, with: text_for(field, :es) - click_link "Français" + select "Français", from: :select_language expect_page_to_have_translatable_field field, :fr, with: text_for(field, :fr) end @@ -149,13 +149,13 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t visit path - select "Français", from: "translation_locale" + select "Français", from: :add_language fill_in_field field, :fr, with: "" click_button update_button_text expect(page).to have_css "#error_explanation" - click_link "Français" + select "Français", from: :select_language expect_page_to_have_translatable_field field, :fr, with: "" end @@ -163,7 +163,7 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t scenario "Update a translation", :js do visit path - click_link "Español" + select "Español", from: :select_language field = fields.sample updated_text = "Corrección de #{text_for(field, :es)}" @@ -186,7 +186,7 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t field = required_fields.sample visit path - click_link "Español" + select "Español", from: :select_language expect_page_to_have_translatable_field field, :es, with: text_for(field, :es) @@ -195,22 +195,21 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t expect(page).to have_css "#error_explanation" - click_link "Español" + select "Español", from: :select_language expect_page_to_have_translatable_field field, :es, with: "" end scenario "Update a translation not having the current locale", :js do translatable.translations.destroy_all - translatable.translations.create( fields.map { |field| [field, text_for(field, :fr)] }.to_h.merge(locale: :fr) ) visit path - expect(page).not_to have_link "English" - expect(page).to have_link "Français" + expect_to_have_language_selected "Français" + expect_not_to_have_language "English" click_button update_button_text @@ -219,22 +218,22 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t path = updated_path_for(translatable) visit path - expect(page).not_to have_link "English" - expect(page).to have_link "Français" + expect_to_have_language_selected "Français" + expect_not_to_have_language "English" end scenario "Remove a translation", :js do visit path - click_link "Español" + select "Español", from: :select_language click_link "Remove language" - expect(page).not_to have_link "Español" + expect_not_to_have_language "Español" click_button update_button_text visit path - expect(page).not_to have_link "Español" + expect_not_to_have_language "Español" end scenario "Remove a translation with invalid data", :js do @@ -244,19 +243,20 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t visit path - click_link "Español" + select "Español", from: :select_language click_link "Remove language" - click_link "English" + select "English", from: :select_language fill_in_field field, :en, with: "" click_button update_button_text expect(page).to have_css "#error_explanation" expect_page_to_have_translatable_field field, :en, with: "" - expect(page).not_to have_link "Español" + expect_to_have_language_selected "English" + expect_not_to_have_language "Español" visit path - click_link "Español" + select "Español", from: :select_language expect_page_to_have_translatable_field field, :es, with: text_for(field, :es) end @@ -279,7 +279,7 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t scenario "Add a translation for a locale with non-underscored name", :js do visit path - select "Português brasileiro", from: "translation_locale" + select "Português brasileiro", from: :add_language fields.each { |field| fill_in_field field, :"pt-BR", with: text_for(field, :"pt-BR") } click_button update_button_text @@ -293,24 +293,22 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t end context "Globalize javascript interface" do - scenario "Highlight current locale", :js do + scenario "Select current locale when its translation exists", :js do visit path - expect(find("a.js-globalize-locale-link.is-active")).to have_content "English" + expect_to_have_language_selected "English" select("Español", from: "locale-switcher") - expect(find("a.js-globalize-locale-link.is-active")).to have_content "Español" + expect_to_have_language_selected "Español" end - scenario "Highlight selected locale", :js do + scenario "Select first locale of existing translations when current locale translation + does not exists", :js do + translatable.translations.where(locale: :en).destroy_all visit path - expect(find("a.js-globalize-locale-link.is-active")).to have_content "English" - - click_link "Español" - - expect(find("a.js-globalize-locale-link.is-active")).to have_content "Español" + expect_to_have_language_selected "Español" end scenario "Show selected locale form", :js do @@ -319,7 +317,7 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t expect_page_to_have_translatable_field field, :en, with: text_for(field, :en) - click_link "Español" + select "Español", from: :select_language expect_page_to_have_translatable_field field, :es, with: text_for(field, :es) end @@ -327,12 +325,9 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t scenario "Select a locale and add it to the form", :js do visit path - select "Français", from: "translation_locale" - - expect(page).to have_link "Français" - - click_link "Français" + select "Français", from: :add_language + expect_to_have_language_selected "Français" expect_page_to_have_translatable_field fields.sample, :fr, with: "" end diff --git a/spec/shared/features/new_translatable.rb b/spec/shared/features/new_translatable.rb index 2d30308b9..c96063a86 100644 --- a/spec/shared/features/new_translatable.rb +++ b/spec/shared/features/new_translatable.rb @@ -71,7 +71,7 @@ shared_examples "new_translatable" do |factory_name, path_name, input_fields, te visit new_translatable_path fill_in_new_translatable_form :en - select "Français", from: "translation_locale" + select "Français", from: :add_language fill_in_new_translatable_form :fr click_button create_button_text @@ -81,7 +81,7 @@ shared_examples "new_translatable" do |factory_name, path_name, input_fields, te scenario "Add only single translation at once not having the current locale", :js do visit new_translatable_path click_link "Remove language" - select "Français", from: "translation_locale" + select "Français", from: :add_language fill_in_new_translatable_form :fr click_button create_button_text @@ -92,7 +92,7 @@ shared_examples "new_translatable" do |factory_name, path_name, input_fields, te scenario "Add a translation for a locale with non-underscored name", :js do visit new_translatable_path click_link "Remove language" - select "Português brasileiro", from: "translation_locale" + select "Português brasileiro", from: :add_language fill_in_new_translatable_form :"pt-BR" click_button create_button_text @@ -127,7 +127,7 @@ shared_examples "new_translatable" do |factory_name, path_name, input_fields, te scenario "Highlight current locale", :js do visit new_translatable_path - expect(find("a.js-globalize-locale-link.is-active")).to have_content "English" + expect_to_have_language_selected "English" end scenario "Highlight new locale added", :js do @@ -135,24 +135,24 @@ shared_examples "new_translatable" do |factory_name, path_name, input_fields, te select("Español", from: "locale-switcher") - expect(find("a.js-globalize-locale-link.is-active")).to have_content "Español" + expect_to_have_language_selected "Español" end scenario "Select a locale and add it to the form", :js do visit new_translatable_path - select "Français", from: "translation_locale" + select "Français", from: :add_language - expect(find("a.js-globalize-locale-link.is-active")).to have_content "Français" expect_page_to_have_translatable_field fields.sample, :fr, with: "" end scenario "Remove a translation", :js do visit new_translatable_path + expect(find("#select_language").value).to eq "en" click_link "Remove language" - expect(page).not_to have_link "English" + expect_not_to_have_language("English") end context "Languages in use" do From 0bbc6be141a8409f323c3b59cbe849e943e63ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 31 May 2019 20:27:31 +0200 Subject: [PATCH 16/44] Add specs to check how visibility of translations interface behaves Co-Authored-By: Sebastia --- spec/shared/features/edit_translatable.rb | 46 +++++++++++++++++++++++ spec/shared/features/new_translatable.rb | 16 ++++++++ 2 files changed, 62 insertions(+) diff --git a/spec/shared/features/edit_translatable.rb b/spec/shared/features/edit_translatable.rb index 64cb30fd4..9a49f1407 100644 --- a/spec/shared/features/edit_translatable.rb +++ b/spec/shared/features/edit_translatable.rb @@ -354,6 +354,52 @@ shared_examples "edit_translatable" do |factory_name, path_name, input_fields, t expect(page).to have_content "1 language in use" end end + + context "When translation interface feature setting" do + describe "At frontend" do + before do + unless front_end_path_to_visit?(path_name) + skip "When path is from backend" + end + end + + scenario "Is enabled translation interface should be rendered" do + visit path + + expect(page).to have_css ".globalize-languages" + end + + scenario "Is disabled translation interface should not be rendered" do + Setting["feature.translation_interface"] = nil + + visit path + + expect(page).not_to have_css ".globalize-languages" + end + end + + describe "At backend" do + before do + if front_end_path_to_visit?(path_name) + skip "When path is from frontend" + end + end + + scenario "Is enabled translation interface should be rendered" do + visit path + + expect(page).to have_css ".globalize-languages" + end + + scenario "Is disabled translation interface should be rendered" do + Setting["feature.translation_interface"] = nil + + visit path + + expect(page).to have_css ".globalize-languages" + end + end + end end end diff --git a/spec/shared/features/new_translatable.rb b/spec/shared/features/new_translatable.rb index c96063a86..22d354b38 100644 --- a/spec/shared/features/new_translatable.rb +++ b/spec/shared/features/new_translatable.rb @@ -178,6 +178,22 @@ shared_examples "new_translatable" do |factory_name, path_name, input_fields, te expect(page).to have_content "0 languages in use" end end + + context "When translation interface feature setting" do + scenario "Is enabled translation interface should be rendered" do + visit new_translatable_path + + expect(page).to have_css ".globalize-languages" + end + + scenario "Is disabled translation interface should not be rendered" do + Setting["feature.translation_interface"] = nil + + visit new_translatable_path + + expect(page).not_to have_css ".globalize-languages" + end + end end end From 07577a050c1a2faefd9fa323b310e71a3f161907 Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 22:53:31 +0200 Subject: [PATCH 17/44] Cover special translation interface behavior at admin information texts When not yet exists I18nContentTranslation languages, SiteCustomization::InformationText section render I18n.locale by default. This was causing that `languages in use` description and default selected language were incorrectly initialized. --- app/helpers/globalize_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/helpers/globalize_helper.rb b/app/helpers/globalize_helper.rb index 96f1d3fbd..592b49170 100644 --- a/app/helpers/globalize_helper.rb +++ b/app/helpers/globalize_helper.rb @@ -60,6 +60,11 @@ module GlobalizeHelper end end + def languages_count + count = I18nContentTranslation.existing_languages.count + count > 0 ? count : 1 + end + def display_translation_style(resource, locale) "display: none;" unless display_translation?(resource, locale) end From cd5095cf68257a5d4cf15557faeeaa1dfe3e41b7 Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 17:19:30 +0200 Subject: [PATCH 18/44] Align admin_notifications form fields with new translations interface --- .../admin/admin_notifications/_form.html.erb | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/app/views/admin/admin_notifications/_form.html.erb b/app/views/admin/admin_notifications/_form.html.erb index d0ef97efe..d671c2517 100644 --- a/app/views/admin/admin_notifications/_form.html.erb +++ b/app/views/admin/admin_notifications/_form.html.erb @@ -3,17 +3,31 @@ <%= translatable_form_for [:admin, @admin_notification] do |f| %> <%= render "shared/errors", resource: @admin_notification %> - <%= f.select :segment_recipient, options_for_select(user_segments_options, - @admin_notification[:segment_recipient]) %> - <%= f.text_field :link %> +
+
+ <%= f.select :segment_recipient, options_for_select(user_segments_options, + @admin_notification[:segment_recipient]) %> +
+
+ <%= f.text_field :link %> +
+
- <%= f.translatable_fields do |translations_form| %> - <%= translations_form.text_field :title %> - <%= translations_form.text_area :body %> - <% end %> +
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title %> +
+
+ <%= translations_form.text_area :body %> +
+ <% end %> +
-
- <%= f.submit t("admin.admin_notifications.#{admin_submit_action(@admin_notification)}.submit_button"), - class: "button success" %> +
+
+ <%= f.submit t("admin.admin_notifications.#{admin_submit_action(@admin_notification)}.submit_button"), + class: "button success" %> +
<% end %> From 6c0f9165c77518e4eab6194b57fdfa4dc219f831 Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 17:28:12 +0200 Subject: [PATCH 19/44] Align admin budget_phases form fields with new translations interface --- app/views/admin/budget_phases/_form.html.erb | 89 +++++++++++--------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/app/views/admin/budget_phases/_form.html.erb b/app/views/admin/budget_phases/_form.html.erb index 6327ff4c6..4bb746219 100644 --- a/app/views/admin/budget_phases/_form.html.erb +++ b/app/views/admin/budget_phases/_form.html.erb @@ -4,62 +4,71 @@ <%= render "shared/errors", resource: @phase %> -
- <%= f.label :starts_at, t("admin.budget_phases.edit.start_date") %> - <%= f.text_field :starts_at, - value: format_date_for_calendar_form(@phase.starts_at), - class: "js-calendar-full", - id: "start_date", - label: false %> -
-
- <%= f.label :ends_at, t("admin.budget_phases.edit.end_date") %> - <%= f.text_field :ends_at, - value: format_date_for_calendar_form(@phase.ends_at), - class: "js-calendar-full", - id: "end_date", - label: false %> +
+
+ <%= f.label :starts_at, t("admin.budget_phases.edit.start_date") %> + <%= f.text_field :starts_at, + value: format_date_for_calendar_form(@phase.starts_at), + class: "js-calendar-full", + id: "start_date", + label: false %> +
+
+ <%= f.label :ends_at, t("admin.budget_phases.edit.end_date") %> + <%= f.text_field :ends_at, + value: format_date_for_calendar_form(@phase.ends_at), + class: "js-calendar-full", + id: "end_date", + label: false %> +
-
+
<%= f.translatable_fields do |translations_form| %> +
+ <%= f.label :description, t("admin.budget_phases.edit.description") %> - <%= f.label :description, t("admin.budget_phases.edit.description") %> + + <%= t("admin.budget_phases.edit.description_help_text") %> + - - <%= t("admin.budget_phases.edit.description_help_text") %> - - -
- <%= translations_form.cktext_area :description, - maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH, - label: false %> +
+ <%= translations_form.cktext_area :description, + maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH, + label: false %> +
- <%= f.label :summary, t("admin.budget_phases.edit.summary") %> +
+ <%= f.label :summary, t("admin.budget_phases.edit.summary") %> - - <%= t("admin.budget_phases.edit.summary_help_text") %> - + + <%= t("admin.budget_phases.edit.summary_help_text") %> + -
- <%= translations_form.cktext_area :summary, - maxlength: Budget::Phase::SUMMARY_MAX_LENGTH, - label: false%> +
+ <%= translations_form.cktext_area :summary, + maxlength: Budget::Phase::SUMMARY_MAX_LENGTH, + label: false %> +
<% end %>
-
- <%= f.check_box :enabled, label: t("admin.budget_phases.edit.enabled") %> +
+
+ <%= f.check_box :enabled, label: t("admin.budget_phases.edit.enabled") %> - - <%= t("admin.budget_phases.edit.enabled_help_text") %> - + + <%= t("admin.budget_phases.edit.enabled_help_text") %> + +
-
- <%= f.submit t("admin.budget_phases.edit.save_changes"), class: "button success expanded" %> +
+
+ <%= f.submit t("admin.budget_phases.edit.save_changes"), class: "button success expanded" %> +
<% end %> From fb39e6c09eba3c166aacaeed7239a3db1f68a08a Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 17:44:57 +0200 Subject: [PATCH 20/44] Align admin budget_groups form fields with new translations interface --- app/views/admin/budget_groups/_form.html.erb | 34 +++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/app/views/admin/budget_groups/_form.html.erb b/app/views/admin/budget_groups/_form.html.erb index 5dc71c1e6..bd3cb7d12 100644 --- a/app/views/admin/budget_groups/_form.html.erb +++ b/app/views/admin/budget_groups/_form.html.erb @@ -1,24 +1,34 @@ <%= render "shared/globalize_locales", resource: @group %> -
- <%= translatable_form_for [:admin, @budget, @group], url: path do |f| %> +<%= translatable_form_for [:admin, @budget, @group], url: path do |f| %> - <%= render "shared/errors", resource: @group %> + <%= render "shared/errors", resource: @group %> +
<%= f.translatable_fields do |translations_form| %> - <%= translations_form.text_field :name, - label: t("admin.budget_groups.form.name"), - maxlength: 50, - placeholder: t("admin.budget_groups.form.name") %> +
+ <%= translations_form.text_field :name, + label: t("admin.budget_groups.form.name"), + maxlength: 50, + placeholder: t("admin.budget_groups.form.name") %> +
<% end %> +
- <% if @group.persisted? %> + <% if @group.persisted? %> +
+
<%= f.select :max_votable_headings, (1..@group.headings.count), label: t("admin.budget_groups.max_votable_headings"), placeholder: t("admin.budget_groups.max_votable_headings") %> - <% end %> - - <%= f.submit t("admin.budget_groups.form.#{action}"), class: "button success" %> +
+
<% end %> -
+ +
+
+ <%= f.submit t("admin.budget_groups.form.#{action}"), class: "button success" %> +
+
+<% end %> From 44ee8aa0c0ae8740ce6ece036c0800596105410a Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 17:59:28 +0200 Subject: [PATCH 21/44] Align admin budget_headings form fields with new translations interface --- .../admin/budget_headings/_form.html.erb | 85 ++++++++++--------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/app/views/admin/budget_headings/_form.html.erb b/app/views/admin/budget_headings/_form.html.erb index 5ef142d1a..45f927ed3 100644 --- a/app/views/admin/budget_headings/_form.html.erb +++ b/app/views/admin/budget_headings/_form.html.erb @@ -1,52 +1,57 @@ <%= render "shared/globalize_locales", resource: @heading %> -
+<%= translatable_form_for [:admin, @budget, @group, @heading], url: path do |f| %> - <%= translatable_form_for [:admin, @budget, @group, @heading], url: path do |f| %> - - <%= render "shared/errors", resource: @heading %> + <%= render "shared/errors", resource: @heading %> +
<%= f.translatable_fields do |translations_form| %> - <%= translations_form.text_field :name, - label: t("admin.budget_headings.form.name"), - maxlength: 50, - placeholder: t("admin.budget_headings.form.name") %> +
+ <%= translations_form.text_field :name, + label: t("admin.budget_headings.form.name"), + maxlength: 50, + placeholder: t("admin.budget_headings.form.name") %> +
<% end %> +
- <%= f.text_field :price, - label: t("admin.budget_headings.form.amount"), - maxlength: 8, - placeholder: t("admin.budget_headings.form.amount") %> +
+
+ <%= f.text_field :price, + label: t("admin.budget_headings.form.amount"), + maxlength: 8, + placeholder: t("admin.budget_headings.form.amount") %> - <%= f.label :population, t("admin.budget_headings.form.population") %> -

- <%= t("admin.budget_headings.form.population_info") %> -

- <%= f.text_field :population, - label: false, - maxlength: 8, - placeholder: t("admin.budget_headings.form.population"), - data: {toggle_focus: "population-info"}, - aria: {describedby: "budgets-population-help-text"} %> + <%= f.label :population, t("admin.budget_headings.form.population") %> +

+ <%= t("admin.budget_headings.form.population_info") %> +

+ <%= f.text_field :population, + label: false, + maxlength: 8, + placeholder: t("admin.budget_headings.form.population"), + data: {toggle_focus: "population-info"}, + aria: {describedby: "budgets-population-help-text"} %> - <%= f.text_field :latitude, - label: t("admin.budget_headings.form.latitude"), - maxlength: 22, - placeholder: "latitude" %> + <%= f.text_field :latitude, + label: t("admin.budget_headings.form.latitude"), + maxlength: 22, + placeholder: "latitude" %> - <%= f.text_field :longitude, - label: t("admin.budget_headings.form.longitude"), - maxlength: 22, - placeholder: "longitude" %> -

- <%= t("admin.budget_headings.form.coordinates_info") %> -

+ <%= f.text_field :longitude, + label: t("admin.budget_headings.form.longitude"), + maxlength: 22, + placeholder: "longitude" %> +

+ <%= t("admin.budget_headings.form.coordinates_info") %> +

- <%= f.check_box :allow_custom_content, label: t("admin.budget_headings.form.allow_content_block") %> -

- <%= t("admin.budget_headings.form.content_blocks_info") %> -

+ <%= f.check_box :allow_custom_content, label: t("admin.budget_headings.form.allow_content_block") %> +

+ <%= t("admin.budget_headings.form.content_blocks_info") %> +

- <%= f.submit t("admin.budget_headings.form.#{action}"), class: "button success" %> - <% end %> -
+ <%= f.submit t("admin.budget_headings.form.#{action}"), class: "button success" %> +
+
+<% end %> From 944e5026051b19a299725757b2ef158c4ba7b8dc Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 18:11:05 +0200 Subject: [PATCH 22/44] Align admin budget form fields with new translations interface --- app/views/admin/budgets/_form.html.erb | 144 +++++++++++++------------ 1 file changed, 75 insertions(+), 69 deletions(-) diff --git a/app/views/admin/budgets/_form.html.erb b/app/views/admin/budgets/_form.html.erb index d20e39009..e8337e551 100644 --- a/app/views/admin/budgets/_form.html.erb +++ b/app/views/admin/budgets/_form.html.erb @@ -6,16 +6,18 @@ <%= render "shared/errors", resource: @budget %> -
+
<%= f.translatable_fields do |translations_form| %> - <%= translations_form.text_field :name, - label: t("activerecord.attributes.budget.name"), - maxlength: Budget.title_max_length, - placeholder: t("activerecord.attributes.budget.name") %> +
+ <%= translations_form.text_field :name, + label: t("activerecord.attributes.budget.name"), + maxlength: Budget.title_max_length, + placeholder: t("activerecord.attributes.budget.name") %> +
<% end %>
-
+
<%= f.select :phase, budget_phases_select_options %>
@@ -58,76 +60,80 @@
<% if @budget.phases.present? %> -
- - - - - - - - - +
+
+
<%= t("admin.budgets.edit.phase") %><%= t("admin.budgets.edit.dates") %><%= t("admin.budgets.edit.enabled") %><%= t("admin.budgets.edit.actions") %>
+ + + + + + + + - <% @budget.phases.order(:id).each do |phase| %> - - - - - - - <% end %> -
<%= t("admin.budgets.edit.phase") %><%= t("admin.budgets.edit.dates") %><%= t("admin.budgets.edit.enabled") %><%= t("admin.budgets.edit.actions") %>
- <%= t("budgets.phase.#{phase.kind}") %> - <% if @budget.current_phase == phase %> - <%= t("admin.budgets.edit.active") %> - <% end %> - - <% if phase.starts_at.present? || phase.ends_at.present? %> - <%= l(phase.starts_at.to_date) if phase.starts_at.present? %> - - - <%= l(phase.ends_at.to_date) if phase.ends_at.present? %> - <% else %> - <%= t("admin.budgets.edit.blank_dates") %> - <% end %> - - "> - - <%= link_to t("admin.budgets.edit.edit_phase"), - edit_admin_budget_budget_phase_path(@budget, phase), - method: :get, class: "button hollow expanded" %> -
+ <% @budget.phases.order(:id).each do |phase| %> + + + <%= t("budgets.phase.#{phase.kind}") %> + <% if @budget.current_phase == phase %> + <%= t("admin.budgets.edit.active") %> + <% end %> + + + <% if phase.starts_at.present? || phase.ends_at.present? %> + <%= l(phase.starts_at.to_date) if phase.starts_at.present? %> + - + <%= l(phase.ends_at.to_date) if phase.ends_at.present? %> + <% else %> + <%= t("admin.budgets.edit.blank_dates") %> + <% end %> + + + "> + + + <%= link_to t("admin.budgets.edit.edit_phase"), + edit_admin_budget_budget_phase_path(@budget, phase), + method: :get, class: "button hollow expanded" %> + + + <% end %> + +
<% end %> -
- <%= render "admin/shared/show_results_fields", form: f %> -
- -
-
- <%= f.submit nil, class: "button success" %> +
+
+ <%= render "admin/shared/show_results_fields", form: f %>
-
- <% if display_calculate_winners_button?(@budget) %> - <%= link_to calculate_winner_button_text(@budget), - calculate_winners_admin_budget_path(@budget), - method: :put, - class: "button hollow" %> - <% end %> +
+
+ <%= f.submit nil, class: "button success" %> +
- <% if @budget.has_winning_investments? %> - <%= link_to t("budgets.show.see_results"), - budget_results_path(@budget), - class: "button hollow margin-left" %> - <% end %> - <% if @budget.persisted? %> - <%= link_to t("admin.budgets.edit.delete"), - admin_budget_path(@budget), - method: :delete, - class: "delete float-right margin-left" %> - <% end %> +
+ <% if display_calculate_winners_button?(@budget) %> + <%= link_to calculate_winner_button_text(@budget), + calculate_winners_admin_budget_path(@budget), + method: :put, + class: "button hollow" %> + <% end %> + + <% if @budget.has_winning_investments? %> + <%= link_to t("budgets.show.see_results"), + budget_results_path(@budget), + class: "button hollow margin-left" %> + <% end %> + <% if @budget.persisted? %> + <%= link_to t("admin.budgets.edit.delete"), + admin_budget_path(@budget), + method: :delete, + class: "delete float-right margin-left" %> + <% end %> +
<% end %> From a7dcc61ab4a38575beac343f33b81fccbe4598cb Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 18:31:25 +0200 Subject: [PATCH 23/44] Align admin legislation draft version form fields with new translations interface --- .../legislation/draft_versions/_form.html.erb | 116 +++++++++--------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/app/views/admin/legislation/draft_versions/_form.html.erb b/app/views/admin/legislation/draft_versions/_form.html.erb index 21831f0f2..3ef7247b4 100644 --- a/app/views/admin/legislation/draft_versions/_form.html.erb +++ b/app/views/admin/legislation/draft_versions/_form.html.erb @@ -15,73 +15,77 @@
<% end %> - <%= f.translatable_fields do |translations_form| %> -
- <%= translations_form.text_field :title, - placeholder: t("admin.legislation.draft_versions.form.title_placeholder") %> -
+
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title, + placeholder: t("admin.legislation.draft_versions.form.title_placeholder") %> +
-
- <%= translations_form.text_area :changelog, - hint: t("admin.legislation.draft_versions.form.use_markdown"), - rows: 5, - placeholder: t("admin.legislation.draft_versions.form.changelog_placeholder") %> -
+
+ <%= translations_form.text_area :changelog, + hint: t("admin.legislation.draft_versions.form.use_markdown"), + rows: 5, + placeholder: t("admin.legislation.draft_versions.form.changelog_placeholder") %> +
-
- <%= translations_form.label :body, nil, hint: t("admin.legislation.draft_versions.form.use_markdown") %> -
+
+ <%= translations_form.label :body, nil, hint: t("admin.legislation.draft_versions.form.use_markdown") %> +
-
-
-
- <%= t("admin.legislation.draft_versions.form.title_html", - draft_version_title: @draft_version.title, - process_title: @process.title ) %> +
+
+
+ <%= t("admin.legislation.draft_versions.form.title_html", + draft_version_title: @draft_version.title, + process_title: @process.title ) %> +
+ +
+ <%= f.submit(class: "button", value: t("admin.legislation.draft_versions.#{admin_submit_action(@draft_version)}.submit_button")) %> +
+ + <%= link_to "#", class: "fullscreen-toggle" do %> + " + data-open-text="<%= t("admin.legislation.draft_versions.form.close_text_editor") %>"> + <%= t("admin.legislation.draft_versions.form.launch_text_editor") %> + + + <% end %>
-
- <%= f.submit(class: "button", value: t("admin.legislation.draft_versions.#{admin_submit_action(@draft_version)}.submit_button")) %> +
+ <%= translations_form.text_area :body, + label: false, + rows: 10, + placeholder: t("admin.legislation.draft_versions.form.body_placeholder") %>
- <%= link_to "#", class: "fullscreen-toggle" do %> - " - data-open-text="<%= t("admin.legislation.draft_versions.form.close_text_editor")%>"> - <%= t("admin.legislation.draft_versions.form.launch_text_editor")%> - - - <% end %> +
+
- -
- <%= translations_form.text_area :body, - label: false, - rows: 10, - placeholder: t("admin.legislation.draft_versions.form.body_placeholder") %> -
- -
-
-
- <% end %> - -
- <%= f.label :status %> - <% ::Legislation::DraftVersion::VALID_STATUSES.each do |status| %> - <%= f.radio_button :status, status, label: false %> - <%= f.label "status_#{status}", t("admin.legislation.draft_versions.statuses.#{status}") %> - <%= t("admin.legislation.draft_versions.form.hints.status.#{status}") %> -
<% end %>
-
- <%= f.label :final_version %> - <%= f.check_box :final_version, label: false %> - <%= t("admin.legislation.draft_versions.form.hints.final_version") %> -
+
+
+ <%= f.label :status %> + <% ::Legislation::DraftVersion::VALID_STATUSES.each do |status| %> + <%= f.radio_button :status, status, label: false %> + <%= f.label "status_#{status}", t("admin.legislation.draft_versions.statuses.#{status}") %> + <%= t("admin.legislation.draft_versions.form.hints.status.#{status}") %> +
+ <% end %> +
-
- <%= f.submit(class: "button success expanded", value: t("admin.legislation.draft_versions.#{admin_submit_action(@draft_version)}.submit_button")) %> +
+ <%= f.label :final_version %> + <%= f.check_box :final_version, label: false %> + <%= t("admin.legislation.draft_versions.form.hints.final_version") %> +
+ +
+ <%= f.submit(class: "button success expanded", value: t("admin.legislation.draft_versions.#{admin_submit_action(@draft_version)}.submit_button")) %> +
<% end %> From 9695b0c7201f92707591bc0bec9d92767fc90704 Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 18:42:18 +0200 Subject: [PATCH 24/44] Align admin legislation homepages form fields with new translations interface --- .../legislation/homepages/_form.html.erb | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/app/views/admin/legislation/homepages/_form.html.erb b/app/views/admin/legislation/homepages/_form.html.erb index 56f892095..d5b5d73ec 100644 --- a/app/views/admin/legislation/homepages/_form.html.erb +++ b/app/views/admin/legislation/homepages/_form.html.erb @@ -5,24 +5,29 @@ <%= translatable_form_for [:admin, @process], url: url, html: {data: {watch_changes: true}} do |f| %> <%= render "shared/errors", resource: @process %> - -
- <%= f.check_box :homepage_enabled, label: t("admin.legislation.processes.form.homepage_enabled") %> +
+
+ <%= f.check_box :homepage_enabled, label: t("admin.legislation.processes.form.homepage_enabled") %> +
- <%= f.translatable_fields do |translations_form| %> -
-
- <%= translations_form.cktext_area :homepage, - language: I18n.locale, - label: t("admin.legislation.processes.form.homepage"), - ckeditor: { height: 500, toolbar: "admin" }, - hint: t("admin.legislation.processes.form.homepage_description") %> +
+ <%= f.translatable_fields do |translations_form| %> +
+
+ <%= translations_form.cktext_area :homepage, + language: I18n.locale, + label: t("admin.legislation.processes.form.homepage"), + ckeditor: { height: 500, toolbar: "admin" }, + hint: t("admin.legislation.processes.form.homepage_description") %> +
-
- <% end %> + <% end %> +
-
- <%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %> +
+
+ <%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %> +
<% end %> From 1d4bde46d6a9504ca1e75a177572b6ec2d6b91ce Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 18:49:26 +0200 Subject: [PATCH 25/44] Align admin legislation milestones summary form fields with new translations interface --- .../milestones/_summary_form.html.erb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/views/admin/legislation/milestones/_summary_form.html.erb b/app/views/admin/legislation/milestones/_summary_form.html.erb index a82273ea5..e43cabf00 100644 --- a/app/views/admin/legislation/milestones/_summary_form.html.erb +++ b/app/views/admin/legislation/milestones/_summary_form.html.erb @@ -3,11 +3,17 @@ display_style: lambda { |locale| enable_translation_style(@process, locale) } %> <%= translatable_form_for [:admin, @process] do |f| %> - <%= f.translatable_fields do |translations_form| %> -
- <%= translations_form.cktext_area :milestones_summary, ckeditor: { language: I18n.locale } %> -
- <% end %> +
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.cktext_area :milestones_summary, ckeditor: { language: I18n.locale } %> +
+ <% end %> +
- <%= f.submit class: "button success" %> +
+
+ <%= f.submit class: "button success" %> +
+
<% end %> From 27a3ff28d3d8680850714b1fa950c8e7048d8cfc Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 18:55:18 +0200 Subject: [PATCH 26/44] Align admin legislation processes form fields with new translations interface --- .../legislation/processes/_form.html.erb | 417 +++++++++--------- 1 file changed, 211 insertions(+), 206 deletions(-) diff --git a/app/views/admin/legislation/processes/_form.html.erb b/app/views/admin/legislation/processes/_form.html.erb index 1e06c552c..d95f65598 100644 --- a/app/views/admin/legislation/processes/_form.html.erb +++ b/app/views/admin/legislation/processes/_form.html.erb @@ -4,253 +4,258 @@ <% if @process.errors.any? %> -
- +
+ - - <%= @process.errors.count %> - <%= t("admin.legislation.processes.errors.form.error", count: @process.errors.count) %> - -
+ + <%= @process.errors.count %> + <%= t("admin.legislation.processes.errors.form.error", count: @process.errors.count) %> + +
<% end %> +
+
+ +

<%= t("admin.legislation.processes.form.draft_phase_description") %>

+
-
- -

<%= t("admin.legislation.processes.form.draft_phase_description") %>

-
+
+ <%= f.text_field :draft_start_date, + value: format_date_for_calendar_form(@process.draft_start_date), + class: "js-calendar-full", + id: "draft_start_date" %> +
-
- <%= f.text_field :draft_start_date, - value: format_date_for_calendar_form(@process.draft_start_date), - class: "js-calendar-full", - id: "draft_start_date" %> -
+
+ <%= f.text_field :draft_end_date, + value: format_date_for_calendar_form(@process.draft_end_date), + class: "js-calendar-full", + id: "draft_end_date" %> +
+
+ <%= f.check_box :draft_phase_enabled, checked: @process.draft_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> +
-
- <%= f.text_field :draft_end_date, - value: format_date_for_calendar_form(@process.draft_end_date), - class: "js-calendar-full", - id: "draft_end_date" %> -
-
- <%= f.check_box :draft_phase_enabled, checked: @process.draft_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> -
+
+
+
-
-
-
+
+ +
-
- -
+
+ <%= f.text_field :start_date, + value: format_date_for_calendar_form(@process.start_date), + class: "js-calendar-full", + id: "start_date" %> +
-
- <%= f.text_field :start_date, - value: format_date_for_calendar_form(@process.start_date), - class: "js-calendar-full", - id: "start_date" %> -
+
+ <%= f.text_field :end_date, + value: format_date_for_calendar_form(@process.end_date), + class: "js-calendar-full", + id: "end_date" %> +
+
+ <%= f.check_box :published, checked: @process.published?, label: t("admin.legislation.processes.form.enabled") %> +
-
- <%= f.text_field :end_date, - value: format_date_for_calendar_form(@process.end_date), - class: "js-calendar-full", - id: "end_date" %> -
-
- <%= f.check_box :published, checked: @process.published?, label: t("admin.legislation.processes.form.enabled") %> -
+
+
+
-
-
-
+
+ +
-
- -
+
+ <%= f.text_field :debate_start_date, + value: format_date_for_calendar_form(@process.debate_start_date), + class: "js-calendar-full", + id: "debate_start_date" %> +
-
- <%= f.text_field :debate_start_date, - value: format_date_for_calendar_form(@process.debate_start_date), - class: "js-calendar-full", - id: "debate_start_date" %> -
+
+ <%= f.text_field :debate_end_date, + value: format_date_for_calendar_form(@process.debate_end_date), + class: "js-calendar-full", + id: "debate_end_date" %> +
+
+ <%= f.check_box :debate_phase_enabled, checked: @process.debate_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> +
-
- <%= f.text_field :debate_end_date, - value: format_date_for_calendar_form(@process.debate_end_date), - class: "js-calendar-full", - id: "debate_end_date" %> -
-
- <%= f.check_box :debate_phase_enabled, checked: @process.debate_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> -
+
+
+
-
-
-
+
+ +
-
- -
+
+ <%= f.text_field :proposals_phase_start_date, + value: format_date_for_calendar_form(@process.proposals_phase_start_date), + class: "js-calendar-full", + id: "proposals_phase_start_date" %> +
-
- <%= f.text_field :proposals_phase_start_date, - value: format_date_for_calendar_form(@process.proposals_phase_start_date), - class: "js-calendar-full", - id: "proposals_phase_start_date" %> -
+
+ <%= f.text_field :proposals_phase_end_date, + value: format_date_for_calendar_form(@process.proposals_phase_end_date), + class: "js-calendar-full", + id: "proposals_phase_end_date" %> +
+
+ <%= f.check_box :proposals_phase_enabled, checked: @process.proposals_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> +
-
- <%= f.text_field :proposals_phase_end_date, - value: format_date_for_calendar_form(@process.proposals_phase_end_date), - class: "js-calendar-full", - id: "proposals_phase_end_date" %> -
-
- <%= f.check_box :proposals_phase_enabled, checked: @process.proposals_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> -
+
+
+
-
-
-
+
+ +
-
- -
+
+ <%= f.text_field :allegations_start_date, + value: format_date_for_calendar_form(@process.allegations_start_date), + class: "js-calendar-full", + id: "allegations_start_date" %> +
-
- <%= f.text_field :allegations_start_date, - value: format_date_for_calendar_form(@process.allegations_start_date), - class: "js-calendar-full", - id: "allegations_start_date" %> -
+
+ <%= f.text_field :allegations_end_date, + value: format_date_for_calendar_form(@process.allegations_end_date), + class: "js-calendar-full", + id: "allegations_end_date" %> +
+
+ <%= f.check_box :allegations_phase_enabled, checked: @process.allegations_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> +
-
- <%= f.text_field :allegations_end_date, - value: format_date_for_calendar_form(@process.allegations_end_date), - class: "js-calendar-full", - id: "allegations_end_date" %> -
-
- <%= f.check_box :allegations_phase_enabled, checked: @process.allegations_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> -
+
+
+
-
-
-
+
+ <%= f.text_field :draft_publication_date, + value: format_date_for_calendar_form(@process.draft_publication_date), + class: "js-calendar-full", + id: "draft_publication_date" %> +
+
+ <%= f.check_box :draft_publication_enabled, checked: @process.draft_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %> +
-
- <%= f.text_field :draft_publication_date, - value: format_date_for_calendar_form(@process.draft_publication_date), - class: "js-calendar-full", - id: "draft_publication_date" %> -
-
- <%= f.check_box :draft_publication_enabled, checked: @process.draft_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %> -
+
+
+
-
-
-
+
+ <%= f.text_field :result_publication_date, + value: format_date_for_calendar_form(@process.result_publication_date), + class: "js-calendar-full", + id: "result_publication_date" %> +
+
+ <%= f.check_box :result_publication_enabled, checked: @process.result_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %> +
-
- <%= f.text_field :result_publication_date, - value: format_date_for_calendar_form(@process.result_publication_date), - class: "js-calendar-full", - id: "result_publication_date" %> -
-
- <%= f.check_box :result_publication_enabled, checked: @process.result_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %> -
+
+
+
-
-
-
+
+ <%= render "documents/nested_documents", documentable: @process, f: f %> +
-
- <%= render "documents/nested_documents", documentable: @process, f: f %> -
+
+
+
-
-
-
+
+ <%= render "images/nested_image", imageable: @process, f: f %> +
-
- <%= render "images/nested_image", imageable: @process, f: f %> -
+
+
+
-
-
-
+
+

<%= t("admin.legislation.processes.form.banner_title") %>

+
-
-

<%= t("admin.legislation.processes.form.banner_title") %>

-
- -
- <%= f.label :background_color, nil, for: "background_color_input" %> -

<%= t("admin.shared.color_help") %>

-
-
- <%= f.text_field :background_color, label: false, type: :color, - value: bg_color_or_default %> -
-
- <%= f.text_field :background_color, label: false, id: "background_color_input" %> +
+ <%= f.label :background_color, nil, for: "background_color_input" %> +

<%= t("admin.shared.color_help") %>

+
+
+ <%= f.text_field :background_color, label: false, type: :color, + value: bg_color_or_default %> +
+
+ <%= f.text_field :background_color, label: false, id: "background_color_input" %> +
-
-
- <%= f.label :font_color, nil, for: "font_color_input" %> -

<%= t("admin.shared.color_help") %>

-
-
- <%= f.text_field :font_color, label: false, type: :color, value: font_color_or_default %> -
-
- <%= f.text_field :font_color, label: false, id: "font_color_input" %> +
+ <%= f.label :font_color, nil, for: "font_color_input" %> +

<%= t("admin.shared.color_help") %>

+
+
+ <%= f.text_field :font_color, label: false, type: :color, value: font_color_or_default %> +
+
+ <%= f.text_field :font_color, label: false, id: "font_color_input" %> +
+ +
+
+
-
-
+
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title, + placeholder: t("admin.legislation.processes.form.title_placeholder") %> +
+ +
+ <%= translations_form.text_area :summary, + rows: 2, + placeholder: t("admin.legislation.processes.form.summary_placeholder"), + hint: t("admin.legislation.processes.form.use_markdown") %> +
+ +
+ <%= translations_form.text_area :description, + rows: 5, + placeholder: t("admin.legislation.processes.form.description_placeholder"), + hint: t("admin.legislation.processes.form.use_markdown") %> +
+ +
+ <%= translations_form.text_area :additional_info, + rows: 10, + placeholder: t("admin.legislation.processes.form.additional_info_placeholder"), + hint: t("admin.legislation.processes.form.use_markdown") %> +
+ <% end %>
- <%= f.translatable_fields do |translations_form| %> -
- <%= translations_form.text_field :title, - placeholder: t("admin.legislation.processes.form.title_placeholder") %> +
+
+ <%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %>
- -
- <%= translations_form.text_area :summary, - rows: 2, - placeholder: t("admin.legislation.processes.form.summary_placeholder"), - hint: t("admin.legislation.processes.form.use_markdown") %> -
- -
- <%= translations_form.text_area :description, - rows: 5, - placeholder: t("admin.legislation.processes.form.description_placeholder"), - hint: t("admin.legislation.processes.form.use_markdown") %> -
- -
- <%= translations_form.text_area :additional_info, - rows: 10, - placeholder: t("admin.legislation.processes.form.additional_info_placeholder"), - hint: t("admin.legislation.processes.form.use_markdown") %> -
- <% end %> - -
- <%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %>
<% end %> From c9eaeffaf285724f362c714444187fd894bd50be Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 19:04:26 +0200 Subject: [PATCH 27/44] Align admin legislation questions form fields with new translations interface --- .../legislation/questions/_form.html.erb | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/app/views/admin/legislation/questions/_form.html.erb b/app/views/admin/legislation/questions/_form.html.erb index e191b26d4..22964c95a 100644 --- a/app/views/admin/legislation/questions/_form.html.erb +++ b/app/views/admin/legislation/questions/_form.html.erb @@ -17,33 +17,37 @@
<% end %> - <%= f.translatable_fields do |translations_form| %> -
- <%= translations_form.text_area :title, - rows: 5, - placeholder: t("admin.legislation.questions.form.title_placeholder"), - label: t("admin.legislation.questions.form.title") %> -
- <% end %> - -
- <%= f.label :question_options, t("admin.legislation.questions.form.question_options") %> +
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_area :title, + rows: 5, + placeholder: t("admin.legislation.questions.form.title_placeholder"), + label: t("admin.legislation.questions.form.title") %> +
+ <% end %>
-
- <%= f.fields_for :question_options do |ff| %> - <%= render "question_option_fields", f: ff %> - <% end %> +
+
+ <%= f.label :question_options, t("admin.legislation.questions.form.question_options") %> +
-
-
- <%= link_to_add_association t("admin.legislation.questions.form.add_option"), - f, :question_options, class: "button hollow" %> +
+ <%= f.fields_for :question_options do |ff| %> + <%= render "question_option_fields", f: ff %> + <% end %> + +
+
+ <%= link_to_add_association t("admin.legislation.questions.form.add_option"), + f, :question_options, class: "button hollow" %> +
-
-
- <%= f.submit(class: "button success expanded", value: t("admin.legislation.questions.#{admin_submit_action(@question)}.submit_button")) %> +
+ <%= f.submit(class: "button success expanded", value: t("admin.legislation.questions.#{admin_submit_action(@question)}.submit_button")) %> +
<% end %> From a700ea2fceb8016f851ee5e3262055aaaae7faf2 Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 19:22:19 +0200 Subject: [PATCH 28/44] Align admin milestones form fields with new translations interface --- app/views/tracking/milestones/_form.html.erb | 63 +++++++++++--------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/app/views/tracking/milestones/_form.html.erb b/app/views/tracking/milestones/_form.html.erb index bd948b661..a6fd6687a 100644 --- a/app/views/tracking/milestones/_form.html.erb +++ b/app/views/tracking/milestones/_form.html.erb @@ -2,35 +2,44 @@ <%= translatable_form_for [:tracking, *resource_hierarchy_for(@milestone)] do |f| %> -
- <%= f.select :status_id, - @statuses.collect { |s| [s.name, s.id] }, - { include_blank: @statuses.any? ? "" : t("tracking.milestones.form.no_statuses_defined") }, - { disabled: @statuses.blank? } %> - <%= link_to t("tracking.milestones.form.admin_statuses"), - admin_milestone_statuses_path %> +
+
+ <%= f.select :status_id, + @statuses.collect { |s| [s.name, s.id] }, + { include_blank: @statuses.any? ? "" : t("tracking.milestones.form.no_statuses_defined") }, + { disabled: @statuses.blank? } %> + <%= link_to t("tracking.milestones.form.admin_statuses"), + admin_milestone_statuses_path %> +
- <%= f.translatable_fields do |translations_form| %> - <%= translations_form.hidden_field :title, value: l(Time.current, format: :datetime), - maxlength: Milestone.title_max_length %> - - <%= translations_form.text_area :description, - rows: 5, - label: t("tracking.milestones.new.description") %> - <% end %> - - <%= f.label :publication_date, t("tracking.milestones.new.date") %> - <%= f.text_field :publication_date, - value: @milestone.publication_date.present? ? l(@milestone.publication_date.to_date) : nil, - label: false, - class: "js-calendar-full" %> - - <%= render "images/admin_image", imageable: @milestone, f: f %> - -
- <%= render "documents/nested_documents", documentable: @milestone, f: f %> +
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.hidden_field :title, value: l(Time.current, format: :datetime), + maxlength: Milestone.title_max_length %> + <%= translations_form.text_area :description, + rows: 5, + label: t("tracking.milestones.new.description") %> +
+ <% end %>
- <%= f.submit nil, class: "button success" %> +
+
+ <%= f.label :publication_date, t("tracking.milestones.new.date") %> + <%= f.text_field :publication_date, + value: @milestone.publication_date.present? ? l(@milestone.publication_date.to_date) : nil, + label: false, + class: "js-calendar-full" %> + + <%= render "images/admin_image", imageable: @milestone, f: f %> + +
+ <%= render "documents/nested_documents", documentable: @milestone, f: f %> +
+ + <%= f.submit nil, class: "button success" %> +
+
<% end %> From 000c6c5911dd9c5da7e63c046e742d7053e39aa1 Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 19:26:46 +0200 Subject: [PATCH 29/44] Align admin active polls form fields with new translations interface --- .../admin/poll/active_polls/_form.html.erb | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/views/admin/poll/active_polls/_form.html.erb b/app/views/admin/poll/active_polls/_form.html.erb index 678445643..be6bd8fb9 100644 --- a/app/views/admin/poll/active_polls/_form.html.erb +++ b/app/views/admin/poll/active_polls/_form.html.erb @@ -4,17 +4,21 @@ <%= render "shared/errors", resource: @active_poll %> - <%= f.translatable_fields do |translations_form| %> -
- <%= t("admin.active_polls.form.description.help_text") %> - <%= translations_form.cktext_area :description, - maxlength: ActivePoll.description_max_length, - label: t("admin.active_polls.form.description.text") %> -
- <% end %> +
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= t("admin.active_polls.form.description.help_text") %> + <%= translations_form.cktext_area :description, + maxlength: ActivePoll.description_max_length, + label: t("admin.active_polls.form.description.text") %> +
+ <% end %> +
-
- <%= f.submit(class: "button success", value: t("shared.save")) %> +
+
+ <%= f.submit(class: "button success", value: t("shared.save")) %> +
<% end %> From bca9364c643d3a98aec9fa658e3ac07c60f93e93 Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 19:31:57 +0200 Subject: [PATCH 30/44] Align admin polls form fields with new translations interface --- app/views/admin/poll/polls/_form.html.erb | 72 +++++++++++++---------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/app/views/admin/poll/polls/_form.html.erb b/app/views/admin/poll/polls/_form.html.erb index 2c8c9f1d6..75b28dc40 100644 --- a/app/views/admin/poll/polls/_form.html.erb +++ b/app/views/admin/poll/polls/_form.html.erb @@ -3,42 +3,47 @@ <%= translatable_form_for [:admin, @poll] do |f| %> <%= render "shared/errors", resource: @poll %> -
-
- <%= f.text_field :starts_at, - value: @poll.starts_at.present? ? l(@poll.starts_at.to_date) : nil, - class: "js-calendar-full" %> -
+
+
+
+ <%= f.text_field :starts_at, + value: @poll.starts_at.present? ? l(@poll.starts_at.to_date) : nil, + class: "js-calendar-full" %> +
-
- <%= f.text_field :ends_at, - value: @poll.ends_at.present? ? l(@poll.ends_at.to_date) : nil, - class: "js-calendar-full" %> +
+ <%= f.text_field :ends_at, + value: @poll.ends_at.present? ? l(@poll.ends_at.to_date) : nil, + class: "js-calendar-full" %> +
+
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :name %> +
- <%= f.translatable_fields do |translations_form| %> -
- <%= translations_form.text_field :name %> -
+
+ <%= translations_form.text_area :summary, rows: 4 %> +
-
- <%= translations_form.text_area :summary, rows: 4 %> -
- -
- <%= translations_form.text_area :description, rows: 8 %> -
- <% end %> - -
- <%= render "images/admin_image", imageable: @poll, f: f %> +
+ <%= translations_form.text_area :description, rows: 8 %> +
+ <% end %>
-
-
- <%= f.check_box :geozone_restricted, data: { checkbox_toggle: "#geozones" } %> +
+
+ <%= render "images/admin_image", imageable: @poll, f: f %> +
+ +
+
+ <%= f.check_box :geozone_restricted, data: { checkbox_toggle: "#geozones" } %> +
@@ -54,10 +59,13 @@
-
-
- <%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"), - class: "button success expanded margin-top" %> +
+
+
+ <%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"), + class: "button success expanded margin-top" %> +
+ <% end %> From 9f98435789ba23a9df62aeec1e1d7bb47e19f37b Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 19:36:53 +0200 Subject: [PATCH 31/44] Align admin polls questions form fields with new translations interface --- app/views/admin/poll/questions/_form.html.erb | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index ccaa0de00..350f25d75 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -6,25 +6,33 @@ <%= f.hidden_field :proposal_id %> -
- <% if @poll.present? %> - <%= f.hidden_field :poll_id, value: @poll.id %> - <% elsif @question.poll.present? %> - <%= f.hidden_field :poll_id, value: @question.poll.id %> - <% else %> -
- <% select_options = Poll.all.map { |p| [p.name, p.id] } %> - <%= f.select :poll_id, - options_for_select(select_options), - prompt: t("admin.questions.index.select_poll"), - label: t("admin.questions.new.poll_label") %> +
+
+ <% if @poll.present? %> + <%= f.hidden_field :poll_id, value: @poll.id %> + <% elsif @question.poll.present? %> + <%= f.hidden_field :poll_id, value: @question.poll.id %> + <% else %> +
+ <% select_options = Poll.all.map { |p| [p.name, p.id] } %> + <%= f.select :poll_id, + options_for_select(select_options), + prompt: t("admin.questions.index.select_poll"), + label: t("admin.questions.new.poll_label") %> +
+ <% end %> +
+
+ +
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title %>
<% end %> +
- <%= f.translatable_fields do |translations_form| %> - <%= translations_form.text_field :title %> - <% end %> - +
<% if !@question.persisted? %> <%= fields_for :votation_type do |votation_f| %>
@@ -56,8 +64,10 @@
<% end %> <% end %> +
-
+
+
<%= f.submit(class: "button success expanded", value: t("shared.save")) %>
From c1a72e716982ce8df0b17e9b3406833196584463 Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 19:42:28 +0200 Subject: [PATCH 32/44] Align admin polls questions answers form fields with new translations interface --- .../poll/questions/answers/_form.html.erb | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/views/admin/poll/questions/answers/_form.html.erb b/app/views/admin/poll/questions/answers/_form.html.erb index 5700e5076..873ce5785 100644 --- a/app/views/admin/poll/questions/answers/_form.html.erb +++ b/app/views/admin/poll/questions/answers/_form.html.erb @@ -9,16 +9,21 @@ <%= f.hidden_field :question_id, value: @answer.question_id || @question.id %> - <%= f.translatable_fields do |translations_form| %> - <%= translations_form.text_field :title %> +
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title %> +
+
+ <%= translations_form.cktext_area :description, maxlength: Poll::Question.description_max_length %> +
+ <% end %> +
-
- <%= translations_form.cktext_area :description, maxlength: Poll::Question.description_max_length %> +
+
+ <%= f.submit(class: "button success expanded", value: t("shared.save")) %>
- <% end %> - -
- <%= f.submit(class: "button success expanded", value: t("shared.save")) %>
<% end %> From 12089282c8e22ba2c174030ef3ce3b37e7b5a521 Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 20:17:56 +0200 Subject: [PATCH 33/44] Align admin progress bars form fields with new translations interface Add new js method to recover selected language to disable correctly default language fields. --- app/assets/javascripts/forms.js.coffee | 3 +- app/assets/javascripts/globalize.js.coffee | 3 ++ .../tracking/progress_bars/_form.html.erb | 49 +++++++++++-------- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/app/assets/javascripts/forms.js.coffee b/app/assets/javascripts/forms.js.coffee index 2a987245c..5cf403e59 100644 --- a/app/assets/javascripts/forms.js.coffee +++ b/app/assets/javascripts/forms.js.coffee @@ -40,7 +40,8 @@ App.Forms = hideOrShowFieldsAfterSelection: -> $("[name='progress_bar[kind]']").on change: -> - title_field = $("[name^='progress_bar'][name$='[title]']").parent() + locale = App.Globalize.selected_language() + title_field = $(".translatable-fields[data-locale=#{locale}]") if this.value == "primary" title_field.hide() diff --git a/app/assets/javascripts/globalize.js.coffee b/app/assets/javascripts/globalize.js.coffee index 1f45eed86..af320e2e1 100644 --- a/app/assets/javascripts/globalize.js.coffee +++ b/app/assets/javascripts/globalize.js.coffee @@ -1,5 +1,8 @@ App.Globalize = + selected_language: -> + $("#select_language").val() + display_locale: (locale) -> App.Globalize.enable_locale(locale) App.Globalize.add_language(locale) diff --git a/app/views/tracking/progress_bars/_form.html.erb b/app/views/tracking/progress_bars/_form.html.erb index 992ef65d9..4a66107d3 100644 --- a/app/views/tracking/progress_bars/_form.html.erb +++ b/app/views/tracking/progress_bars/_form.html.erb @@ -2,30 +2,39 @@ <%= translatable_form_for [:tracking, *resource_hierarchy_for(@progress_bar)] do |f| %> -
- <%= f.enum_select :kind %> +
+
+ <%= f.enum_select :kind %> +
- <%= f.translatable_fields do |translations_form| %> -
- <%= translations_form.text_field :title %> -
- <% end %> +
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title %> +
+ <% end %> +
<% progress_options = { min: ProgressBar::RANGE.min, max: ProgressBar::RANGE.max, step: 1 } %> -
- <%= f.text_field :percentage, { type: :range, - id: "percentage_range", - class: "column" }.merge(progress_options) %> -
-
-
- <%= f.text_field :percentage, { type: :number, - label: false, - class: "input-group-field" }.merge(progress_options) %> - % +
+
+ <%= f.text_field :percentage, { type: :range, + id: "percentage_range", + class: "column" }.merge(progress_options) %> +
+ +
+
+ <%= f.text_field :percentage, { type: :number, + label: false, + class: "input-group-field" }.merge(progress_options) %> + % +
+
+ +
+ <%= f.submit nil, class: "button success" %>
- - <%= f.submit nil, class: "button success" %> <% end %> From 220a5fc68496dd8a1d48f4ea208512f48a5708ae Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 20:22:44 +0200 Subject: [PATCH 34/44] Align admin site customization pages form fields with new translations interface --- .../site_customization/pages/_form.html.erb | 70 +++++++++++-------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/app/views/admin/site_customization/pages/_form.html.erb b/app/views/admin/site_customization/pages/_form.html.erb index a32965341..0411a5311 100644 --- a/app/views/admin/site_customization/pages/_form.html.erb +++ b/app/views/admin/site_customization/pages/_form.html.erb @@ -13,41 +13,51 @@
<% end %> +
+
+
+
-
-
+
+

<%= t("admin.site_customization.pages.form.options") %>

+ <%= f.label :status %> + <% ::SiteCustomization::Page::VALID_STATUSES.each do |status| %> + <%= f.radio_button :status, status, label: false %> + <%= f.label "status_#{status}", t("admin.site_customization.pages.page.status_#{status}") %> +
+ <% end %> + + <%= f.check_box :more_info_flag, class: "small" %> + <%= f.check_box :print_content_flag %> +
+ +
+ <%= f.label :slug %> +

<%= t("admin.site_customization.pages.new.slug_help_html") %> + <%= f.text_field :slug, label: false, size: 80, maxlength: 80 %> +

-
-

<%= t("admin.site_customization.pages.form.options") %>

- <%= f.label :status %> - <% ::SiteCustomization::Page::VALID_STATUSES.each do |status| %> - <%= f.radio_button :status, status, label: false %> - <%= f.label "status_#{status}", t("admin.site_customization.pages.page.status_#{status}") %> -
- <% end %> - - <%= f.check_box :more_info_flag, class: "small" %> - <%= f.check_box :print_content_flag %> +
+
+
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title %> +
+
+ <%= translations_form.text_field :subtitle %> +
+
+ <%= translations_form.cktext_area :content, + ckeditor: { language: I18n.locale, toolbar: "admin" } %> +
+ <% end %> +
-
- <%= f.label :slug %> -

<%= t("admin.site_customization.pages.new.slug_help_html") %> - <%= f.text_field :slug, label: false, size: 80, maxlength: 80 %> -

-
-
- <%= f.translatable_fields do |translations_form| %> - <%= translations_form.text_field :title %> - <%= translations_form.text_field :subtitle %> -
- <%= translations_form.cktext_area :content, - ckeditor: { language: I18n.locale, toolbar: "admin" } %> -
- <% end %> - -
+
+
<%= f.submit class: "button success expanded" %>
From f3022b2cecb4b5c432d5a72fa6a0cb59dd90666e Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 20:29:06 +0200 Subject: [PATCH 35/44] Align admin widget cards form fields with new translations interface --- app/views/admin/widget/cards/_form.html.erb | 64 +++++++++++++-------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/app/views/admin/widget/cards/_form.html.erb b/app/views/admin/widget/cards/_form.html.erb index f16789f5a..ab0762859 100644 --- a/app/views/admin/widget/cards/_form.html.erb +++ b/app/views/admin/widget/cards/_form.html.erb @@ -2,40 +2,54 @@ <%= translatable_form_for [:admin, @card] do |f| %> - <%= f.translatable_fields do |translations_form| %> -
- <%= translations_form.text_field :label %> -
+
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :label %> +
- <%= translations_form.text_field :title %> +
+ <%= translations_form.text_field :title %> +
- <%= translations_form.text_area :description, rows: 5 %> +
+ <%= translations_form.text_area :description, rows: 5 %> +
-
- <%= translations_form.text_field :link_text %> -
- <% end %> - -
- <%= f.text_field :link_url %> +
+ <%= translations_form.text_field :link_text %> +
+ <% end %>
- <% unless @card.header? %> - <%= f.label :columns %> -

<%= t("admin.site_customization.pages.cards.columns_help") %>

-
- <%= f.select :columns, (1..12), label: false %> +
+
+ <%= f.text_field :link_url %>
- <% end %> +
+ +
+ <% unless @card.header? %> +
+ <%= f.label :columns %> +

<%= t("admin.site_customization.pages.cards.columns_help") %>

+
+ <%= f.select :columns, (1..12), label: false %> +
+
+ <% end %> +
<%= f.hidden_field :header, value: @card.header? %> <%= f.hidden_field :site_customization_page_id, value: @card.site_customization_page_id %> - -
-
- <%= render "images/nested_image", imageable: @card, f: f %> +
+
+
+ <%= render "images/nested_image", imageable: @card, f: f %> +
+
+
+ <%= f.submit(t("admin.homepage.#{action_name}.#{@card.header? ? "submit_header" : "submit_card"}"), class: "button success") %>
- - <%= f.submit(t("admin.homepage.#{action_name}.#{@card.header? ? "submit_header" : "submit_card"}"), class: "button success") %> <% end %> From 0602a38742e0f230a8eb74c1a63dbe5788b3cb1e Mon Sep 17 00:00:00 2001 From: taitus Date: Sat, 1 Jun 2019 22:09:07 +0200 Subject: [PATCH 36/44] Fix Style: Display Titles without highlight --- app/views/admin/budget_phases/edit.html.erb | 6 ++++-- app/views/admin/budgets/edit.html.erb | 6 ++++-- app/views/admin/budgets/new.html.erb | 4 +--- .../admin/legislation/draft_versions/new.html.erb | 4 +--- .../admin/legislation/questions/edit.html.erb | 14 ++++++++------ app/views/admin/legislation/questions/new.html.erb | 7 ++++--- app/views/admin/poll/polls/new.html.erb | 8 +++++--- .../admin/site_customization/pages/edit.html.erb | 9 +++++---- .../admin/site_customization/pages/new.html.erb | 7 ++++--- 9 files changed, 36 insertions(+), 29 deletions(-) diff --git a/app/views/admin/budget_phases/edit.html.erb b/app/views/admin/budget_phases/edit.html.erb index 7161abc88..9cf9a6745 100644 --- a/app/views/admin/budget_phases/edit.html.erb +++ b/app/views/admin/budget_phases/edit.html.erb @@ -1,7 +1,9 @@ <%= back_link_to edit_admin_budget_path(@phase.budget) %> -
-

<%= t("admin.budgets.edit.title") %> - <%= t("budgets.phase.#{@phase.kind}") %>

+
+
+

<%= t("admin.budgets.edit.title") %> - <%= t("budgets.phase.#{@phase.kind}") %>

+
<%= render "/admin/budget_phases/form" %> diff --git a/app/views/admin/budgets/edit.html.erb b/app/views/admin/budgets/edit.html.erb index 508279796..2ccbba53a 100644 --- a/app/views/admin/budgets/edit.html.erb +++ b/app/views/admin/budgets/edit.html.erb @@ -1,7 +1,9 @@ <%= back_link_to admin_budgets_path %> -
-

<%= t("admin.budgets.edit.title") %>

+
+
+

<%= t("admin.budgets.edit.title") %>

+
<%= render "/admin/budgets/form" %> diff --git a/app/views/admin/budgets/new.html.erb b/app/views/admin/budgets/new.html.erb index aca444559..a9d08340c 100644 --- a/app/views/admin/budgets/new.html.erb +++ b/app/views/admin/budgets/new.html.erb @@ -1,5 +1,3 @@ -
-

<%= t("admin.budgets.new.title") %>

-
+

<%= t("admin.budgets.new.title") %>

<%= render "/admin/budgets/form" %> diff --git a/app/views/admin/legislation/draft_versions/new.html.erb b/app/views/admin/legislation/draft_versions/new.html.erb index 90b2c634f..fd3498afa 100644 --- a/app/views/admin/legislation/draft_versions/new.html.erb +++ b/app/views/admin/legislation/draft_versions/new.html.erb @@ -11,9 +11,7 @@ <%= render "admin/legislation/processes/subnav", process: @process, active: "draft_versions" %> -
-

<%= t("admin.legislation.draft_versions.new.title") %>

-
+

<%= t("admin.legislation.draft_versions.new.title") %>

<%= render "form", url: admin_legislation_process_draft_versions_path(@process) %>
diff --git a/app/views/admin/legislation/questions/edit.html.erb b/app/views/admin/legislation/questions/edit.html.erb index 6db283eba..3151efa90 100644 --- a/app/views/admin/legislation/questions/edit.html.erb +++ b/app/views/admin/legislation/questions/edit.html.erb @@ -10,13 +10,15 @@ <%= render "admin/legislation/processes/subnav", process: @process, active: "questions" %> -
-

<%= t("admin.legislation.questions.edit.title", question_title: @question.title) %>

+
+
+

<%= t("admin.legislation.questions.edit.title", question_title: @question.title) %>

-
- <%= link_to t("admin.legislation.questions.index.delete"), admin_legislation_process_question_path(@process, @question), - method: :delete, - class: "button hollow alert" %> +
+ <%= link_to t("admin.legislation.questions.index.delete"), admin_legislation_process_question_path(@process, @question), + method: :delete, + class: "button hollow alert" %> +
diff --git a/app/views/admin/legislation/questions/new.html.erb b/app/views/admin/legislation/questions/new.html.erb index 6b9c54519..da50c0e0a 100644 --- a/app/views/admin/legislation/questions/new.html.erb +++ b/app/views/admin/legislation/questions/new.html.erb @@ -9,9 +9,10 @@

<%= @process.title %>

<%= render "admin/legislation/processes/subnav", process: @process, active: "questions" %> - -
-

<%= t("admin.legislation.questions.new.title") %>

+
+
+

<%= t("admin.legislation.questions.new.title") %>

+
<%= render "form", url: admin_legislation_process_questions_path(@process) %> diff --git a/app/views/admin/poll/polls/new.html.erb b/app/views/admin/poll/polls/new.html.erb index 6cc6c0d8f..528b7ff69 100644 --- a/app/views/admin/poll/polls/new.html.erb +++ b/app/views/admin/poll/polls/new.html.erb @@ -1,7 +1,9 @@ -
- <%= back_link_to %> +
+
+ <%= back_link_to %> -

<%= t("admin.polls.new.title") %>

+

<%= t("admin.polls.new.title") %>

+
diff --git a/app/views/admin/site_customization/pages/edit.html.erb b/app/views/admin/site_customization/pages/edit.html.erb index 716652079..1965b636f 100644 --- a/app/views/admin/site_customization/pages/edit.html.erb +++ b/app/views/admin/site_customization/pages/edit.html.erb @@ -3,11 +3,12 @@ <% end %> <%= back_link_to admin_site_customization_pages_path %> +
+
+

<%= t("admin.site_customization.pages.edit.title", page_title: @page.title) %>

-
-

<%= t("admin.site_customization.pages.edit.title", page_title: @page.title) %>

- - <%= link_to t("admin.site_customization.pages.index.delete"), admin_site_customization_page_path(@page), method: :delete, class: "delete float-right" %> + <%= link_to t("admin.site_customization.pages.index.delete"), admin_site_customization_page_path(@page), method: :delete, class: "delete float-right" %> +
<%= render "form" %> diff --git a/app/views/admin/site_customization/pages/new.html.erb b/app/views/admin/site_customization/pages/new.html.erb index b180e73d7..dd6fdddd6 100644 --- a/app/views/admin/site_customization/pages/new.html.erb +++ b/app/views/admin/site_customization/pages/new.html.erb @@ -3,9 +3,10 @@ <% end %> <%= back_link_to admin_site_customization_pages_path %> - -
-

<%= t("admin.site_customization.pages.new.title") %>

+
+
+

<%= t("admin.site_customization.pages.new.title") %>

+
<%= render "form" %> From b2d8851bcce7a99393fe0d01c0e6df71102f7748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Mon, 3 Jun 2019 12:49:17 +0200 Subject: [PATCH 37/44] Add the option to disable languages managment to cover special cases We understand languages management as the ability to add new languages or remove existing ones. When no option is passed it will allow language manipulation by default. There are 3 special places where we want block languages management: - admin legislation processes homepage - admin legislation processes milestones summary - proposals retired form Co-Authored-By: Sebastia --- app/helpers/globalize_helper.rb | 5 ----- .../legislation/homepages/_form.html.erb | 3 ++- .../milestones/_summary_form.html.erb | 3 ++- .../_globalize_locales.html.erb | 3 ++- app/views/proposals/retire_form.html.erb | 2 +- .../shared/_common_globalize_locales.html.erb | 1 - app/views/shared/_globalize_locales.html.erb | 3 ++- .../admin/legislation/processes_spec.rb | 21 +++++++++++++++++++ spec/features/proposals_spec.rb | 15 +++++++++++++ 9 files changed, 45 insertions(+), 11 deletions(-) diff --git a/app/helpers/globalize_helper.rb b/app/helpers/globalize_helper.rb index 592b49170..74ebc5ba0 100644 --- a/app/helpers/globalize_helper.rb +++ b/app/helpers/globalize_helper.rb @@ -96,11 +96,6 @@ module GlobalizeHelper end end - def can_manipulate_languages? - params[:controller] != "admin/legislation/milestones" && - params[:controller] != "admin/legislation/homepages" - end - def translation_enabled_tag(locale, enabled) hidden_field_tag("enabled_translations[#{locale}]", (enabled ? 1 : 0)) end diff --git a/app/views/admin/legislation/homepages/_form.html.erb b/app/views/admin/legislation/homepages/_form.html.erb index d5b5d73ec..4ce79ab30 100644 --- a/app/views/admin/legislation/homepages/_form.html.erb +++ b/app/views/admin/legislation/homepages/_form.html.erb @@ -1,6 +1,7 @@ <%= render "shared/globalize_locales", resource: @process, - display_style: lambda { |locale| enable_translation_style(@process, locale) } %> + display_style: lambda { |locale| enable_translation_style(@process, locale) }, + manage_languages: false %> <%= translatable_form_for [:admin, @process], url: url, html: {data: {watch_changes: true}} do |f| %> diff --git a/app/views/admin/legislation/milestones/_summary_form.html.erb b/app/views/admin/legislation/milestones/_summary_form.html.erb index e43cabf00..3c4297049 100644 --- a/app/views/admin/legislation/milestones/_summary_form.html.erb +++ b/app/views/admin/legislation/milestones/_summary_form.html.erb @@ -1,6 +1,7 @@ <%= render "shared/globalize_locales", resource: @process, - display_style: lambda { |locale| enable_translation_style(@process, locale) } %> + display_style: lambda { |locale| enable_translation_style(@process, locale) }, + manage_languages: false %> <%= translatable_form_for [:admin, @process] do |f| %>
diff --git a/app/views/admin/site_customization/information_texts/_globalize_locales.html.erb b/app/views/admin/site_customization/information_texts/_globalize_locales.html.erb index 61969d2f0..ef93a7ae7 100644 --- a/app/views/admin/site_customization/information_texts/_globalize_locales.html.erb +++ b/app/views/admin/site_customization/information_texts/_globalize_locales.html.erb @@ -1,3 +1,4 @@ <%= render "shared/common_globalize_locales", resource: nil, - display_style: lambda { |locale| site_customization_display_translation_style(locale) } %> + display_style: lambda { |locale| site_customization_display_translation_style(locale) }, + manage_languages: defined?(manage_languages) ? manage_languages : true %> diff --git a/app/views/proposals/retire_form.html.erb b/app/views/proposals/retire_form.html.erb index 0a54ecd92..604cd1a47 100644 --- a/app/views/proposals/retire_form.html.erb +++ b/app/views/proposals/retire_form.html.erb @@ -10,7 +10,7 @@ <%= t("proposals.retire_form.warning") %>
- <%= render "shared/globalize_locales", resource: @proposal %> + <%= render "shared/globalize_locales", resource: @proposal, manage_languages: false %> <%= translatable_form_for(@proposal, url: retire_proposal_path(@proposal)) do |f| %> <%= render "shared/errors", resource: @proposal %> diff --git a/app/views/shared/_common_globalize_locales.html.erb b/app/views/shared/_common_globalize_locales.html.erb index c114135c3..bf29a7344 100644 --- a/app/views/shared/_common_globalize_locales.html.erb +++ b/app/views/shared/_common_globalize_locales.html.erb @@ -10,7 +10,6 @@ options_for_select_language(resource), prompt: "Choose language", class: "js-select-language" %> -
<% if manage_languages %> <% I18n.available_locales.each do |locale| %> diff --git a/app/views/shared/_globalize_locales.html.erb b/app/views/shared/_globalize_locales.html.erb index a43961ab5..38464ac3b 100644 --- a/app/views/shared/_globalize_locales.html.erb +++ b/app/views/shared/_globalize_locales.html.erb @@ -1,5 +1,6 @@ <% if translations_interface_enabled? %> <%= render "shared/common_globalize_locales", resource: resource, - display_style: lambda { |locale| enable_translation_style(resource, locale) } %> + display_style: lambda { |locale| enable_translation_style(resource, locale) }, + manage_languages: defined?(manage_languages) ? manage_languages : true %> <% end %> diff --git a/spec/features/admin/legislation/processes_spec.rb b/spec/features/admin/legislation/processes_spec.rb index 3b233717b..2e22c4404 100644 --- a/spec/features/admin/legislation/processes_spec.rb +++ b/spec/features/admin/legislation/processes_spec.rb @@ -282,4 +282,25 @@ describe "Admin collaborative legislation" do expect(page).to have_content "There is still a long journey ahead of us" end end + + context "Special interface translation behaviour" do + let!(:process) { create(:legislation_process) } + + before { Setting["feature.translation_interface"] = true } + after { Setting["feature.translation_interface"] = nil } + + scenario "Cant manage translations on homepage form" do + visit edit_admin_legislation_process_homepage_path(process) + + expect(page).not_to have_css "#add_language" + expect(page).not_to have_link "Remove language" + end + + scenario "Cant manage translations on milestones summary form" do + visit admin_legislation_process_milestones_path(process) + + expect(page).not_to have_css "#add_language" + expect(page).not_to have_link "Remove language" + end + end end diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 62e851e6d..426f13a0a 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -604,6 +604,21 @@ describe "Proposals" do expect(page).to have_content unfeasible.title expect(page).not_to have_content duplicated.title end + + context "Special interface translation behaviour" do + before { Setting["feature.translation_interface"] = true } + after { Setting["feature.translation_interface"] = nil } + + scenario "Cant manage translations" do + proposal = create(:proposal) + login_as(proposal.author) + + visit retire_form_proposal_path(proposal) + + expect(page).not_to have_css "#add_language" + expect(page).not_to have_link "Remove language" + end + end end scenario "Update should not be posible if logged user is not the author" do From 10939fddb17699092aedc98747f20c4b09483074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Wed, 5 Jun 2019 16:16:19 +0200 Subject: [PATCH 38/44] Add missing translation and fix indentation --- app/views/shared/_common_globalize_locales.html.erb | 2 +- config/locales/en/admin.yml | 1 + config/locales/es/admin.yml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/shared/_common_globalize_locales.html.erb b/app/views/shared/_common_globalize_locales.html.erb index bf29a7344..514d1faf2 100644 --- a/app/views/shared/_common_globalize_locales.html.erb +++ b/app/views/shared/_common_globalize_locales.html.erb @@ -8,7 +8,7 @@ <%= select_tag :select_language, options_for_select_language(resource), - prompt: "Choose language", + prompt: t("admin.translations.select_language_prompt"), class: "js-select-language" %>
<% if manage_languages %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 183bc5abe..af3441f46 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -1631,6 +1631,7 @@ en: card_title: Edit card submit_card: Save card translations: + select_language_prompt: "Choose language" remove_language: Remove language add_language: Add language change_log: diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index f4c5df39d..7d4f7b88d 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -1629,6 +1629,7 @@ es: card_title: Editar tarjeta submit_card: Guardar tarjeta translations: + select_language_prompt: "Seleccionar idioma" remove_language: Eliminar idioma add_language: Añadir idioma change_log: From 7f754e5c8f7588d1c12eeaf16c97536e3c1c1376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Wed, 5 Jun 2019 17:52:08 +0200 Subject: [PATCH 39/44] Add row wrapper to form --- .../admin/budget_investments/edit.html.erb | 222 +++++++++--------- 1 file changed, 112 insertions(+), 110 deletions(-) diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb index e1f48f0c9..ef6540c9e 100644 --- a/app/views/admin/budget_investments/edit.html.erb +++ b/app/views/admin/budget_investments/edit.html.erb @@ -4,130 +4,132 @@ <%= render "shared/globalize_locales", resource: @investment %> -<%= translatable_form_for @investment, - url: admin_budget_budget_investment_path(@budget, @investment) do |f| %> +
+ <%= translatable_form_for @investment, + url: admin_budget_budget_investment_path(@budget, @investment) do |f| %> - <%= render "shared/errors", resource: @investment %> + <%= render "shared/errors", resource: @investment %> - <% Budget::Investment.filter_params(params).to_h.each do |filter_name, filter_value| %> - <%= hidden_field_tag filter_name, filter_value %> - <% end %> - -
- <%= f.translatable_fields do |translations_form| %> -
- <%= translations_form.text_field :title, - maxlength: Budget::Investment.title_max_length %> -
- -
- <%= translations_form.cktext_area :description, - maxlength: Budget::Investment.description_max_length, - ckeditor: { language: I18n.locale } %> -
+ <% Budget::Investment.filter_params(params).to_h.each do |filter_name, filter_value| %> + <%= hidden_field_tag filter_name, filter_value %> <% end %> -
- <%= f.label :tag_list, t("admin.budget_investments.edit.user_tags") %> - <%= f.text_field :tag_list, - value: @investment.tag_list.sort.join(","), - label: false %> -
+
+ <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title, + maxlength: Budget::Investment.title_max_length %> +
-
-
- <%= f.text_field :external_url %> +
+ <%= translations_form.cktext_area :description, + maxlength: Budget::Investment.description_max_length, + ckeditor: { language: I18n.locale } %> +
+ <% end %> + +
+ <%= f.label :tag_list, t("admin.budget_investments.edit.user_tags") %> + <%= f.text_field :tag_list, + value: @investment.tag_list.sort.join(","), + label: false %>
-
- <%= f.select :heading_id, budget_heading_select_options(@budget), include_blank: t("admin.budget_investments.edit.select_heading") %> -
-
-
+
+
+ <%= f.text_field :external_url %> +
-
- -
-

<%= t("admin.budget_investments.edit.classification") %>

- -
- <%= f.select(:administrator_id, - @admins.collect{ |a| [a.description_or_name_and_email, a.id ] }, - { include_blank: t("admin.budget_investments.edit.undefined") }) %> +
+ <%= f.select :heading_id, budget_heading_select_options(@budget), include_blank: t("admin.budget_investments.edit.select_heading") %> +
-
- <%= f.label :valuation_tag_list, t("admin.budget_investments.edit.tags") %> -
- <% @tags.each do |tag| %> - <%= tag.name %> +
+ +
+

<%= t("admin.budget_investments.edit.classification") %>

+ +
+ <%= f.select(:administrator_id, + @admins.collect{ |a| [a.description_or_name_and_email, a.id ] }, + { include_blank: t("admin.budget_investments.edit.undefined") }) %> +
+
+ +
+ <%= f.label :valuation_tag_list, t("admin.budget_investments.edit.tags") %> +
+ <% @tags.each do |tag| %> + <%= tag.name %> + <% end %> +
+ <%= f.text_field :valuation_tag_list, + value: @investment.valuation_tag_list.sort.join(","), + label: false, + placeholder: t("admin.budget_investments.edit.tags_placeholder"), + class: "js-tag-list" %> +
+ +
+ <%= f.label :valuator_ids, t("admin.budget_investments.edit.user_groups") %> +
    + <%= f.collection_check_boxes :valuator_group_ids, @valuator_groups, :id, :name do |group| %> +
  • <%= group.label(title: group.object.name) { group.check_box + truncate(group.object.name, length: 60) } %>
  • + <% end %> +
+
+ +
+
+ <%= f.label :valuator_ids, t("admin.budget_investments.edit.assigned_valuators") %> +
    + <%= f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %> +
  • <%= b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %>
  • + <% end %> +
+
+ +
+
+ <%= f.label :tracker_ids, t("admin.budget_investments.edit.assigned_trackers") %> +
    + <%= f.collection_check_boxes :tracker_ids, @trackers, :id, :email do |b| %> +
  • <%= b.label(title: tracker_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %>
  • + <% end %> +
+
+
+ +
+ <% if @investment.incompatible? || @investment.winner? %> +
+

<%= t("admin.budget_investments.edit.compatibility") %>

+ <%= f.label :incompatible do %> + <%= f.check_box :incompatible, title: t("admin.budget_investments.edit.compatibility"), label: false %> + <%= t("admin.budget_investments.edit.mark_as_incompatible") %> + <% end %> +
+ <% end %> +
+

<%= t("admin.budget_investments.edit.selection") %>

+ <%= f.label :selected do %> + <%= f.check_box :selected, title: t("admin.budget_investments.edit.selection"), label: false %> + <%= t("admin.budget_investments.edit.mark_as_selected") %> <% end %>
- <%= f.text_field :valuation_tag_list, - value: @investment.valuation_tag_list.sort.join(","), - label: false, - placeholder: t("admin.budget_investments.edit.tags_placeholder"), - class: "js-tag-list" %>
+
+ <%= f.text_field :milestone_tag_list, + value: @investment.milestone_tag_list.sort.join(", "), + label: t("admin.budget_investments.edit.milestone_tags") %> +
+ +
- <%= f.label :valuator_ids, t("admin.budget_investments.edit.user_groups") %> -
    - <%= f.collection_check_boxes :valuator_group_ids, @valuator_groups, :id, :name do |group| %> -
  • <%= group.label(title: group.object.name) { group.check_box + truncate(group.object.name, length: 60) } %>
  • - <% end %> -
+ <%= f.submit(class: "button", value: t("admin.budget_investments.edit.submit_button")) %>
- -
-
- <%= f.label :valuator_ids, t("admin.budget_investments.edit.assigned_valuators") %> -
    - <%= f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %> -
  • <%= b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %>
  • - <% end %> -
-
- -
-
- <%= f.label :tracker_ids, t("admin.budget_investments.edit.assigned_trackers") %> -
    - <%= f.collection_check_boxes :tracker_ids, @trackers, :id, :email do |b| %> -
  • <%= b.label(title: tracker_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %>
  • - <% end %> -
-
-
- -
- <% if @investment.incompatible? || @investment.winner? %> -
-

<%= t("admin.budget_investments.edit.compatibility") %>

- <%= f.label :incompatible do %> - <%= f.check_box :incompatible, title: t("admin.budget_investments.edit.compatibility"), label: false %> - <%= t("admin.budget_investments.edit.mark_as_incompatible") %> - <% end %> -
- <% end %> -
-

<%= t("admin.budget_investments.edit.selection") %>

- <%= f.label :selected do %> - <%= f.check_box :selected, title: t("admin.budget_investments.edit.selection"), label: false %> - <%= t("admin.budget_investments.edit.mark_as_selected") %> - <% end %> -
-
- -
- <%= f.text_field :milestone_tag_list, - value: @investment.milestone_tag_list.sort.join(", "), - label: t("admin.budget_investments.edit.milestone_tags") %> -
- - -
- <%= f.submit(class: "button", value: t("admin.budget_investments.edit.submit_button")) %> -
-<% end %> + <% end %> +
From 97eab7445d7a2549ce5c9bfdacb89aff72b49c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Wed, 5 Jun 2019 18:32:13 +0200 Subject: [PATCH 40/44] Move translations from admin.yml to general.yml After extract translation interface partials from admin folder translations should be placed in general.yml file inside shared context. --- app/views/shared/_common_globalize_locales.html.erb | 6 +++--- config/locales/en/admin.yml | 4 ---- config/locales/es/admin.yml | 4 ---- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/views/shared/_common_globalize_locales.html.erb b/app/views/shared/_common_globalize_locales.html.erb index 514d1faf2..c7250a718 100644 --- a/app/views/shared/_common_globalize_locales.html.erb +++ b/app/views/shared/_common_globalize_locales.html.erb @@ -8,12 +8,12 @@ <%= select_tag :select_language, options_for_select_language(resource), - prompt: t("admin.translations.select_language_prompt"), + prompt: t("shared.translations.select_language_prompt"), class: "js-select-language" %>
<% if manage_languages %> <% I18n.available_locales.each do |locale| %> - <%= link_to t("admin.translations.remove_language"), "#", + <%= link_to t("shared.translations.remove_language"), "#", style: display_destroy_locale_style(resource, locale), class: "delete js-delete-language js-delete-#{locale}", data: { locale: locale } %> @@ -25,7 +25,7 @@ <% if manage_languages %> <%= select_tag :add_language, options_for_add_language, - prompt: t("admin.translations.add_language"), + prompt: t("shared.translations.add_language"), class: "js-add-language" %> <% end %>
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index af3441f46..b097258fa 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -1630,10 +1630,6 @@ en: submit_header: Save header card_title: Edit card submit_card: Save card - translations: - select_language_prompt: "Choose language" - remove_language: Remove language - add_language: Add language change_log: title: "Change Log" id: "ID" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 7d4f7b88d..8c46fc408 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -1628,10 +1628,6 @@ es: submit_header: Guardar encabezado card_title: Editar tarjeta submit_card: Guardar tarjeta - translations: - select_language_prompt: "Seleccionar idioma" - remove_language: Eliminar idioma - add_language: Añadir idioma change_log: title: "Historial" id: "ID" From b86c0d3c30892140f61420d0b9a94641bb2bbf45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Wed, 12 Jun 2019 11:12:38 +0200 Subject: [PATCH 41/44] Delete unused file This file was used at previous version of translation interface. --- app/views/admin/shared/_globalize_tabs.html.erb | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 app/views/admin/shared/_globalize_tabs.html.erb diff --git a/app/views/admin/shared/_globalize_tabs.html.erb b/app/views/admin/shared/_globalize_tabs.html.erb deleted file mode 100644 index 9b9fc81af..000000000 --- a/app/views/admin/shared/_globalize_tabs.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -
    - <% I18n.available_locales.each do |locale| %> -
  • - <%= link_to name_for_locale(locale), "#", - style: display_style.call(locale), - class: "js-globalize-locale-link #{highlight_class(resource, locale)}", - data: { locale: locale }, - remote: true %> -
  • - <% end %> -
From a5a62b7471d924010d6d80f35f446ba49b221461 Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 12 Jun 2019 21:44:35 +0200 Subject: [PATCH 42/44] Add Tracking to backend_translations_enabled? --- app/helpers/translatable_form_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/translatable_form_helper.rb b/app/helpers/translatable_form_helper.rb index b4c80757f..807fa8d6f 100644 --- a/app/helpers/translatable_form_helper.rb +++ b/app/helpers/translatable_form_helper.rb @@ -11,7 +11,7 @@ module TranslatableFormHelper end def backend_translations_enabled? - (controller.class.parents & [Admin, Management, Valuation]).any? + (controller.class.parents & [Admin, Management, Valuation, Tracking]).any? end def highlight_translation_html_class From 58962186cd45dc03418b2bf08499756bbbc02d87 Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 12 Jun 2019 22:17:15 +0200 Subject: [PATCH 43/44] Add tracking as backend path --- spec/support/common_actions/translations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/common_actions/translations.rb b/spec/support/common_actions/translations.rb index 768e60059..949dc5ada 100644 --- a/spec/support/common_actions/translations.rb +++ b/spec/support/common_actions/translations.rb @@ -58,7 +58,7 @@ module Translations end def front_end_path_to_visit?(path) - path[/admin|managment|valuation/].blank? + path[/admin|managment|valuation|tracking/].blank? end def expect_to_have_language(language) From 12d20b481d421328b4ee85d13503ab0862a23da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Wed, 12 Jun 2019 23:52:41 +0200 Subject: [PATCH 44/44] Fix error during rebase --- spec/features/admin/site_customization/information_texts_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/admin/site_customization/information_texts_spec.rb b/spec/features/admin/site_customization/information_texts_spec.rb index 542040580..3d12a3511 100644 --- a/spec/features/admin/site_customization/information_texts_spec.rb +++ b/spec/features/admin/site_customization/information_texts_spec.rb @@ -84,6 +84,7 @@ describe "Admin custom information texts" do scenario "Update a translation", :js do key = "proposals.form.proposal_title" + create(:i18n_content, key: key, value_fr: "Titre de la proposition") visit admin_site_customization_information_texts_path(tab: "proposals")