From 73043fc823c5e5f9fd02a5f1087fb7df70d99445 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Fri, 18 Jul 2014 09:22:19 +0000 Subject: [PATCH] SSDM-616: Add ability to create Projects in the ELN (Refactoring) SVN: 32105 --- .../ProjectForm/ProjectFormController.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ProjectForm/ProjectFormController.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ProjectForm/ProjectFormController.js index 578248c3b6d..1a68a40a9a9 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ProjectForm/ProjectFormController.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ProjectForm/ProjectFormController.js @@ -39,6 +39,48 @@ function ProjectFormController(mainController, mode, project) { this.updateProject = function() { if(this._mainController.profile.allDataStores.length > 0) { + var method = ""; + if(this._projectFormModel.mode === FormMode.CREATE) { + method = "insertProject"; + } else if(this._projectFormModel.mode === FormMode.EDIT) { + method = "updateProject"; + } + + var parameters = { + //API Method + "method" : method, + //Identification Info + "projectSpace" : this._projectFormModel.project.spaceCode, + "projectCode" : this._projectFormModel.project.code, + "projectDescription" : this._projectFormModel.project.description + }; + + var _this = this; + this._mainController.serverFacade.createReportFromAggregationService(this._mainController.profile.allDataStores[0].code, parameters, function(response) { + if(response.error) { //Error Case 1 + Util.showError(response.error.message, function() {Util.unblockUI();}); + } else if (response.result.columns[1].title === "Error") { //Error Case 2 + var stacktrace = response.result.rows[0][1].value; + Util.showStacktraceAsError(stacktrace); + } else if (response.result.columns[0].title === "STATUS" && response.result.rows[0][0].value === "OK") { //Success Case + var message = ""; + if(_this._mode === FormMode.CREATE) { + message = "Created."; + } else if(_this._mode === FormMode.EDIT) { + message = "Updated."; + } + + var callbackOk = function() { + _this._mainController.changeView("showProjectPageFromIdentifier", projectIdentifier); + Util.unblockUI(); + } + + Util.showSuccess(message, callbackOk); + } else { //This should never happen + Util.showError("Unknown Error.", function() {Util.unblockUI();}); + } + + }); } else { Util.showError("No DSS available.", function() {Util.unblockUI();}); -- GitLab