Make right click work on procedure list links

This commit is contained in:
Paul Chavard 2018-08-07 18:53:48 +02:00
parent 66598edfb9
commit 8625c9d0bc
2 changed files with 15 additions and 16 deletions

View file

@ -1,9 +1,10 @@
$(document).on('turbolinks:load', link_init); $(document).on('turbolinks:load', link_init);
function link_init() { function link_init() {
$('#dossiers-list tr').on('click', function (event) { $('#dossiers-list tr').on('click', function(event) {
if (event.target.className !== 'btn-sm btn-danger') { var href = $(this).data('href');
$(location).attr('href', $(this).data('dossier_url')); if (href && event.target.tagName !== 'A') {
location.href = href;
} }
}); });
} }

View file

@ -13,22 +13,20 @@
- @procedures.each do |procedure| - @procedures.each do |procedure|
- procedure = procedure.decorate - procedure = procedure.decorate
%tr{ id: "tr_dossier_#{procedure.id}", 'data-dossier_url' => admin_procedure_path(id: procedure.id) } - admin_procedure_href = admin_procedure_path(procedure)
%td= procedure.id %tr{ id: "tr_dossier_#{procedure.id}", data: { href: admin_procedure_href } }
%td.col-xs-6 %td= link_to(procedure.id, admin_procedure_href)
= procedure.libelle %td.col-xs-6= link_to(procedure.libelle, admin_procedure_href)
- if @active_class - if procedure.publiee?
%td.procedure-lien= link_to procedure.lien, procedure.lien, 'data-method' => :get %td.procedure-lien= link_to(procedure.lien, procedure.lien)
- if @active_class || @archived_class - if procedure.publiee_ou_archivee?
%td %td= link_to(procedure.published_at_fr, admin_procedure_href)
= procedure.published_at_fr
- else - else
%td= link_to(procedure.created_at_fr, admin_procedure_href)
%td %td
= procedure.created_at_fr = link_to('Cloner', admin_procedure_clone_path(procedure.id), data: { method: :put }, class: 'btn-sm btn-primary clone-btn')
%td
= link_to('Cloner', admin_procedure_clone_path(procedure.id), 'data-method' => :put, class: 'btn-sm btn-primary clone-btn')
- if !procedure.publiee_ou_archivee? - 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.paginate
= smart_listing.pagination_per_page_links = smart_listing.pagination_per_page_links