fixed minor issue on submit

This commit is contained in:
francescomangiacrapa 2020-11-06 11:27:57 +01:00
parent 733042b8bd
commit 25abea9473
1 changed files with 25 additions and 12 deletions

View File

@ -30,6 +30,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RootPanel;
/**
@ -64,7 +65,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
private LinkedHashMap<Long, List<GeoNaFormDataObject>> savedMap = new LinkedHashMap<Long, List<GeoNaFormDataObject>>();
//private List<MetaDataProfileBean> orderedListMetadataProfilesForGeona = null;
private boolean projectSavedWithSuccess;
/**
* This is the entry point method.
@ -119,6 +120,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
private void buildNewCards(Collection<GeoNaFormCardModel> orderedCards) {
projectSavedWithSuccess = false; //resetting state of saving
mainPanel.setLoaderVisible("Loading...", true);
resetUI();
//ordered values
@ -204,14 +206,20 @@ public class GeoPortalDataEntryApp implements EntryPoint {
final Modal modal = new Modal(true);
modal.setCloseVisible(false);
modal.setTitle("Saving project...");
modal.hide(false);
final HorizontalPanel modalContainerPanel = new HorizontalPanel();
final LoaderIcon loader = new LoaderIcon();
loader.setText("Trying to save the data, please wait...");
modal.add(loader);
modalContainerPanel.add(loader);
modal.add(modalContainerPanel);
GeoportalDataEntryServiceAsync.Util.getInstance().saveGeonaDataForms(saveGeonaDataFormsEvent.getListGeonaDataForms(), new AsyncCallback<CommitReport>() {
@Override
public void onFailure(Throwable caught) {
modalContainerPanel.clear();
modal.setCloseVisible(true);
try {
modal.remove(loader);
}catch (Exception e) {
@ -220,7 +228,6 @@ public class GeoPortalDataEntryApp implements EntryPoint {
alert.setType(AlertType.ERROR);
alert.setClose(false);
modal.add(alert);
modal.setCloseVisible(true);
//resetUI();
geoNaMainForm.enableButtonSave(true);
}
@ -235,6 +242,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
switch (result.getState()) {
case OK:
alert.setType(AlertType.SUCCESS);
projectSavedWithSuccess = true;
purgeFileUploaded();
break;
case WARN:
@ -250,7 +258,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
alert.setClose(false);
modal.add(alert);
modal.setCloseVisible(true);
try {
savedMap.put(result.getRecordId(), saveGeonaDataFormsEvent.getListGeonaDataForms());
}catch (Exception e) {
@ -274,17 +282,22 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onCreateNewProject(CreateNewProjectEvent newProjectEvent) {
//means the form was not submitted
if(savedMap.size()==0) {
boolean confirm = Window.confirm("Creating a new project, the current project (is not saved) and will be lost, Confirm?");
if(confirm)
// means the form was not submitted
if (savedMap.size() == 0) {
boolean confirm = Window.confirm(
"Creating a new project, the current project (is not saved) and will be lost, Confirm?");
if (confirm)
buildNewCards(orderedCards);
}else {
} else if (projectSavedWithSuccess) {
//means the project has been saved
buildNewCards(orderedCards);
} else {
//means the project reported one ore more errors after the submit
boolean confirm = Window.confirm("Creating a new project, the web-forms will be cleaned, Confirm?");
if(confirm)
if (confirm)
buildNewCards(orderedCards);
}
}
});
}