From 8625c9d0bc58b632586afdb999082f5321dc9ded Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 7 Aug 2018 18:53:48 +0200 Subject: [PATCH] Make right click work on procedure list links --- .../old_design/dossiers_list_link.js | 7 +++--- app/views/admin/procedures/_list.html.haml | 24 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/old_design/dossiers_list_link.js b/app/assets/javascripts/old_design/dossiers_list_link.js index 7193bb433..18b167ace 100644 --- a/app/assets/javascripts/old_design/dossiers_list_link.js +++ b/app/assets/javascripts/old_design/dossiers_list_link.js @@ -1,9 +1,10 @@ $(document).on('turbolinks:load', link_init); function link_init() { - $('#dossiers-list tr').on('click', function (event) { - if (event.target.className !== 'btn-sm btn-danger') { - $(location).attr('href', $(this).data('dossier_url')); + $('#dossiers-list tr').on('click', function(event) { + var href = $(this).data('href'); + if (href && event.target.tagName !== 'A') { + location.href = href; } }); } diff --git a/app/views/admin/procedures/_list.html.haml b/app/views/admin/procedures/_list.html.haml index f1948b526..b0157955e 100644 --- a/app/views/admin/procedures/_list.html.haml +++ b/app/views/admin/procedures/_list.html.haml @@ -13,22 +13,20 @@ - @procedures.each do |procedure| - procedure = procedure.decorate - %tr{ id: "tr_dossier_#{procedure.id}", 'data-dossier_url' => admin_procedure_path(id: procedure.id) } - %td= procedure.id - %td.col-xs-6 - = procedure.libelle - - if @active_class - %td.procedure-lien= link_to procedure.lien, procedure.lien, 'data-method' => :get - - if @active_class || @archived_class - %td - = procedure.published_at_fr + - admin_procedure_href = admin_procedure_path(procedure) + %tr{ id: "tr_dossier_#{procedure.id}", data: { href: admin_procedure_href } } + %td= link_to(procedure.id, admin_procedure_href) + %td.col-xs-6= link_to(procedure.libelle, admin_procedure_href) + - if procedure.publiee? + %td.procedure-lien= link_to(procedure.lien, procedure.lien) + - if procedure.publiee_ou_archivee? + %td= link_to(procedure.published_at_fr, admin_procedure_href) - else - %td - = procedure.created_at_fr + %td= link_to(procedure.created_at_fr, admin_procedure_href) %td - = link_to('Cloner', admin_procedure_clone_path(procedure.id), 'data-method' => :put, class: 'btn-sm btn-primary clone-btn') + = link_to('Cloner', admin_procedure_clone_path(procedure.id), data: { method: :put }, class: 'btn-sm btn-primary clone-btn') - if !procedure.publiee_ou_archivee? - = link_to('X', url_for(controller: 'admin/procedures', action: :destroy, id: procedure.id), 'data-method' => :delete, class: 'btn-sm btn-danger') + = link_to('X', url_for(controller: 'admin/procedures', action: :destroy, id: procedure.id), data: { method: :delete }, class: 'btn-sm btn-danger') = smart_listing.paginate = smart_listing.pagination_per_page_links