Fired event after Record Updated

pull/4/head
Francesco Mangiacrapa 3 years ago
parent 9d3f3bf380
commit 3df7ab1787

@ -38,7 +38,7 @@ public class ConstantsGeoPortalDataEntryApp {
* Aug 6, 2021
*/
public enum ACTION_ON_ITEM {
SHOW_ON_MAP, SHOW_METADATA, SHOW_REPORT, DELETE_RECORD, EDIT_RECORD
SHOW_ON_MAP, SHOW_METADATA, SHOW_REPORT, SHOW_EDIT_MODE, DELETE_RECORD, UPDATED_RECORD
}
/**

@ -75,7 +75,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
private static final String DIV_PORTLET_ID = "geoportal-data-entry";
public static final GeoportalDataEntryServiceAsync geoportalDataEntryService = GWT.create(GeoportalDataEntryService.class);
public static final GeoportalDataEntryServiceAsync geoportalDataEntryService = GWT
.create(GeoportalDataEntryService.class);
private final HandlerManager appManagerBus = new HandlerManager(null);
@ -151,7 +152,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
int topBorder = workspace.getAbsoluteTop();
int footer = 85; // footer is bottombar + sponsor
int headerSize = 90;
//int headerSize = 30;
// int headerSize = 30;
int rootHeight = Window.getClientHeight() - topBorder - headerSize - footer;// - ((footer ==
// null)?0:(footer.getOffsetHeight()-15));
@ -428,8 +429,12 @@ public class GeoPortalDataEntryApp implements EntryPoint {
@Override
public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) {
SortFilter sortFilter = getListOfRecordsEvent.getSortFilter();
if(sortFilter==null){
sortFilter = mainTabPanel.getCurrentSortFilter();
}
grpw = new GeonaRecordsPaginatedView(appManagerBus, RECORD_TYPE.CONCESSIONE, null,
getListOfRecordsEvent.getSortFilter());
sortFilter);
mainTabPanel.showListOfConcessioniView(grpw);
}
});
@ -505,7 +510,8 @@ public class GeoPortalDataEntryApp implements EntryPoint {
case SHOW_REPORT:
final Modal modal2 = new Modal(true, true);
modal2.setTitle("Report <div style='color:#555; font-size:22px;'>"+concessione.getNome()+"</div>");
modal2.setTitle("Report <div style='color:#555; font-size:22px;'>" + concessione.getNome()
+ "</div>");
modal2.setWidth(800);
modal2.setCloseVisible(true);
if (concessione.getValidationReport() == null) {
@ -518,18 +524,27 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modal2.show();
break;
case EDIT_RECORD:
case SHOW_EDIT_MODE:
final Modal modal3 = new Modal(true, true);
modal3.setTitle("Edit <div style='color:#555; font-size:22px;'>"+concessione.getNome()+"</div>");
modal3.setTitle("Edit <div style='color:#555; font-size:22px;'>" + concessione.getNome()
+ "</div>");
modal3.setWidth(950);
modal3.setHeight("700px");
modal3.setCloseVisible(true);
((Element)modal3.getElement().getChildNodes().getItem(1)).addClassName("modal-body-custom");
EditModeRecord emr = new EditModeRecord(concessione,RECORD_TYPE.CONCESSIONE);
((Element) modal3.getElement().getChildNodes().getItem(1))
.addClassName("modal-body-custom");
EditModeRecord emr = new EditModeRecord(appManagerBus, concessione,
RECORD_TYPE.CONCESSIONE);
modal3.add(emr);
modal3.show();
break;
case UPDATED_RECORD:
appManagerBus.fireEvent(
new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
mainTabPanel.getCurrentSortFilter()));
break;
case DELETE_RECORD:
String htmlMsg = "Going to delete the project with:";

@ -21,7 +21,7 @@ public class ActionOnItemEvent<T extends RecordDV> extends GwtEvent<ActionOnItem
private ACTION_ON_ITEM action;
/**
* Instantiates a new click item event.
* Instantiates a new action on item event.
*
* @param selectItems the select items
* @param doAction the do action
@ -81,6 +81,11 @@ public class ActionOnItemEvent<T extends RecordDV> extends GwtEvent<ActionOnItem
return action;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();

@ -237,7 +237,7 @@ public class GeonaMainTabPanel extends Composite {
listConcessioni = grpw.getSelectItems();
}
appManagerBus
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.EDIT_RECORD));
.fireEvent(new ActionOnItemEvent<ConcessioneDV>(listConcessioni, ACTION_ON_ITEM.SHOW_EDIT_MODE));
}
});

@ -2,7 +2,9 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit;
import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.ACTION_ON_ITEM;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
import org.gcube.portlets.user.geoportaldataentry.client.events.ActionOnItemEvent;
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor.JSONEditorWrapper;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
@ -12,6 +14,7 @@ import com.github.gwtbootstrap.client.ui.Tab;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Random;
@ -51,6 +54,8 @@ public class EditModeRecord extends Composite {
private JSONEditorWrapper jsEditor;
private HandlerManager appManagerBus;
/**
* The Interface EditModeRecordUiBinder.
*
@ -64,26 +69,28 @@ public class EditModeRecord extends Composite {
/**
* Instantiates a new edits the mode record.
*
* @param appManagerBus the app manager bus
* @param selectedConcessione the selected concessione
* @param type the type
*/
public EditModeRecord(BaseConcessioneDV selectedConcessione, RECORD_TYPE type) {
public EditModeRecord(HandlerManager appManagerBus, BaseConcessioneDV selectedConcessione, RECORD_TYPE type) {
initWidget(uiBinder.createAndBindUi(this));
this.selectedConcessione = selectedConcessione;
this.recordType = type;
this.appManagerBus = appManagerBus;
instanceJSONEditor();
bindEvents();
}
private void instanceJSONEditor() {
rawUpdatePanel.clear();
final FlowPanel fp = new FlowPanel();
fp.getElement().setId("jsoneditor" + Random.nextInt());
fp.setHeight("400px");
rawUpdatePanel.add(fp);
GeoPortalDataEntryApp.geoportalDataEntryService.getJSONRecord(selectedConcessione.getItemId(), recordType,
new AsyncCallback<String>() {
@ -138,6 +145,9 @@ public class EditModeRecord extends Composite {
// TODO: handle exception
}
appManagerBus.fireEvent(
new ActionOnItemEvent<ConcessioneDV>(null, ACTION_ON_ITEM.UPDATED_RECORD));
}
@Override
@ -152,8 +162,9 @@ public class EditModeRecord extends Composite {
selectedConcessione = result;
instanceJSONEditor();
Window.alert("Project '"+result.getNome()+"' updated correctly");
Window.alert("Project '" + result.getNome() + "' updated correctly");
appManagerBus.fireEvent(
new ActionOnItemEvent<ConcessioneDV>(null, ACTION_ON_ITEM.UPDATED_RECORD));
}
});

@ -2,11 +2,30 @@ package org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor;
import com.google.gwt.core.client.JavaScriptObject;
/**
* The Class JSONEditorWrapper.
*
* Wrapper for https://github.com/josdejong/jsoneditor
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 27, 2021
*/
public class JSONEditorWrapper extends JavaScriptObject {
/**
* Instantiates a new JSON editor wrapper.
*/
protected JSONEditorWrapper() {
}
/**
* Inits the.
*
* @param divID the div ID
* @return the JSON editor wrapper
*/
public static native JSONEditorWrapper init(String divID) /*-{
var container = $doc.getElementById(divID);
var options = {
@ -20,6 +39,11 @@ public class JSONEditorWrapper extends JavaScriptObject {
return new $wnd.JSONEditor(container, options);
}-*/;
/**
* Sets the.
*
* @param json the json
*/
public final native void set(String json) /*-{
var toJSONObject = JSON.parse(json);
// set json
@ -28,19 +52,37 @@ public class JSONEditorWrapper extends JavaScriptObject {
this.refresh();
}-*/;
/**
* Gets the text.
*
* @return the text
*/
public final native String getText() /*-{
console.log("this.get(): " +this.getText());
return this.getText();
}-*/;
/**
* On error.
*/
public final native void onError() /*-{
this.onError(error);
}-*/;
/**
* Sets the mode.
*
* @param mode the new mode
*/
public final native void setMode(String mode) /*-{
this.setMode(mode);
}-*/;
/**
* Sets the name.
*
* @param rootName the new name
*/
public final native void setName(String rootName) /*-{
this.setName(rootName);
}-*/;

Loading…
Cancel
Save