Commit b3e1656a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

saving as a file added

parent f24ebb3a
......@@ -37,6 +37,7 @@
},
"dependencies": {
"dual-listbox": "^1.0.3",
"file-saver": "^1.3.3",
"http-status-codes": "^1.1.6",
"js-cookie": "^2.1.3",
"log4js": "0.6.38",
......
......@@ -172,10 +172,15 @@ ElementExportPanel.prototype._createDownloadButton = function() {
});
var button = Functions.createElement({
type : "button",
name : "downloadButton",
content : " Download",
onclick : function() {
return self.createResponseString().then(function(result) {
logger.info(result);
var blob = new Blob([ result ], {
type : "text/plain;charset=utf-8"
});
var FileSaver = require("file-saver");
return FileSaver.saveAs(blob, self.getProject().getProjectId() + "-elements.txt");
}).then(null, GuiConnector.alert);
},
});
......
......@@ -246,6 +246,28 @@ describe('ElementExportPanel', function() {
});
});
it('download file', function() {
var exportObject;
var project;
return ServerConnector.getProject().then(function(result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function(configuration) {
exportObject = new ElementExportPanel({
element : testDiv,
project : project,
configuration : configuration,
});
return exportObject.init();
}).then(function() {
$("input[name='ALL']", $(testDiv)).each(function(index, element) {
element.checked = true;
});
var element = $("[name='downloadButton']", $(testDiv))[0];
return element.onclick();
});
});
describe('createResponseRow', function() {
it('description with new line', function() {
var exportObject = new ElementExportPanel({
......
......@@ -24,6 +24,7 @@ global.window.$ = $;
// additions to jsdom implementations:
global.Option = window.Option;
global.Blob = window.Blob;
var originalCreateElement = document.createElement;
document.createElement = function(arg) {
......@@ -42,6 +43,9 @@ window.open = function() {
};
return result;
};
window.URL.createObjectURL = function(){
};
// pileup is using heavily some browser defined javascript
var pileup = require('pileup');
......
Supports Markdown
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