Skip to content
Snippets Groups Projects
Commit cfe4e6ac authored by juanf's avatar juanf
Browse files

BIS-675 / SP-1214 : ELN UI - Ask to save changes if work can be lost (Ask to...

BIS-675 / SP-1214 : ELN UI - Ask to save changes if work can be lost (Ask to save changes on Data Set Form)

SVN: 30794
parent 6a4e36c4
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,11 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) { ...@@ -26,6 +26,11 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) {
this.mode = mode; this.mode = mode;
this.dataSetTypes = null; this.dataSetTypes = null;
this.files = []; this.files = [];
this.isFormDirty = false;
this.isDirty = function() {
return this.isFormDirty;
}
this.init = function() { this.init = function() {
var localInstance = this; var localInstance = this;
...@@ -131,6 +136,7 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) { ...@@ -131,6 +136,7 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) {
} }
this._updateFileOptions = function() { this._updateFileOptions = function() {
var localInstance = this;
$wrapper = $("#fileOptionsContainer"); //Clean existing $wrapper = $("#fileOptionsContainer"); //Clean existing
$wrapper.empty(); $wrapper.empty();
...@@ -142,11 +148,16 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) { ...@@ -142,11 +148,16 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) {
} }
if(this.files.length > 1) { if(this.files.length > 1) {
var $textField = this._getInputField('text', 'folderName', 'Folder Name', null, true);
$textField.change(function(event) {
localInstance.isFormDirty = true;
});
var $folderName = $('<fieldset>') var $folderName = $('<fieldset>')
.append($('<div>', { class : "control-group"}) .append($('<div>', { class : "control-group"})
.append($('<label>', {class : 'control-label'}).text('Folder Name:')) .append($('<label>', {class : 'control-label'}).text('Folder Name:'))
.append($('<div>', {class: 'controls'}) .append($('<div>', {class: 'controls'})
.append(this._getInputField('text', 'folderName', 'Folder Name', null, true)) .append($textField)
.append(' (Required)')) .append(' (Required)'))
); );
$wrapper.append($folderName); $wrapper.append($folderName);
...@@ -164,14 +175,19 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) { ...@@ -164,14 +175,19 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) {
); );
$wrapper.append($fileFieldSetIsDirectory); $wrapper.append($fileFieldSetIsDirectory);
var localInstance = this;
$("#isZipDirectoryUpload").change(function() { $("#isZipDirectoryUpload").change(function() {
localInstance.isFormDirty = true;
if($("#isZipDirectoryUpload"+":checked").val() === "on") { if($("#isZipDirectoryUpload"+":checked").val() === "on") {
var $textField = localInstance._getInputField('text', 'folderName', 'Folder Name', null, true);
$textField.change(function(event) {
localInstance.isFormDirty = true;
});
var $folderName = $('<fieldset>', { "id" : "folderNameContainer"}) var $folderName = $('<fieldset>', { "id" : "folderNameContainer"})
.append($('<div>', { class : "control-group"}) .append($('<div>', { class : "control-group"})
.append($('<label>', {class : 'control-label'}).text('Folder Name:')) .append($('<label>', {class : 'control-label'}).text('Folder Name:'))
.append($('<div>', {class: 'controls'}) .append($('<div>', {class: 'controls'})
.append(localInstance._getInputField('text', 'folderName', 'Folder Name', null, true)) .append($textField)
.append(' (Required)')) .append(' (Required)'))
); );
$("#fileOptionsContainer").append($folderName); $("#fileOptionsContainer").append($folderName);
...@@ -196,6 +212,7 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) { ...@@ -196,6 +212,7 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) {
} }
this._repaintMetadata = function(dataSetType) { this._repaintMetadata = function(dataSetType) {
var localInstance = this;
$("#metadataContainer").empty(); $("#metadataContainer").empty();
var $wrapper = $("<div>"); var $wrapper = $("<div>");
...@@ -224,6 +241,10 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) { ...@@ -224,6 +241,10 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) {
$fieldset.append($controlGroup); $fieldset.append($controlGroup);
var $component = this.getFieldForPropertyType(propertyType); var $component = this.getFieldForPropertyType(propertyType);
$component.change(function(event) {
localInstance.isFormDirty = true;
});
$controls.append($component); $controls.append($component);
if(propertyType.mandatory) { if(propertyType.mandatory) {
$controls.append(' (Required)') $controls.append(' (Required)')
...@@ -423,6 +444,7 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) { ...@@ -423,6 +444,7 @@ function DataSetForm(serverFacade, containerId, profile, sample, mode) {
Util.showError(errorMessage, function() {Util.unblockUI();}); Util.showError(errorMessage, function() {Util.unblockUI();});
} else if (response.result.columns[0].title === "STATUS" && response.result.rows[0][0].value === "OK") { //Success Case } else if (response.result.columns[0].title === "STATUS" && response.result.rows[0][0].value === "OK") { //Success Case
var callbackOk = function() { var callbackOk = function() {
localInstance.isFormDirty = false;
Util.unblockUI(); Util.unblockUI();
mainController.navigationBar.backButton(null); mainController.navigationBar.backButton(null);
} }
......
...@@ -49,10 +49,10 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod ...@@ -49,10 +49,10 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod
this.sample = sample; this.sample = sample;
this.storage = null; this.storage = null;
this.dataSetViewer = null; this.dataSetViewer = null;
this.isDirty = false; this.isFormDirty = false;
this.isDirty = function() { this.isDirty = function() {
return this.isDirty; return this.isFormDirty;
} }
this.init = function() { this.init = function() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment