Merge pull request #7517 from betagouv/fix_stable_id_var

fix: renommage de var id en stable_id
This commit is contained in:
LeSim 2022-07-05 12:02:49 +02:00 committed by GitHub
commit 12770f1308
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 34 additions and 33 deletions

View file

@ -33,8 +33,8 @@ class TypesDeChampEditor::AddChampButtonComponent < ApplicationComponent
libelle: champ_libelle,
type_champ: TypeDeChamp.type_champs.fetch(:text),
private: annotations? ? true : nil,
parent_id: @parent&.stable_id,
after_id: ''
parent_stable_id: @parent&.stable_id,
after_stable_id: ''
}.compact
}
}

View file

@ -28,14 +28,14 @@ class TypesDeChampEditor::ChampComponent < ApplicationComponent
type_de_champ_editor_move_url_value: move_admin_procedure_type_de_champ_path(procedure, type_de_champ.stable_id),
type_de_champ_editor_move_up_url_value: move_up_admin_procedure_type_de_champ_path(procedure, type_de_champ.stable_id),
type_de_champ_editor_move_down_url_value: move_down_admin_procedure_type_de_champ_path(procedure, type_de_champ.stable_id),
type_de_champ_editor_type_de_champ_id_value: coordinate.stable_id
type_de_champ_editor_type_de_champ_stable_id_value: type_de_champ.stable_id
}
}
end
def form_options
{
url: type_de_champ_path,
url: admin_procedure_type_de_champ_path(procedure, type_de_champ.stable_id),
multipart: true,
html: { id: nil, class: 'form width-100' }
}

View file

@ -16,7 +16,7 @@ module Administrateurs
end
def update
type_de_champ = @procedure.draft_revision.find_and_ensure_exclusive_use(params[:id])
type_de_champ = @procedure.draft_revision.find_and_ensure_exclusive_use(params[:stable_id])
if type_de_champ.update(type_de_champ_update_params)
if params[:should_render]
@ -31,21 +31,21 @@ module Administrateurs
def move
flash.notice = "Formulaire enregistré"
@procedure.draft_revision.move_type_de_champ(params[:id], params[:position].to_i)
@procedure.draft_revision.move_type_de_champ(params[:stable_id], params[:position].to_i)
end
def move_up
flash.notice = "Formulaire enregistré"
@coordinate = @procedure.draft_revision.move_up_type_de_champ(params[:id])
@coordinate = @procedure.draft_revision.move_up_type_de_champ(params[:stable_id])
end
def move_down
flash.notice = "Formulaire enregistré"
@coordinate = @procedure.draft_revision.move_down_type_de_champ(params[:id])
@coordinate = @procedure.draft_revision.move_down_type_de_champ(params[:stable_id])
end
def destroy
@coordinate = @procedure.draft_revision.remove_type_de_champ(params[:id])
@coordinate = @procedure.draft_revision.remove_type_de_champ(params[:stable_id])
reset_procedure
flash.notice = "Formulaire enregistré"
end
@ -55,7 +55,7 @@ module Administrateurs
def type_de_champ_create_params
params
.required(:type_de_champ)
.permit(:type_champ, :parent_id, :private, :libelle, :after_id)
.permit(:type_champ, :parent_stable_id, :private, :libelle, :after_stable_id)
end
def type_de_champ_update_params

View file

@ -7,7 +7,7 @@ import { ApplicationController } from './application_controller';
export class TypeDeChampEditorController extends ApplicationController {
static values = {
typeDeChampId: String,
typeDeChampStableId: String,
moveUrl: String,
moveUpUrl: String,
moveDownUrl: String
@ -16,7 +16,7 @@ export class TypeDeChampEditorController extends ApplicationController {
declare readonly moveUrlValue: string;
declare readonly moveUpUrlValue: string;
declare readonly moveDownUrlValue: string;
declare readonly typeDeChampIdValue: string;
declare readonly typeDeChampStableIdValue: string;
declare readonly isVisible: boolean;
#latestPromise = Promise.resolve();
@ -139,16 +139,17 @@ export class TypeDeChampEditorController extends ApplicationController {
? '.add-to-block'
: '.add-to-root';
const input = parent.querySelector<HTMLInputElement>(
`${selector} ${AFTER_ID_INPUT_SELECTOR}`
`${selector} ${AFTER_STABLE_ID_INPUT_SELECTOR}`
);
if (input) {
input.value = this.typeDeChampIdValue;
input.value = this.typeDeChampStableIdValue;
}
}
}
}
const AFTER_ID_INPUT_SELECTOR = 'input[name="type_de_champ[after_id]"]';
const AFTER_STABLE_ID_INPUT_SELECTOR =
'input[name="type_de_champ[after_stable_id]"]';
function createForm(action: string, method: string) {
const form = document.createElement('form');

View file

@ -43,8 +43,8 @@ class ProcedureRevision < ApplicationRecord
end
def add_type_de_champ(params)
parent_stable_id = params.delete(:parent_id)
after_stable_id = params.delete(:after_id)
parent_stable_id = params.delete(:parent_stable_id)
after_stable_id = params.delete(:after_stable_id)
coordinate = {}

View file

@ -464,7 +464,7 @@ Rails.application.routes.draw do
resources :experts, controller: 'experts_procedures', only: [:index, :create, :update, :destroy]
resources :types_de_champ, only: [:create, :update, :destroy] do
resources :types_de_champ, only: [:create, :update, :destroy], param: :stable_id do
collection do
get :estimate_fill_duration
end

View file

@ -78,7 +78,7 @@ describe Champ do
procedure.active_revision.add_type_de_champ(
libelle: 'header',
type_champ: 'header_section',
parent_id: procedure.types_de_champ.find(&:repetition?).stable_id
parent_stable_id: procedure.types_de_champ.find(&:repetition?).stable_id
)
end
end
@ -524,7 +524,7 @@ describe Champ do
let(:champ_text_attrs) { attributes_for(:champ_text, type_de_champ: tdc_text, row: 1) }
before do
procedure.active_revision.add_type_de_champ(libelle: 'sub integer', type_champ: 'integer_number', parent_id: tdc_repetition.stable_id)
procedure.active_revision.add_type_de_champ(libelle: 'sub integer', type_champ: 'integer_number', parent_stable_id: tdc_repetition.stable_id)
end
context 'when creating the model directly' do

View file

@ -38,7 +38,7 @@ describe Champs::HeaderSectionChamp do
revision.add_type_de_champ(
libelle: tdc.libelle,
type_champ: tdc.type_champ,
parent_id: tdc_repetition.stable_id
parent_stable_id: tdc_repetition.stable_id
)
end
end

View file

@ -163,8 +163,8 @@ describe TagsSubstitutionConcern, type: :model do
let(:template) { '--Répétition--' }
let(:repetition) do
repetition_tdc = procedure.active_revision.add_type_de_champ(type_champ: 'repetition', libelle: 'Répétition')
procedure.active_revision.add_type_de_champ(type_champ: 'text', libelle: 'Nom', parent_id: repetition_tdc.stable_id)
procedure.active_revision.add_type_de_champ(type_champ: 'text', libelle: 'Prénom', parent_id: repetition_tdc.stable_id)
procedure.active_revision.add_type_de_champ(type_champ: 'text', libelle: 'Nom', parent_stable_id: repetition_tdc.stable_id)
procedure.active_revision.add_type_de_champ(type_champ: 'text', libelle: 'Prénom', parent_stable_id: repetition_tdc.stable_id)
repetition_tdc
end

View file

@ -182,7 +182,7 @@ describe Dossier do
procedure.draft_revision.add_type_de_champ({
type_champ: TypeDeChamp.type_champs.fetch(:checkbox),
libelle: "oui ou non",
parent_id: repetition_type_de_champ.stable_id
parent_stable_id: repetition_type_de_champ.stable_id
})
procedure.draft_revision.remove_type_de_champ(yes_no_type_de_champ.stable_id)
@ -365,8 +365,8 @@ describe Dossier do
let!(:procedure) do
create(:procedure).tap do |p|
repetition = p.draft_revision.add_type_de_champ(type_champ: :repetition, libelle: 'p1')
p.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c1', parent_id: repetition.stable_id)
p.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c2', parent_id: repetition.stable_id)
p.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c1', parent_stable_id: repetition.stable_id)
p.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c2', parent_stable_id: repetition.stable_id)
p.publish!
end
end
@ -377,7 +377,7 @@ describe Dossier do
context 'when a child tdc is added in the middle' do
before do
added_tdc = procedure.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c3', parent_id: repetition_stable_id)
added_tdc = procedure.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c3', parent_stable_id: repetition_stable_id)
procedure.draft_revision.move_type_de_champ(added_tdc.stable_id, 1)
end

View file

@ -1477,7 +1477,7 @@ describe Dossier do
draft = proc_test.draft_revision
tdc_repetition = draft.add_type_de_champ(type_champ: :repetition, libelle: "repetition")
draft.add_type_de_champ(type_champ: :communes, libelle: "communes", parent_id: tdc_repetition.stable_id)
draft.add_type_de_champ(type_champ: :communes, libelle: "communes", parent_stable_id: tdc_repetition.stable_id)
dossier_test = create(:dossier, procedure: proc_test)
repetition = proc_test.types_de_champ_for_procedure_presentation.repetition.first

View file

@ -34,7 +34,7 @@ describe ProcedureRevision do
end
context 'with a repetition child' do
let(:tdc_params) { text_params.merge(parent_id: type_de_champ_repetition.stable_id) }
let(:tdc_params) { text_params.merge(parent_stable_id: type_de_champ_repetition.stable_id) }
it do
expect { subject }.to change { draft.reload.types_de_champ.count }.from(4).to(5)
@ -93,7 +93,7 @@ describe ProcedureRevision do
draft.add_type_de_champ({
type_champ: TypeDeChamp.type_champs.fetch(:text),
libelle: "second child",
parent_id: type_de_champ_repetition.stable_id
parent_stable_id: type_de_champ_repetition.stable_id
})
end
@ -101,7 +101,7 @@ describe ProcedureRevision do
draft.add_type_de_champ({
type_champ: TypeDeChamp.type_champs.fetch(:text),
libelle: "last child",
parent_id: type_de_champ_repetition.stable_id
parent_stable_id: type_de_champ_repetition.stable_id
})
end
@ -159,7 +159,7 @@ describe ProcedureRevision do
draft.add_type_de_champ({
type_champ: TypeDeChamp.type_champs.fetch(:text),
libelle: "second child",
parent_id: type_de_champ_repetition.stable_id
parent_stable_id: type_de_champ_repetition.stable_id
})
end
@ -167,7 +167,7 @@ describe ProcedureRevision do
draft.add_type_de_champ({
type_champ: TypeDeChamp.type_champs.fetch(:text),
libelle: "last child",
parent_id: type_de_champ_repetition.stable_id
parent_stable_id: type_de_champ_repetition.stable_id
})
end