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

View File

@ -24,7 +24,8 @@
<b:Tab icon="PENCIL" active="true" heading="Edit the source"
ui:field="tabRawUpdate">
<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>
<g:HTML addStyleNames="{style.info-panel}">
<p style='color: #585858'>
@ -41,7 +42,8 @@
del progetto") reported in
<span style='color: green'>green</span>
by the
Editor <br/>
Editor
<br />
<span>At the end of the changes press the "Update" button to make
them persistent on the service</span>
</p>
@ -49,15 +51,23 @@
<g:FlowPanel ui:field="rawUpdatePanel">
</g:FlowPanel>
<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 icon="UPLOAD_ALT" heading="Update File/s"
ui:field="tabUploadFiles">
<b:Heading size="3">Update the file/s</b:Heading>
<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>
<g:FlowPanel ui:field="filesUpdatePanel">
</g:FlowPanel>
<g:HTML addStyleNames="{style.info-panel}">
<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:TabPanel>
</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.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
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.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.constants.LabelType;
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.ChangeHandler;
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.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
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.HTMLPanel;
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 {
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";
@ -75,7 +81,7 @@ public class UpdateFileset extends Composite {
private List<String> listFileSetPaths;
private boolean placeholderRemoved = false;
private boolean listBoxPathsPlaceholder = true;
private String recordId;
@ -85,9 +91,13 @@ public class UpdateFileset extends Composite {
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.
@ -103,7 +113,7 @@ public class UpdateFileset extends Composite {
for (String path : listFileSetPaths) {
listBoxPaths.addItem(path);
}
listBoxPaths.setWidth(_700PX);
listBoxPaths.setWidth(_FORM_FIELDS_SIZE);
// add handler on select
listBoxPaths.addChangeHandler(new ChangeHandler() {
@ -113,9 +123,9 @@ public class UpdateFileset extends Composite {
GWT.log("Profile type selection changed...");
cgSelectFile.setVisible(false);
if (!placeholderRemoved) {
listBoxPaths.removeItem(0); // this is the placeholder
placeholderRemoved = true;
if (listBoxPathsPlaceholder) {
listBoxPaths.removeItem(0); // this is the placeholder, removing it once
listBoxPathsPlaceholder = false;
}
showUploadFileGUI();
}
@ -141,12 +151,10 @@ public class UpdateFileset extends Composite {
@Override
public void onClick(ClickEvent event) {
if (mDU != null) {
if (checkValidUpload()) {
Window.alert("I can save...");
} else {
Window.alert("New file not found. " + UPLOAD_MISSING_FILE);
}
if (checkValidUpload() == null) {
Window.alert("I can save...");
} else {
Window.alert("New file not found. " + UPLOAD_MISSING_FILE);
}
}
@ -162,12 +170,14 @@ public class UpdateFileset extends Composite {
buttonUpdate.setVisible(false);
uploadFileContainer.clear();
controlsContent.clear();
listBoxIndexPlaceholder = true;
fieldUploadWidget = null;
// listBoxIndex.clear();
cgSelectFile.setVisible(true);
ListBox listBoxIndex = new ListBox();
listBoxIndex.setWidth(_700PX);
listBoxIndex.setWidth(_FORM_FIELDS_SIZE);
listBoxIndex.addItem("Select a content...");
if (listBoxPaths.getSelectedItemText().contains("abstract_relazione")) {
@ -230,24 +240,11 @@ public class UpdateFileset extends Composite {
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,
List<WorkspaceContentDV> listWSC) {
// ListBox listBoxIndex = new ListBox();
// listBoxIndex.addItem("Select a content...");
if (listWSC == null || listWSC.isEmpty()) {
showMessage(section + " DOES NOT CONTAIN FILES", LabelType.WARNING);
return;
@ -257,42 +254,92 @@ public class UpdateFileset extends Composite {
// adding handler once
if (posizIndex == 0) {
listBoxIndex.addChangeHandler(new ChangeHandler() {
@Override
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();
HTML label = new HTML();
label.setHTML("With new one:");
uploadFileContainer.add(label);
mDU = new MultipleDilaogUpload();
uploadFileContainer.add(mDU);
buttonUpdate.setVisible(true);
}
if (listWSC.size() > 0) {
FlexTable table = new FlexTable();
table.addStyleName("table-current-content");
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() {
GWT.log("Checking is valid File");
if (mDU.getFileUploadingState() != null && mDU.getFileUploadingState().getFile() != null) {
return mDU.getFileUploadingState().getFile().getTempSystemPath() != null;
uploadFileContainer.add(table);
}
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) {

View File

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

View File

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