fixed css. Improved Add Resources

This commit is contained in:
Francesco Mangiacrapa 2021-03-30 12:24:44 +02:00
parent a008757303
commit f0fcf09b0e
5 changed files with 47 additions and 18 deletions

View File

@ -12,6 +12,7 @@
border: 1px groove #444 !important;
box-shadow: 0px 0px 0px 0px #000 !important;
padding: 10px !important;
margin: 5px !important;
}
.legend-style {
@ -46,8 +47,10 @@
font-weight: bold;
}
.the-margin-left {
.the-margin-gotoitem {
margin-left: 5px;
margin-top: 10px;
margin-bottom: 10px;
}
</ui:style>
<g:HTMLPanel ui:field="createDatasetMainPanel">
@ -419,7 +422,7 @@
<g:Label>Go to the Item</g:Label>
<b:Button title="Go to the Item"
ui:field="goToDatasetButton" type="LINK" visible="false"
styleName="{style.the-margin-left}"></b:Button>
styleName="{style.the-margin-gotoitem}"></b:Button>
</g:HorizontalPanel>
<b:Button title="Add resources to the just created item"

View File

@ -319,8 +319,9 @@ public class MetaDataFieldSkeleton extends Composite{
// get vocabulary fields
List<String> vocabulary = field.getVocabulary();
GWT.log("Vocabulary: "+field.getFieldName());
for (String term : vocabulary) {
GWT.log("Adding term: "+term);
tempListBox.addItem(term);
}

View File

@ -7,9 +7,11 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElement
import com.github.gwtbootstrap.client.ui.AlertBlock;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.TextArea;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@ -53,6 +55,8 @@ public class AddResourceToDataset extends Composite{
@UiField Button addResourceButton;
@UiField AlertBlock infoBlock;
@UiField Button goToDatasetButton;
@UiField ControlGroup urlControlGroup;
@UiField ControlGroup nameControlGroup;
public AddResourceToDataset(HandlerManager eventBus, String datasetId, String datasetOrg, String owner, final String datasetUrl) {
initWidget(uiBinder.createAndBindUi(this));
@ -80,19 +84,31 @@ public class AddResourceToDataset extends Composite{
@UiHandler("addResourceButton")
void onAddButtonClick(ClickEvent e){
infoBlock.setVisible(false);
urlControlGroup.setType(ControlGroupType.NONE);
nameControlGroup.setType(ControlGroupType.NONE);
// validation
if(resourceUrlTextBox.getText().isEmpty() || resourceNameTextBox.getText().isEmpty()){
if (resourceUrlTextBox.getText().isEmpty()) {
showAlert("Url and name fields cannot be empty", AlertType.ERROR);
showAlert("'URL' field cannot be empty", AlertType.ERROR);
urlControlGroup.setType(ControlGroupType.ERROR);
return;
}
// validation
if (resourceNameTextBox.getText().isEmpty() || resourceNameTextBox.getText().isEmpty()) {
showAlert("'Name' field cannot be empty", AlertType.ERROR);
nameControlGroup.setType(ControlGroupType.ERROR);
return;
}
//THE URL must be HTTPS, see #21068
if(!(resourceNameTextBox.getText().toLowerCase().startsWith("https://"))){
showAlert("The URL must be HTTPS and starts with \"https://\" (e.g. https://your-resource.com)", AlertType.ERROR);
if(!(resourceUrlTextBox.getText().toLowerCase().startsWith("https://"))){
showAlert("The URL must be HTTPS, so start with \"https://\" (e.g. https://your-resource.com)", AlertType.ERROR);
urlControlGroup.setType(ControlGroupType.ERROR);
return;
}
@ -169,6 +185,6 @@ public class AddResourceToDataset extends Composite{
}
};
t.schedule(4000);
t.schedule(8000);
}
}

View File

@ -1,6 +1,7 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui" xmlns:g="urn:import:com.google.gwt.user.client.ui">
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
.form-main-style {
margin-left: 10px;
@ -56,19 +57,23 @@
is required
</small>
</b:Legend>
<b:Alert type="INFO" close="false">Only HTTPS URLs are allowed.
If you have a desktop file upload it to Workspace and use the 'Public Link' facility to get its HTTPS URL</b:Alert>
<b:ControlGroup>
<b:ControlGroup ui:field="urlControlGroup">
<b:ControlLabel for="url" title="File url">
<font color="red">*</font>
URL:
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" placeholder="https://example.com/image.jpg"
b:id="url" title="Product's title" ui:field="resourceUrlTextBox" />
<b:TextBox alternateSize="LARGE"
placeholder="https://example.com/image.jpg" b:id="url"
title="Product's title" ui:field="resourceUrlTextBox" />
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlGroup ui:field="nameControlGroup">
<b:ControlLabel for="name" title="Resource name">
<font color="red">*</font>
Name:
@ -80,19 +85,22 @@
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="description" title="Resource description">
<b:ControlLabel for="description"
title="Resource description">
Description:
</b:ControlLabel>
<b:Controls>
<b:TextArea alternateSize="LARGE"
placeholder="Some useful notes about data" b:id="description"
title="Resource description" ui:field="resourceDescriptionTextArea" />
title="Resource description"
ui:field="resourceDescriptionTextArea" />
</b:Controls>
</b:ControlGroup>
<!-- Alert blocks for info/errors -->
<b:AlertBlock type="INFO" animation="true" visible="false"
close="false" ui:field="infoBlock" styleName="{style.block-alert-style}"></b:AlertBlock>
<b:AlertBlock type="INFO" animation="true"
visible="false" close="false" ui:field="infoBlock"
styleName="{style.block-alert-style}"></b:AlertBlock>
<!-- Add resource button -->
<b:Button title="Add resource" ui:field="addResourceButton"

View File

@ -67,6 +67,7 @@
width: 100%;
border-collapse: separate;
display: table;
border-spacing: 5px;
}
.wizard-creator div {