Split mute rule form into seperate partial and replace on create

This commit is contained in:
Andreas Nedbal 2022-11-20 16:30:24 +01:00 committed by Andreas Nedbal
parent 40d5dc41dd
commit efef85b7c6
4 changed files with 12 additions and 7 deletions

View File

@ -12,7 +12,10 @@ class Settings::MutesController < ApplicationController
respond_to do |format|
format.turbo_stream do
render turbo_stream: turbo_stream.append("rules", partial: "settings/mutes/rule", locals: { rule: })
render turbo_stream: [
turbo_stream.replace("form", partial: "settings/mutes/form"),
turbo_stream.append("rules", partial: "settings/mutes/rule", locals: { rule: })
]
end
format.html { redirect_to settings_muted_path }

View File

@ -0,0 +1,6 @@
#form.form-group
%form{ action: settings_muted_path, method: "post" }
.input-group
%input.form-control#muted_phrase{ name: :muted_phrase, placeholder: t(".placeholder"), data: { controller: :autofocus } }
.input-group-append
%button.btn.btn-primary{ type: "submit" }= t("voc.add")

View File

@ -6,12 +6,7 @@
#rules
- @rules.each do |rule|
= render "settings/mutes/rule", rule: rule
.form-group
%form{ action: settings_muted_path, method: "post" }
.input-group
%input.form-control#muted_phrase{ name: :muted_phrase, placeholder: t(".placeholder") }
.input-group-append
%button.btn.btn-primary{ type: "submit" }= t("voc.add")
= render "settings/mutes/form"
- provide(:title, generate_title(t(".title")))
- parent_layout "user/settings"

View File

@ -408,6 +408,7 @@ en:
heading: "Muted Terms"
body: "Muting words (or longer phrases) will prevent questions containing those to appear in your inbox."
note: "Note: Filtered questions are discarded completely from your inbox, and won't reappear if you remove a filter later on."
form:
placeholder: "Add a new muted term…"
privacy:
edit: