summaryrefslogtreecommitdiff
path: root/ishtar_common/templates/blocks
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-10-27 11:55:34 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:20:59 +0100
commit183c1422d978e2b1cbb1d47e0a024dcee57ae3f9 (patch)
treecc39c3e69039af5bc7854602a4ec9c956e0b4316 /ishtar_common/templates/blocks
parent62e05e799962d810804d0cd5f8d377ac8b434a01 (diff)
downloadIshtar-183c1422d978e2b1cbb1d47e0a024dcee57ae3f9.tar.bz2
Ishtar-183c1422d978e2b1cbb1d47e0a024dcee57ae3f9.zip
Syndication - search UI
Diffstat (limited to 'ishtar_common/templates/blocks')
-rw-r--r--ishtar_common/templates/blocks/DataTables-external-sources.html14
-rw-r--r--ishtar_common/templates/blocks/DataTables.html40
2 files changed, 54 insertions, 0 deletions
diff --git a/ishtar_common/templates/blocks/DataTables-external-sources.html b/ishtar_common/templates/blocks/DataTables-external-sources.html
new file mode 100644
index 000000000..ce4d67ada
--- /dev/null
+++ b/ishtar_common/templates/blocks/DataTables-external-sources.html
@@ -0,0 +1,14 @@
+{% load i18n %}
+
+<div class="d-flex justify-content-center">
+<div class="btn-group btn-group-toggle" data-toggle="buttons">
+ <label class="btn btn-secondary active">
+ <input type="radio" name="_sources" id="default" autocomplete="off" checked> {% trans "Local" %}
+ </label>
+ {% for source_id, source_label in external_sources %}
+ <label class="btn btn-secondary">
+ <input type="radio" name="_sources" id="{{source_id}}" autocomplete="off"> {{source_label}}
+ </label>
+ {% endfor %}
+</div>
+</div>
diff --git a/ishtar_common/templates/blocks/DataTables.html b/ishtar_common/templates/blocks/DataTables.html
index f116d9573..135e2a51e 100644
--- a/ishtar_common/templates/blocks/DataTables.html
+++ b/ishtar_common/templates/blocks/DataTables.html
@@ -25,6 +25,9 @@
</div>
</div>
+{% if external_sources %}
+{% include "blocks/DataTables-external-sources.html" %}
+{% endif %}
{% if current_model.STATISTIC_MODALITIES or gallery or use_map %}
{% include "blocks/DataTables-tabs.html" %}
{% else %}
@@ -104,6 +107,15 @@ datatable_submit_search = function(not_submited){
datatable_{{sname}}.ajax.url(url);
datatable_{{sname}}.draw();
+{% if external_sources %}{% for source_id, source_label in external_sources %}
+ if (!not_submited){
+ url = "{{source}}?submited=1&" + data;
+ } else {
+ url = "{{source}}?" + data;
+ }
+ datatable_{{sname}}_{{source_id}}.ajax.url(url);
+ datatable_{{sname}}_{{source_id}}.draw();
+{% endfor %}{% endif %}
setTimeout( // wait for modal-progress to be loaded on the page
function(){
@@ -219,6 +231,34 @@ jQuery(document).ready(function(){
datatable_{{sname}}.on('deselect', dt_multi_enable_disable_submit_button);
{% endif %}
+{% if external_sources %}{% for source_id, source_label in external_sources %}
+ var base_external_source = "{{source}}";
+
+ if (default_search_vector){
+ base_source += "?search_vector=" + default_search_vector + "&submited=1";
+ }
+
+ datatable_options = {
+ "ajax": {
+ "url": base_external_source,
+ "dataSrc": function (json) {
+ if (!default_search_vector) manage_pinned_search("{{name}}", json);
+ update_submit_args();
+ setTimeout( // 50ms is waited on load so...
+ function(){
+ $('.modal-progress').modal('hide');
+ }, 500);
+ return json.rows;
+ }
+ },
+ "deferLoading": 0
+ };
+ $.extend(datatable_options, datatables_default);
+ if (datatables_i18n) datatable_options['language'] = datatables_i18n;
+ datatable_{{sname}}_{{source_id}} = jQuery("#grid_{{name}}_{{source_id}}").DataTable(datatable_options);
+
+{% endfor %}{% endif %}
+
{% if multiple %}
jQuery("#add_button_{{name}}").click(function (){
var mygrid = jQuery("#grid_{{name}}");