diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index 2b7cb2adf..434221619 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -123,17 +123,19 @@ class Admin::ProceduresController < AdminController def transfer admin = Administrateur.find_by_email(params[:email_admin]) - return render '/admin/procedures/transfer', formats: 'js', status: 404 if admin.nil? + if admin.nil? + render '/admin/procedures/transfer', formats: 'js', status: 404 + else + procedure = current_administrateur.procedures.find(params[:procedure_id]) + clone_procedure = procedure.clone - procedure = current_administrateur.procedures.find(params[:procedure_id]) - clone_procedure = procedure.clone + clone_procedure.administrateur = admin + clone_procedure.save - clone_procedure.administrateur = admin - clone_procedure.save + flash.now.notice = "La procédure a correctement été clonée vers le nouvel administrateur." - flash.now.notice = "La procédure a correctement été cloné vers le nouvel administrateur." - - render '/admin/procedures/transfer', formats: 'js', status: 200 + render '/admin/procedures/transfer', formats: 'js', status: 200 + end end def archive diff --git a/app/views/admin/procedures/_modal_transfer.html.haml b/app/views/admin/procedures/_modal_transfer.html.haml index 733b19936..66edd79ab 100644 --- a/app/views/admin/procedures/_modal_transfer.html.haml +++ b/app/views/admin/procedures/_modal_transfer.html.haml @@ -5,18 +5,23 @@ .modal-header %button.close{ "aria-label" => "Close", "data-dismiss" => "modal", :type => "button" } %span{ "aria-hidden" => "true" } × + %h4#myModalLabel.modal-title - Petit transfert de procédure entre administrateur + Transférer la procédure à un autre administrateur + .modal-body %p Cette fonctionnalité vous permet de transmettre un clone de votre procédure à un autre administrateur. + %div{ style:'margin-top:20px' } = text_field_tag :email_admin, '', { class: 'form-control', - type: 'email', - placeholder: 'Email administrateur cible', - style: 'width: 300px; margin-left:auto; margin-right:auto' } + type: 'email', + placeholder: 'Email administrateur cible', + style: 'width: 300px; margin-left:auto; margin-right:auto' } + #not_found_admin.center.text-danger{ style:'display: none; margin-top: 10px;' } Cet administrateur n'existe pas. + .modal-footer = submit_tag "Envoyer", class: 'btn btn-success' = button_tag 'Annuler', class: %w(btn btn btn-default), id: 'cancel', data: { dismiss: 'modal' } diff --git a/app/views/admin/procedures/transfer.js.erb b/app/views/admin/procedures/transfer.js.erb index d57f2f48f..02e1bbdf6 100644 --- a/app/views/admin/procedures/transfer.js.erb +++ b/app/views/admin/procedures/transfer.js.erb @@ -1,11 +1,12 @@ <%- if response.status == 404 %> transfer_errors_message(true); <%- else %> - <% flash.each do |type, message| %> - $("#flash_message").html("