in progress Edit Mode

This commit is contained in:
Francesco Mangiacrapa 2021-09-29 16:13:39 +02:00
parent 8627416400
commit 378f9419a6
5 changed files with 133 additions and 60 deletions

View File

@ -1,7 +1,5 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui.edit; package org.gcube.portlets.user.geoportaldataentry.client.ui.edit;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV; import org.gcube.application.geoportalcommon.shared.products.paths.FileSetPathsDV;
@ -26,6 +24,7 @@ import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
/** /**
@ -41,12 +40,15 @@ public class EditModeRecord extends Composite {
@UiField @UiField
Tab tabRawUpdate; Tab tabRawUpdate;
@UiField
Tab tabUploadFiles;
@UiField @UiField
FlowPanel rawUpdatePanel; FlowPanel rawUpdatePanel;
@UiField @UiField
FlowPanel filesUpdatePanel; ScrollPanel filesUpdatePanel;
@UiField @UiField
Button buttonJSONUpdate; Button buttonJSONUpdate;
@ -81,6 +83,8 @@ public class EditModeRecord extends Composite {
this.selectedConcessione = selectedConcessione; this.selectedConcessione = selectedConcessione;
this.recordType = type; this.recordType = type;
this.appManagerBus = appManagerBus; this.appManagerBus = appManagerBus;
this.filesUpdatePanel.setHeight("490px");
//filesUpdatePanel.getElement().getStyle().setProperty("maxHeight", "550px");
instanceJSONEditor(); instanceJSONEditor();
instanceUpdateFilesetEditor(); instanceUpdateFilesetEditor();
@ -99,6 +103,7 @@ public class EditModeRecord extends Composite {
@Override @Override
public void onSuccess(FileSetPathsDV fileSetPaths) { public void onSuccess(FileSetPathsDV fileSetPaths) {
UpdateFileset updateFileset = new UpdateFileset(selectedConcessione, recordType, fileSetPaths.getFileSetPaths()); UpdateFileset updateFileset = new UpdateFileset(selectedConcessione, recordType, fileSetPaths.getFileSetPaths());
//updateFileset.setHeight("300px !important");
filesUpdatePanel.add(updateFileset); filesUpdatePanel.add(updateFileset);
} }
}); });

View File

@ -24,7 +24,8 @@
<b:Tab icon="PENCIL" active="true" heading="Edit the source" <b:Tab icon="PENCIL" active="true" heading="Edit the source"
ui:field="tabRawUpdate"> ui:field="tabRawUpdate">
<b:Heading size="3">Source Project Editor</b:Heading> <b:Heading size="3">Source Project Editor</b:Heading>
<b:Label type="INFO">You can update the Source Project by editing its model <b:Label type="INFO">You can update the Source Project by editing
its model
data displayed in the following Editor.</b:Label> data displayed in the following Editor.</b:Label>
<g:HTML addStyleNames="{style.info-panel}"> <g:HTML addStyleNames="{style.info-panel}">
<p style='color: #585858'> <p style='color: #585858'>
@ -41,7 +42,8 @@
del progetto") reported in del progetto") reported in
<span style='color: green'>green</span> <span style='color: green'>green</span>
by the by the
Editor <br/> Editor
<br />
<span>At the end of the changes press the "Update" button to make <span>At the end of the changes press the "Update" button to make
them persistent on the service</span> them persistent on the service</span>
</p> </p>
@ -49,15 +51,23 @@
<g:FlowPanel ui:field="rawUpdatePanel"> <g:FlowPanel ui:field="rawUpdatePanel">
</g:FlowPanel> </g:FlowPanel>
<b:Button icon="SAVE" type="INFO" <b:Button icon="SAVE" type="INFO"
addStyleNames="{style.button-save-style}" ui:field="buttonJSONUpdate">UPDATE</b:Button> addStyleNames="{style.button-save-style}"
ui:field="buttonJSONUpdate">UPDATE</b:Button>
</b:Tab> </b:Tab>
<b:Tab icon="UPLOAD_ALT" heading="Update File/s" <b:Tab icon="UPLOAD_ALT" heading="Update File/s"
ui:field="tabUploadFiles"> ui:field="tabUploadFiles">
<b:Heading size="3">Update the file/s</b:Heading> <b:Heading size="3">Update the file/s</b:Heading>
<b:Label type="INFO">By choosing a section (e.g. "relazione") and <b:Label type="INFO">By choosing a section (e.g. "relazione") and
uploading new file/s the old one/s will be replaced</b:Label> uploading new file/s the old one/s will be replaced</b:Label>
<g:FlowPanel ui:field="filesUpdatePanel"> <g:HTML addStyleNames="{style.info-panel}">
</g:FlowPanel> <p style='color: #585858'>
At the end of the changes press the "Update" button to
make
them persistent on the service
</p>
</g:HTML>
<g:ScrollPanel ui:field="filesUpdatePanel">
</g:ScrollPanel>
</b:Tab> </b:Tab>
</b:TabPanel> </b:TabPanel>
</g:HTMLPanel> </g:HTMLPanel>

View File

@ -11,7 +11,10 @@ import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScav
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE; import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.upload.MultipleDilaogUpload; import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField;
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.DataTypeWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ControlGroup; import com.github.gwtbootstrap.client.ui.ControlGroup;
@ -20,15 +23,18 @@ import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.constants.LabelType; import com.github.gwtbootstrap.client.ui.constants.LabelType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; 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.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
@ -42,7 +48,7 @@ import com.google.gwt.user.client.ui.Widget;
*/ */
public class UpdateFileset extends Composite { public class UpdateFileset extends Composite {
private static final String _700PX = "700px"; private static final String _FORM_FIELDS_SIZE = "740px";
private static final String UPLOAD_MISSING_FILE = "You must upload a file"; private static final String UPLOAD_MISSING_FILE = "You must upload a file";
@ -75,7 +81,7 @@ public class UpdateFileset extends Composite {
private List<String> listFileSetPaths; private List<String> listFileSetPaths;
private boolean placeholderRemoved = false; private boolean listBoxPathsPlaceholder = true;
private String recordId; private String recordId;
@ -85,9 +91,13 @@ public class UpdateFileset extends Composite {
private RECORD_TYPE recordType; private RECORD_TYPE recordType;
private MultipleDilaogUpload mDU; // private MultipleDilaogUpload mDU;
private ChangeHandler listBoxIndexHandler; private boolean listBoxIndexPlaceholder = true;
private HandlerManager uiBus = new HandlerManager(null);
private MetaDataField fieldUploadWidget;
/** /**
* Instantiates a new update fileset. * Instantiates a new update fileset.
@ -103,7 +113,7 @@ public class UpdateFileset extends Composite {
for (String path : listFileSetPaths) { for (String path : listFileSetPaths) {
listBoxPaths.addItem(path); listBoxPaths.addItem(path);
} }
listBoxPaths.setWidth(_700PX); listBoxPaths.setWidth(_FORM_FIELDS_SIZE);
// add handler on select // add handler on select
listBoxPaths.addChangeHandler(new ChangeHandler() { listBoxPaths.addChangeHandler(new ChangeHandler() {
@ -113,9 +123,9 @@ public class UpdateFileset extends Composite {
GWT.log("Profile type selection changed..."); GWT.log("Profile type selection changed...");
cgSelectFile.setVisible(false); cgSelectFile.setVisible(false);
if (!placeholderRemoved) { if (listBoxPathsPlaceholder) {
listBoxPaths.removeItem(0); // this is the placeholder listBoxPaths.removeItem(0); // this is the placeholder, removing it once
placeholderRemoved = true; listBoxPathsPlaceholder = false;
} }
showUploadFileGUI(); showUploadFileGUI();
} }
@ -141,12 +151,10 @@ public class UpdateFileset extends Composite {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
if (mDU != null) { if (checkValidUpload() == null) {
if (checkValidUpload()) { Window.alert("I can save...");
Window.alert("I can save..."); } else {
} else { Window.alert("New file not found. " + UPLOAD_MISSING_FILE);
Window.alert("New file not found. " + UPLOAD_MISSING_FILE);
}
} }
} }
@ -162,12 +170,14 @@ public class UpdateFileset extends Composite {
buttonUpdate.setVisible(false); buttonUpdate.setVisible(false);
uploadFileContainer.clear(); uploadFileContainer.clear();
controlsContent.clear(); controlsContent.clear();
listBoxIndexPlaceholder = true;
fieldUploadWidget = null;
// listBoxIndex.clear(); // listBoxIndex.clear();
cgSelectFile.setVisible(true); cgSelectFile.setVisible(true);
ListBox listBoxIndex = new ListBox(); ListBox listBoxIndex = new ListBox();
listBoxIndex.setWidth(_700PX); listBoxIndex.setWidth(_FORM_FIELDS_SIZE);
listBoxIndex.addItem("Select a content..."); listBoxIndex.addItem("Select a content...");
if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) { if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) {
@ -230,24 +240,11 @@ public class UpdateFileset extends Composite {
controlsContent.add(listBoxIndex); controlsContent.add(listBoxIndex);
// if (listBoxIndex.getItemCount() > 1) {
// listBoxIndex.addChangeHandler(new ChangeHandler() {
//
// @Override
// public void onChange(ChangeEvent event) {
// showFileBrowseInteraction();
// }
// });
// }
} }
private void fillListBoxToBeReplaced(ListBox listBoxIndex, String section, int posizIndex, String title, private void fillListBoxToBeReplaced(ListBox listBoxIndex, String section, int posizIndex, String title,
List<WorkspaceContentDV> listWSC) { List<WorkspaceContentDV> listWSC) {
// ListBox listBoxIndex = new ListBox();
// listBoxIndex.addItem("Select a content...");
if (listWSC == null || listWSC.isEmpty()) { if (listWSC == null || listWSC.isEmpty()) {
showMessage(section + " DOES NOT CONTAIN FILES", LabelType.WARNING); showMessage(section + " DOES NOT CONTAIN FILES", LabelType.WARNING);
return; return;
@ -257,42 +254,92 @@ public class UpdateFileset extends Composite {
// adding handler once // adding handler once
if (posizIndex == 0) { if (posizIndex == 0) {
listBoxIndex.addChangeHandler(new ChangeHandler() { listBoxIndex.addChangeHandler(new ChangeHandler() {
@Override @Override
public void onChange(ChangeEvent event) { public void onChange(ChangeEvent event) {
showFileBrowseInteraction();
if (listBoxIndexPlaceholder) {
listBoxIndex.removeItem(0); // this is the placeholder, removing it once
listBoxIndexPlaceholder = false;
}
showFileBrowseInteraction(listWSC);
} }
}); });
} }
// //
// controlsContent.add(listBoxIndex);
for (WorkspaceContentDV wsContent : listWSC) {
String name = wsContent.getName() == null || wsContent.getName().isEmpty() ? wsContent.getLink()
: wsContent.getName();
}
} }
private void showFileBrowseInteraction() { private void showFileBrowseInteraction(List<WorkspaceContentDV> listWSC) {
uploadFileContainer.clear(); uploadFileContainer.clear();
HTML label = new HTML();
label.setHTML("With new one:");
uploadFileContainer.add(label); if (listWSC.size() > 0) {
mDU = new MultipleDilaogUpload(); FlexTable table = new FlexTable();
uploadFileContainer.add(mDU); table.addStyleName("table-current-content");
buttonUpdate.setVisible(true); table.setHTML(0, 0, "<span style='color:rgb(155, 80, 78); font-weight:bold;'>Current content:</span>");
} table.setHTML(1, 0, "<span style='color:rgb(155, 80, 78);'>Filename</span>");
table.setHTML(1, 1, "<span style='color:rgb(155, 80, 78);'>MimeType<span>");
table.setHTML(1, 2, "<span style='color:rgb(155, 80, 78);'>Link</span>");
int i = 2;
for (WorkspaceContentDV wsContent : listWSC) {
table.setHTML(i, 0, wsContent.getName());
table.setHTML(i, 1, wsContent.getMimetype());
String link = "<a href=" + wsContent.getLink() + ">Download</a>";
table.setHTML(i, 2, link);
i++;
}
private boolean checkValidUpload() { uploadFileContainer.add(table);
GWT.log("Checking is valid File");
if (mDU.getFileUploadingState() != null && mDU.getFileUploadingState().getFile() != null) {
return mDU.getFileUploadingState().getFile().getTempSystemPath() != null;
} }
return false; HTML label = new HTML();
label.getElement().getStyle().setMarginTop(10, Unit.PX);
label.setHTML("<b>With new content:</b>");
uploadFileContainer.add(label);
// mDU = new MultipleDilaogUpload();
MetadataFieldWrapper uploadField = new MetadataFieldWrapper();
uploadField.setFieldName("File");
uploadField.setMandatory(true);
uploadField.setType(DataTypeWrapper.File);
uploadField.setMaxOccurs(1000);
try {
fieldUploadWidget = new MetaDataField(uploadField, uiBus);
//BrowseFilePanel fieldsetContent = new BrowseFilePanel(fieldUploadWidget);
uploadFileContainer.add(fieldUploadWidget);
buttonUpdate.setVisible(true);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Test if profile data are valid.
*
* @return the string
*/
private String checkValidUpload() {
for (MetaDataFieldSkeleton field : fieldUploadWidget.getListOfMetadataFields()) {
field.removeError();
String error = field.isFieldValueValid();
if (error != null) {
field.showError();
String errorMsg = field.getFieldNameOriginal() + " is not valid. Suggestion: " + error;
return errorMsg;
}
}
return null;
} }
private void showMessage(String txt, LabelType type) { private void showMessage(String txt, LabelType type) {

View File

@ -14,7 +14,7 @@
</ui:style> </ui:style>
<g:HTMLPanel> <g:HTMLPanel>
<b:Form type="INLINE"> <b:Form type="INLINE">
<b:Fieldset addStyleNames="form-fielset-edit"> <b:Fieldset addStyleNames="form-fieldset-edit">
<b:ControlGroup> <b:ControlGroup>
<b:ControlLabel>Section</b:ControlLabel> <b:ControlLabel>Section</b:ControlLabel>
<b:Controls> <b:Controls>
@ -30,7 +30,9 @@
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
<b:ControlGroup> <b:ControlGroup>
<g:HTMLPanel ui:field="uploadFileContainer"></g:HTMLPanel> <g:ScrollPanel>
<g:HTMLPanel ui:field="uploadFileContainer"></g:HTMLPanel>
</g:ScrollPanel>
</b:ControlGroup> </b:ControlGroup>
</b:Fieldset> </b:Fieldset>
</b:Form> </b:Form>

View File

@ -94,8 +94,17 @@ h1 {
pointer-events: none; pointer-events: none;
} }
.form-fielset-edit { .form-fieldset-edit {
margin: 10px 0px !important; margin: 10px 0px !important;
border: 1px groove #ddd !important; border: 1px groove #ddd !important;
padding: 10px !important; padding: 10px !important;
} }
.table-current-content {
width: 100%;
background-color: #efefef;
}
.table-current-content td {
padding: 5px;
}