Commit 01b4e0de authored by Piotr Gawron's avatar Piotr Gawron
Browse files

publication list depended on button extension

parent 1b97c14a
......@@ -2,9 +2,9 @@
var $ = require('jquery');
var jQuery = $;
var dt = require('datatables.net')();
var dtReorder = require('datatables.net-rowreorder')();
require('jquery-ui/dialog');
require('datatables.net')();
require('datatables.net-rowreorder')();
require('jquery-ui/jquery-ui');
var Promise = require("bluebird");
......
......@@ -2,7 +2,8 @@
/* exported logger */
var $ = require('jquery');
require('datatables.net-rowreorder');
require('datatables.net')();
require('datatables.net-rowreorder')();
var AddOverlayDialog = require('../AddOverlayDialog');
var Panel = require('../Panel');
......
......@@ -2,6 +2,8 @@
var Promise = require("bluebird");
var $ = require('jquery');
require('datatables.net')();
require('datatables.net-rowreorder')();
/* exported logger */
......@@ -37,6 +39,34 @@ function PublicationListDialog(params) {
$(self.tableElement).DataTable().ajax.reload();
});
self.getElement().insertBefore(Functions.createElement({
type: "button",
content: 'CSV <span class="ui-icon ui-icon-arrowthickstop-1-s"></span>',
xss: false,
onclick: function () {
var data = $(self.tableElement).DataTable().data();
GuiConnector.showProcessing();
return self.getServerConnector().getPublications({
start: 0,
length: data.page.info().recordsDisplay,
sortColumn: self.getColumnsDefinition()[data.order()[0][0]].name,
sortOrder: data.order()[0][1],
search: data.search(),
modelId: self.getSubmapFilterValue()
}).then(function (publicationList) {
return self.publicationListAsCsvString(publicationList);
}).then(function (result) {
var blob = new Blob([result], {
type: "text/plain;charset=utf-8"
});
var FileSaver = require("file-saver");
return FileSaver.saveAs(blob, "publications.csv");
}).catch(GuiConnector.alert).finally(function () {
GuiConnector.hideProcessing();
});
}
}), self.tableElement);
}
PublicationListDialog.prototype = Object.create(AbstractGuiElement.prototype);
......@@ -198,36 +228,6 @@ PublicationListDialog.prototype.show = function () {
ajax: function (data, callback, settings) {
resolve(self._dataTableAjaxCall(data, callback, settings));
},
dom: 'Bfrtip',
buttons: [
{
text: 'CSV <span class="ui-icon ui-icon-arrowthickstop-1-s"></span>',
action: function (e, data) {
GuiConnector.showProcessing();
return self.getServerConnector().getPublications({
start: 0,
length: data.page.info().recordsDisplay,
sortColumn: self.getColumnsDefinition()[data.order()[0][0]].name,
sortOrder: data.order()[0][1],
search: data.search(),
modelId: self.getSubmapFilterValue()
}).then(function (publicationList) {
return self.publicationListAsCsvString(publicationList);
}).then(function (result) {
var blob = new Blob([result], {
type: "text/plain;charset=utf-8"
});
var FileSaver = require("file-saver");
return FileSaver.saveAs(blob, "publications.csv");
}).catch(function (error) {
GuiConnector.alert(error);
}).finally(function () {
GuiConnector.hideProcessing();
});
}
}
],
columns: self.getColumnsDefinition()
});
});
......
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