added submit
This commit is contained in:
parent
ccde169dfb
commit
0681dd6b2c
|
@ -66,12 +66,10 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
CreateMetadataForm baseForm = new CreateMetadataForm(Arrays.asList(geonaForm.getMetadataProfileBean()));
|
||||
geonaForm.setMetadataForm(baseForm);
|
||||
String key = geonaForm.getMetadataProfileBean().getType();
|
||||
boolean isFormRepeatible = false;
|
||||
if(geonaForm.getFormCardTitle()!=null) {
|
||||
key = geonaForm.getFormCardTitle().getTitle();
|
||||
isFormRepeatible = geonaForm.getFormCardTitle().isInternalRepeatibleForm();
|
||||
}
|
||||
geoNaMainForm.addForm(geonaForm,isFormRepeatible);
|
||||
geoNaMainForm.addForm(key, geonaForm);
|
||||
mapForms.put(key, geonaForm);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ import java.util.List;
|
|||
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.MetadataFormCard;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Tab;
|
||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||
|
@ -15,6 +17,7 @@ import com.google.gwt.event.dom.client.ClickEvent;
|
|||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
@ -42,16 +45,17 @@ public class GeonaDataEntryMainForm extends Composite {
|
|||
initWidget(uiBinder.createAndBindUi(this));
|
||||
}
|
||||
|
||||
public void addForm(GeoNaFormCardModel geonFormModel, boolean isFormRepeatible){
|
||||
public void addForm(String tabHeading, GeoNaFormCardModel geonFormModel){
|
||||
listCards.add(geonFormModel);
|
||||
addForm(geonFormModel.getMetadataForm(), geonFormModel.getMetadataProfileBean().getType(), isFormRepeatible);
|
||||
createNewCard(tabHeading, geonFormModel);
|
||||
}
|
||||
|
||||
|
||||
private void addForm(final CreateMetadataForm createMetadataForm, String tabHeading, boolean repeatible){
|
||||
private void createNewCard(String tabHeading, final GeoNaFormCardModel geonFormModel){
|
||||
final Tab tab = new Tab();
|
||||
tab.setHeading(tabHeading);
|
||||
MetadataFormCard mfc = new MetadataFormCard(tab, createMetadataForm, repeatible);
|
||||
//MetadataFormCard mfc = new MetadataFormCard(tab, createMetadataForm, repeatible);
|
||||
MetadataFormCard mfc = new MetadataFormCard(tab,geonFormModel);
|
||||
listTabs.add(tab);
|
||||
mainTabPanel.add(tab);
|
||||
|
||||
|
@ -77,12 +81,32 @@ public class GeonaDataEntryMainForm extends Composite {
|
|||
@UiHandler("buttonSave")
|
||||
void saveData(ClickEvent e){
|
||||
|
||||
boolean canSave = true;
|
||||
|
||||
for (String metadataType : mapForms.keySet()) {
|
||||
MetadataFormCard card = mapForms.get(metadataType);
|
||||
boolean isValid = card.validateForm();
|
||||
card.setValidCard(isValid);
|
||||
if(isValid==false)
|
||||
canSave = false;
|
||||
}
|
||||
|
||||
List<GeoNaFormDataObject> listGoneFormObjects = new ArrayList<GeoNaFormDataObject>();
|
||||
|
||||
if(canSave) {
|
||||
for (String metadataType : mapForms.keySet()) {
|
||||
MetadataFormCard card = mapForms.get(metadataType);
|
||||
List<GenericDatasetBean> listGDB = new ArrayList<GenericDatasetBean>(card.getListForms().size());
|
||||
for (CreateMetadataForm form : card.getListForms()) {
|
||||
listGDB.add(form.getFormDataBean());
|
||||
|
||||
}
|
||||
listGoneFormObjects.add(new GeoNaFormDataObject(listGDB, card.getGeonaFormModel().getFormCardTitle()));
|
||||
}
|
||||
}
|
||||
|
||||
Window.alert("I cane save: "+listGoneFormObjects);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,35 +13,78 @@ import com.github.gwtbootstrap.client.ui.constants.IconType;
|
|||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The Class MetadataFormCard.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Oct 12, 2020
|
||||
*/
|
||||
public class MetadataFormCard {
|
||||
|
||||
/** The heading. */
|
||||
private String heading;
|
||||
|
||||
/** The tab. */
|
||||
private Tab tab;
|
||||
|
||||
/** The repeatible. */
|
||||
private boolean repeatible;
|
||||
|
||||
/** The list forms. */
|
||||
private List<CreateMetadataForm> listForms = new ArrayList<CreateMetadataForm>();
|
||||
|
||||
/** The form card event handler. */
|
||||
private MetadataFormCardEventHandler formCardEventHandler = new MetadataFormCardEventHandler();
|
||||
|
||||
/** The geona form model. */
|
||||
private GeoNaFormCardModel geonaFormModel;
|
||||
|
||||
/**
|
||||
* The Class MetadataFormCardEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Oct 12, 2020
|
||||
*/
|
||||
private class MetadataFormCardEventHandler implements GenericFormEventsListener{
|
||||
|
||||
/**
|
||||
* On form data valid.
|
||||
*
|
||||
* @param genericDatasetBean the generic dataset bean
|
||||
*/
|
||||
@Override
|
||||
public void onFormDataValid(GenericDatasetBean genericDatasetBean) {
|
||||
setTabStatus();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* On form data edit.
|
||||
*/
|
||||
@Override
|
||||
public void onFormDataEdit() {
|
||||
resetTabStatus();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* On form aborted.
|
||||
*/
|
||||
@Override
|
||||
public void onFormAborted() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* On validation error.
|
||||
*
|
||||
* @param throwable the throwable
|
||||
* @param errorMsg the error msg
|
||||
*/
|
||||
@Override
|
||||
public void onValidationError(Throwable throwable, String errorMsg) {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -50,14 +93,25 @@ public class MetadataFormCard {
|
|||
|
||||
}
|
||||
|
||||
public MetadataFormCard(Tab tab, CreateMetadataForm createMetadataForm, boolean repeatible) {
|
||||
/**
|
||||
* Instantiates a new metadata form card.
|
||||
*
|
||||
* @param tab the tab
|
||||
* @param geonaFormModel the geona form model
|
||||
*/
|
||||
public MetadataFormCard(Tab tab, GeoNaFormCardModel geonaFormModel) {
|
||||
this.tab = tab;
|
||||
this.repeatible = repeatible;
|
||||
this.buildCard(createMetadataForm);
|
||||
createMetadataForm.addListener(formCardEventHandler);
|
||||
|
||||
this.geonaFormModel = geonaFormModel;
|
||||
this.repeatible = geonaFormModel.getFormCardTitle().isInternalRepeatibleForm();
|
||||
this.buildCard(geonaFormModel.getMetadataForm());
|
||||
geonaFormModel.getMetadataForm().addListener(formCardEventHandler);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds the card.
|
||||
*
|
||||
* @param createMetadataForm the create metadata form
|
||||
*/
|
||||
private void buildCard(final CreateMetadataForm createMetadataForm) {
|
||||
|
||||
if(repeatible) {
|
||||
|
@ -70,6 +124,7 @@ public class MetadataFormCard {
|
|||
public void onClick(ClickEvent event) {
|
||||
CreateMetadataForm newForm = new CreateMetadataForm(createMetadataForm.getMetadataProfiles());
|
||||
addNewForm(newForm);
|
||||
//newForm.getCreateButton().setFocus(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -77,6 +132,11 @@ public class MetadataFormCard {
|
|||
addNewForm(createMetadataForm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the new form.
|
||||
*
|
||||
* @param newForm the new form
|
||||
*/
|
||||
private void addNewForm(final CreateMetadataForm newForm) {
|
||||
tab.add(newForm);
|
||||
listForms.add(newForm);
|
||||
|
@ -99,10 +159,20 @@ public class MetadataFormCard {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list forms.
|
||||
*
|
||||
* @return the list forms
|
||||
*/
|
||||
public List<CreateMetadataForm> getListForms() {
|
||||
return listForms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the heading.
|
||||
*
|
||||
* @return the heading
|
||||
*/
|
||||
public String getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
@ -121,6 +191,11 @@ public class MetadataFormCard {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the valid card.
|
||||
*
|
||||
* @param bool the new valid card
|
||||
*/
|
||||
public void setValidCard(boolean bool) {
|
||||
if(bool)
|
||||
tab.setIcon(IconType.OK_SIGN);
|
||||
|
@ -129,15 +204,25 @@ public class MetadataFormCard {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tab status.
|
||||
*/
|
||||
private void setTabStatus() {
|
||||
boolean isValid = validateForm();
|
||||
if(isValid)
|
||||
tab.setIcon(IconType.OK_SIGN);
|
||||
else
|
||||
tab.setIcon(IconType.REMOVE_SIGN);
|
||||
tab.setIcon(IconType.MINUS_SIGN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset tab status.
|
||||
*/
|
||||
private void resetTabStatus() {
|
||||
tab.setIcon(null);
|
||||
}
|
||||
|
||||
public GeoNaFormCardModel getGeonaFormModel() {
|
||||
return geonaFormModel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
||||
|
||||
public class GeoNaFormDataObject implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3620244260086172039L;
|
||||
|
||||
private List<GenericDatasetBean> listGDB;
|
||||
private ConcessioniFormCardTitle theType;
|
||||
|
||||
public GeoNaFormDataObject(){
|
||||
|
||||
}
|
||||
|
||||
public GeoNaFormDataObject(List<GenericDatasetBean> listGDB, ConcessioniFormCardTitle theType) {
|
||||
super();
|
||||
this.listGDB = listGDB;
|
||||
this.theType = theType;
|
||||
}
|
||||
|
||||
public List<GenericDatasetBean> getListGDB() {
|
||||
return listGDB;
|
||||
}
|
||||
|
||||
public void setListGDB(List<GenericDatasetBean> listGDB) {
|
||||
this.listGDB = listGDB;
|
||||
}
|
||||
public ConcessioniFormCardTitle getTheType() {
|
||||
return theType;
|
||||
}
|
||||
public void setTheType(ConcessioniFormCardTitle theType) {
|
||||
this.theType = theType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GeoNaFormDataObject [listGDB=" + listGDB + ", theType=" + theType + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue