minor fix for actions allowed after product creation

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@132575 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-10-04 12:58:26 +00:00
parent adfc7a1e77
commit 169974e09b
2 changed files with 73 additions and 48 deletions

View File

@ -111,7 +111,7 @@ public class CreateDatasetForm extends Composite{
@UiField Anchor licenseUrlAnchor;
@UiField Paragraph unavailableUrl;
@UiField TagsPanel tagsPanel;
// info panels
@UiField Icon infoIconLicenses;
@UiField FocusPanel focusPanelLicenses;
@ -608,59 +608,72 @@ public class CreateDatasetForm extends Composite{
}else{
alertOnContinue("Checking if a product with such title already exists, please wait...", AlertType.INFO);
// better check for title (only if the dataset was not created.. if it is the case, fields are not frozen)
if(!titleTextBox.isEnabled())
actionsAfterOnContinue();
else{
alertOnContinue("Checking if a product with such title already exists, please wait...", AlertType.INFO);
// better check for title
ckanServices.datasetIdAlreadyExists(titleTextBox.getText(), new AsyncCallback<Boolean>() {
ckanServices.datasetIdAlreadyExists(titleTextBox.getText(), new AsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
@Override
public void onSuccess(Boolean result) {
if(result){
if(result){
alertOnContinue("Sorry but a product with such title already exists, try to change it", AlertType.WARNING);
}else{
// check what to do
if(isWorkspaceRequest){
// we need to show the page to handle resources one by one from the workspace
formFirstStep.setVisible(false);
boolean resourcesPresent = receivedBean.getResources() != null && receivedBean.getResources().size() > 0 ? true : false;
formSecondStep.setVisible(resourcesPresent);
formThirdStep.setVisible(!resourcesPresent);
// add the resources to the container panel
if(workspaceResourcesContainer.getWidget() == null)
workspaceResourcesContainer.add(resourcesTable);
alertOnContinue("Sorry but a product with such title already exists, try to change it", AlertType.WARNING);
}else{
// this is not a workspace request
formFirstStep.setVisible(false);
formThirdStep.setVisible(true);
actionsAfterOnContinue();
}
if(metadataProfilesFormatListbox.getSelectedItemText().equals(NONE_PROFILE))
selectedProfile.setText("");
else
selectedProfile.setText("Selected Profile is " + metadataProfilesFormatListbox.getSelectedItemText());
}
}
@Override
public void onFailure(Throwable caught) {
@Override
public void onFailure(Throwable caught) {
alertOnContinue("Sorry but there was a problem while checking if the inserted data are correct", AlertType.ERROR);
alertOnContinue("Sorry but there was a problem while checking if the inserted data are correct", AlertType.ERROR);
}
});
}
});
}
}
}
/**
* After onContinue ...
*/
private void actionsAfterOnContinue(){
// check what to do
if(isWorkspaceRequest){
// we need to show the page to handle resources one by one from the workspace
formFirstStep.setVisible(false);
boolean resourcesPresent = receivedBean.getResources() != null && receivedBean.getResources().size() > 0 ? true : false;
formSecondStep.setVisible(resourcesPresent);
formThirdStep.setVisible(!resourcesPresent);
// add the resources to the container panel
if(workspaceResourcesContainer.getWidget() == null)
workspaceResourcesContainer.add(resourcesTable);
}else{
// this is not a workspace request
formFirstStep.setVisible(false);
formThirdStep.setVisible(true);
}
if(metadataProfilesFormatListbox.getSelectedItemText().equals(NONE_PROFILE))
selectedProfile.setText("");
else
selectedProfile.setText("Selected Profile is " + metadataProfilesFormatListbox.getSelectedItemText());
}
@UiHandler("goBackButtonFirstStep")
void onGoBackButtonFirstStep(ClickEvent e){
@ -850,7 +863,6 @@ public class CreateDatasetForm extends Composite{
// add tabs to resources panel
tabPanel.selectTab(0);
// form container
AddResourceContainer container = new AddResourceContainer(datasetUrl);
container.add(tabPanel);
@ -879,7 +891,7 @@ public class CreateDatasetForm extends Composite{
* Prepare the info icons of all core metadata info
*/
private void prepareInfoIcons() {
// tags
tagsPanel.prepareIcon(popupOpenedIds);
@ -1173,6 +1185,10 @@ public class CreateDatasetForm extends Composite{
licenseListbox.setEnabled(false);
organizationsListbox.setEnabled(false);
addCustomFieldButton.setEnabled(false);
metadataProfilesFormatListbox.setEnabled(false);
for(CustomFieldEntry ce: customFieldEntriesList)
ce.freeze();
// disable profile fields
for (MetaDataFieldSkeleton field : listOfMetadataFields) {

View File

@ -41,13 +41,13 @@ public class CustomFieldEntry extends Composite {
public CustomFieldEntry(HandlerManager eventBus, String key, String value, boolean isCustomCreatedByUser) {
initWidget(uiBinder.createAndBindUi(this));
// save information
this.eventBus = eventBus;
this.value = value;
this.key = key;
this.isCustomCreatedByUser = isCustomCreatedByUser;
// remove the first appendbox
if(!isCustomCreatedByUser){
this.valueFieldPrepend.removeFromParent();
@ -63,11 +63,11 @@ public class CustomFieldEntry extends Composite {
public String getKey(){
if(isCustomCreatedByUser){
return ((TextBox)this.keyFieldPrepend.getWidget(1)).getText();
}
return key;
}
@ -77,11 +77,11 @@ public class CustomFieldEntry extends Composite {
* @return
*/
public String getValue(){
if(isCustomCreatedByUser){
return ((TextBox)this.valueFieldPrepend.getWidget(1)).getText();
}
return value;
@ -95,4 +95,13 @@ public class CustomFieldEntry extends Composite {
}
/**
* Remove delete button
*/
public void freeze() {
removeCustomField.setEnabled(false);
}
}