From a10006ef7a8ca85f3614ec47fa027d7bf543e351 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Fri, 18 Mar 2016 10:53:53 +0000 Subject: [PATCH] SSDM-3357 : Links on codes, refactoring. SVN: 35934 --- .../webapps/eln-lims/html/js/util/FormUtil.js | 23 +++++++++++++++++++ .../AdvancedSearch/AdvancedSearchView.js | 23 +++---------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js index d0535007f44..77d2dfd36e3 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js @@ -720,4 +720,27 @@ var FormUtil = new function() { return $toolbarContainer; } + + this.getFormLink = function(displayName, entityKind, permIdOrIdentifier) { + var view = null; + switch(entityKind) { + case "Sample": + view = "showViewSamplePageFromPermId"; + break; + case "Experiment": + view = "showExperimentPageFromIdentifier"; + break; + case "DataSet": + view = "showViewDataSetPageFromPermId"; + break; + } + + var href = Util.getURLFor(mainController.sideMenu.getCurrentNodeId(), view, permIdOrIdentifier); + var click = function() { + mainController.changeView(view, permIdOrIdentifier); + } + var link = $("<a>", { "href" : href, "class" : "browser-compatible-javascript-link" }).append(displayName); + link.click(click); + return link; + } } \ No newline at end of file diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchView.js index 753a8d4bf55..170cfe7d30a 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchView.js @@ -367,31 +367,14 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { this._getGridForResults = function(results, isGlobalSearch) { var getCodeClick = function(data) { - var href = null; - var click = null; switch(data.entityKind) { - case "Sample": - href = Util.getURLFor(mainController.sideMenu.getCurrentNodeId(), "showViewSamplePageFromPermId", data.permId); - click = function() { - mainController.changeView('showViewSamplePageFromPermId', data.permId); - } - break; case "Experiment": - href = Util.getURLFor(mainController.sideMenu.getCurrentNodeId(), "showExperimentPageFromIdentifier", data.identifier); - click = function() { - mainController.changeView('showExperimentPageFromIdentifier', data.identifier); - } + return FormUtil.getFormLink(data.code, data.entityKind, data.identifier); break; - case "DataSet": - href = Util.getURLFor(mainController.sideMenu.getCurrentNodeId(), "showViewDataSetPageFromPermId", data.permId); - click = function() { - mainController.changeView('showViewDataSetPageFromPermId', data.permId); - } + default: + return FormUtil.getFormLink(data.code, data.entityKind, data.permId); break; } - var link = $("<a>", { "href" : href, "class" : "browser-compatible-javascript-link" }).append(data.code); - link.click(click); - return link; } var columns = [ { -- GitLab