diff --git a/app/assets/javascripts/forms.js.coffee b/app/assets/javascripts/forms.js.coffee index 34ea71916..5cf403e59 100644 --- a/app/assets/javascripts/forms.js.coffee +++ b/app/assets/javascripts/forms.js.coffee @@ -40,14 +40,15 @@ 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() - $("#globalize_locales").hide() + $(".globalize-languages").hide() else title_field.show() - $("#globalize_locales").show() + $(".globalize-languages").show() $("[name='progress_bar[kind]']").change() diff --git a/app/assets/javascripts/globalize.js.coffee b/app/assets/javascripts/globalize.js.coffee index 1238402a2..af320e2e1 100644 --- a/app/assets/javascripts/globalize.js.coffee +++ b/app/assets/javascripts/globalize.js.coffee @@ -1,37 +1,47 @@ App.Globalize = + selected_language: -> + $("#select_language").val() + 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 +53,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 +64,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) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index b7d5a9647..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; } @@ -1080,6 +1084,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/globalize_helper.rb b/app/helpers/globalize_helper.rb index 92d02b63e..74ebc5ba0 100644 --- a/app/helpers/globalize_helper.rb +++ b/app/helpers/globalize_helper.rb @@ -1,17 +1,76 @@ 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 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 + + 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 + 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 @@ -19,38 +78,31 @@ 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 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 diff --git a/app/helpers/translatable_form_helper.rb b/app/helpers/translatable_form_helper.rb index 934ab19b0..807fa8d6f 100644 --- a/app/helpers/translatable_form_helper.rb +++ b/app/helpers/translatable_form_helper.rb @@ -11,7 +11,11 @@ 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 + "highlight" if translations_interface_enabled? end class TranslatableFormBuilder < FoundationRailsHelper::FormBuilder @@ -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 } } diff --git a/app/views/admin/admin_notifications/_form.html.erb b/app/views/admin/admin_notifications/_form.html.erb index 0048c93a5..d671c2517 100644 --- a/app/views/admin/admin_notifications/_form.html.erb +++ b/app/views/admin/admin_notifications/_form.html.erb @@ -1,19 +1,33 @@ -<%= 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 %> - <%= 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 %> 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..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 "admin/shared/globalize_locales", resource: @group %> +<%= 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 %> diff --git a/app/views/admin/budget_headings/_form.html.erb b/app/views/admin/budget_headings/_form.html.erb index 4fe3b75da..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 "admin/shared/globalize_locales", resource: @heading %> +<%= 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 %> diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb index 8b94f5cac..ef6540c9e 100644 --- a/app/views/admin/budget_investments/edit.html.erb +++ b/app/views/admin/budget_investments/edit.html.erb @@ -2,132 +2,134 @@ <%= 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| %> +
+ <%= 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 %> +
diff --git a/app/views/admin/budget_phases/_form.html.erb b/app/views/admin/budget_phases/_form.html.erb index 05b4139be..4bb746219 100644 --- a/app/views/admin/budget_phases/_form.html.erb +++ b/app/views/admin/budget_phases/_form.html.erb @@ -1,65 +1,74 @@ -<%= render "admin/shared/globalize_locales", resource: @phase %> +<%= render "shared/globalize_locales", resource: @phase %> <%= translatable_form_for [:admin, @phase.budget, @phase] do |f| %> <%= 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 %> 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/_form.html.erb b/app/views/admin/budgets/_form.html.erb index b552821e1..e8337e551 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| %> @@ -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 %> 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/_form.html.erb b/app/views/admin/legislation/draft_versions/_form.html.erb index 754b420ca..3ef7247b4 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| %> @@ -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 %> 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/homepages/_form.html.erb b/app/views/admin/legislation/homepages/_form.html.erb index d5e276aa2..4ce79ab30 100644 --- a/app/views/admin/legislation/homepages/_form.html.erb +++ b/app/views/admin/legislation/homepages/_form.html.erb @@ -1,28 +1,34 @@ -<%= render "admin/shared/globalize_tabs", +<%= 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| %> <%= 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 %> diff --git a/app/views/admin/legislation/milestones/_summary_form.html.erb b/app/views/admin/legislation/milestones/_summary_form.html.erb index 952926572..3c4297049 100644 --- a/app/views/admin/legislation/milestones/_summary_form.html.erb +++ b/app/views/admin/legislation/milestones/_summary_form.html.erb @@ -1,13 +1,20 @@ -<%= render "admin/shared/globalize_tabs", +<%= 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| %> - <%= 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 %> diff --git a/app/views/admin/legislation/processes/_form.html.erb b/app/views/admin/legislation/processes/_form.html.erb index eb9b1d6d2..d95f65598 100644 --- a/app/views/admin/legislation/processes/_form.html.erb +++ b/app/views/admin/legislation/processes/_form.html.erb @@ -1,256 +1,261 @@ -<%= 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| %> <% 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 %> diff --git a/app/views/admin/legislation/questions/_form.html.erb b/app/views/admin/legislation/questions/_form.html.erb index daccb3dfe..22964c95a 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| %> @@ -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 %> 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/active_polls/_form.html.erb b/app/views/admin/poll/active_polls/_form.html.erb index 4e7fc766e..be6bd8fb9 100644 --- a/app/views/admin/poll/active_polls/_form.html.erb +++ b/app/views/admin/poll/active_polls/_form.html.erb @@ -1,20 +1,24 @@ -<%= 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| %> <%= 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 %> diff --git a/app/views/admin/poll/polls/_form.html.erb b/app/views/admin/poll/polls/_form.html.erb index 98c1d8d2f..75b28dc40 100644 --- a/app/views/admin/poll/polls/_form.html.erb +++ b/app/views/admin/poll/polls/_form.html.erb @@ -1,44 +1,49 @@ -<%= 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 %> -
-
- <%= 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 %> 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/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index c7aadadf8..350f25d75 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| %> @@ -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")) %>
diff --git a/app/views/admin/poll/questions/answers/_form.html.erb b/app/views/admin/poll/questions/answers/_form.html.erb index 06194cd96..873ce5785 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| %> @@ -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 %> 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/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 %> -
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..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 "admin/shared/common_globalize_locales", +<%= 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/admin/site_customization/pages/_form.html.erb b/app/views/admin/site_customization/pages/_form.html.erb index 90075a24b..0411a5311 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? %> @@ -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" %>
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" %> diff --git a/app/views/admin/widget/cards/_form.html.erb b/app/views/admin/widget/cards/_form.html.erb index 413be15d1..ab0762859 100644 --- a/app/views/admin/widget/cards/_form.html.erb +++ b/app/views/admin/widget/cards/_form.html.erb @@ -1,41 +1,55 @@ -<%= render "admin/shared/globalize_locales", resource: @card %> +<%= render "shared/globalize_locales", resource: @card %> <%= 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 %> diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index dbf9cdb9e..39266eb5a 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -1,13 +1,16 @@ -<%= render "admin/shared/globalize_locales", resource: @investment %> - <%= translatable_form_for(@investment, url: form_url, method: :post, html: { multipart: true }) do |f| %> <%= render "shared/errors", resource: @investment %> -
+
<%= f.select :heading_id, budget_heading_select_options(@budget), {include_blank: true, } %>
+
+
+ <%= render "shared/globalize_locales", resource: @investment %> +
+
<%= f.translatable_fields do |translations_form| %>
diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb index b4b3c71e4..33f60dd91 100644 --- a/app/views/debates/_form.html.erb +++ b/app/views/debates/_form.html.erb @@ -1,11 +1,10 @@ -<%= render "admin/shared/globalize_locales", resource: @debate %> +<%= render "shared/globalize_locales", resource: @debate %> <%= translatable_form_for(@debate) do |f| %> <%= 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 faeada8d6..92505e408 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -1,10 +1,10 @@ -<%= render "admin/shared/globalize_locales", resource: @proposal %> +<%= render "shared/globalize_locales", resource: @proposal %> <%= translatable_form_for(@proposal, url: form_url) do |f| %> <%= render "shared/errors", resource: @proposal %> -
+
<%= f.translatable_fields do |translations_form| %>
<%= translations_form.text_field :title, diff --git a/app/views/proposals/retire_form.html.erb b/app/views/proposals/retire_form.html.erb index 9a73c9782..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 "admin/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 new file mode 100644 index 000000000..c7250a718 --- /dev/null +++ b/app/views/shared/_common_globalize_locales.html.erb @@ -0,0 +1,32 @@ +
" + 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) %>"> +
+ + <%= selected_languages_description(resource) %> + + <%= select_tag :select_language, + options_for_select_language(resource), + prompt: t("shared.translations.select_language_prompt"), + class: "js-select-language" %> +
+ <% if manage_languages %> + <% I18n.available_locales.each do |locale| %> + <%= 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 } %> + <% end %> + <% end %> +
+
+
+ <% if manage_languages %> + <%= select_tag :add_language, + options_for_add_language, + prompt: t("shared.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..38464ac3b --- /dev/null +++ b/app/views/shared/_globalize_locales.html.erb @@ -0,0 +1,6 @@ +<% if translations_interface_enabled? %> + <%= render "shared/common_globalize_locales", + resource: resource, + display_style: lambda { |locale| enable_translation_style(resource, locale) }, + manage_languages: defined?(manage_languages) ? manage_languages : true %> +<% end %> diff --git a/app/views/tracking/milestones/_form.html.erb b/app/views/tracking/milestones/_form.html.erb index f9a86d376..a6fd6687a 100644 --- a/app/views/tracking/milestones/_form.html.erb +++ b/app/views/tracking/milestones/_form.html.erb @@ -1,36 +1,45 @@ -<%= render "admin/shared/globalize_locales", resource: @milestone %> +<%= render "shared/globalize_locales", resource: @milestone %> <%= 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 %> diff --git a/app/views/tracking/progress_bars/_form.html.erb b/app/views/tracking/progress_bars/_form.html.erb index 07720485e..4a66107d3 100644 --- a/app/views/tracking/progress_bars/_form.html.erb +++ b/app/views/tracking/progress_bars/_form.html.erb @@ -1,31 +1,40 @@ -<%= 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| %> -
- <%= 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 %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 183bc5abe..b097258fa 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -1630,9 +1630,6 @@ en: submit_header: Save header card_title: Edit card submit_card: Save card - translations: - remove_language: Remove language - add_language: Add language change_log: title: "Change Log" id: "ID" 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/admin.yml b/config/locales/es/admin.yml index f4c5df39d..8c46fc408 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -1628,9 +1628,6 @@ es: submit_header: Guardar encabezado card_title: Editar tarjeta submit_card: Guardar tarjeta - translations: - remove_language: Eliminar idioma - add_language: Añadir idioma change_log: title: "Historial" id: "ID" 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/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/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/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..3d12a3511 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,25 +76,26 @@ 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 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") - 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 +114,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" 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 diff --git a/spec/shared/features/edit_translatable.rb b/spec/shared/features/edit_translatable.rb index ed19ad63c..9a49f1407 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 @@ -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,14 +325,81 @@ 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 + + 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 + + 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 56fb6a028..22d354b38 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,64 @@ 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 + 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 + + 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 diff --git a/spec/support/common_actions/translations.rb b/spec/support/common_actions/translations.rb index e45ae346a..949dc5ada 100644 --- a/spec/support/common_actions/translations.rb +++ b/spec/support/common_actions/translations.rb @@ -58,6 +58,18 @@ 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) + 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