Provided the "View Document" and "View As JSON" facilities

This commit is contained in:
Francesco Mangiacrapa 2023-05-03 11:29:45 +02:00
parent cc15c66701
commit aae6504d25
6 changed files with 96 additions and 44 deletions

View File

@ -4,12 +4,13 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v3.2.0-SNAPSHOT] - 2022-02-09
## [v3.2.0-SNAPSHOT] - 2022-05-03
- Implemented the Update facility [#24166]
- Integrated with the geoportal-data-mapper library [#24244]
- Integrated the Geoportal Data-Viewer Widget [#25015]
- Passed to Geoportal_Resolver service [#25031]
- Provided the "View Document" and "View As JSON" facilities
## [v3.1.0] - 2023-03-06

View File

@ -56,6 +56,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainTabPanel;
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView;
import org.gcube.portlets.user.geoportaldataentry.client.ui.ModalWindow;
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.EditModeRecord;
import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.UpdateRecord;
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.LifecycleInformationPanel;
@ -879,13 +880,13 @@ public class GeoPortalDataEntryApp implements EntryPoint {
switch (createRelationHE.getRelactionActionType()) {
case DELETE: {
GcubeUserRole myRole = myRights.getRoleRights().getUserRole();
// TODO REMOVE THIS IF AFTER ADDING ALL THE OPERATIONS IN THE IS
// OPERATIONS/RIGHTS CONFIGURATION
if (!myRole.equals(GcubeUserRole.DATA_MANAGER) && !myRole.equals(GcubeUserRole.DATA_EDITOR)) {
String action = RELACTION_ACTION_TYPE.DELETE +" Relation";
String action = RELACTION_ACTION_TYPE.DELETE + " Relation";
String msg = "You are not authorized to perform the action: " + action;
ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()),
@ -893,7 +894,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
modalW.show();
return;
}
if (createRelationHE.getFromProject() == null || createRelationHE.getToProject() == null) {
DialogInform di = new DialogInform(null, "No selection", "You must select a Project");
di.center();
@ -1441,7 +1442,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
switch (action) {
case VIEW_ON_MAP: {
final Modal modal = new Modal(true, true);
modal.setTitle("Show on Map the Project...");
modal.setCloseVisible(true);
@ -1557,6 +1558,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
case EDIT_PROJECT: {
final Modal modal3 = new Modal(true, true);
modal3.setTitle(
"<span style='font-size:20px;'>Update Project with id: <span style='color:#555; font-size:20px;'>"
@ -1590,7 +1592,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
isNotInDRAFT = true;
}
}
UpdateRecord ur = new UpdateRecord(appManagerBus, resultDocumentDV.getProfileID(),
resultDocumentDV.getId(), width, height);
@ -1636,10 +1638,11 @@ public class GeoPortalDataEntryApp implements EntryPoint {
break;
}
//It is the show document
case SHOW_METADATA: {
GWT.log("VIEW SHOW_METADATA fired");
// It is the show document
case VIEW_PROJECT_AS_DOCUMENT: {
GWT.log("VIEW VIEW_PROJECT_AS_DOCUMENT fired");
final Modal modal = new Modal(true, true);
modal.setCloseVisible(true);
final int height = Window.getClientHeight() * 70 / 100;
@ -1688,6 +1691,27 @@ public class GeoPortalDataEntryApp implements EntryPoint {
break;
}
case VIEW_PROJECT_AS_JSON: {
GWT.log("VIEW VIEW_PROJECT_AS_JSON fired");
final Modal modal = new Modal(true, true);
modal.setCloseVisible(true);
final int height = Window.getClientHeight() * 70 / 100;
int width = Window.getClientWidth() * 70 / 100;
modal.setMaxHeigth("none");
modal.setWidth(width);
modal.setHeight(height + "px");
modal.setTitle(
"<span style='font-size:20px;'>View as JSON for Project ID: <span style='color:#555; font-size:20px;'>"
+ resultDocumentDV.getId() + "</span></span>");
EditModeRecord editMode = new EditModeRecord(appManagerBus, resultDocumentDV, height);
modal.add(editMode);
modal.show();
break;
}
case DELETE_PROJECT: {
String htmlMsg = "Going to delete the project with:";

View File

@ -97,9 +97,12 @@ public class GeonaMainTabPanel extends Composite {
@UiField
Tab tabGetListOfProjects;
@UiField
NavLink navView;
NavLink navViewAsDocument;
@UiField
NavLink navViewAsJSON;
@UiField
NavLink navShowOnMap;
@ -246,8 +249,8 @@ public class GeonaMainTabPanel extends Composite {
}
});
navView.addClickHandler(new ClickHandler() {
navViewAsDocument.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
@ -256,8 +259,23 @@ public class GeonaMainTabPanel extends Composite {
listDocuments = grpw.getSelectItems();
}
appManagerBus
.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.SHOW_METADATA));
appManagerBus.fireEvent(new OperationOnItemEvent<DocumentDV>(listDocuments,
OPERATION_ON_ITEM.VIEW_PROJECT_AS_DOCUMENT));
}
});
navViewAsJSON.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
List<DocumentDV> listDocuments = null;
if (grpw != null && grpw.getSelectItems() != null) {
listDocuments = grpw.getSelectItems();
}
appManagerBus.fireEvent(
new OperationOnItemEvent<DocumentDV>(listDocuments, OPERATION_ON_ITEM.VIEW_PROJECT_AS_JSON));
}
});
@ -474,21 +492,7 @@ public class GeonaMainTabPanel extends Composite {
GEOPORTAL_DATA_HANDLER.geoportal_data_list);
if (dataListHandler != null) {
// NavLink link = new NavLink(ucd.getName());
// link.addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent event) {
//
// appManagerBus.fireEvent(new GetListOfRecordsEvent(false, ucd.getProfileID(),
// getCurrentProjectsSearchingFilter(), true));
// }
// });
ucdProjectTypesForListingDataView.add(ucd);
// listOfProjectTablePanel.addProjectType(link);
listOfProjectTablePanel.addProjectType(ucd);
}

View File

@ -74,7 +74,8 @@
<g:HTMLPanel ui:field="introGNA">
<b:Hero ui:field="introGNAHero">
<b:Heading size="2" ui:field="welcomeTitle">Welcome
to GeoPortal Data Entry</b:Heading>
to GeoPortal Data
Entry</b:Heading>
<b:Paragraph ui:field="welcomeDescription"></b:Paragraph>
<b:Paragraph>select "Create New Project"</b:Paragraph>
</b:Hero>
@ -99,10 +100,14 @@
<g:FlowPanel>
<g:FlowPanel addStyleNames="move-sticky">
<b:NavPills>
<b:NavLink ui:field="navView" title="View Document"
icon="FILE">View Document</b:NavLink>
<b:NavLink ui:field="navViewAsDocument"
title="View Document" icon="FILE">View Document</b:NavLink>
<b:NavLink ui:field="navViewAsJSON"
title="View Document as JSON" icon="CODE">View as JSON</b:NavLink>
<b:Divider addStyleNames="{style.divider-border-right}" />
<b:NavLink ui:field="navShowOnMap" title="Show on Map"
icon="MAP_MARKER">Show on Map</b:NavLink>
<b:Divider addStyleNames="{style.divider-border-right}" />
<b:NavLink ui:field="navShowReport"
title="Show Publication Report" icon="FILE_TEXT_ALT">Publication Report</b:NavLink>
<b:NavLink ui:field="navEditMode" title="Edit"

View File

@ -14,8 +14,10 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.edit.jseditor.JSONEd
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.DialogInform;
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Tab;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
@ -27,11 +29,11 @@ import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
@ -68,6 +70,8 @@ public class EditModeRecord extends Composite {
private final HandlerManager editorManagerBus = new HandlerManager(null);
private int modalHeight;
/**
* The Interface EditModeRecordUiBinder.
*
@ -78,12 +82,14 @@ public class EditModeRecord extends Composite {
interface EditModeRecordUiBinder extends UiBinder<Widget, EditModeRecord> {
}
public EditModeRecord(HandlerManager appManagerBus, ResultDocumentDV selectedProject) {
public EditModeRecord(HandlerManager appManagerBus, ResultDocumentDV selectedProject, int modalHeight) {
initWidget(uiBinder.createAndBindUi(this));
this.modalHeight = modalHeight;
this.selectedProject = selectedProject;
this.appManagerBus = appManagerBus;
this.filesUpdatePanel.setHeight("490px");
// filesUpdatePanel.getElement().getStyle().setProperty("maxHeight", "550px");
this.filesUpdatePanel.setHeight((modalHeight - 50) + "px");
// filesUpdatePanel.getElement().modalHeight().setProperty("maxHeight",
// "550px");
// TODO Must be instanceUpdateFilesetEditor
tabUploadFiles.asWidget().getElement().getStyle().setVisibility(Visibility.HIDDEN);
@ -121,9 +127,14 @@ public class EditModeRecord extends Composite {
private void instanceJSONEditor() {
rawUpdatePanel.clear();
final HorizontalPanel hpLoader = new HorizontalPanel();
final LoaderIcon lc = new LoaderIcon("Loading Project... please wait");
hpLoader.add(lc);
rawUpdatePanel.add(hpLoader);
final FlowPanel fp = new FlowPanel();
fp.getElement().setId("jsoneditor" + Random.nextInt());
fp.setHeight("410px");
fp.setHeight((modalHeight - 160) + "px");
rawUpdatePanel.add(fp);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@ -134,6 +145,7 @@ public class EditModeRecord extends Composite {
@Override
public void onSuccess(String jsonData) {
hpLoader.clear();
GWT.log("Instance JSON Editor with: " + jsonData);
jsEditor = JSONEditorWrapper.init(fp.getElement().getId());
jsEditor.setName(selectedProject.getId());
@ -152,7 +164,13 @@ public class EditModeRecord extends Composite {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
rawUpdatePanel.clear();
Alert alert = new Alert(
"Sorry, I cannot show the source Project with id '" + selectedProject.getId()
+ "' Refresh an try again. Error: " + caught.getMessage(),
AlertType.ERROR);
alert.setClose(false);
rawUpdatePanel.add(alert);
}
});

View File

@ -21,13 +21,13 @@
<g:HTMLPanel>
<b:TabPanel tabPosition="left" ui:field="tabPanel">
<b:Tab icon="PENCIL" active="true" heading="Edit the Project"
<b:Tab icon="CODE" active="true" heading="Project"
ui:field="tabRawUpdate">
<b:Heading size="3">Source Project Editor</b:Heading>
<b:Label type="INFO">You can update the project by editing
<b:Heading size="3">Source Project as JSON</b:Heading>
<b:Label type="INFO" visible="false">You can update the project by editing
the
model data displayed in the following editor.</b:Label>
<g:HTML addStyleNames="{style.info-panel}">
<g:HTML visible="false" addStyleNames="{style.info-panel}">
<p style='color: #585858'>
Be careful not to change the
keys (e.g. nome, introduzione,
@ -52,7 +52,7 @@
</g:FlowPanel>
<b:Button icon="SAVE" type="INFO"
addStyleNames="{style.button-save-style}"
ui:field="buttonJSONUpdate">UPDATE</b:Button>
ui:field="buttonJSONUpdate" visible="false">UPDATE</b:Button>
</b:Tab>
<b:Tab icon="UPLOAD_ALT" heading="Manage File/s"
ui:field="tabUploadFiles">