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

SSDM-2435 : Polishing sample dataset uploader

SVN: 34777
parent c12a8896
No related branches found
No related tags found
No related merge requests found
...@@ -67,13 +67,11 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { ...@@ -67,13 +67,11 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) {
); );
$dataSetTypeFieldSet.append($dataSetTypeDropDown); $dataSetTypeFieldSet.append($dataSetTypeDropDown);
var ownerName = "Sample";
var owner = this._dataSetFormModel.sample.identifier; var owner = this._dataSetFormModel.sample.identifier;
if(this._dataSetFormModel.sample.experimentIdentifierOrNull) { if(this._dataSetFormModel.sample.experimentIdentifierOrNull) {
owner = this._dataSetFormModel.sample.experimentIdentifierOrNull + "/" + this._dataSetFormModel.sample.code; owner = this._dataSetFormModel.sample.experimentIdentifierOrNull + "/" + this._dataSetFormModel.sample.code;
} }
$dataSetTypeFieldSet.append(FormUtil.getFieldForLabelWithText(ownerName, owner)); $dataSetTypeFieldSet.append(FormUtil.getFieldForTextWithLabel(owner, "Sample"));
// //
// Registration and modification info // Registration and modification info
...@@ -157,8 +155,15 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { ...@@ -157,8 +155,15 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) {
.append($('<div>', { class : "form-group"}) .append($('<div>', { class : "form-group"})
.append($('<label>', {class : 'control-label '+ FormUtil.labelColumnClass}).text('Uncompress before import:')) .append($('<label>', {class : 'control-label '+ FormUtil.labelColumnClass}).text('Uncompress before import:'))
.append($('<div>', {class: FormUtil.controlColumnClass}) .append($('<div>', {class: FormUtil.controlColumnClass})
.append(FormUtil._getBooleanField('isZipDirectoryUpload', 'Uncompress before import:'))) .append(FormUtil.getFieldForPropertyType({
dataType : "BOOLEAN",
code : 'isZipDirectoryUpload',
description : 'Uncompress before import:'
})))
); );
$wrapper.append($fileFieldSetIsDirectory); $wrapper.append($fileFieldSetIsDirectory);
$("#isZipDirectoryUpload").change(function() { $("#isZipDirectoryUpload").change(function() {
......
...@@ -72,7 +72,7 @@ var FormUtil = new function() { ...@@ -72,7 +72,7 @@ var FormUtil = new function() {
return $fieldset; return $fieldset;
} }
this.getFieldForLabelWithText = function(label, text, id, postComponent, cssForText) { this.getFieldForTextWithLabel = function(text, label) {
var $fieldset = $('<div>'); var $fieldset = $('<div>');
var $controlGroup = $('<div>', {class : 'form-group'}); var $controlGroup = $('<div>', {class : 'form-group'});
...@@ -86,19 +86,10 @@ var FormUtil = new function() { ...@@ -86,19 +86,10 @@ var FormUtil = new function() {
$controlGroup.append($controlLabel); $controlGroup.append($controlLabel);
$controlGroup.append($controls); $controlGroup.append($controls);
if(postComponent) {
$controlGroup.append(postComponent);
}
$fieldset.append($controlGroup); $fieldset.append($controlGroup);
var $component = $("<p>", {'class' : 'form-control-static', 'style' : 'border:none; box-shadow:none; background:transparent; word-wrap: break-word; white-space: pre-line;'}); var $component = $("<p>", {'class' : 'form-control-static', 'style' : 'border:none; box-shadow:none; background:transparent; word-wrap: break-word; white-space: pre-line;'});
if(cssForText) {
$component.css(cssForText);
}
$component.text(text); $component.text(text);
if(id) {
$component.attr('id', id);
}
$controls.append($component); $controls.append($component);
return $fieldset; return $fieldset;
...@@ -107,40 +98,29 @@ var FormUtil = new function() { ...@@ -107,40 +98,29 @@ var FormUtil = new function() {
// //
// Get Field from property // Get Field from property
// //
this.getVocabularyLabelForTermCode = function(propertyType, termCode) {
var vocabulary = propertyType.vocabulary;
if(vocabulary) {
for(var tIdx = 0; tIdx < vocabulary.terms.length; tIdx++) {
if(vocabulary.terms[tIdx].code === termCode) {
return vocabulary.terms[tIdx].label;
}
}
}
return termCode;
}
this.getFieldForPropertyType = function(propertyType) { this.getFieldForPropertyType = function(propertyType) {
var $component = null; var $component = null;
if (propertyType.dataType === "BOOLEAN") { if (propertyType.dataType === "BOOLEAN") {
$component = this._getBooleanField(propertyType.code, propertyType.description); $component = getBooleanField(propertyType.code, propertyType.description);
} else if (propertyType.dataType === "CONTROLLEDVOCABULARY") { } else if (propertyType.dataType === "CONTROLLEDVOCABULARY") {
$component = this._getDropDownFieldForVocabulary(propertyType.code, propertyType.vocabulary.terms, propertyType.description, propertyType.mandatory); $component = getDropDownFieldForVocabulary(propertyType.code, propertyType.vocabulary.terms, propertyType.description, propertyType.mandatory);
} else if (propertyType.dataType === "HYPERLINK") { } else if (propertyType.dataType === "HYPERLINK") {
$component = this._getInputField("url", propertyType.code, propertyType.description, null, propertyType.mandatory); $component = getInputField("url", propertyType.code, propertyType.description, null, propertyType.mandatory);
} else if (propertyType.dataType === "INTEGER") { } else if (propertyType.dataType === "INTEGER") {
$component = this._getInputField("number", propertyType.code, propertyType.description, '1', propertyType.mandatory); $component = getInputField("number", propertyType.code, propertyType.description, '1', propertyType.mandatory);
} else if (propertyType.dataType === "MATERIAL") { } else if (propertyType.dataType === "MATERIAL") {
$component = this._getInputField("text", propertyType.code, propertyType.description, null, propertyType.mandatory); $component = getInputField("text", propertyType.code, propertyType.description, null, propertyType.mandatory);
} else if (propertyType.dataType === "MULTILINE_VARCHAR") { } else if (propertyType.dataType === "MULTILINE_VARCHAR") {
$component = this._getTextBox(propertyType.code, propertyType.description, propertyType.mandatory); $component = getTextBox(propertyType.code, propertyType.description, propertyType.mandatory);
} else if (propertyType.dataType === "REAL") { } else if (propertyType.dataType === "REAL") {
$component = this._getInputField("number", propertyType.code, propertyType.description, 'any', propertyType.mandatory); $component = getInputField("number", propertyType.code, propertyType.description, 'any', propertyType.mandatory);
} else if (propertyType.dataType === "TIMESTAMP") { } else if (propertyType.dataType === "TIMESTAMP") {
$component = this._getDatePickerField(propertyType.code, propertyType.description, propertyType.mandatory); $component = getDatePickerField(propertyType.code, propertyType.description, propertyType.mandatory);
} else if (propertyType.dataType === "VARCHAR") { } else if (propertyType.dataType === "VARCHAR") {
$component = this._getInputField("text", propertyType.code, propertyType.description, null, propertyType.mandatory); $component = getInputField("text", propertyType.code, propertyType.description, null, propertyType.mandatory);
} else if (propertyType.dataType === "XML") { } else if (propertyType.dataType === "XML") {
$component = this._getTextBox(propertyType.code, propertyType.description, propertyType.mandatory); $component = getTextBox(propertyType.code, propertyType.description, propertyType.mandatory);
} }
return $component; return $component;
...@@ -149,11 +129,11 @@ var FormUtil = new function() { ...@@ -149,11 +129,11 @@ var FormUtil = new function() {
// //
// Form Fields // Form Fields
// //
this._getBooleanField = function(id, alt) { var getBooleanField = function(id, alt) {
return $('<div>', {'class' : 'checkbox'}).append($('<input>', {'type' : 'checkbox', 'id' : id, 'alt' : alt, 'placeholder' : alt })); return $('<div>', {'class' : 'checkbox'}).append($('<input>', {'type' : 'checkbox', 'id' : id, 'alt' : alt, 'placeholder' : alt }));
} }
this._getDropDownFieldForVocabulary = function(code, terms, alt, isRequired) { var getDropDownFieldForVocabulary = function(code, terms, alt, isRequired) {
var $component = $("<select>", {'placeholder' : alt, 'class' : 'form-control'}); var $component = $("<select>", {'placeholder' : alt, 'class' : 'form-control'});
$component.attr('id', code); $component.attr('id', code);
...@@ -169,7 +149,7 @@ var FormUtil = new function() { ...@@ -169,7 +149,7 @@ var FormUtil = new function() {
return $component; return $component;
} }
this._getInputField = function(type, id, alt, step, isRequired) { var getInputField = function(type, id, alt, step, isRequired) {
var $component = $('<input>', {'type' : type, 'id' : id, 'alt' : alt, 'placeholder' : alt, 'class' : 'form-control'}); var $component = $('<input>', {'type' : type, 'id' : id, 'alt' : alt, 'placeholder' : alt, 'class' : 'form-control'});
if (isRequired) { if (isRequired) {
$component.attr('required', ''); $component.attr('required', '');
...@@ -180,7 +160,7 @@ var FormUtil = new function() { ...@@ -180,7 +160,7 @@ var FormUtil = new function() {
return $component; return $component;
} }
this._getTextBox = function(id, alt, isRequired) { var getTextBox = function(id, alt, isRequired) {
var $component = $('<textarea>', {'id' : id, 'alt' : alt, 'style' : 'height: 80px; width: 450px;', 'placeholder' : alt, 'class' : 'form-control'}); var $component = $('<textarea>', {'id' : id, 'alt' : alt, 'style' : 'height: 80px; width: 450px;', 'placeholder' : alt, 'class' : 'form-control'});
if (isRequired) { if (isRequired) {
$component.attr('required', ''); $component.attr('required', '');
...@@ -188,7 +168,7 @@ var FormUtil = new function() { ...@@ -188,7 +168,7 @@ var FormUtil = new function() {
return $component; return $component;
} }
this._getDatePickerField = function(id, alt, isRequired) { var getDatePickerField = function(id, alt, isRequired) {
var $component = $('<div>', {'class' : 'form-group', 'style' : 'margin-left: 0px;', 'placeholder' : alt }); var $component = $('<div>', {'class' : 'form-group', 'style' : 'margin-left: 0px;', 'placeholder' : alt });
var $subComponent = $('<div>', {'class' : 'input-group date', 'id' : 'datetimepicker_' + id }); var $subComponent = $('<div>', {'class' : 'input-group date', 'id' : 'datetimepicker_' + id });
var $input = $('<input>', {'class' : 'form-control', 'type' : 'text', 'id' : id, 'data-format' : 'yyyy-MM-dd HH:mm:ss'}); var $input = $('<input>', {'class' : 'form-control', 'type' : 'text', 'id' : id, 'data-format' : 'yyyy-MM-dd HH:mm:ss'});
......
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