From ee1597ad6b538e1fc7588324b43b172852d446cb Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Mon, 2 Jun 2014 11:27:42 +0000 Subject: [PATCH] SSDM-216: ELN UI - GENERAL - Cloning samples in ELN SVN: 31624 --- .../webapps/newbrowser/html/img/copy-icon.png | Bin 0 -> 583 bytes .../newbrowser/html/js/views/SampleForm.js | 72 ++++++++++++++++-- 2 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/img/copy-icon.png diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/img/copy-icon.png b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/img/copy-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..aff939695ce660001cf22462d0064b9796920b93 GIT binary patch literal 583 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPq8xtq9aa8N$J_ZKHE1oWnAr-gY-U;k$GLUG!xW7gA z;J<K&?4)^WGiP|JXgTeCUj1d|mgC#pl5cNYJMU`L>cz8`Wv=FnzP|PEcbWe6^DoXb z{hMo1ykM{1zq#`=4FYeTH=D9ZkU^l2p`n0<p+%WNL57jxAqNA8JA;D-6T=~VQarXA ztq*n_D`(r1-Vpv{V#<4tzBz{z-z)5S{C=nK4rV-t-QhT>Ex^EWpO<0BiRT~v&CY*j zJ1~9st?6;qAo~)w<h++<?(cqQ-*hFE;m!}E9qR4}+6BLS<JMrv+o62sb4+OH=}k6A zUvLz#3otM_FmNz1Dlo7#Fwl-u#kyf#w(;NNTXnp5|KVdexU)Mx)O4P01V>&Si_hgP zGt<f$7#Bn^^fkWzw$=MVJd0jkBf}ex>wi?9@IBx|cbmgh{rtW+Z+6O7Nv=3*zf9i$ W;AEQvs;@X0fWXt$&t;ucLK6V~zqoS% literal 0 HcmV?d00001 diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js index e6366eae0c5..6c0539bb9b8 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js @@ -285,6 +285,10 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod return "<a id='pinButton' class='btn btn-default " + inspectedClass + "'><img src='./img/pin-icon.png' style='width:16px; height:16px;' /></a>"; } + this.getCopyButton = function() { + return "<a id='copyButton' class='btn btn-default'><img src='./img/copy-icon.png' style='width:16px; height:16px;' /></a>"; + } + this.enablePINButtonEvent = function() { var localReference = this; $( "#pinButton" ).click(function() { @@ -297,6 +301,49 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod }); } + this.enableCopyButtonEvent = function() { + var localReference = this; + $( "#copyButton" ).click(function() { + var component = "<div class='form-horizontal'>" + component += "Input a new code for the duplicate, the duplicate will not have parents or children: <br><br>"; + component += "<div class='form-group col-md-9'>"; + component += "<label class='control-label " + localReference.labelColumnClass+ "'>Code (*):</label>"; + component += "<div class='" + localReference.controlColumnClass + "'>"; + component += "<input type='text' class='form-control' placeholder='Code' id='newSampleCodeForCopy' pattern='[a-zA-Z0-9_\\-\\.]+' required>"; + component += "</div>"; + component += "<div class='" + localReference.controlColumnClass + "'>"; + component += " (Allowed characters are: letters, numbers, '-', '_', '.')"; + component += "</div>"; + component += "</div>"; + + var css = { + 'text-align' : 'left', + 'top' : '15%', + 'width' : '70%', + 'left' : '15%', + 'right' : '20%', + 'overflow' : 'auto' + }; + + Util.blockUI(component + "<br><br><br> <a class='btn btn-default' id='copyAccept'>Accept</a> <a class='btn btn-default' id='copyCancel'>Cancel</a>", css); + + $("#copyAccept").on("click", function(event) { + var newSampleCodeForCopy = $("#newSampleCodeForCopy"); + var isValid = newSampleCodeForCopy[0].checkValidity(); + if(isValid) { + var newSampleCodeForCopyValue = newSampleCodeForCopy.val(); + localReference.createSample(newSampleCodeForCopyValue); + Util.unblockUI(); + } + }); + + $("#copyCancel").on("click", function(event) { + Util.unblockUI(); + }); + + }); + } + this.repaint = function() { $("#"+this.containerId).empty(); var sampleType = profile.getTypeForTypeCode(this.sampleTypeCode); @@ -315,6 +362,7 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod var pinButton = ""; var editButton = ""; var hierarchyButton = ""; + var copyButton = ""; if (this.mode === SampleFormMode.CREATE) { message = "Create"; @@ -322,19 +370,21 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod message = "Update"; pinButton = this.getPINButton(); hierarchyButton = this.getHierarchyButton(); + copyButton = this.getCopyButton(); sampleTypeDisplayName = sample.code; } else if (this.mode === SampleFormMode.VIEW) { message = "View"; pinButton = this.getPINButton(); - hierarchyButton = this.getHierarchyButton(); editButton = this.getEditButton(); + hierarchyButton = this.getHierarchyButton(); + copyButton = this.getCopyButton(); sampleTypeDisplayName = sample.code; } if(this.isELNSubExperiment) { message += " Sub Experiment"; } - component += "<h2>" + message + " " + sampleTypeDisplayName + " " + pinButton + " " + hierarchyButton + " " + editButton + "</h2>"; + component += "<h2>" + message + " " + sampleTypeDisplayName + " " + pinButton + " " + copyButton + " " + hierarchyButton + " " + editButton + "</h2>"; if (this.mode !== SampleFormMode.CREATE) { component += "<img data-preview-loaded='false' class='zoomableImage' id='preview-image' src='./img/image_loading.gif' style='height:300px; margin-right:20px;'></img>" @@ -558,6 +608,7 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod if (this.mode !== SampleFormMode.CREATE) { this.enablePINButtonEvent(); + this.enableCopyButtonEvent(); } if (this.mode === SampleFormMode.VIEW) { @@ -608,7 +659,7 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod } } - this.createSample = function() { + this.createSample = function(isCopyWithNewCode) { Util.blockUI(); //Other properties @@ -739,11 +790,20 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod // "sampleExperimentCode": sampleExperiment }; + if(isCopyWithNewCode) { + parameters["method"] = "insertSample"; + parameters["sampleCode"] = isCopyWithNewCode; + parameters["sampleParents"] = []; + parameters["sampleChildren"] = []; + parameters["sampleChildrenNew"] = []; + parameters["sampleChildrenRemoved"] = []; + } + var localReference = this; if(this.profile.allDataStores.length > 0) { this.serverFacade.createReportFromAggregationService(this.profile.allDataStores[0].code, parameters, function(response) { - localReference.createSampleCallback(response, localReference); + localReference.createSampleCallback(response, localReference, isCopyWithNewCode); }); } else { Util.showError("No DSS available.", function() {Util.unblockUI();}); @@ -752,7 +812,7 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod return false; } - this.createSampleCallback = function(response, localReference) { + this.createSampleCallback = function(response, localReference, isCopyWithNewCode) { 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 @@ -780,6 +840,8 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod message = "Created."; } else if(this.mode === SampleFormMode.EDIT) { message = "Updated."; + } else if(isCopyWithNewCode) { + message = "copied with new code: " + isCopyWithNewCode + "."; } var callbackOk = function() { -- GitLab