Skip to content

Commit

Permalink
[#9513] Fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
mmagn committed Nov 29, 2024
1 parent 3941238 commit 95ca13f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
6 changes: 3 additions & 3 deletions app/controllers/administrateurs/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def publication
end

def check_path
path = params.permit(:path)[:path]
path = params[:path]
@path_available = @procedure.path_available?(path)
@other_procedure = @procedure.other_procedure_with_path(path)

Expand All @@ -308,12 +308,12 @@ def path
end

def update_path
new_path = params.permit(:path)[:path]
new_path = params[:path]
other_procedure = @procedure.other_procedure_with_path(new_path)

if other_procedure.present? && !current_administrateur.owns?(other_procedure)
flash.alert = "Cette URL de démarche n'est pas disponible"
return redirect_to admin_procedure_path_path(@procedure)
return redirect_to [:admin, @procedure, :path]
end

@procedure.claim_path(current_administrateur, new_path)
Expand Down
2 changes: 0 additions & 2 deletions app/models/concerns/procedure_path_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ module ProcedurePathConcern
included do
has_many :procedure_paths, dependent: :destroy, autosave: true

# validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,200}\z/ }, uniqueness: { scope: [:path, :closed_at, :hidden_at, :unpublished_at], case_sensitive: false }

after_initialize :ensure_path_exists
before_validation :ensure_path_exists

Expand Down
32 changes: 19 additions & 13 deletions app/views/administrateurs/procedures/path.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,26 @@
= render Dsfr::AlertComponent.new(state: :info, size: :sm, extra_class_names: 'fr-mb-2w') do |c|
- c.with_body do
%p
Si vous avez communiqué le lien de votre démarche à des usagers et que vous souhaitez le modifier, pensez à leur communiquer le nouveau lien.
Si vous avez communiqué le lien de votre démarche à des usagers et que vous souhaitez le modifier, les anciens liens resteront accessibles.

.fr-input
.flex
%span.placeholder
= commencer_url(path: '')
= text_field_tag(:path, @procedure.path,
id: 'procedure_path',
placeholder: t('activerecord.attributes.procedure.procedure_path_placeholder'),
required: true,
class: 'unstyled flex-1',
pattern: '[a-z0-9.\-_]{3,200}',
autocomplete: 'off',
data: { controller: 'turbo-input', turbo_input_url_value: admin_procedure_check_path_path })
.fr-input-group
= label_tag :procedure_path, class: 'fr-label' do
= t('activerecord.attributes.procedure.procedure_path')

%span.fr-hint-text
= t('activerecord.attributes.procedure.hints.procedure_path')
.fr-input
.flex
%span.placeholder
= commencer_url(path: '')
= text_field_tag(:path, @procedure.path,
id: 'procedure_path',
placeholder: t('activerecord.attributes.procedure.procedure_path_placeholder'),
required: true,
class: 'unstyled flex-1',
pattern: '[a-z0-9.\-_]{3,200}',
autocomplete: 'off',
data: { controller: 'turbo-input', turbo_input_url_value: admin_procedure_check_path_path })
#check_path

= render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f)

0 comments on commit 95ca13f

Please sign in to comment.