-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9389 from tchak/fix-update-champs
fix(dossier): removing options from multiselect should update conditions
- Loading branch information
Showing
5 changed files
with
24 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
class Champs::OptionsController < ApplicationController | ||
include TurboChampsConcern | ||
|
||
before_action :authenticate_logged_user! | ||
|
||
def remove | ||
@champ = policy_scope(Champ).includes(:champs).find(params[:champ_id]) | ||
@champ.remove_option([params[:option]].compact) | ||
champ = policy_scope(Champ).includes(:champs).find(params[:champ_id]) | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
= fields_for @champ.input_name, @champ do |form| | ||
= turbo_stream.replace @champ.input_group_id do | ||
= render EditableChamp::EditableChampComponent.new champ: @champ, form: | ||
= render partial: 'shared/dossiers/update_champs', locals: { to_show: @to_show, to_hide: @to_hide, to_update: @to_update } |
9 changes: 1 addition & 8 deletions
9
app/views/instructeurs/dossiers/update_annotations.turbo_stream.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1 @@ | ||
- 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| | ||
= turbo_stream.replace champ.input_group_id do | ||
= render EditableChamp::EditableChampComponent.new champ:, form: | ||
= render partial: 'shared/dossiers/update_champs', locals: { to_show: @to_show, to_hide: @to_hide, to_update: @to_update } |
15 changes: 15 additions & 0 deletions
15
app/views/shared/dossiers/_update_champs.turbo_stream.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,4 @@ | ||
- 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: | ||
= 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.remove_all(".editable-champ .spinner-removable"); | ||
= turbo_stream.hide_all(".editable-champ .spinner"); | ||
= turbo_stream.replace_all '.dossier-edit-sticky-footer' do | ||
= render Dossiers::EditFooterComponent.new(dossier: @dossier, annotation: false) |