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 %>
-
- <%= f.label :title, t("proposals.form.proposal_title") %> - <%= f.text_field :title, maxlength: Proposal.title_max_length, placeholder: t("proposals.form.proposal_title"), label: false, data: {js_suggest_result: "js_suggest_result", js_suggest: "#js-suggest", js_url: suggest_proposals_path}%> -
-
+ + <%= f.translatable_fields do |translations_form| %> +
+ <%= translations_form.text_field :title, + maxlength: Proposal.title_max_length, + placeholder: t("proposals.form.proposal_title"), + label: t("proposals.form.proposal_title"), + data: { js_suggest_result: "js_suggest_result", + js_suggest: "#js-suggest", + js_url: suggest_proposals_path } %> +
+
+ +
+ <%= translations_form.label :summary %> +

> + <%= 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)} %> +
+ +
+ <%= translations_form.cktext_area :description, + maxlength: Proposal.description_max_length, + ckeditor: { language: I18n.locale }, + label: t("proposals.form.proposal_text") %> +
+ <% end %> <%= f.invisible_captcha :subtitle %> -
- <%= f.label :summary, t("proposals.form.proposal_summary") %> -

<%= 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"} %> -
- -
- <%= f.label :description, t("proposals.form.proposal_text") %> - <%= f.cktext_area :description, maxlength: Proposal.description_max_length, ckeditor: { language: I18n.locale }, label: false %> -
-
<%= f.label :video_url, t("proposals.form.proposal_video_url") %>

<%= 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"} %>
diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index d2ecf5776..a101430ad 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -15,6 +15,11 @@ describe "Proposals" do context "Concerns" do it_behaves_like "notifiable in-app", Proposal it_behaves_like "relationable", Proposal + it_behaves_like "translatable", + "proposal", + "edit_proposal_path", + %w[title summary], + { "description" => :ckeditor } end context "Index" do