From 028f03beeaa5b2c864a4266eae270dc1a9e543f0 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Mon, 5 Oct 2015 09:41:06 +0000 Subject: [PATCH] SSDM-2435 : Polishing sample dataset uploader SVN: 34777 --- .../html/js/DataSetFormView.js | 13 +++-- .../dataset-uploader/html/js/FormUtil.js | 52 ++++++------------- 2 files changed, 25 insertions(+), 40 deletions(-) diff --git a/openbis/source/core-plugins/dataset-uploader/1/as/webapps/dataset-uploader/html/js/DataSetFormView.js b/openbis/source/core-plugins/dataset-uploader/1/as/webapps/dataset-uploader/html/js/DataSetFormView.js index b915d9b7dce..8cc5d1ec801 100644 --- a/openbis/source/core-plugins/dataset-uploader/1/as/webapps/dataset-uploader/html/js/DataSetFormView.js +++ b/openbis/source/core-plugins/dataset-uploader/1/as/webapps/dataset-uploader/html/js/DataSetFormView.js @@ -67,13 +67,11 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { ); $dataSetTypeFieldSet.append($dataSetTypeDropDown); - - var ownerName = "Sample"; var owner = this._dataSetFormModel.sample.identifier; if(this._dataSetFormModel.sample.experimentIdentifierOrNull) { 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 @@ -157,8 +155,15 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { .append($('<div>', { class : "form-group"}) .append($('<label>', {class : 'control-label '+ FormUtil.labelColumnClass}).text('Uncompress before import:')) .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); $("#isZipDirectoryUpload").change(function() { diff --git a/openbis/source/core-plugins/dataset-uploader/1/as/webapps/dataset-uploader/html/js/FormUtil.js b/openbis/source/core-plugins/dataset-uploader/1/as/webapps/dataset-uploader/html/js/FormUtil.js index 7e103579f93..93ad43ac465 100644 --- a/openbis/source/core-plugins/dataset-uploader/1/as/webapps/dataset-uploader/html/js/FormUtil.js +++ b/openbis/source/core-plugins/dataset-uploader/1/as/webapps/dataset-uploader/html/js/FormUtil.js @@ -72,7 +72,7 @@ var FormUtil = new function() { return $fieldset; } - this.getFieldForLabelWithText = function(label, text, id, postComponent, cssForText) { + this.getFieldForTextWithLabel = function(text, label) { var $fieldset = $('<div>'); var $controlGroup = $('<div>', {class : 'form-group'}); @@ -86,19 +86,10 @@ var FormUtil = new function() { $controlGroup.append($controlLabel); $controlGroup.append($controls); - if(postComponent) { - $controlGroup.append(postComponent); - } $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;'}); - if(cssForText) { - $component.css(cssForText); - } $component.text(text); - if(id) { - $component.attr('id', id); - } $controls.append($component); return $fieldset; @@ -107,40 +98,29 @@ var FormUtil = new function() { // // 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) { var $component = null; if (propertyType.dataType === "BOOLEAN") { - $component = this._getBooleanField(propertyType.code, propertyType.description); + $component = getBooleanField(propertyType.code, propertyType.description); } 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") { - $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") { - $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") { - $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") { - $component = this._getTextBox(propertyType.code, propertyType.description, propertyType.mandatory); + $component = getTextBox(propertyType.code, propertyType.description, propertyType.mandatory); } 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") { - $component = this._getDatePickerField(propertyType.code, propertyType.description, propertyType.mandatory); + $component = getDatePickerField(propertyType.code, propertyType.description, propertyType.mandatory); } 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") { - $component = this._getTextBox(propertyType.code, propertyType.description, propertyType.mandatory); + $component = getTextBox(propertyType.code, propertyType.description, propertyType.mandatory); } return $component; @@ -149,11 +129,11 @@ var FormUtil = new function() { // // 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 })); } - this._getDropDownFieldForVocabulary = function(code, terms, alt, isRequired) { + var getDropDownFieldForVocabulary = function(code, terms, alt, isRequired) { var $component = $("<select>", {'placeholder' : alt, 'class' : 'form-control'}); $component.attr('id', code); @@ -169,7 +149,7 @@ var FormUtil = new function() { 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'}); if (isRequired) { $component.attr('required', ''); @@ -180,7 +160,7 @@ var FormUtil = new function() { 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'}); if (isRequired) { $component.attr('required', ''); @@ -188,7 +168,7 @@ var FormUtil = new function() { 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 $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'}); -- GitLab