diff options
Diffstat (limited to 'ishtar_common/templates/blocks/DataTables.html')
-rw-r--r-- | ishtar_common/templates/blocks/DataTables.html | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/ishtar_common/templates/blocks/DataTables.html b/ishtar_common/templates/blocks/DataTables.html index 9f0ab04ca..95ebbbc6b 100644 --- a/ishtar_common/templates/blocks/DataTables.html +++ b/ishtar_common/templates/blocks/DataTables.html @@ -167,6 +167,26 @@ update_submit_args = function(){ return false; }; +update_select_args = function(dt){ + let nb_row = dt.rows( { selected: true } ).count(); + $(".sl-number").html(nb_row); + if (nb_row == 0){ + $(".selected-lines .sl-whole").show(); + $(".selected-lines .sl-selected").hide(); + update_submit_args(); + return; + } + $(".selected-lines .sl-selected").show(); + $(".selected-lines .sl-whole").hide(); + let extra_sources = [{% for slug, name, extra_source in extra_sources %} + ["{{slug}}", "{{name}}", "{{extra_source}}"]{% if not forloop.last %},{% endif %} + {% endfor %}]; + let extra_tpl = [{% for template in current_model.label_templates %} + ["{{template.slug}}", "{{template.get_baselink_for_labels}}"]{% if not forloop.last %},{% endif %} + {% endfor %}]; + update_export_urls(dt, "{{sname}}", "{{source}}", "{{source_full}}", extra_sources, extra_tpl); +} + var current_source = "default"; jQuery(document).ready(function(){ @@ -284,11 +304,35 @@ jQuery(document).ready(function(){ datatable_{{sname}} = jQuery("#grid_{{name}}").DataTable(datatable_options); {% if not multiple_select %} - datatable_{{sname}}.on('select', dt_single_enable_disable_submit_button); - datatable_{{sname}}.on('deselect', dt_single_enable_disable_submit_button); + datatable_{{sname}}.on( + 'select', + function(e, dt, type, indexes){ + update_select_args(dt); + dt_single_enable_disable_submit_button(e, dt, type, indexes); + } + ); + datatable_{{sname}}.on( + 'deselect', + function(e, dt, type, indexes){ + update_select_args(dt); + dt_single_enable_disable_submit_button(e, dt, type, indexes); + } + ); {% else %} - datatable_{{sname}}.on('select', dt_multi_enable_disable_submit_button); - datatable_{{sname}}.on('deselect', dt_multi_enable_disable_submit_button); + datatable_{{sname}}.on( + 'select', + function(e, dt, type, indexes){ + update_select_args(dt); + dt_multi_enable_disable_submit_button(e, dt, type, indexes); + } + ); + datatable_{{sname}}.on( + 'deselect', + function(e, dt, type, indexes){ + update_select_args(dt); + dt_multi_enable_disable_submit_button(e, dt, type, indexes); + } + ); {% endif %} {% if external_sources %}{% for source_id, source_label, source_url in external_sources %} |