diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js index cf9f9bb4b6c2e1390cf7f41f0f6b79bb2c364152..dbacbccd7ba984ea861364c53264c50436b8bad0 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js @@ -377,7 +377,7 @@ function ServerFacade(openbisServer) { this.updateSamples = function(sampleTypeCode, fileKeyAtHTTPSession, somethingOrNull, callbackFunction) { this.openbisServer.updateSamples(sampleTypeCode, fileKeyAtHTTPSession, somethingOrNull, callbackFunction); } - + this.fileUpload = function(file, callbackFunction) { //Building Form Data Object for Multipart File Upload var formData = new FormData(); @@ -410,6 +410,24 @@ function ServerFacade(openbisServer) { return GET; } + // + // Sample Others functions + // + this.moveSample = function(sampleIdentifier, experimentIdentifier, callbackFunction) { + this.createReportFromAggregationService(profile.getDefaultDataStoreCode(), + { + "method" : "moveSample", + "sampleIdentifier" : sampleIdentifier, + "experimentIdentifier" : experimentIdentifier + }, + function(data){ + if(data.result.rows[0][0].value == "OK") { + callbackFunction(true); + } else { + callbackFunction(false); + } + }); + } // // Data Set Import Related Functions // diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleController.js index adc8088a71016608bb61b5c4a7bdb88dc5c74b19..bf5e1b19d0217791bcbc9f64379d286544aac257 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleController.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleController.js @@ -27,6 +27,20 @@ function MoveSampleController(samplePermId) { } this.move = function() { - var breakMePlease = 0; + var _this = this; + if(!this._moveSampleModel.sample.identifier) { + Util.showError("Dear user, please choose the experiment first, try harder!", function() {}); + return; + } + + mainController.serverFacade.moveSample( + this._moveSampleModel.sample.identifier, + this._moveSampleModel.experimentIdentifier, function(isOK) { + if(isOK) { + Util.showSuccess("Sample " + _this._moveSampleModel.sample.identifier + " moved to " + _this._moveSampleModel.experimentIdentifier, function() { Util.unblockUI(); }); + } else { + Util.showError("Sample " + _this._moveSampleModel.sample.identifier + " failed " + _this._moveSampleModel.experimentIdentifier, function() {}); + } + }); } } \ No newline at end of file diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleView.js index 0ce512d9a2ca1bd5ff2d3ad3db967b66455651e5..0b40b6bca941bc489e68c965ad08794a40c2cb47 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleView.js @@ -24,7 +24,7 @@ function MoveSampleView(moveSampleController, moveSampleModel) { var $window = $('<form>', { 'class' : 'form-horizontal', 'action' : 'javascript:void(0);' }); $window.submit(function() { Util.unblockUI(); - _this._moveSampleModel.actionFunction(_this._moveSampleModel.sample); + _this._moveSampleController.move(); }); $window.append($('<legend>').append("Move Sample")); @@ -45,11 +45,7 @@ function MoveSampleView(moveSampleController, moveSampleModel) { $window.append($experimentSection); this.repaintExistingExperiment(); - var $btnAccept = $('<input>', { 'type': 'submit', 'class' : 'btn btn-primary', 'value' : 'Accept' }); - $btnAccept.click(function() { - _this._moveSampleController.move(); - }); - + var $btnAccept = $('<input>', { 'type': 'submit', 'class' : 'btn btn-primary', 'value' : 'Accept' }); var $btnCancel = $('<a>', { 'class' : 'btn btn-default' }).append('Cancel'); $btnCancel.click(function() { Util.unblockUI();