diff --git a/app/controllers/management/proposals_controller.rb b/app/controllers/management/proposals_controller.rb index f24e94303..93e20f690 100644 --- a/app/controllers/management/proposals_controller.rb +++ b/app/controllers/management/proposals_controller.rb @@ -1,6 +1,7 @@ class Management::ProposalsController < Management::BaseController include HasOrders include CommentableActions + include Translatable before_action :only_verified_users, except: :print before_action :set_proposal, only: [:vote, :show] @@ -52,10 +53,10 @@ class Management::ProposalsController < Management::BaseController end def proposal_params - params.require(:proposal).permit(:title, :summary, :description, :video_url, - :responsible_name, :tag_list, :terms_of_service, :geozone_id, - :skip_map, - map_location_attributes: [:latitude, :longitude, :zoom]) + attributes = [:video_url, :responsible_name, :tag_list, + :terms_of_service, :geozone_id, + :skip_map, map_location_attributes: [:latitude, :longitude, :zoom]] + params.require(:proposal).permit(attributes, translation_params(Proposal)) end def resource_model diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index d2b876f06..9bf5dc7fd 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -3,6 +3,7 @@ class ProposalsController < ApplicationController include CommentableActions include FlagActions include ImageAttributes + include Translatable before_action :parse_tag_filter, only: :index before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary] @@ -37,7 +38,6 @@ class ProposalsController < ApplicationController def create @proposal = Proposal.new(proposal_params.merge(author: current_user)) - if @proposal.save redirect_to created_proposal_path(@proposal), notice: I18n.t("flash.actions.create.proposal") else @@ -98,12 +98,13 @@ class ProposalsController < ApplicationController private def proposal_params - params.require(:proposal).permit(:title, :summary, :description, :video_url, - :responsible_name, :tag_list, :terms_of_service, - :geozone_id, :skip_map, image_attributes: image_attributes, - documents_attributes: [:id, :title, :attachment, - :cached_attachment, :user_id, :_destroy], - map_location_attributes: [:latitude, :longitude, :zoom]) + attributes = [:video_url,:responsible_name, :tag_list, + :terms_of_service, :geozone_id, :skip_map, + image_attributes: image_attributes, + documents_attributes: [:id, :title, :attachment, :cached_attachment, + :user_id, :_destroy], + map_location_attributes: [:latitude, :longitude, :zoom]] + params.require(:proposal).permit(attributes, translation_params(Proposal)) end def retired_params diff --git a/app/helpers/proposals_helper.rb b/app/helpers/proposals_helper.rb index ecd8a1490..3879d4679 100644 --- a/app/helpers/proposals_helper.rb +++ b/app/helpers/proposals_helper.rb @@ -64,6 +64,10 @@ module ProposalsHelper proposals_current_view == "default" ? "minimal" : "default" end + def summary_help_text_id(translations_form) + "summary-help-text-#{translations_form.locale}" + end + def link_to_toggle_proposal_selection(proposal) if proposal.selected? button_text = t("admin.proposals.index.selected") diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb index f7a5e57f9..dbe789e9a 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -1,32 +1,50 @@ -<%= form_for(@proposal, url: form_url) do |f| %> +<%= render "admin/shared/globalize_locales", resource: @proposal %> + +<%= translatable_form_for(@proposal, url: form_url) do |f| %> + <%= render "shared/errors", resource: @proposal %>
> + <%= t("proposals.form.proposal_summary_note") %> +
+ <%= translations_form.text_area :summary, + rows: 4, maxlength: 200, + label: false, + placeholder: t("proposals.form.proposal_summary"), + aria: {describedby: summary_help_text_id(translations_form)} %> +<%= t("proposals.form.proposal_summary_note") %>
- <%= f.text_area :summary, rows: 4, maxlength: 200, label: false, - placeholder: t("proposals.form.proposal_summary"), - aria: {describedby: "summary-help-text"} %> -<%= t("proposals.form.proposal_video_url_note") %>
- <%= f.text_field :video_url, placeholder: t("proposals.form.proposal_video_url"), label: false, + <%= f.text_field :video_url, placeholder: t("proposals.form.proposal_video_url"), + label: false, aria: {describedby: "video-url-help-text"} %>