diff options
Diffstat (limited to 'ishtar_common/templates/blocks/DataTables.html')
-rw-r--r-- | ishtar_common/templates/blocks/DataTables.html | 84 |
1 files changed, 53 insertions, 31 deletions
diff --git a/ishtar_common/templates/blocks/DataTables.html b/ishtar_common/templates/blocks/DataTables.html index 8ef1a5403..19ffd948e 100644 --- a/ishtar_common/templates/blocks/DataTables.html +++ b/ishtar_common/templates/blocks/DataTables.html @@ -25,7 +25,7 @@ </div> </div> -{% for source_id, source_label, source_url in external_sources %} +{% for source_id, source_label, source_url, columns, column_labels, export_urls in external_sources %} <div class="modal fade table-modal-lg" tabindex="-1" role="dialog" aria-hidden="true" id="modal_grid_{{name}}_{{source_id}}"> <div class="modal-dialog full modal-lg"> @@ -62,7 +62,7 @@ $('#modal_grid_{{name}}').on('hide.bs.modal', function (e) { bs_hide_table("{{name}}"); }); -{% for source_id, source_label, source_url in external_sources %} +{% for source_id, source_label, source_url, columns, column_labels, export_urls in external_sources %} $('#modal_grid_{{name}}_{{source_id}}').on('show.bs.modal', function (e) { bs_expand_table("{{name}}_{{source_id}}"); }); @@ -103,7 +103,7 @@ var selItems_{{sname}} = new Array(); {% if gallery %} gallery_submit_search = function(image_page){ - {% if external_sources %}{% for source_id, source_label, source_url in external_sources %} + {% if external_sources %}{% for source_id, source_label, source_url, columns, column_labels, export_urls in external_sources %} _gallery_submit_search(image_page, query_vars, "{{name}}", "{{source_url}}", "-{{source_id}}"); {% endfor %}{% endif %} return _gallery_submit_search(image_page, query_vars, "{{name}}", "{{source}}"); @@ -114,7 +114,7 @@ map_submit_search = function(){ if (current_source == "default"){ return _map_submit_search(query_vars, "{{name}}", "{{source}}"); } - {% if external_sources %}{% for source_id, source_label, source_url in external_sources %} + {% if external_sources %}{% for source_id, source_label, source_url, columns, column_labels, export_urls in external_sources %} else if (current_source == "{{source_id}}"){ return _map_submit_search(query_vars, "{{name}}", "{{source_url}}", "{{source_id}}"); } @@ -123,17 +123,17 @@ map_submit_search = function(){ {% endif %} extra_list = [ - "default"{% for source_id, source_label, source_url in external_sources %}, + "default"{% for source_id, source_label, source_url, columns, column_labels, export_urls in external_sources %}, "{{source_id}}"{% endfor %} ]; sources = [ - "{{source}}"{% for source_id, source_label, source_url in external_sources %}, + "{{source}}"{% for source_id, source_label, source_url, columns, column_labels, export_urls in external_sources %}, "{{source_url}}"{% endfor %} ]; stats_submit_search = function(){ - {% if external_sources %}{% for source_id, source_label, source_url in external_sources %} + {% if external_sources %}{% for source_id, source_label, source_url, columns, column_labels, export_urls in external_sources %} _stats_submit_search(query_vars, "{{name}}", "{{source_url}}", "{{source_id}}"); {% endfor %}{% endif %} return _stats_submit_search(query_vars, "{{name}}", "{{source}}"); @@ -151,7 +151,7 @@ datatable_submit_search = function(not_submited){ datatable_{{sname}}.ajax.url(url); datatable_{{sname}}.draw(); -{% if external_sources %}{% for source_id, source_label, source_url in external_sources %} +{% if external_sources %}{% for source_id, source_label, source_url, columns, column_labels, export_urls in external_sources %} if (!not_submited){ url = "{{source_url}}?submited=1&" + data; } else { @@ -170,16 +170,23 @@ datatable_submit_search = function(not_submited){ return false; }; -update_submit_args = function(){ - var data = search_get_query_data(query_vars, "{{name}}"); - var csv_url = "{{source}}csv?submited=1&" + data; - $(".{{sname}}-csv").attr("href", csv_url); - var csv_full_url = "{{source_full}}csv?submited=1&" + data; - $(".{{sname}}-csv-full").attr("href", csv_full_url); +update_submit_args = function(source_cls){ + if (!source_cls) source_cls = "sources-default"; + let data = search_get_query_data(query_vars, "{{name}}"); + let extra = "?submited=1&" + data; + let csv_url = "{{source}}csv" + extra; + $("." + source_cls + " .{{sname}}-csv").attr("href", csv_url); + let csv_full_url = "{{source_full}}csv?submited=1&" + data; + $("." + source_cls + " .{{sname}}-csv-full").attr("href", csv_full_url); {% for slug, name, extra_source in extra_sources %} - $(".{{slug}}-csv-full").attr("href", '{{extra_source}}csv?submited=1&' + data);{% endfor %} + $("." + source_cls + " .{{slug}}-csv-full").attr("href", '{{extra_source}}csv?submited=1&' + data);{% endfor %} {% for template in current_model.label_templates %} - $(".{{template.slug}}-labels").attr("href", '{{template.get_baselink_for_labels}}?submited=1&' + data);{% endfor %} + $("." + source_cls + " .{{template.slug}}-labels").attr("href", '{{template.get_baselink_for_labels}}?submited=1&' + data);{% endfor %} + + $("." + source_cls + " .{{sname}}-csv-external").each(function(){ + let url = $(this).attr("href").split('?')[0] + extra; + $(this).attr("href", url); + }); if ($('.modal-progress').length > 0){ $('.modal-progress').modal('hide'); @@ -187,24 +194,24 @@ update_submit_args = function(){ return false; }; -update_select_args = function(dt){ +update_select_args = function(dt, source_cls){ let nb_row = dt.rows( { selected: true } ).count(); - $(".sl-number").html(nb_row); + $("." + source_cls + " .sl-number").html(nb_row); if (nb_row == 0){ - $(".selected-lines .sl-whole").show(); - $(".selected-lines .sl-selected").hide(); - update_submit_args(); + $("." + source_cls + " .selected-lines .sl-whole").show(); + $("." + source_cls + " .selected-lines .sl-selected").hide(); + update_submit_args(source_cls); return; } - $(".selected-lines .sl-selected").show(); - $(".selected-lines .sl-whole").hide(); + $("." + source_cls + " .selected-lines .sl-selected").show(); + $("." + source_cls + " .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); + update_export_urls(dt, source_cls, "{{sname}}", "{{source}}", "{{source_full}}", extra_sources, extra_tpl); } var current_source = "default"; @@ -227,7 +234,7 @@ jQuery(document).ready(function(){ return false; } ); - {% for source_id, source_label, source_url in external_sources %} + {% for source_id, source_label, source_url, columns, column_labels, export_urls in external_sources %} $("#source_button_{{source_id}}").click( function(){ current_source = "{{source_id}}"; @@ -327,14 +334,14 @@ jQuery(document).ready(function(){ datatable_{{sname}}.on( 'select', function(e, dt, type, indexes){ - update_select_args(dt); + update_select_args(dt, 'sources-default'); dt_single_enable_disable_submit_button(e, dt, type, indexes); } ); datatable_{{sname}}.on( 'deselect', function(e, dt, type, indexes){ - update_select_args(dt); + update_select_args(dt, 'sources-default'); dt_single_enable_disable_submit_button(e, dt, type, indexes); } ); @@ -342,20 +349,20 @@ jQuery(document).ready(function(){ datatable_{{sname}}.on( 'select', function(e, dt, type, indexes){ - update_select_args(dt); + update_select_args(dt, 'sources-default'); dt_multi_enable_disable_submit_button(e, dt, type, indexes); } ); datatable_{{sname}}.on( 'deselect', function(e, dt, type, indexes){ - update_select_args(dt); + update_select_args(dt, 'sources-default'); dt_multi_enable_disable_submit_button(e, dt, type, indexes); } ); {% endif %} -{% if external_sources %}{% for source_id, source_label, source_url in external_sources %} +{% if external_sources %}{% for source_id, source_label, source_url, columns, column_labels, export_urls in external_sources %} var base_external_source = "{{source_url}}"; if (default_search_vector){ @@ -375,10 +382,13 @@ jQuery(document).ready(function(){ } }, "deferLoading": 0, + "select": { + "style": 'multi' + }, "dom": 'litp', "columns": [ { "data": "id", "visible": false }, - { "data": "link", "orderable": false },{% for col in extra_cols %} + { "data": "link", "orderable": false },{% for col in columns %} { "data": "{{col}}", "defaultContent": "-", "render": $.fn.dataTable.render.ellipsis( 70, true ) }{% if not forloop.last %},{% endif %}{% endfor %} ] @@ -386,6 +396,18 @@ jQuery(document).ready(function(){ $.extend(datatable_options_{{source_id}}, datatables_default); if (datatables_i18n) datatable_options_{{source_id}}['language'] = datatables_i18n; datatable_{{sname}}_{{source_id}} = jQuery("#grid_{{name}}_{{source_id}}").DataTable(datatable_options_{{source_id}}); + datatable_{{sname}}_{{source_id}}.on( + 'select', + function(e, dt, type, indexes){ + update_select_args(dt, 'sources-{{source_id}}'); + } + ); + datatable_{{sname}}_{{source_id}}.on( + 'deselect', + function(e, dt, type, indexes){ + update_select_args(dt, 'sources-{{source_id}}'); + } + ); {% endfor %}{% endif %} |