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

when uploading data overlay without specified type set default GENERIC

parent 7f3507aa
......@@ -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;
"use strict";
var Readable = require('stream').Readable;
var toBlob = require('stream-to-blob');
require("../mocha-config");
var $ = require('jquery');
......@@ -10,6 +13,7 @@ var chai = require('chai');
var assert = chai.assert;
var logger = require('../logger');
describe('AddOverlayDialog', function () {
it('addOverlay', function () {
......@@ -57,4 +61,37 @@ describe('AddOverlayDialog', function () {
});
});
describe('processFile', function () {
it('set default type', function () {
var dialog;
var file;
return ServerConnector.getProject().then(function (project) {
dialog = createDialog(project);
return dialog.init();
}).then(function () {
dialog.setType("GENETIC_VARIANT");
assert.equal("GENETIC_VARIANT", dialog.getType());
var stream = new Readable;
stream.push("s1\n");
stream.push(null);
return new Promise(function (resolve, reject) {
toBlob(stream, function (err, blob) {
if (err) return reject(err.message);
file = blob;
file.name = "test.txt";
resolve(blob);
})
});
}).then(function () {
return dialog.processFile(file);
}).then(function () {
assert.equal("GENERIC", dialog.getType());
});
});
});
});
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