diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-23 16:28:29 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-23 16:57:27 +0100 |
commit | 3a2bf111c08ceab32c3d5f2d0ba1cb1411cd7604 (patch) | |
tree | 37e2e1fff05b0df048b9718bf72a89fba2c27b6b /ishtar_common/templates | |
parent | ddad462113533ebdb0e39766571b2cb602c3c95d (diff) | |
download | Ishtar-3a2bf111c08ceab32c3d5f2d0ba1cb1411cd7604.tar.bz2 Ishtar-3a2bf111c08ceab32c3d5f2d0ba1cb1411cd7604.zip |
Search result - export: export only selected
Diffstat (limited to 'ishtar_common/templates')
-rw-r--r-- | ishtar_common/templates/blocks/DataTables-content.html | 4 | ||||
-rw-r--r-- | ishtar_common/templates/blocks/DataTables.html | 52 |
2 files changed, 52 insertions, 4 deletions
diff --git a/ishtar_common/templates/blocks/DataTables-content.html b/ishtar_common/templates/blocks/DataTables-content.html index 9de143cd4..832b60d22 100644 --- a/ishtar_common/templates/blocks/DataTables-content.html +++ b/ishtar_common/templates/blocks/DataTables-content.html @@ -54,6 +54,10 @@ {% endfor %} </div> </div>{% endif %} + <span class="selected-lines"> + <span class="sl-whole">{% trans "whole table" %}</span> + <span class="sl-selected"><span class="sl-number"></span> {% trans "selected item(s)" %}</span> + </span> </div> </div> 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 %} |