From 712a13bbdf1f891bfc89cbfde978adf10b25e4cf Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 5 Nov 2018 09:48:22 +0100 Subject: [PATCH] _createResponseCell extracted into abstract class --- .../main/js/gui/export/AbstractExportPanel.js | 23 +++++++++++++++++++ .../main/js/gui/export/ElementExportPanel.js | 21 ----------------- .../main/js/gui/export/NetworkExportPanel.js | 23 ------------------- 3 files changed, 23 insertions(+), 44 deletions(-) diff --git a/frontend-js/src/main/js/gui/export/AbstractExportPanel.js b/frontend-js/src/main/js/gui/export/AbstractExportPanel.js index 53314ef96d..d4d6662772 100644 --- a/frontend-js/src/main/js/gui/export/AbstractExportPanel.js +++ b/frontend-js/src/main/js/gui/export/AbstractExportPanel.js @@ -644,4 +644,27 @@ AbstractExportPanel.prototype.getBioEntityAllColumns = function () { }]; }; + +/** + * + * @param {BioEntity} bioEntity + * @param {ExportColumn} column + * @returns {Promise<string>} + * @protected + */ +AbstractExportPanel.prototype._createResponseCell = function (bioEntity, column) { + var valuePromise; + if (Functions.isString(column.method)) { + valuePromise = Promise.resolve(bioEntity[column.method]()); + } else { + valuePromise = Promise.resolve(column.method(bioEntity, this.getProject())); + } + return valuePromise.then(function (value) { + if (Functions.isString(value)) { + value = value.replace(/[\n\r]/g, ' '); + } + return value; + }); +}; + module.exports = AbstractExportPanel; diff --git a/frontend-js/src/main/js/gui/export/ElementExportPanel.js b/frontend-js/src/main/js/gui/export/ElementExportPanel.js index cf1ef8e869..8c96fec2a2 100644 --- a/frontend-js/src/main/js/gui/export/ElementExportPanel.js +++ b/frontend-js/src/main/js/gui/export/ElementExportPanel.js @@ -125,27 +125,6 @@ ElementExportPanel.prototype.createResponseString = function () { }); }; -/** - * - * @param {BioEntity} alias - * @param column - * @returns {Promise<string>} - * @private - */ -ElementExportPanel.prototype._createResponseCell = function (alias, column) { - var valuePromise; - if (Functions.isString(column.method)) { - valuePromise = Promise.resolve(alias[column.method]()); - } else { - valuePromise = Promise.resolve(column.method(alias, this.getProject())); - } - return valuePromise.then(function (value) { - if (Functions.isString(value)) { - value = value.replace(/[\n\r]/g, ' '); - } - return value; - }); -}; /** * * @param {Alias} alias diff --git a/frontend-js/src/main/js/gui/export/NetworkExportPanel.js b/frontend-js/src/main/js/gui/export/NetworkExportPanel.js index 77a11e11a1..a64762b7f7 100644 --- a/frontend-js/src/main/js/gui/export/NetworkExportPanel.js +++ b/frontend-js/src/main/js/gui/export/NetworkExportPanel.js @@ -249,27 +249,4 @@ NetworkExportPanel.prototype.createResponseRow = function (reaction, columns, mi }); }; -/** - * - * @param {Reaction} reaction - * @param {ExportColumn} column - * @returns {Promise<string>} - * @private - */ -NetworkExportPanel.prototype._createResponseCell = function (reaction, column) { - var valuePromise; - if (Functions.isString(column.method)) { - valuePromise = Promise.resolve(reaction[column.method]()); - } else { - valuePromise = Promise.resolve(column.method(reaction, this.getProject())); - } - - return valuePromise.then(function (value) { - if (Functions.isString(value)) { - value = value.replace(/[\n\r]/g, ' '); - } - return value; - }); -}; - module.exports = NetworkExportPanel; -- GitLab