From b671b9f4d82beb8a85f71d91f9a6b8e0ba2ce066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 7 Jul 2021 02:11:12 +0200 Subject: [PATCH 1/7] Move investment form partial to a component --- .../investments/form_component.html.erb | 107 +++++++++++++++++ .../budgets/investments/form_component.rb | 21 ++++ .../budgets/investments_controller.rb | 2 +- .../budgets/investments_controller.rb | 6 - app/views/budgets/investments/_form.html.erb | 110 +----------------- 5 files changed, 130 insertions(+), 116 deletions(-) create mode 100644 app/components/budgets/investments/form_component.html.erb create mode 100644 app/components/budgets/investments/form_component.rb diff --git a/app/components/budgets/investments/form_component.html.erb b/app/components/budgets/investments/form_component.html.erb new file mode 100644 index 000000000..73730f718 --- /dev/null +++ b/app/components/budgets/investments/form_component.html.erb @@ -0,0 +1,107 @@ +<%= translatable_form_for(investment, url: url, html: { multipart: true }) do |f| %> + + <%= render "shared/errors", resource: investment %> + +
+ <% unless budget.single_heading? %> +
+ <%= f.select :heading_id, budget_heading_select_options(budget), { include_blank: true } %> +
+ <% end %> + +
+
+ <%= render "shared/globalize_locales", resource: investment %> +
+
+ + <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title, + maxlength: Budget::Investment.title_max_length, + data: suggest_data(investment) %> +
+
+ +
+ <%= translations_form.text_area :description, + maxlength: Budget::Investment.description_max_length, + class: "html-area" %> +
+ <% end %> + + <%= f.invisible_captcha :subtitle %> + + <% if feature?(:allow_images) %> +
+ <%= render "images/nested_image", imageable: investment, f: f %> +
+ <% end %> + + <% if feature?(:allow_attached_documents) %> +
+ <%= render "documents/nested_documents", documentable: investment, f: f %> +
+ <% end %> + + <% if feature?(:map) %> +
+ <%= render "map_locations/form_fields", + form: f, + map_location: investment.map_location || MapLocation.new, + label: t("budgets.investments.form.map_location"), + help: t("budgets.investments.form.map_location_instructions"), + remove_marker_label: t("budgets.investments.form.map_remove_marker"), + parent_class: "budget_investment", + i18n_namespace: "budgets.investments" %> +
+ <% end %> + +
+ <%= f.text_field :location %> +
+ +
+ <%= f.text_field :organization_name %> +
+ +
+ <%= f.label :tag_list, t("budgets.investments.form.tags_label") %> +

<%= t("budgets.investments.form.tags_instructions") %>

+ +
+ <%= f.label :category_tag_list, t("budgets.investments.form.tag_category_label") %> + <% categories.each do |tag| %> + <%= tag.name %> + <% end %> +
+ +
+ <%= f.text_field :tag_list, value: investment.tag_list.to_s, + label: false, + placeholder: t("budgets.investments.form.tags_placeholder"), + aria: { describedby: "tags-list-help-text" }, + class: "js-tag-list tag-autocomplete", + data: { js_url: suggest_tags_path } %> +
+ + <%= render SDG::RelatedListSelectorComponent.new(f) %> + + <% unless current_user.manager? %> + +
+ <%= f.check_box :terms_of_service, + title: t("form.accept_terms_title"), + label: t("form.accept_terms", + policy: link_to(t("form.policy"), "/privacy", target: "blank"), + conditions: link_to(t("form.conditions"), "/conditions", target: "blank") + ) %> +
+ + <% end %> + +
+ <%= f.submit(nil, class: "button expanded") %> +
+
+<% end %> diff --git a/app/components/budgets/investments/form_component.rb b/app/components/budgets/investments/form_component.rb new file mode 100644 index 000000000..181328e04 --- /dev/null +++ b/app/components/budgets/investments/form_component.rb @@ -0,0 +1,21 @@ +class Budgets::Investments::FormComponent < ApplicationComponent + include TranslatableFormHelper + include GlobalizeHelper + attr_reader :investment, :url + delegate :current_user, :budget_heading_select_options, :suggest_data, to: :helpers + + def initialize(investment, url:) + @investment = investment + @url = url + end + + private + + def budget + investment.budget + end + + def categories + Tag.category.order(:name) + end +end diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 6286fe13b..a06e68d1e 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -22,7 +22,7 @@ module Budgets before_action :load_ballot, only: [:index, :show] before_action :load_heading, only: [:index, :show] before_action :set_random_seed, only: :index - before_action :load_categories, only: [:index, :new, :create, :edit, :update] + before_action :load_categories, only: :index before_action :set_default_investment_filter, only: :index before_action :set_view, only: :index before_action :load_content_blocks, only: :index diff --git a/app/controllers/management/budgets/investments_controller.rb b/app/controllers/management/budgets/investments_controller.rb index 627964a69..ae3abf85d 100644 --- a/app/controllers/management/budgets/investments_controller.rb +++ b/app/controllers/management/budgets/investments_controller.rb @@ -18,7 +18,6 @@ class Management::Budgets::InvestmentsController < Management::BaseController end def new - load_categories end def create @@ -30,7 +29,6 @@ class Management::Budgets::InvestmentsController < Management::BaseController notice = t("flash.actions.create.notice", resource_name: Budget::Investment.model_name.human, count: 1) redirect_to management_budget_investment_path(@budget, @investment), notice: notice else - load_categories render :new end end @@ -59,8 +57,4 @@ class Management::Budgets::InvestmentsController < Management::BaseController def load_budget @budget = Budget.find_by_slug_or_id! params[:budget_id] end - - def load_categories - @categories = Tag.category.order(:name) - end end diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index 8296a2e30..4ef77fb0d 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -1,109 +1 @@ -<%= translatable_form_for(@investment, url: form_url, html: { multipart: true }) do |f| %> - - <%= render "shared/errors", resource: @investment %> - -
- <% unless @budget.single_heading? %> -
- <%= f.select :heading_id, budget_heading_select_options(@budget), { include_blank: true } %> -
- <% end %> - -
-
- <%= render "shared/globalize_locales", resource: @investment %> -
-
- - <%= f.translatable_fields do |translations_form| %> -
- <%= translations_form.text_field :title, - maxlength: Budget::Investment.title_max_length, - data: suggest_data(@investment) %> -
-
- -
- <%= translations_form.text_area :description, - maxlength: Budget::Investment.description_max_length, - class: "html-area" %> -
- <% end %> - - <%= f.invisible_captcha :subtitle %> - - <% if feature?(:allow_images) %> -
- <%= render "images/nested_image", imageable: @investment, f: f %> -
- <% end %> - - <% if feature?(:allow_attached_documents) %> -
- <%= render "documents/nested_documents", documentable: @investment, f: f %> -
- <% end %> - - <% if feature?(:map) %> -
- - <%= render "map_locations/form_fields", - form: f, - map_location: @investment.map_location || MapLocation.new, - label: t("budgets.investments.form.map_location"), - help: t("budgets.investments.form.map_location_instructions"), - remove_marker_label: t("budgets.investments.form.map_remove_marker"), - parent_class: "budget_investment", - i18n_namespace: "budgets.investments" %> - -
- <% end %> - -
- <%= f.text_field :location %> -
- -
- <%= f.text_field :organization_name %> -
- -
- <%= f.label :tag_list, t("budgets.investments.form.tags_label") %> -

<%= t("budgets.investments.form.tags_instructions") %>

- -
- <%= f.label :category_tag_list, t("budgets.investments.form.tag_category_label") %> - <% @categories.each do |tag| %> - <%= tag.name %> - <% end %> -
- -
- <%= f.text_field :tag_list, value: @investment.tag_list.to_s, - label: false, - placeholder: t("budgets.investments.form.tags_placeholder"), - aria: { describedby: "tags-list-help-text" }, - class: "js-tag-list tag-autocomplete", - data: { js_url: suggest_tags_path } %> -
- - <%= render SDG::RelatedListSelectorComponent.new(f) %> - - <% unless current_user.manager? %> - -
- <%= f.check_box :terms_of_service, - title: t("form.accept_terms_title"), - label: t("form.accept_terms", - policy: link_to(t("form.policy"), "/privacy", target: "blank"), - conditions: link_to(t("form.conditions"), "/conditions", target: "blank") - ) %> -
- - <% end %> - -
- <%= f.submit(nil, class: "button expanded") %> -
-
-<% end %> +<%= render Budgets::Investments::FormComponent.new(@investment, url: form_url) %> From 9ebb0b660ef55935d6301ee2b069cbf59b9d1b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 7 Jul 2021 02:42:38 +0200 Subject: [PATCH 2/7] Remove unnecessary multipart parameter Rails automatically adds it when using file fields inside a form. --- app/components/budgets/investments/form_component.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/budgets/investments/form_component.html.erb b/app/components/budgets/investments/form_component.html.erb index 73730f718..e54fb9edc 100644 --- a/app/components/budgets/investments/form_component.html.erb +++ b/app/components/budgets/investments/form_component.html.erb @@ -1,4 +1,4 @@ -<%= translatable_form_for(investment, url: url, html: { multipart: true }) do |f| %> +<%= translatable_form_for(investment, url: url) do |f| %> <%= render "shared/errors", resource: investment %> From 355153813d360951f4da90d352ca61e9504f7395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 7 Jul 2021 02:51:14 +0200 Subject: [PATCH 3/7] Remove row and column divs in investment form We don't need any row classes anymore because the already has a maximum width. As for columns, we only have one column in this form, so we don't need them either. Besides, the form's parent element already has a padding. Although most CONSUL installation don't enable the translation interface, we're adding some code to take this case into account. --- .../stylesheets/budgets/investments/form.scss | 13 ++ .../investments/form_component.html.erb | 184 +++++++++--------- 2 files changed, 102 insertions(+), 95 deletions(-) create mode 100644 app/assets/stylesheets/budgets/investments/form.scss diff --git a/app/assets/stylesheets/budgets/investments/form.scss b/app/assets/stylesheets/budgets/investments/form.scss new file mode 100644 index 000000000..22c5a3a65 --- /dev/null +++ b/app/assets/stylesheets/budgets/investments/form.scss @@ -0,0 +1,13 @@ +.budget-investment-form { + + .globalize-languages, + .translatable-fields { + @include grid-row-nest; + @include grid-column-gutter; + } + + .sdg-related-list-selector { + padding-left: 0; + padding-right: 0; + } +} diff --git a/app/components/budgets/investments/form_component.html.erb b/app/components/budgets/investments/form_component.html.erb index e54fb9edc..e76e567c5 100644 --- a/app/components/budgets/investments/form_component.html.erb +++ b/app/components/budgets/investments/form_component.html.erb @@ -1,107 +1,101 @@ -<%= translatable_form_for(investment, url: url) do |f| %> +<%= translatable_form_for(investment, url: url, html: { class: "budget-investment-form" }) do |f| %> <%= render "shared/errors", resource: investment %> -
- <% unless budget.single_heading? %> -
- <%= f.select :heading_id, budget_heading_select_options(budget), { include_blank: true } %> -
- <% end %> + <% unless budget.single_heading? %> +
+ <%= f.select :heading_id, budget_heading_select_options(budget), { include_blank: true } %> +
+ <% end %> -
-
- <%= render "shared/globalize_locales", resource: investment %> -
+
+ <%= render "shared/globalize_locales", resource: investment %> +
+ + <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title, + maxlength: Budget::Investment.title_max_length, + data: suggest_data(investment) %> +
+
+ +
+ <%= translations_form.text_area :description, + maxlength: Budget::Investment.description_max_length, + class: "html-area" %> +
+ <% end %> + + <%= f.invisible_captcha :subtitle %> + + <% if feature?(:allow_images) %> +
+ <%= render "images/nested_image", imageable: investment, f: f %> +
+ <% end %> + + <% if feature?(:allow_attached_documents) %> +
+ <%= render "documents/nested_documents", documentable: investment, f: f %> +
+ <% end %> + + <% if feature?(:map) %> +
+ <%= render "map_locations/form_fields", + form: f, + map_location: investment.map_location || MapLocation.new, + label: t("budgets.investments.form.map_location"), + help: t("budgets.investments.form.map_location_instructions"), + remove_marker_label: t("budgets.investments.form.map_remove_marker"), + parent_class: "budget_investment", + i18n_namespace: "budgets.investments" %> +
+ <% end %> + +
+ <%= f.text_field :location %> +
+ +
+ <%= f.text_field :organization_name %> +
+ +
+ <%= f.label :tag_list, t("budgets.investments.form.tags_label") %> +

<%= t("budgets.investments.form.tags_instructions") %>

+ +
+ <%= f.label :category_tag_list, t("budgets.investments.form.tag_category_label") %> + <% categories.each do |tag| %> + <%= tag.name %> + <% end %>
- <%= f.translatable_fields do |translations_form| %> -
- <%= translations_form.text_field :title, - maxlength: Budget::Investment.title_max_length, - data: suggest_data(investment) %> -
-
+
+ <%= f.text_field :tag_list, value: investment.tag_list.to_s, + label: false, + placeholder: t("budgets.investments.form.tags_placeholder"), + aria: { describedby: "tags-list-help-text" }, + class: "js-tag-list tag-autocomplete", + data: { js_url: suggest_tags_path } %> +
-
- <%= translations_form.text_area :description, - maxlength: Budget::Investment.description_max_length, - class: "html-area" %> -
- <% end %> + <%= render SDG::RelatedListSelectorComponent.new(f) %> - <%= f.invisible_captcha :subtitle %> - - <% if feature?(:allow_images) %> -
- <%= render "images/nested_image", imageable: investment, f: f %> -
- <% end %> - - <% if feature?(:allow_attached_documents) %> -
- <%= render "documents/nested_documents", documentable: investment, f: f %> -
- <% end %> - - <% if feature?(:map) %> -
- <%= render "map_locations/form_fields", - form: f, - map_location: investment.map_location || MapLocation.new, - label: t("budgets.investments.form.map_location"), - help: t("budgets.investments.form.map_location_instructions"), - remove_marker_label: t("budgets.investments.form.map_remove_marker"), - parent_class: "budget_investment", - i18n_namespace: "budgets.investments" %> -
- <% end %> - -
- <%= f.text_field :location %> + <% unless current_user.manager? %> +
+ <%= f.check_box :terms_of_service, + title: t("form.accept_terms_title"), + label: t("form.accept_terms", + policy: link_to(t("form.policy"), "/privacy", target: "blank"), + conditions: link_to(t("form.conditions"), "/conditions", target: "blank") + ) %>
+ <% end %> -
- <%= f.text_field :organization_name %> -
- -
- <%= f.label :tag_list, t("budgets.investments.form.tags_label") %> -

<%= t("budgets.investments.form.tags_instructions") %>

- -
- <%= f.label :category_tag_list, t("budgets.investments.form.tag_category_label") %> - <% categories.each do |tag| %> - <%= tag.name %> - <% end %> -
- -
- <%= f.text_field :tag_list, value: investment.tag_list.to_s, - label: false, - placeholder: t("budgets.investments.form.tags_placeholder"), - aria: { describedby: "tags-list-help-text" }, - class: "js-tag-list tag-autocomplete", - data: { js_url: suggest_tags_path } %> -
- - <%= render SDG::RelatedListSelectorComponent.new(f) %> - - <% unless current_user.manager? %> - -
- <%= f.check_box :terms_of_service, - title: t("form.accept_terms_title"), - label: t("form.accept_terms", - policy: link_to(t("form.policy"), "/privacy", target: "blank"), - conditions: link_to(t("form.conditions"), "/conditions", target: "blank") - ) %> -
- - <% end %> - -
- <%= f.submit(nil, class: "button expanded") %> -
+
+ <%= f.submit(nil, class: "button expanded") %>
<% end %> From 5cb617f46de1882252077d5b38c338f851f2fcb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 7 Jul 2021 15:58:39 +0200 Subject: [PATCH 4/7] Make edit and new investment forms similar One of them was less wide than the other one. We're still only adding the heading to the form for the new investment, just like in the original budgets redesign. --- app/views/budgets/investments/edit.html.erb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/budgets/investments/edit.html.erb b/app/views/budgets/investments/edit.html.erb index ffdb0dcdf..6821e7697 100644 --- a/app/views/budgets/investments/edit.html.erb +++ b/app/views/budgets/investments/edit.html.erb @@ -1,6 +1,7 @@ -
-
+
+

<%= t("management.budget_investments.edit") %>

- <%= render "/budgets/investments/form", form_url: budget_investment_path(@budget, @investment) %>
+ + <%= render "/budgets/investments/form", form_url: budget_investment_path(@budget, @investment) %>
From 62ca76258712d274976af57738e9c79dc3983277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 7 Jul 2021 16:33:56 +0200 Subject: [PATCH 5/7] Only show terms acceptance on new investment form No need to accept the terms when updating the investment. --- .../investments/form_component.html.erb | 2 +- .../investments/form_component_spec.rb | 36 +++++++++++++++++++ spec/system/budgets/investments_spec.rb | 2 -- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 spec/components/budgets/investments/form_component_spec.rb diff --git a/app/components/budgets/investments/form_component.html.erb b/app/components/budgets/investments/form_component.html.erb index e76e567c5..3410ddcb6 100644 --- a/app/components/budgets/investments/form_component.html.erb +++ b/app/components/budgets/investments/form_component.html.erb @@ -84,7 +84,7 @@ <%= render SDG::RelatedListSelectorComponent.new(f) %> - <% unless current_user.manager? %> + <% unless current_user.manager? || investment.persisted? %>
<%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), diff --git a/spec/components/budgets/investments/form_component_spec.rb b/spec/components/budgets/investments/form_component_spec.rb new file mode 100644 index 000000000..8e6bcfb11 --- /dev/null +++ b/spec/components/budgets/investments/form_component_spec.rb @@ -0,0 +1,36 @@ +require "rails_helper" + +describe Budgets::Investments::FormComponent, type: :component do + include Rails.application.routes.url_helpers + + let(:budget) { create(:budget) } + + before do + allow(controller).to receive(:current_user).and_return(create(:user)) + allow(request).to receive(:path_parameters).and_return(budget_id: budget.id) + end + + describe "accept terms of services field" do + it "is shown for new investments" do + investment = build(:budget_investment, budget: budget) + + render_inline Budgets::Investments::FormComponent.new( + investment, + url: budget_investments_path(budget) + ) + + expect(page).to have_field "I agree to the Privacy Policy and the Terms and conditions of use" + end + + it "is not shown for existing investments" do + investment = create(:budget_investment, budget: budget) + + render_inline Budgets::Investments::FormComponent.new( + investment, + url: budget_investment_path(budget, investment) + ) + + expect(page).not_to have_field "I agree to the Privacy Policy and the Terms and conditions of use" + end + end +end diff --git a/spec/system/budgets/investments_spec.rb b/spec/system/budgets/investments_spec.rb index 60b056d95..87a55a069 100644 --- a/spec/system/budgets/investments_spec.rb +++ b/spec/system/budgets/investments_spec.rb @@ -633,7 +633,6 @@ describe "Budget Investments" do click_link("Edit", match: :first) fill_in "Title", with: "Park improvements" - check "budget_investment_terms_of_service" click_button "Update Investment" @@ -651,7 +650,6 @@ describe "Budget Investments" do visit user_path(daniel, filter: "budget_investments") click_link("Edit", match: :first) fill_in "Title", with: "" - check "budget_investment_terms_of_service" click_button "Update Investment" From a87e8bd34d0783f9660234abf30938181c25c3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 7 Jul 2021 17:01:50 +0200 Subject: [PATCH 6/7] Move new investment button styles to CSS files --- app/assets/stylesheets/budgets/investments/form.scss | 5 +++++ app/components/budgets/investments/form_component.html.erb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/budgets/investments/form.scss b/app/assets/stylesheets/budgets/investments/form.scss index 22c5a3a65..de48941b5 100644 --- a/app/assets/stylesheets/budgets/investments/form.scss +++ b/app/assets/stylesheets/budgets/investments/form.scss @@ -10,4 +10,9 @@ padding-left: 0; padding-right: 0; } + + [type="submit"] { + @include regular-button; + width: 100%; + } } diff --git a/app/components/budgets/investments/form_component.html.erb b/app/components/budgets/investments/form_component.html.erb index 3410ddcb6..d1261be91 100644 --- a/app/components/budgets/investments/form_component.html.erb +++ b/app/components/budgets/investments/form_component.html.erb @@ -96,6 +96,6 @@ <% end %>
- <%= f.submit(nil, class: "button expanded") %> + <%= f.submit %>
<% end %> From 823cc37ce8f38445db838027b7c74bf35d6633fd Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 7 Apr 2020 12:11:28 +0200 Subject: [PATCH 7/7] Update styles and layout for new budget investment form --- .../stylesheets/budgets/investments/form.scss | 46 ++++- .../stylesheets/budgets/investments/new.scss | 15 +- app/assets/stylesheets/layout.scss | 1 - .../investments/form_component.html.erb | 166 +++++++++--------- .../budgets/investments/new.html.erb | 2 +- config/locales/en/general.yml | 2 + config/locales/es/general.yml | 2 + 7 files changed, 148 insertions(+), 86 deletions(-) diff --git a/app/assets/stylesheets/budgets/investments/form.scss b/app/assets/stylesheets/budgets/investments/form.scss index de48941b5..6d84a466d 100644 --- a/app/assets/stylesheets/budgets/investments/form.scss +++ b/app/assets/stylesheets/budgets/investments/form.scss @@ -1,5 +1,34 @@ .budget-investment-form { + .required-fields { + @include full-width-background($adjust-padding: true); + background: $light; + margin-bottom: $line-height; + padding-top: $line-height; + } + + > fieldset > legend { + float: left; + font-size: rem-calc(36); + font-weight: bold; + margin-bottom: $line-height; + text-transform: uppercase; + + + * { + clear: left; + } + } + + select { + min-height: $line-height * 2; + + @include breakpoint(medium) { + &:not(.js-add-language):not(.js-select-language) { + width: 50%; + } + } + } + .globalize-languages, .translatable-fields { @include grid-row-nest; @@ -13,6 +42,21 @@ [type="submit"] { @include regular-button; - width: 100%; + font-size: map-get($button-sizes, large); + margin-top: $line-height; + } + + .actions { + border: 6px solid $border; + border-radius: rem-calc(12); + margin-left: auto; + margin-right: auto; + margin-top: $line-height * 2; + padding: $line-height * 2 $line-height; + text-align: center; + + @include breakpoint(medium) { + width: 75%; + } } } diff --git a/app/assets/stylesheets/budgets/investments/new.scss b/app/assets/stylesheets/budgets/investments/new.scss index bda89bd63..f13325fbf 100644 --- a/app/assets/stylesheets/budgets/investments/new.scss +++ b/app/assets/stylesheets/budgets/investments/new.scss @@ -1,19 +1,27 @@ .budget-investment-new { $border-width: 4px; + @include grid-column-gutter; - > * { - @include grid-column-gutter; + > :first-child:not(.print-info) { + @include full-width-background($adjust-padding: true); + background: $light; + margin-top: -$line-height; + padding-top: $line-height; + } + + h1 { + margin-bottom: 0; } header { @include has-fa-icon(building, regular, after); align-items: center; + background-color: $body-background; border: $border-width solid; color: $brand-secondary; border-bottom-right-radius: rem-calc(12); border-top-right-radius: rem-calc(12); display: flex; - margin-bottom: $line-height * 2; margin-top: $line-height * 2; @include breakpoint(large) { @@ -38,7 +46,6 @@ display: flex; flex: 1; font-size: rem-calc(36); - margin-bottom: 0; padding: $line-height * 2 0; @include breakpoint(large) { diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 85778926f..ec9aef363 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1074,7 +1074,6 @@ form { .checkbox, .radio { - display: inline-block; font-weight: normal; line-height: $line-height; vertical-align: middle; diff --git a/app/components/budgets/investments/form_component.html.erb b/app/components/budgets/investments/form_component.html.erb index d1261be91..34283dbd8 100644 --- a/app/components/budgets/investments/form_component.html.erb +++ b/app/components/budgets/investments/form_component.html.erb @@ -2,100 +2,108 @@ <%= render "shared/errors", resource: investment %> - <% unless budget.single_heading? %> -
- <%= f.select :heading_id, budget_heading_select_options(budget), { include_blank: true } %> -
- <% end %> +
+ <%= t("shared.required") %> -
- <%= render "shared/globalize_locales", resource: investment %> -
- - <%= f.translatable_fields do |translations_form| %> -
- <%= translations_form.text_field :title, - maxlength: Budget::Investment.title_max_length, - data: suggest_data(investment) %> -
-
+ <% unless budget.single_heading? %> +
+ <%= f.select :heading_id, budget_heading_select_options(budget), { include_blank: true } %> +
+ <% end %>
- <%= translations_form.text_area :description, - maxlength: Budget::Investment.description_max_length, - class: "html-area" %> + <%= render "shared/globalize_locales", resource: investment %>
- <% end %> + + <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title, + maxlength: Budget::Investment.title_max_length, + data: suggest_data(investment) %> +
+
+ +
+ <%= translations_form.text_area :description, + maxlength: Budget::Investment.description_max_length, + class: "html-area" %> +
+ <% end %> +
<%= f.invisible_captcha :subtitle %> - <% if feature?(:allow_images) %> -
- <%= render "images/nested_image", imageable: investment, f: f %> -
- <% end %> +
+ <%= t("shared.optional") %> - <% if feature?(:allow_attached_documents) %> -
- <%= render "documents/nested_documents", documentable: investment, f: f %> -
- <% end %> + <% if feature?(:allow_images) %> +
+ <%= render "images/nested_image", imageable: investment, f: f %> +
+ <% end %> + + <% if feature?(:allow_attached_documents) %> +
+ <%= render "documents/nested_documents", documentable: investment, f: f %> +
+ <% end %> + + <% if feature?(:map) %> +
+ <%= render "map_locations/form_fields", + form: f, + map_location: investment.map_location || MapLocation.new, + label: t("budgets.investments.form.map_location"), + help: t("budgets.investments.form.map_location_instructions"), + remove_marker_label: t("budgets.investments.form.map_remove_marker"), + parent_class: "budget_investment", + i18n_namespace: "budgets.investments" %> +
+ <% end %> - <% if feature?(:map) %>
- <%= render "map_locations/form_fields", - form: f, - map_location: investment.map_location || MapLocation.new, - label: t("budgets.investments.form.map_location"), - help: t("budgets.investments.form.map_location_instructions"), - remove_marker_label: t("budgets.investments.form.map_remove_marker"), - parent_class: "budget_investment", - i18n_namespace: "budgets.investments" %> -
- <% end %> - -
- <%= f.text_field :location %> -
- -
- <%= f.text_field :organization_name %> -
- -
- <%= f.label :tag_list, t("budgets.investments.form.tags_label") %> -

<%= t("budgets.investments.form.tags_instructions") %>

- -
- <%= f.label :category_tag_list, t("budgets.investments.form.tag_category_label") %> - <% categories.each do |tag| %> - <%= tag.name %> - <% end %> + <%= f.text_field :location %>
-
- <%= f.text_field :tag_list, value: investment.tag_list.to_s, - label: false, - placeholder: t("budgets.investments.form.tags_placeholder"), - aria: { describedby: "tags-list-help-text" }, - class: "js-tag-list tag-autocomplete", - data: { js_url: suggest_tags_path } %> -
- - <%= render SDG::RelatedListSelectorComponent.new(f) %> - - <% unless current_user.manager? || investment.persisted? %>
- <%= f.check_box :terms_of_service, - title: t("form.accept_terms_title"), - label: t("form.accept_terms", - policy: link_to(t("form.policy"), "/privacy", target: "blank"), - conditions: link_to(t("form.conditions"), "/conditions", target: "blank") - ) %> + <%= f.text_field :organization_name %>
- <% end %> -
+
+ <%= f.label :tag_list, t("budgets.investments.form.tags_label") %> +

<%= t("budgets.investments.form.tags_instructions") %>

+ +
+ <%= f.label :category_tag_list, t("budgets.investments.form.tag_category_label") %> + <% categories.each do |tag| %> + <%= tag.name %> + <% end %> +
+ +
+ <%= f.text_field :tag_list, value: investment.tag_list.to_s, + label: false, + placeholder: t("budgets.investments.form.tags_placeholder"), + aria: { describedby: "tags-list-help-text" }, + class: "js-tag-list tag-autocomplete", + data: { js_url: suggest_tags_path } %> +
+ + <%= render SDG::RelatedListSelectorComponent.new(f) %> +
+ +
+ <% unless current_user.manager? || investment.persisted? %> +
+ <%= f.check_box :terms_of_service, + title: t("form.accept_terms_title"), + label: t("form.accept_terms", + policy: link_to(t("form.policy"), "/privacy", target: "blank"), + conditions: link_to(t("form.conditions"), "/conditions", target: "blank") + ) %> +
+ <% end %> + <%= f.submit %>
<% end %> diff --git a/app/views/management/budgets/investments/new.html.erb b/app/views/management/budgets/investments/new.html.erb index d8fa9048c..d2b280606 100644 --- a/app/views/management/budgets/investments/new.html.erb +++ b/app/views/management/budgets/investments/new.html.erb @@ -1,6 +1,6 @@
-
+ diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index a58e5e6ba..d0d1ff500 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -774,6 +774,8 @@ en: zero: "0 languages in use" one: "1 language in use" other: "%{count} languages in use" + optional: "Optional" + required: "Required" social: facebook: "%{org} Facebook" twitter: "%{org} Twitter" diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 81a903d8c..aa8b4b8ee 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -774,6 +774,8 @@ es: zero: "0 idiomas en uso" one: "1 idioma en uso" other: "%{count} idiomas en uso" + optional: "Opcional" + required: "Obligatorio" social: facebook: "Facebook de %{org}" twitter: "Twitter de %{org}"