Commit 813a9b9a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge remote-tracking branch 'origin/master' into...

Merge remote-tracking branch 'origin/master' into 911-remove-additional-options-in-copy-from-selecting-annotators-min13-1
parents 9bab4c74 f2846ad5
......@@ -30,7 +30,9 @@ minerva (14.0.0~beta.0) unstable; urgency=low
* Bug fix: creating project with too long name hung (#916)
* Bug fix: too long user login thrown an error (#915)
* Bug fix: width of info window adjust to the content size (#903)
* Bug fix: list of types when copying from annotators contains only types
* Bug fix: when uploading generic data overlay the type was not updated in
case the type was not specified in the input file (#906)
* Bug fix: list of types when copying from annotators contains only types
that are selectable in the dialog (#911)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 21 Aug 2019 21:00:00 +0200
......
......@@ -146,7 +146,6 @@ AddOverlayDialog.prototype.processFile = function (file) {
var overlay = overlayParser.parse(evt.target.result);
var nameInput = $("[name='overlay-name']", self.getElement())[0];
var descriptionInput = $("[name='overlay-description']", self.getElement())[0];
var typeSelect = $("[name='overlay-type']", self.getElement());
if (overlay.getName() !== undefined) {
nameInput.value = overlay.getName();
} else {
......@@ -163,9 +162,13 @@ AddOverlayDialog.prototype.processFile = function (file) {
if (overlay.getDescription() !== undefined) {
descriptionInput.value = overlay.getDescription();
}
if (overlay.getType() !== undefined) {
typeSelect.val(overlay.getType());
self.setType(overlay.getType());
} else {
self.setType("GENERIC");
}
if (overlayParser.containsMixedNewLineCharacters(evt.target.result)) {
GuiConnector.warn("Selected file contains new line characters from different operating systems " +
"(MAC/Windows/Linux). This might cause confusion when reading the file in the editor later on.")
......@@ -187,7 +190,7 @@ AddOverlayDialog.prototype.processFile = function (file) {
/**
*
* @param {string} fileContent
* @param {?null|string} fileContent
*/
AddOverlayDialog.prototype.setFileContent = function (fileContent) {
if (typeof fileContent === 'string' || fileContent instanceof String) {
......@@ -324,4 +327,24 @@ AddOverlayDialog.prototype.open = function () {
$(div).dialog("open");
};
/**
*
* @param {string} type
*/
AddOverlayDialog.prototype.setType = function (type) {
var self = this;
if (type !== undefined) {
var typeSelect = $("[name='overlay-type']", self.getElement());
typeSelect.val(type);
}
};
/**
*
* @return {string}
*/
AddOverlayDialog.prototype.getType = function () {
var self = this;
return $("[name='overlay-type']", self.getElement()).val();
};
module.exports = AddOverlayDialog;
......@@ -10,6 +10,7 @@ var chai = require('chai');
var assert = chai.assert;
var logger = require('../logger');
describe('AddOverlayDialog', function () {
it('addOverlay', function () {
......@@ -57,4 +58,25 @@ describe('AddOverlayDialog', function () {
});
});
describe('processFile', function () {
it('set default type', function () {
var dialog;
return ServerConnector.getProject().then(function (project) {
dialog = createDialog(project);
return dialog.init();
}).then(function () {
dialog.setType("GENETIC_VARIANT");
assert.equal("GENETIC_VARIANT", dialog.getType());
return helper.stringToBlob("s1\n");
}).then(function (file) {
return dialog.processFile(file);
}).then(function () {
assert.equal("GENERIC", dialog.getType());
});
});
});
});
......@@ -79,18 +79,10 @@ describe('AddProjectDialog', function () {
it('sbml file', function () {
var dialog = createDialog();
var file;
return new Promise(function (resolve, reject) {
toBlob(fs.createReadStream('testFiles/map/sbml.xml'), function (err, blob) {
if (err) return reject(err.message);
file = blob;
file.name = "sbml.xml";
resolve(blob);
})
}).then(function () {
return dialog.init();
}).then(function () {
return dialog.init().then(function () {
return helper.fileToBlob('testFiles/map/sbml.xml');
}).then(function (file) {
return dialog.callListeners("onFileUpload", file);
}).then(function () {
var converter = dialog.getConverter();
......@@ -100,7 +92,6 @@ describe('AddProjectDialog', function () {
});
it('invalid zip', function () {
var dialog = createDialog();
var file;
var buf = fs.readFileSync("testFiles/map/invalid-project.zip");
buf.name = "invalid-project.zip";
......@@ -114,18 +105,10 @@ describe('AddProjectDialog', function () {
});
it('CellDesigner file', function () {
var dialog = createDialog();
var file;
return new Promise(function (resolve, reject) {
toBlob(fs.createReadStream('testFiles/map/cell_designer.xml'), function (err, blob) {
if (err) return reject(err.message);
file = blob;
file.name = "sbml.xml";
resolve(blob);
})
}).then(function () {
return dialog.init();
}).then(function () {
return dialog.init().then(function () {
return helper.fileToBlob('testFiles/map/cell_designer.xml');
}).then(function (file) {
return dialog.callListeners("onFileUpload", file);
}).then(function () {
var converter = dialog.getConverter();
......
"use strict";
var Readable = require('stream').Readable;
var toBlob = require('stream-to-blob');
require("./mocha-config");
var $ = require('jquery');
......@@ -643,6 +646,39 @@ Helper.prototype.createGoogleCanvas = function () {
});
};
/**
*
* @param {string} content
* @return {Promise<Blob>}
*/
Helper.prototype.stringToBlob = function (content) {
var stream = new Readable;
stream.push(content);
stream.push(null);
return new Promise(function (resolve, reject) {
toBlob(stream, function (err, blob) {
if (err) return reject(err.message);
blob.name = "test.txt";
resolve(blob);
})
});
};
/**
*
* @param {string} path
* @return {Promise<Blob>}
*/
Helper.prototype.fileToBlob = function (path) {
var self = this;
return self.readFile(path).then(function (content) {
return self.stringToBlob(content);
}).then(function (blob) {
blob.name = require('path').basename(path);
return blob;
});
};
/**
*
* @type {number}
......
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