From 5d1327644604599c8aab7b475c1511e7a88f7987 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Wed, 16 Mar 2016 10:55:03 +0100 Subject: [PATCH] Fiabilisation de la suppression des gestionnaires par un administrateur --- app/assets/javascripts/admin.js | 16 ++++++++++------ app/assets/stylesheets/application.scss | 4 ++++ app/views/admin/gestionnaires/_list.html.haml | 19 ++++++++----------- app/views/admin/gestionnaires/index.html.haml | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/admin.js index 28147b38c..6b66994cc 100644 --- a/app/assets/javascripts/admin.js +++ b/app/assets/javascripts/admin.js @@ -2,13 +2,17 @@ $(document).on('page:load', destroy_action); $(document).ready(destroy_action); function destroy_action(){ - $("#destroy").on('click', function(){ - $("#destroy").hide(); - $("#confirm").show(); + $(".delete").on('click', function(){ + $(this).hide(); + $(this).closest('td').find(".confirm").show(); }); - $("#confirm #cancel").on('click', function(){ - $("#destroy").show(); - $("#confirm").hide(); + $(".cancel").on('click', function(){ + $(this).closest('td').find(".delete").show(); + $(this).closest('td').find(".confirm").hide(); + }); + + $("#liste_gestionnaire #libelle").on('click', function(){ + setTimeout(destroy_action, 500); }); } \ No newline at end of file diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index ffb4d2d33..b5c193e7e 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -231,6 +231,10 @@ div.pagination { display: none; } +.confirm { + display: none; +} + .fa { width: 15px; text-align: center; diff --git a/app/views/admin/gestionnaires/_list.html.haml b/app/views/admin/gestionnaires/_list.html.haml index f2533b45c..caceecc00 100644 --- a/app/views/admin/gestionnaires/_list.html.haml +++ b/app/views/admin/gestionnaires/_list.html.haml @@ -1,21 +1,18 @@ - unless smart_listing.empty? - %table.table + %table.table#liste_gestionnaire %thead %th#libelle= smart_listing.sortable 'Email', 'email' + %th= '' - @gestionnaires.each do |gestionnaire| %tr - %td= gestionnaire.email + %td{style:'padding-top: 11px; font-size:15px'}= gestionnaire.email %td{ style: 'text-align:right' } - %span#destroy{ class: "fa fa-times" } - #confirm - =link_to(admin_gestionnaire_path(id: gestionnaire.id), method: :delete) do - %span#valid{ class: "fa fa-check btn-success" } - %span#valid - Valider - %span - | - %span#cancel{ class: "fa fa-minus btn-danger" } + .delete.btn.btn-sm.glyphicon.glyphicon-remove + + .confirm + =link_to 'Valider', admin_gestionnaire_path(id: gestionnaire.id), {method: :delete, class: 'btn btn-sm btn-success'} + .cancel.btn.btn-sm.btn-danger.glyphicon.glyphicon-minus{style: 'top: 0'} = smart_listing.paginate = smart_listing.pagination_per_page_links diff --git a/app/views/admin/gestionnaires/index.html.haml b/app/views/admin/gestionnaires/index.html.haml index 37c893a40..78803f487 100644 --- a/app/views/admin/gestionnaires/index.html.haml +++ b/app/views/admin/gestionnaires/index.html.haml @@ -7,7 +7,7 @@ .col-md-1.col-lg-1   .col-md-6.col-lg-6 - %h3 Ajouter un gestionnaire + %h3 Ajouter un accompagnateur #procedure_new.section.section-label = form_for @gestionnaire, url: {controller: 'admin/gestionnaires', action: :create} do |f| .row