errors are now highlighted to help the user to understand which is the mistake he is making
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@131460 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6468bd1a12
commit
2f791c50a6
|
@ -40,6 +40,7 @@ import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
import com.github.gwtbootstrap.client.ui.base.ListItem;
|
import com.github.gwtbootstrap.client.ui.base.ListItem;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||||
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.dom.client.Element;
|
import com.google.gwt.dom.client.Element;
|
||||||
|
@ -159,6 +160,10 @@ public class CreateDatasetForm extends Composite{
|
||||||
@UiField FocusPanel focusPanelResources;
|
@UiField FocusPanel focusPanelResources;
|
||||||
@UiField Popover popoverResources;
|
@UiField Popover popoverResources;
|
||||||
@UiField ControlGroup metadataProfilesControlGroup;
|
@UiField ControlGroup metadataProfilesControlGroup;
|
||||||
|
@UiField ControlGroup productTitleGroup;
|
||||||
|
@UiField ControlGroup maintainerControlGroup;
|
||||||
|
@UiField ControlGroup versionControlGroup;
|
||||||
|
@UiField ControlGroup organizationsGroup;
|
||||||
|
|
||||||
// error message
|
// error message
|
||||||
protected static final String ERROR_PRODUCT_CREATION = "There was an error while trying to publish your product, sorry.. Retry later";
|
protected static final String ERROR_PRODUCT_CREATION = "There was an error while trying to publish your product, sorry.. Retry later";
|
||||||
|
@ -966,9 +971,12 @@ public class CreateDatasetForm extends Composite{
|
||||||
private String areProfileDataValid() {
|
private String areProfileDataValid() {
|
||||||
|
|
||||||
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
||||||
|
|
||||||
|
field.removeError();
|
||||||
|
|
||||||
String error = field.isFieldValueValid();
|
String error = field.isFieldValueValid();
|
||||||
if(error != null){
|
if(error != null){
|
||||||
|
field.showError();
|
||||||
return field.getFieldName() + " is not valid. Suggestion: " + error;
|
return field.getFieldName() + " is not valid. Suggestion: " + error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1037,9 +1045,17 @@ public class CreateDatasetForm extends Composite{
|
||||||
private String validateDataOnContinue() {
|
private String validateDataOnContinue() {
|
||||||
|
|
||||||
String errorMessage = null;
|
String errorMessage = null;
|
||||||
|
|
||||||
|
// remove errors
|
||||||
|
productTitleGroup.setType(ControlGroupType.NONE);
|
||||||
|
maintainerControlGroup.setType(ControlGroupType.NONE);
|
||||||
|
versionControlGroup.setType(ControlGroupType.NONE);
|
||||||
|
metadataProfilesControlGroup.setType(ControlGroupType.NONE);
|
||||||
|
organizationsGroup.setType(ControlGroupType.NONE);
|
||||||
|
|
||||||
if(titleTextBox.getText().isEmpty()){
|
if(titleTextBox.getText().isEmpty()){
|
||||||
errorMessage = "Missing title";
|
errorMessage = "Missing title";
|
||||||
|
productTitleGroup.setType(ControlGroupType.ERROR);
|
||||||
return errorMessage;
|
return errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1049,8 +1065,10 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
for (String word : splittedTitle) {
|
for (String word : splittedTitle) {
|
||||||
|
|
||||||
if(!word.matches(regexTitleSubWord))
|
if(!word.matches(regexTitleSubWord)){
|
||||||
|
productTitleGroup.setType(ControlGroupType.ERROR);
|
||||||
return "Please note that only alphanumeric characters are allowed for the title";
|
return "Please note that only alphanumeric characters are allowed for the title";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,6 +1076,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
String regexMail = "\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b";
|
String regexMail = "\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b";
|
||||||
if(!validateByRegExpression(maintainerEmailTextbox.getText(), regexMail)){
|
if(!validateByRegExpression(maintainerEmailTextbox.getText(), regexMail)){
|
||||||
errorMessage = "Not valid maintainer email";
|
errorMessage = "Not valid maintainer email";
|
||||||
|
maintainerControlGroup.setType(ControlGroupType.ERROR);
|
||||||
return errorMessage;
|
return errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1065,15 +1084,18 @@ public class CreateDatasetForm extends Composite{
|
||||||
try{
|
try{
|
||||||
Integer.valueOf(versionTextbox.getText());
|
Integer.valueOf(versionTextbox.getText());
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
versionControlGroup.setType(ControlGroupType.ERROR);
|
||||||
return errorMessage = "Version must be a natural number";
|
return errorMessage = "Version must be a natural number";
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if metadata profile is different from none and its mandatory fields have been fulfilled
|
// check if metadata profile is different from none and its mandatory fields have been fulfilled
|
||||||
if(checkSelectedMetaDataProfile()){
|
if(checkSelectedMetaDataProfile()){
|
||||||
errorMessage = "You must select a metadata profile different frome none";
|
errorMessage = "You must select a metadata profile different frome none";
|
||||||
|
metadataProfilesControlGroup.setType(ControlGroupType.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(organizationsListbox.getSelectedItemText() == null){
|
if(organizationsListbox.getSelectedItemText() == null){
|
||||||
|
organizationsGroup.setType(ControlGroupType.ERROR);
|
||||||
errorMessage = "You must select an organization in which you want to publish";
|
errorMessage = "You must select an organization in which you want to publish";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
<b:AlertBlock type="INFO" close="false" animation="true"
|
<b:AlertBlock type="INFO" close="false" animation="true"
|
||||||
visible="false" ui:field="infoBlock" styleName="{style.block-alert-style}"></b:AlertBlock>
|
visible="false" ui:field="infoBlock" styleName="{style.block-alert-style}"></b:AlertBlock>
|
||||||
|
|
||||||
<b:ControlGroup>
|
<b:ControlGroup ui:field="productTitleGroup" >
|
||||||
<b:ControlLabel for="title" title="Product title">
|
<b:ControlLabel for="title" title="Product title">
|
||||||
<font color="red">*</font>
|
<font color="red">*</font>
|
||||||
Title :
|
Title :
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
</b:Controls>
|
</b:Controls>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
|
|
||||||
<b:ControlGroup>
|
<b:ControlGroup ui:field="organizationsGroup">
|
||||||
<b:ControlLabel for="organization"
|
<b:ControlLabel for="organization"
|
||||||
title="Select the organizations in which you want
|
title="Select the organizations in which you want
|
||||||
to publish the product">Publish in:</b:ControlLabel>
|
to publish the product">Publish in:</b:ControlLabel>
|
||||||
|
@ -162,7 +162,7 @@
|
||||||
</b:Controls>
|
</b:Controls>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
|
|
||||||
<b:ControlGroup>
|
<b:ControlGroup ui:field="versionControlGroup">
|
||||||
<b:ControlLabel for="version"
|
<b:ControlLabel for="version"
|
||||||
title="Product version expressed as positive integer number">
|
title="Product version expressed as positive integer number">
|
||||||
Version:
|
Version:
|
||||||
|
@ -193,7 +193,7 @@
|
||||||
</b:Controls>
|
</b:Controls>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
|
|
||||||
<b:ControlGroup>
|
<b:ControlGroup ui:field="authorEmailControlGroup">
|
||||||
<b:ControlLabel for="email" title="Product author's email">
|
<b:ControlLabel for="email" title="Product author's email">
|
||||||
<font color="red">*</font>
|
<font color="red">*</font>
|
||||||
Author Email:
|
Author Email:
|
||||||
|
@ -232,7 +232,7 @@
|
||||||
</b:Controls>
|
</b:Controls>
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
|
|
||||||
<b:ControlGroup>
|
<b:ControlGroup ui:field="maintainerControlGroup">
|
||||||
<b:ControlLabel for="emailMaintaner" title="Product author's email">
|
<b:ControlLabel for="emailMaintaner" title="Product author's email">
|
||||||
Maintainer Email:
|
Maintainer Email:
|
||||||
</b:ControlLabel>
|
</b:ControlLabel>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataFieldWr
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.CheckBox;
|
import com.github.gwtbootstrap.client.ui.CheckBox;
|
||||||
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||||
import com.github.gwtbootstrap.client.ui.ControlLabel;
|
import com.github.gwtbootstrap.client.ui.ControlLabel;
|
||||||
import com.github.gwtbootstrap.client.ui.Controls;
|
import com.github.gwtbootstrap.client.ui.Controls;
|
||||||
import com.github.gwtbootstrap.client.ui.Icon;
|
import com.github.gwtbootstrap.client.ui.Icon;
|
||||||
|
@ -17,6 +18,7 @@ import com.github.gwtbootstrap.client.ui.ListBox;
|
||||||
import com.github.gwtbootstrap.client.ui.Popover;
|
import com.github.gwtbootstrap.client.ui.Popover;
|
||||||
import com.github.gwtbootstrap.client.ui.TextArea;
|
import com.github.gwtbootstrap.client.ui.TextArea;
|
||||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||||
import com.github.gwtbootstrap.datetimepicker.client.ui.DateTimeBox;
|
import com.github.gwtbootstrap.datetimepicker.client.ui.DateTimeBox;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -61,6 +63,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
@UiField Controls controls;
|
@UiField Controls controls;
|
||||||
@UiField Icon infoIcon;
|
@UiField Icon infoIcon;
|
||||||
@UiField FocusPanel focusPanelIconContainer;
|
@UiField FocusPanel focusPanelIconContainer;
|
||||||
|
@UiField ControlGroup metafieldControlGroup;
|
||||||
|
|
||||||
private static final String REGEX_IS_NUMBER = "[0-9]+[.]?[0-9]+";
|
private static final String REGEX_IS_NUMBER = "[0-9]+[.]?[0-9]+";
|
||||||
|
|
||||||
|
@ -848,4 +851,16 @@ public class MetaDataFieldSkeleton extends Composite{
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeError() {
|
||||||
|
|
||||||
|
metafieldControlGroup.setType(ControlGroupType.NONE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showError() {
|
||||||
|
|
||||||
|
metafieldControlGroup.setType(ControlGroupType.ERROR);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -23,7 +23,7 @@
|
||||||
}
|
}
|
||||||
</ui:style>
|
</ui:style>
|
||||||
<g:HTMLPanel width="100%">
|
<g:HTMLPanel width="100%">
|
||||||
<b:ControlGroup>
|
<b:ControlGroup ui:field="metafieldControlGroup">
|
||||||
<b:ControlLabel ui:field="controlLabel">
|
<b:ControlLabel ui:field="controlLabel">
|
||||||
<font color="red" ui:field="mandatorySymbol">*</font>
|
<font color="red" ui:field="mandatorySymbol">*</font>
|
||||||
<span ui:field="name"></span>
|
<span ui:field="name"></span>
|
||||||
|
|
|
@ -348,7 +348,7 @@ public class Utils {
|
||||||
for(MetadataField metadataField: toWrap){
|
for(MetadataField metadataField: toWrap){
|
||||||
|
|
||||||
MetadataFieldWrapper wrapperObj = new MetadataFieldWrapper();
|
MetadataFieldWrapper wrapperObj = new MetadataFieldWrapper();
|
||||||
wrapperObj.setDefaultValue(metadataField.getDefaulValue());
|
wrapperObj.setDefaultValue(metadataField.getDefaultValue());
|
||||||
wrapperObj.setFieldName(metadataField.getFieldName());
|
wrapperObj.setFieldName(metadataField.getFieldName());
|
||||||
wrapperObj.setType(DataType.valueOf(metadataField.getDataType().toString()));
|
wrapperObj.setType(DataType.valueOf(metadataField.getDataType().toString()));
|
||||||
wrapperObj.setMandatory(metadataField.getMandatory());
|
wrapperObj.setMandatory(metadataField.getMandatory());
|
||||||
|
|
Loading…
Reference in New Issue