diff --git a/app/controllers/help_center/support_threads_controller.rb b/app/controllers/help_center/support_threads_controller.rb index 6a07663..79bfb91 100644 --- a/app/controllers/help_center/support_threads_controller.rb +++ b/app/controllers/help_center/support_threads_controller.rb @@ -67,6 +67,6 @@ def set_support_thread end def support_thread_params - params.require(:support_thread).permit(:title, :content, :support_category_id, support_posts_attributes: [:body]) + params.require(:support_thread).permit(:title, :content, :position, :support_category_id, support_posts_attributes: [:body]) end end diff --git a/app/views/help_center/support_posts/_form.html.erb b/app/views/help_center/support_posts/_form.html.erb index 098a8f9..7d21b11 100644 --- a/app/views/help_center/support_posts/_form.html.erb +++ b/app/views/help_center/support_posts/_form.html.erb @@ -1,32 +1,47 @@ -<%= form_for [@support_thread, @support_post], - url: (@support_post.persisted? ? help_center.support_thread_support_post_path(@support_thread, @support_post) : help_center.support_thread_support_posts_path(@support_thread)), - html: { data: { behavior: "comment-form" } } do |f| %> - - <% if @support_post.errors.any? %> +<%= form_for @support_thread, + url: (@support_thread.persisted? ? help_center.support_thread_path(@support_thread) : help_center.support_threads_path), + html: { data: {behavior: "comment-form"} } do |f| %> + <% if @support_thread.errors.any? %>
-

<%= pluralize(@support_post.errors.count, "error") %> prohibited this support_post from being saved:

- +

<%= pluralize(@support_thread.errors.count, "error") %> prohibited this support_thread from being saved:

<% end %> - -
- <%= f.text_area :body, placeholder: t('add_a_comment'), rows: 8, class: "form-control simplemde", data: { behavior: "comment-body" } %> +
+ <%= f.label :support_category_id, t('choose_a_category') %> + <%= f.collection_select :support_category_id, SupportCategory.sorted, :id, :name, {include_blank: t('pick_a_category')}, {autofocus: true, class: "form-control"} %>
- -
-
- - <%# Describe text formatting options here with a link %> - <%#= link_to "Parsed with Markdown", "https://guides.github.com/features/mastering-markdown/", target: "_blank" %> - -
- - <%= f.button "#{f.object.new_record? ? t('comment') : t('update_comment') }", class: "btn btn-primary", data: {disable_with: " #{t('saving_comment')}"} %> +
+ <%= f.label t('title') %> + <%= f.text_field :title, placeholder: t('how_do_i'), class: "form-control" %> +
+
+ <%= f.label t('position') %> + <%= f.text_field :position, class: "form-control" %> +
+
+ <%= f.label t('content') %> + <%= f.rich_text_area :content %> +
+ <% if local_assigns.fetch(:posts, true) %> + <% if !f.object.new_record? %> + <%= f.fields_for :support_posts do |p| %> +
+ <%= p.label :body, t('what_help_needed') %> + <%= p.text_area :body, placeholder: t('add_a_comment'), rows: 10, class: "form-control simplemde", data: { behavior: "comment-body" } %> +
+ <% end %> + <% end %> + <% end %> +
+ <% if f.object.new_record? %> + <%= f.button t('add'), class: "btn btn-primary", data: {disable_with: " #{t('saving')}"} %> + <% else %> + <%= f.button t('update'), class: "btn btn-primary", data: {disable_with: " #{t('saving')}"} %> + <% end %>
- <% end %> diff --git a/app/views/help_center/support_posts/_support_post.html.erb b/app/views/help_center/support_posts/_support_post.html.erb index 942bde0..9ea1b1b 100644 --- a/app/views/help_center/support_posts/_support_post.html.erb +++ b/app/views/help_center/support_posts/_support_post.html.erb @@ -1,8 +1,6 @@ <%# We don't currently cache the support posts because they have permissions to deal with %> - <%= content_tag :div, id: dom_id(support_post), class: support_post_classes(support_post) do %> -
- +
<% if is_moderator_or_owner?(support_post) %>
<%= link_to icon("fas","edit"), simple_discussion.edit_support_thread_support_post_path(@support_thread, support_post), @@ -19,10 +17,8 @@ %>
<% end %> -
<%= avatar_tag(support_post.user.email) %> - <%= support_post.user.name %> <%= support_user_badge(support_post.user) %> @@ -32,16 +28,13 @@
- -
+
<%= formatted_content support_post.body %>
- <% if @support_thread.solved? && support_post.solved? %> -