Merge pull request #9389 from tchak/fix-update-champs
fix(dossier): removing options from multiselect should update conditions
This commit is contained in:
commit
17cfc547fb
5 changed files with 24 additions and 27 deletions
|
@ -1,8 +1,12 @@
|
||||||
class Champs::OptionsController < ApplicationController
|
class Champs::OptionsController < ApplicationController
|
||||||
|
include TurboChampsConcern
|
||||||
|
|
||||||
before_action :authenticate_logged_user!
|
before_action :authenticate_logged_user!
|
||||||
|
|
||||||
def remove
|
def remove
|
||||||
@champ = policy_scope(Champ).includes(:champs).find(params[:champ_id])
|
champ = policy_scope(Champ).includes(:champs).find(params[:champ_id])
|
||||||
@champ.remove_option([params[:option]].compact)
|
champ.remove_option([params[:option]].compact)
|
||||||
|
champs = champ.private? ? champ.dossier.champs_private_all : champ.dossier.champs_public_all
|
||||||
|
@to_show, @to_hide, @to_update = champs_to_turbo_update({ params[:champ_id] => true }, champs)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
= fields_for @champ.input_name, @champ do |form|
|
= render partial: 'shared/dossiers/update_champs', locals: { to_show: @to_show, to_hide: @to_hide, to_update: @to_update }
|
||||||
= turbo_stream.replace @champ.input_group_id do
|
|
||||||
= render EditableChamp::EditableChampComponent.new champ: @champ, form:
|
|
||||||
|
|
|
@ -1,8 +1 @@
|
||||||
- if @to_show.present?
|
= render partial: 'shared/dossiers/update_champs', locals: { to_show: @to_show, to_hide: @to_hide, to_update: @to_update }
|
||||||
= turbo_stream.show_all(@to_show)
|
|
||||||
- if @to_hide.present?
|
|
||||||
= turbo_stream.hide_all(@to_hide)
|
|
||||||
- @to_update.each do |champ|
|
|
||||||
= fields_for champ.input_name, champ do |form|
|
|
||||||
= turbo_stream.replace champ.input_group_id do
|
|
||||||
= render EditableChamp::EditableChampComponent.new champ:, form:
|
|
||||||
|
|
15
app/views/shared/dossiers/_update_champs.turbo_stream.haml
Normal file
15
app/views/shared/dossiers/_update_champs.turbo_stream.haml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
- if to_show.present?
|
||||||
|
= turbo_stream.show_all(to_show)
|
||||||
|
- if to_hide.present?
|
||||||
|
= turbo_stream.hide_all(to_hide)
|
||||||
|
- to_update.each do |champ|
|
||||||
|
= fields_for champ.input_name, champ do |form|
|
||||||
|
- if champ.refresh_after_update?
|
||||||
|
= turbo_stream.replace champ.input_group_id do
|
||||||
|
= render EditableChamp::EditableChampComponent.new champ:, form:
|
||||||
|
- else
|
||||||
|
= turbo_stream.update champ.labelledby_id do
|
||||||
|
= render EditableChamp::ChampLabelContentComponent.new champ:, form:
|
||||||
|
|
||||||
|
= turbo_stream.remove_all(".editable-champ .spinner-removable")
|
||||||
|
= turbo_stream.hide_all(".editable-champ .spinner")
|
|
@ -1,17 +1,4 @@
|
||||||
- if @to_show.present?
|
= render partial: 'shared/dossiers/update_champs', locals: { to_show: @to_show, to_hide: @to_hide, to_update: @to_update, dossier: @dossier, annotation: false }
|
||||||
= turbo_stream.show_all(@to_show)
|
|
||||||
- if @to_hide.present?
|
|
||||||
= turbo_stream.hide_all(@to_hide)
|
|
||||||
- @to_update.each do |champ|
|
|
||||||
= fields_for champ.input_name, champ do |form|
|
|
||||||
- if champ.refresh_after_update?
|
|
||||||
= turbo_stream.replace champ.input_group_id do
|
|
||||||
= render EditableChamp::EditableChampComponent.new champ:, form:
|
|
||||||
- else
|
|
||||||
= turbo_stream.update champ.labelledby_id do
|
|
||||||
= render EditableChamp::ChampLabelContentComponent.new champ:, form:
|
|
||||||
|
|
||||||
= turbo_stream.remove_all(".editable-champ .spinner-removable");
|
|
||||||
= turbo_stream.hide_all(".editable-champ .spinner");
|
|
||||||
= turbo_stream.replace_all '.dossier-edit-sticky-footer' do
|
= turbo_stream.replace_all '.dossier-edit-sticky-footer' do
|
||||||
= render Dossiers::EditFooterComponent.new(dossier: @dossier, annotation: false)
|
= render Dossiers::EditFooterComponent.new(dossier: @dossier, annotation: false)
|
||||||
|
|
Loading…
Reference in a new issue