Skip to content
Snippets Groups Projects
Commit 3cd3a0b9 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

direct calls to ServerConnector removed from ElementExportPanel

parent 712a13bb
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!490Resolve "common functionality of NetworkExportPanel and GraphicsExportPanel should be extracted to abstract class"
...@@ -223,7 +223,7 @@ AbstractExportPanel.prototype.getMiriamTypesDualListbox = function () { ...@@ -223,7 +223,7 @@ AbstractExportPanel.prototype.getMiriamTypesDualListbox = function () {
* *
* @param {{columnName:string, name:string}[]} columnTypes * @param {{columnName:string, name:string}[]} columnTypes
* @returns {HTMLElement} * @returns {HTMLElement}
* @private * @protected
*/ */
AbstractExportPanel.prototype._createSelectColumnDiv = function (columnTypes) { AbstractExportPanel.prototype._createSelectColumnDiv = function (columnTypes) {
var columnDiv = Functions.createElement({ var columnDiv = Functions.createElement({
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
/* exported logger */ /* exported logger */
var AbstractExportPanel = require('./AbstractExportPanel'); var AbstractExportPanel = require('./AbstractExportPanel');
var Functions = require('../../Functions');
var GuiMessageError = require('../GuiMessageError'); var GuiMessageError = require('../GuiMessageError');
var IdentifiedElement = require('../../map/data/IdentifiedElement'); var IdentifiedElement = require('../../map/data/IdentifiedElement');
// noinspection JSUnusedLocalSymbols
var logger = require('../../logger'); var logger = require('../../logger');
var Promise = require("bluebird"); var Promise = require("bluebird");
...@@ -23,7 +23,7 @@ var Promise = require("bluebird"); ...@@ -23,7 +23,7 @@ var Promise = require("bluebird");
* @extends AbstractExportPanel * @extends AbstractExportPanel
*/ */
function ElementExportPanel(params) { function ElementExportPanel(params) {
params.panelName = "elementExport"; params["panelName"] = "elementExport";
AbstractExportPanel.call(this, params); AbstractExportPanel.call(this, params);
} }
...@@ -37,14 +37,11 @@ ElementExportPanel.prototype.constructor = ElementExportPanel; ...@@ -37,14 +37,11 @@ ElementExportPanel.prototype.constructor = ElementExportPanel;
ElementExportPanel.prototype.init = function () { ElementExportPanel.prototype.init = function () {
var self = this; var self = this;
var element = self.getElement(); var element = self.getElement();
var configuration; var configuration = self.getConfiguration();
return ServerConnector.getConfiguration().then(function (result) { var typeDiv = self._createSelectTypeDiv(configuration.getElementTypes());
configuration = result; element.appendChild(typeDiv);
var typeDiv = self._createSelectTypeDiv(configuration.getElementTypes()); element.appendChild(self._createSelectColumnDiv(self.getAllColumns()));
element.appendChild(typeDiv); return self.getServerConnector().getProjectStatistics(self.getProject().getProjectId()).then(function (statistics) {
element.appendChild(self._createSelectColumnDiv(self.getAllColumns()));
return ServerConnector.getProjectStatistics(self.getProject().getProjectId());
}).then(function (statistics) {
return self._createMiriamTypeDiv(statistics.getElementAnnotations()); return self._createMiriamTypeDiv(statistics.getElementAnnotations());
}).then(function (div) { }).then(function (div) {
element.appendChild(div); element.appendChild(div);
......
...@@ -12,19 +12,22 @@ var assert = require('assert'); ...@@ -12,19 +12,22 @@ var assert = require('assert');
describe('ElementExportPanel', function () { describe('ElementExportPanel', function () {
function createExportPanel(project) {
return new ElementExportPanel({
element: testDiv,
project: project,
serverConnector: ServerConnector,
configuration: helper.getConfiguration()
});
}
describe('getSelectedTypes', function () { describe('getSelectedTypes', function () {
it('select single element', function () { it('select single element', function () {
var exportObject; var exportObject;
var project; var project;
return ServerConnector.getProject().then(function (result) { return ServerConnector.getProject().then(function (result) {
project = result; project = result;
return ServerConnector.getConfiguration(); exportObject = createExportPanel(project);
}).then(function (configuration) {
exportObject = new ElementExportPanel({
element: testDiv,
project: project,
configuration: configuration
});
return exportObject.init(); return exportObject.init();
}).then(function () { }).then(function () {
$("input[name='Degraded']", $(testDiv)).each(function (index, element) { $("input[name='Degraded']", $(testDiv)).each(function (index, element) {
...@@ -41,19 +44,10 @@ describe('ElementExportPanel', function () { ...@@ -41,19 +44,10 @@ describe('ElementExportPanel', function () {
var project; var project;
var elementTypes; var elementTypes;
var configuration; elementTypes = helper.getConfiguration().getSimpleElementTypeNames();
return ServerConnector.getProject().then(function (result) {
return ServerConnector.getConfiguration().then(function (result) {
configuration = result;
elementTypes = configuration.getSimpleElementTypeNames();
return ServerConnector.getProject();
}).then(function (result) {
project = result; project = result;
exportObject = new ElementExportPanel({ exportObject = createExportPanel(project);
element: testDiv,
project: project,
configuration: configuration
});
return exportObject.init(); return exportObject.init();
}).then(function () { }).then(function () {
$("input[name='Degraded']", $(testDiv)).each(function (index, element) { $("input[name='Degraded']", $(testDiv)).each(function (index, element) {
...@@ -75,13 +69,7 @@ describe('ElementExportPanel', function () { ...@@ -75,13 +69,7 @@ describe('ElementExportPanel', function () {
var project; var project;
return ServerConnector.getProject().then(function (result) { return ServerConnector.getProject().then(function (result) {
project = result; project = result;
return ServerConnector.getConfiguration(); exportObject = createExportPanel(project);
}).then(function (configuration) {
exportObject = new ElementExportPanel({
element: testDiv,
project: project,
configuration: configuration
});
return exportObject.init(); return exportObject.init();
}).then(function () { }).then(function () {
$("input[name='column_name']", $(testDiv)).each(function (index, element) { $("input[name='column_name']", $(testDiv)).each(function (index, element) {
...@@ -95,20 +83,9 @@ describe('ElementExportPanel', function () { ...@@ -95,20 +83,9 @@ describe('ElementExportPanel', function () {
it('select all', function () { it('select all', function () {
var exportObject; var exportObject;
var project; var project;
var elementTypes; return ServerConnector.getProject().then(function (result) {
var configuration;
return ServerConnector.getConfiguration().then(function (result) {
configuration = result;
elementTypes = configuration.getElementTypes();
return ServerConnector.getProject();
}).then(function (result) {
project = result; project = result;
exportObject = new ElementExportPanel({ exportObject = createExportPanel(project);
element: testDiv,
project: project,
configuration: configuration
});
return exportObject.init(); return exportObject.init();
}).then(function () { }).then(function () {
$("input[name='column_name']", $(testDiv)).each(function (index, element) { $("input[name='column_name']", $(testDiv)).each(function (index, element) {
...@@ -130,13 +107,7 @@ describe('ElementExportPanel', function () { ...@@ -130,13 +107,7 @@ describe('ElementExportPanel', function () {
var project; var project;
return ServerConnector.getProject().then(function (result) { return ServerConnector.getProject().then(function (result) {
project = result; project = result;
return ServerConnector.getConfiguration(); exportObject = createExportPanel(project);
}).then(function (configuration) {
exportObject = new ElementExportPanel({
element: testDiv,
project: project,
configuration: configuration
});
return exportObject.init(); return exportObject.init();
}).then(function () { }).then(function () {
var dlb = exportObject.getMiriamTypesDualListbox(); var dlb = exportObject.getMiriamTypesDualListbox();
...@@ -158,13 +129,7 @@ describe('ElementExportPanel', function () { ...@@ -158,13 +129,7 @@ describe('ElementExportPanel', function () {
var project; var project;
return ServerConnector.getProject().then(function (result) { return ServerConnector.getProject().then(function (result) {
project = result; project = result;
return ServerConnector.getConfiguration(); exportObject = createExportPanel(project);
}).then(function (configuration) {
exportObject = new ElementExportPanel({
element: testDiv,
project: project,
configuration: configuration
});
return exportObject.init(); return exportObject.init();
}).then(function () { }).then(function () {
assert.ok(exportObject.getIncludedCompartmentsDualListbox().available.length > 0); assert.ok(exportObject.getIncludedCompartmentsDualListbox().available.length > 0);
...@@ -183,13 +148,7 @@ describe('ElementExportPanel', function () { ...@@ -183,13 +148,7 @@ describe('ElementExportPanel', function () {
var project; var project;
return ServerConnector.getProject().then(function (result) { return ServerConnector.getProject().then(function (result) {
project = result; project = result;
return ServerConnector.getConfiguration(); exportObject = createExportPanel(project);
}).then(function (configuration) {
exportObject = new ElementExportPanel({
element: testDiv,
project: project,
configuration: configuration
});
return exportObject.init(); return exportObject.init();
}).then(function () { }).then(function () {
var dlb = exportObject.getExcludedCompartmentsDualListbox(); var dlb = exportObject.getExcludedCompartmentsDualListbox();
...@@ -208,13 +167,7 @@ describe('ElementExportPanel', function () { ...@@ -208,13 +167,7 @@ describe('ElementExportPanel', function () {
var project; var project;
return ServerConnector.getProject().then(function (result) { return ServerConnector.getProject().then(function (result) {
project = result; project = result;
return ServerConnector.getConfiguration(); exportObject = createExportPanel(project);
}).then(function (configuration) {
exportObject = new ElementExportPanel({
element: testDiv,
project: project,
configuration: configuration
});
return exportObject.init(); return exportObject.init();
}).then(function () { }).then(function () {
$("input[name='ALL']", $(testDiv)).each(function (index, element) { $("input[name='ALL']", $(testDiv)).each(function (index, element) {
...@@ -235,13 +188,7 @@ describe('ElementExportPanel', function () { ...@@ -235,13 +188,7 @@ describe('ElementExportPanel', function () {
var project; var project;
return ServerConnector.getProject().then(function (result) { return ServerConnector.getProject().then(function (result) {
project = result; project = result;
return ServerConnector.getConfiguration(); exportObject = createExportPanel(project);
}).then(function (configuration) {
exportObject = new ElementExportPanel({
element: testDiv,
project: project,
configuration: configuration
});
return exportObject.init(); return exportObject.init();
}).then(function () { }).then(function () {
return exportObject.createResponseString(); return exportObject.createResponseString();
...@@ -256,13 +203,7 @@ describe('ElementExportPanel', function () { ...@@ -256,13 +203,7 @@ describe('ElementExportPanel', function () {
var project; var project;
return ServerConnector.getProject().then(function (result) { return ServerConnector.getProject().then(function (result) {
project = result; project = result;
return ServerConnector.getConfiguration(); exportObject = createExportPanel(project);
}).then(function (configuration) {
exportObject = new ElementExportPanel({
element: testDiv,
project: project,
configuration: configuration
});
return exportObject.init(); return exportObject.init();
}).then(function () { }).then(function () {
$("input[name='ALL']", $(testDiv)).each(function (index, element) { $("input[name='ALL']", $(testDiv)).each(function (index, element) {
...@@ -275,11 +216,7 @@ describe('ElementExportPanel', function () { ...@@ -275,11 +216,7 @@ describe('ElementExportPanel', function () {
describe('createResponseRow', function () { describe('createResponseRow', function () {
it('description with new line', function () { it('description with new line', function () {
var exportObject = new ElementExportPanel({ var exportObject = createExportPanel(helper.createProject());
element: testDiv,
project: helper.createProject(),
configuration: helper.getConfiguration()
});
var alias = helper.createAlias(exportObject.getProject().getModels()[0]); var alias = helper.createAlias(exportObject.getProject().getModels()[0]);
var desc = "test\ntest2\n"; var desc = "test\ntest2\n";
alias.setDescription(desc); alias.setDescription(desc);
...@@ -289,11 +226,7 @@ describe('ElementExportPanel', function () { ...@@ -289,11 +226,7 @@ describe('ElementExportPanel', function () {
}); });
it('complex name', function () { it('complex name', function () {
var complexName = "Complex name2"; var complexName = "Complex name2";
var exportObject = new ElementExportPanel({ var exportObject = createExportPanel(helper.createProject());
element: testDiv,
project: helper.createProject(),
configuration: helper.getConfiguration()
});
var alias = helper.createAlias(exportObject.getProject().getModels()[0]); var alias = helper.createAlias(exportObject.getProject().getModels()[0]);
var complex = helper.createAlias(exportObject.getProject().getModels()[0]); var complex = helper.createAlias(exportObject.getProject().getModels()[0]);
complex.setName(complexName); complex.setName(complexName);
...@@ -304,11 +237,7 @@ describe('ElementExportPanel', function () { ...@@ -304,11 +237,7 @@ describe('ElementExportPanel', function () {
}); });
it('compartment name', function () { it('compartment name', function () {
var compartmentName = "Compartment name2"; var compartmentName = "Compartment name2";
var exportObject = new ElementExportPanel({ var exportObject = createExportPanel(helper.createProject());
element: testDiv,
project: helper.createProject(),
configuration: helper.getConfiguration()
});
var alias = helper.createAlias(exportObject.getProject().getModels()[0]); var alias = helper.createAlias(exportObject.getProject().getModels()[0]);
var compartment = helper.createAlias(exportObject.getProject().getModels()[0]); var compartment = helper.createAlias(exportObject.getProject().getModels()[0]);
compartment.setName(compartmentName); compartment.setName(compartmentName);
...@@ -318,11 +247,7 @@ describe('ElementExportPanel', function () { ...@@ -318,11 +247,7 @@ describe('ElementExportPanel', function () {
}); });
}); });
it('column with function manipulating data', function () { it('column with function manipulating data', function () {
var exportObject = new ElementExportPanel({ var exportObject = createExportPanel(helper.createProject());
element: testDiv,
project: helper.createProject(),
configuration: helper.getConfiguration()
});
var alias = helper.createAlias(); var alias = helper.createAlias();
return exportObject.createResponseRow(alias, [{ return exportObject.createResponseRow(alias, [{
"columnName": "id", "columnName": "id",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment