fetch etablissement when editing the dossier
This commit is contained in:
parent
df2eaa9542
commit
b6c74b0e83
3 changed files with 11 additions and 3 deletions
|
@ -2,7 +2,7 @@
|
||||||
id: @champ.input_id,
|
id: @champ.input_id,
|
||||||
aria: { describedby: @champ.describedby_id },
|
aria: { describedby: @champ.describedby_id },
|
||||||
placeholder: t(".placeholder"),
|
placeholder: t(".placeholder"),
|
||||||
data: { controller: 'turbo-input', turbo_input_url_value: champs_siret_path(@champ.id) },
|
data: { controller: 'turbo-input', turbo_input_load_on_connect_value: @champ.prefilled? && @champ.value.present? && @champ.etablissement.blank?, turbo_input_url_value: champs_siret_path(@champ.id) },
|
||||||
required: @champ.required?,
|
required: @champ.required?,
|
||||||
pattern: "[0-9]{14}",
|
pattern: "[0-9]{14}",
|
||||||
title: t(".title"),
|
title: t(".title"),
|
||||||
|
|
|
@ -4,13 +4,18 @@ import { ApplicationController } from './application_controller';
|
||||||
|
|
||||||
export class TurboInputController extends ApplicationController {
|
export class TurboInputController extends ApplicationController {
|
||||||
static values = {
|
static values = {
|
||||||
url: String
|
url: String,
|
||||||
|
loadOnConnect: { type: Boolean, default: false }
|
||||||
};
|
};
|
||||||
|
|
||||||
declare readonly urlValue: string;
|
declare readonly urlValue: string;
|
||||||
|
declare readonly loadOnConnectValue: boolean;
|
||||||
|
|
||||||
connect(): void {
|
connect(): void {
|
||||||
this.on('input', () => this.debounce(this.load, 200));
|
this.on('input', () => this.debounce(this.load, 200));
|
||||||
|
if (this.loadOnConnectValue) {
|
||||||
|
this.load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private load(): void {
|
private load(): void {
|
||||||
|
|
|
@ -6,7 +6,10 @@ RSpec.describe DossierPrefillableConcern do
|
||||||
let(:dossier) { create(:dossier, :brouillon, procedure: procedure) }
|
let(:dossier) { create(:dossier, :brouillon, procedure: procedure) }
|
||||||
let(:types_de_champ_public) { [] }
|
let(:types_de_champ_public) { [] }
|
||||||
|
|
||||||
subject(:fill) { dossier.prefill!(values); dossier.reload }
|
subject(:fill) do
|
||||||
|
dossier.prefill!(values)
|
||||||
|
dossier.reload
|
||||||
|
end
|
||||||
|
|
||||||
shared_examples 'a dossier marked as prefilled' do
|
shared_examples 'a dossier marked as prefilled' do
|
||||||
it 'marks the dossier as prefilled' do
|
it 'marks the dossier as prefilled' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue