diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/index.html b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/index.html index 55804be981ab4cec1887d9f07f9d2e6319a6982a..069a1bf4c26f092ece84e6dcbec2b79e7e7fff00 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/index.html +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/index.html @@ -76,6 +76,7 @@ <script type="text/javascript" src="./js/views/SampleHierarchy.js"></script> <script type="text/javascript" src="./js/views/SampleTable.js"></script> <script type="text/javascript" src="./js/views/ExperimentForm.js"></script> + <script type="text/javascript" src="./js/views/ProjectForm.js"></script> <script type="text/javascript" src="./js/widgets/DataSetViewer.js"></script> <script type="text/javascript" src="./js/widgets/SampleLinksWidget.js"></script> diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/controllers/MainController.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/controllers/MainController.js index 65c470c8c26e4a02c1aee83dd502e0f496d8e156..aa55d51df85ea0beb3ca7edfef8361218a6922ef 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/controllers/MainController.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/controllers/MainController.js @@ -171,6 +171,13 @@ function MainController(profile) { document.title = "Search"; this._showSearchPage(arg); break; + case "showProjectPageFromPermId": + var _this = this; + this.serverFacade.getProjectFromPermId(arg, function(project) { + document.title = "Project " + project.code; + _this._showProjectPageFromPermId(project); + }); + break; case "showExperimentPageFromIdentifier": var _this = this; this.serverFacade.listExperimentsForIdentifiers([arg], function(data) { @@ -323,9 +330,16 @@ function MainController(profile) { }); } + this._showProjectPageFromPermId = function(project) { + //Show Form + var projectForm = new ProjectForm("mainContainer", this, project); + projectForm.init(); + this.currentView = projectForm; + } + this._showExperimentPageFromIdentifier = function(experiment) { //Show Form - var experimentForm = new ExperimentForm("mainContainer", this, experiment); + var experimentForm = new ExperimentForm("mainContainer", this, experiment, ExperimentFormMode.VIEW); experimentForm.init(); this.currentView = experimentForm; } diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js index b4b3a7d394ee38b19059f7de5314fc1694ee6ffe..a4907a8aeb9baaa6ceb130d939a8b342c51ddeee 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js @@ -65,6 +65,17 @@ function ServerFacade(openbisServer) { this.openbisServer.listExperiments(projects, null, callbackFunction); } + this.getProjectFromPermId = function(permId, callbackFunction) { + this.openbisServer.listProjects(function(data) { + data.result.forEach(function(project){ + if(project.permId === permId) { + callbackFunction(project); + return; + } + }); + }); + } + this.listExperimentsForIdentifiers = function(experimentsIdentifiers, callbackFunction) { this.openbisServer.listExperimentsForIdentifiers(experimentsIdentifiers, callbackFunction); } diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ExperimentForm.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ExperimentForm.js index f025a2a3a6b3b8515ff7ff086b1f350f04946499..f9114eb8531e0e788f7089854990396929289126 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ExperimentForm.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ExperimentForm.js @@ -14,10 +14,17 @@ * limitations under the License. */ -function ExperimentForm(containerId, mainController, experiment) { +ExperimentFormMode = { + CREATE : 0, + EDIT : 1, + VIEW : 2 +} + +function ExperimentForm(containerId, mainController, experiment, mode) { this._containerId = containerId; this._mainController = mainController; this._experiment = experiment; + this._mode = mode; this.init = function() { this.repaint(); @@ -31,30 +38,45 @@ function ExperimentForm(containerId, mainController, experiment) { var $formColumn = $("<div>", { "class" : "col-md-12"}); $form.append($formColumn); - $formColumn.append($("<h1>").append("Experiment " + this._experiment.identifier)); - var $createSubExpBtn = $("<a>", { "class" : "btn btn-default"}).append("Create Sub Experiment"); - $createSubExpBtn.click(function() { - var $dropdown = FormUtil.getSampleTypeDropdown("sampleTypeDropdown", true); - Util.blockUI("Select the type for the sub Experiment: <br><br>" + $dropdown[0].outerHTML + "<br> or <a class='btn btn-default' id='sampleTypeDropdownCancel'>Cancel</a>"); - - $("#sampleTypeDropdown").on("change", function(event) { - var sampleTypeCode = $("#sampleTypeDropdown")[0].value; - var argsMap = { - "sampleTypeCode" : sampleTypeCode, - "experimentIdentifier" : _this._experiment.identifier - } - var argsMapStr = JSON.stringify(argsMap); + // + // Title + // + if(this._mode === ExperimentFormMode.VIEW || this._mode === ExperimentFormMode.EDIT) { + $formColumn.append($("<h1>").append("Experiment " + this._experiment.identifier)); + } + + // + // Metadata Fields + // + + + // + // Create Sub Experiment + // + if(this._mode === ExperimentFormMode.VIEW) { + var $createSubExpBtn = $("<a>", { "class" : "btn btn-default"}).append("Create Sub Experiment"); + $createSubExpBtn.click(function() { + var $dropdown = FormUtil.getSampleTypeDropdown("sampleTypeDropdown", true); + Util.blockUI("Select the type for the sub Experiment: <br><br>" + $dropdown[0].outerHTML + "<br> or <a class='btn btn-default' id='sampleTypeDropdownCancel'>Cancel</a>"); - _this._mainController.changeView("showCreateSubExperimentPage", argsMapStr); - }); - - $("#sampleTypeDropdownCancel").on("click", function(event) { - Util.unblockUI(); + $("#sampleTypeDropdown").on("change", function(event) { + var sampleTypeCode = $("#sampleTypeDropdown")[0].value; + var argsMap = { + "sampleTypeCode" : sampleTypeCode, + "experimentIdentifier" : _this._experiment.identifier + } + var argsMapStr = JSON.stringify(argsMap); + + _this._mainController.changeView("showCreateSubExperimentPage", argsMapStr); + }); + + $("#sampleTypeDropdownCancel").on("click", function(event) { + Util.unblockUI(); + }); }); - }); - - $formColumn.append($createSubExpBtn); + $formColumn.append($createSubExpBtn); + } $("#" + this._containerId).append($form); } } \ No newline at end of file diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ProjectForm.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ProjectForm.js new file mode 100644 index 0000000000000000000000000000000000000000..8bb730b9b04f8e46e19d26ca64808687bb0da531 --- /dev/null +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ProjectForm.js @@ -0,0 +1,45 @@ +/* + * Copyright 2014 ETH Zuerich, Scientific IT Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +function ProjectForm(containerId, mainController, project) { + this._containerId = containerId; + this._mainController = mainController; + this._project = project; + + this.init = function() { + this.repaint(); + } + + this.repaint = function() { + var _this = this; + $("#" + this._containerId).empty(); + + var $form = $("<div>", { "class" : "row"}); + var $formColumn = $("<div>", { "class" : "col-md-12"}); + + $form.append($formColumn); + + // + // Title + // + $formColumn.append($("<h1>").append("Project /" + this._project.spaceCode + "/" + this._project.code)); + + // + // Metadata Fields + // + + $("#" + this._containerId).append($form); + } +} \ No newline at end of file diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/widgets/SideMenuWidget.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/widgets/SideMenuWidget.js index 78d9d4162948d696f5fa8bbc31c9f519f53bb484..01dda05778c130c0f7fe1ccfd0c4103ec1fd408c 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/widgets/SideMenuWidget.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/widgets/SideMenuWidget.js @@ -90,7 +90,7 @@ function SideMenuWidget(mainController, containerId, serverFacade) { var newMenuIfSelectedProject = { children : [] } - var menuItemProject = new SideMenuWidgetComponent(true, false, project.code, menuItemSpace, newMenuIfSelectedProject, null, null); + var menuItemProject = new SideMenuWidgetComponent(true, false, project.code, menuItemSpace, newMenuIfSelectedProject, "showProjectPageFromPermId", project.permId); newMenuIfSelectedSpace.children.push(menuItemProject); } }