Commit 6a2ab8c0 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

976: Limit queries to custom search to predefined collections

Task-Url: https://pm.winseda.de/issues/976
parent 8a08601d
......@@ -13,6 +13,7 @@ var SourceSelection = function(options) {
}, options);
this.form = null;
this.table = null;
};
SourceSelection.prototype.selectAll = function() {
......@@ -122,13 +123,15 @@ SourceSelection.prototype.getSelectionDialog = function() {
this.form = null;
modalFormHandler = new ModalFormHandler({
formUrl: "/getCollectionSelectionDialog",
method: "POST",
data: JSON.stringify({"sourceIds" : _this.getSelectedSourceIds()}),
contentType: "application/json",
identifier: form_identifier,
//additionalModalClasses: "wider-modal",
additionalModalClasses: "wide-modal",
translations: [{placeholder: "~*servererror.head", key: "~de.dariah.genericsearch.view.async.servererror.head"},
{placeholder: "~*servererror.body", key: "~de.dariah.genericsearch.view.async.servererror.body"},
{placeholder: "~*validationerrors.head", key: "~de.dariah.genericsearch.view.collection.notification.error_crawling_exception.head"},
......@@ -139,6 +142,12 @@ SourceSelection.prototype.getSelectionDialog = function() {
},
setupCallback: function(form) {
_this.form = form;
_this.table = $(_this.form).find('#model-list-source-selection').DataTable({
"order": [[ 1, "asc" ]],
"columnDefs": [
{"targets": [1], "width": "100%"}
]
});
},
displayCallback: function(form) {
$(form).find("#source-selection-check-all").bind("change", function() { _this.handleSelectionDialogSelectAll($(this).prop("checked")); });
......@@ -149,17 +158,29 @@ SourceSelection.prototype.getSelectionDialog = function() {
};
SourceSelection.prototype.handleSelectionDialogSelectAll = function(selectAll) {
$(this.form).find("#model-list-source-selection tbody input[type='checkbox']").prop("checked", selectAll);
this.table.rows().every(function (index, element) {
var data = this.data();
var row = $(this.node());
var selectChk = row.find('td:first-child input[type="checkbox"]');
selectChk.prop("checked", selectAll);
});
};
SourceSelection.prototype.handleSelectionDialogSelect = function() {
var _this = this;
var allSelected = true;
$("#model-list-source-selection tbody input[type='checkbox']").each(function() {
if (!$(this).prop("checked")) {
this.table.rows().every(function (index, element) {
var data = this.data();
var row = $(this.node());
var selectChk = row.find('td:first-child input[type="checkbox"]');
if (!$(selectChk).prop("checked")) {
allSelected = false;
}
})
});
$(this.form).find("#source-selection-check-all").unbind("change");
$(this.form).find("#source-selection-check-all").prop("checked", allSelected);
......@@ -169,13 +190,19 @@ SourceSelection.prototype.handleSelectionDialogSelect = function() {
SourceSelection.prototype.handleSelectionDialogAccepted = function() {
var selectedDatasources = [];
var allSelected = true;
$("#model-list-source-selection tbody input[type='checkbox']").each(function() {
if ($(this).prop("checked")===true) {
selectedDatasources.push($(this).val());
sourceSelection.table.rows().every(function (index, element) {
var data = this.data();
var row = $(this.node());
var selectChk = row.find('td:first-child input[type="checkbox"]');
if ($(selectChk).prop("checked")===true) {
selectedDatasources.push($(selectChk).val());
} else {
allSelected = false;
}
});
});
this.setSelectedSourceIds(allSelected ? [] : selectedDatasources);
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment