summaryrefslogtreecommitdiff
path: root/ishtar_common/templates
diff options
context:
space:
mode:
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
commit6d265fdc8707a636f5faaf362b2e3df8c1cb1f5c (patch)
tree37e2e1fff05b0df048b9718bf72a89fba2c27b6b /ishtar_common/templates
parentd78e35b13a6c311ad0465928d7a21c630a50bcf2 (diff)
downloadIshtar-6d265fdc8707a636f5faaf362b2e3df8c1cb1f5c.tar.bz2
Ishtar-6d265fdc8707a636f5faaf362b2e3df8c1cb1f5c.zip
Search result - export: export only selected
Diffstat (limited to 'ishtar_common/templates')
-rw-r--r--ishtar_common/templates/blocks/DataTables-content.html4
-rw-r--r--ishtar_common/templates/blocks/DataTables.html52
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>&nbsp;{% 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 %}