From a7a53f8b48ffe1365e3738f1fb4fc5ceb9a0594a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 16 May 2024 12:30:02 +0200 Subject: [PATCH 1/8] starting #27488 --- CHANGELOG.md | 6 ++++++ pom.xml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d82955..5dfcb36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ 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). +## [v2.2.0-SNAPSHOT] - 2024-05-16 + +#### Enhancements + +- [#27488] In edit mode allowed to delete fields according to data type + ## [v2.1.1] - 2024-03-19 #### Enhancements diff --git a/pom.xml b/pom.xml index ad56ef7..9c31f47 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.widgets metadata-profile-form-builder-widget jar - 2.1.1 + 2.2.0-SNAPSHOT Metadata Profile Form Builder The Metadata Profile Form Builder is a widget able to build dynamically a web form by reading "gCube Metadata Profile/s" From 9a98135759580e1db1929b6ddb635c795fea0c8f Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 24 May 2024 15:57:04 +0200 Subject: [PATCH 2/8] in progress --- CHANGELOG.md | 4 +- .../ui/metadata/MetaDataFieldSkeleton.java | 257 ++++++++++++++---- .../ui/metadata/MetaDataFieldSkeleton.ui.xml | 42 ++- .../client/ui/upload/DialogUpload.java | 16 ++ .../client/ui/upload/TimerUpload.java | 4 + .../shared/metadata/ErasableField.java | 6 + .../shared/metadata/MetadataFieldWrapper.java | 13 +- 7 files changed, 275 insertions(+), 67 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/ErasableField.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dfcb36..de4422f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,11 @@ 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). -## [v2.2.0-SNAPSHOT] - 2024-05-16 +## [v2.2.0-SNAPSHOT] - 2024-05-17 #### Enhancements -- [#27488] In edit mode allowed to delete fields according to data type +- [#27488] In edit mode allowed to erase (not mandatory) fields according to data type ## [v2.1.1] - 2024-03-19 diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java index 3542b48..777fca0 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java @@ -58,10 +58,24 @@ import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; +/** + * The Class MetaDataFieldSkeleton. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * May 20, 2024 + */ public class MetaDataFieldSkeleton extends Composite { private static MetaDataFieldSkeletonUiBinder uiBinder = GWT.create(MetaDataFieldSkeletonUiBinder.class); + /** + * The Interface MetaDataFieldSkeletonUiBinder. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * May 20, 2024 + */ interface MetaDataFieldSkeletonUiBinder extends UiBinder { } @@ -85,6 +99,11 @@ public class MetaDataFieldSkeleton extends Composite { FocusPanel focusPanelIconContainer; @UiField ControlGroup metafieldControlGroup; + + @UiField + Button eraseButton; + @UiField + FlowPanel eraseFieldContainer; // private static final String REGEX_IS_NUMBER = "[0-9]+[.]?[0-9]+"; @@ -122,16 +141,26 @@ public class MetaDataFieldSkeleton extends Composite { private static final String UPLOAD_MISSING_FILE = "You must upload a file"; + /** + * Instantiates a new meta data field skeleton. + * + * @param field the field + * @param eventBus the event bus + * @param operation the operation + * @throws Exception the exception + */ public MetaDataFieldSkeleton(final MetadataFieldWrapper field, HandlerManager eventBus, OPERATION operation) throws Exception { initWidget(uiBinder.createAndBindUi(this)); // prepare information this.field = field; - // event bus this.eventBus = eventBus; + eraseFieldContainer.setVisible(false); + eraseButton.setIcon(IconType.BAN_CIRCLE); + // bind bind(); @@ -420,11 +449,7 @@ public class MetaDataFieldSkeleton extends Composite { // if it is not mandatory and not multi-selection, add a disabled option // (placeholder) if (!field.getMandatory() && !field.isMultiSelection()) { - tempListBox.addItem("Select " + field.getFieldName()); - tempListBox.setValue(0, ""); - tempListBox.getElement().getElementsByTagName("option").getItem(0).setAttribute("disabled", - "disabled"); - tempListBox.setSelectedValue("Select " + field.getFieldName()); + listBoxSelectPlaceholder(tempListBox); } // get vocabulary fields @@ -438,23 +463,23 @@ public class MetaDataFieldSkeleton extends Composite { if (field.getDefaultValue() != null) tempListBox.setSelectedValue(field.getDefaultValue()); - //to be sure + // to be sure tempListBox.setMultipleSelect(field.isMultiSelection()); - + if (operation.equals(OPERATION.UPDATE)) { try { if (field.getCurrentValues() != null) { if (field.isMultiSelection()) { - //Buggy in Bootstrap + // Buggy in Bootstrap for (String value : field.getCurrentValues()) { - GWT.log("Multiple Selecting: "+value); + GWT.log("Multiple Selecting: " + value); tempListBox.setSelectedValue((String) value); } - }else { - GWT.log("Selecting: "+field.getCurrentSingleValue()); + } else { + GWT.log("Selecting: " + field.getCurrentSingleValue()); tempListBox.setSelectedValue((String) field.getCurrentSingleValue()); } - + } } catch (Exception e) { // TODO: handle exception @@ -505,6 +530,11 @@ public class MetaDataFieldSkeleton extends Composite { holder.setWidth("96%"); else holder.setWidth("95%"); + + //If the field is erasable views the erase panel + if(field.isErasableField()) { + eraseFieldContainer.setVisible(true); + } // set the notes, if any, and the popover if (field.getNote() != null && !field.getNote().isEmpty()) { @@ -541,7 +571,7 @@ public class MetaDataFieldSkeleton extends Composite { } /** - * Bind on events + * Bind on events. */ private void bind() { @@ -557,8 +587,22 @@ public class MetaDataFieldSkeleton extends Composite { } }); + eraseButton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + erase(); + + } + }); + } + /** + * On info icon click. + * + * @param c the c + */ @UiHandler("focusPanelIconContainer") void onInfoIconClick(ClickEvent c) { @@ -577,8 +621,8 @@ public class MetaDataFieldSkeleton extends Composite { } /** - * Check if this field has valid values - * + * Check if this field has valid values. + * * @return a string with the occurred error on error, null otherwise */ public String isFieldValueValid() { @@ -764,10 +808,10 @@ public class MetaDataFieldSkeleton extends Composite { } /** - * Check if this string is a number - * - * @param numberValue - * @return + * Check if this string is a number. + * + * @param numberValue the number value + * @return true, if is a number */ private boolean isANumber(String numberValue) { return numberValue.matches("-?\\d+(\\.\\d+)?"); @@ -776,9 +820,9 @@ public class MetaDataFieldSkeleton extends Composite { /** * Check if value matches validator (regex). In case validator is null, true is * returned. - * - * @param value - * @param validator + * + * @param value the value + * @param validator the validator * @return true if validator is null OR value.matches(reges), false otherwise */ private boolean checkValidator(String value, String validator) { @@ -793,8 +837,8 @@ public class MetaDataFieldSkeleton extends Composite { /** * Returns the current value of the field. In case of TimeInterval or TimeList * see getTimeIntervalOrTimeListWithoutMissing() - * - * @return + * + * @return the field current value */ public List getFieldCurrentValue() { @@ -918,9 +962,9 @@ public class MetaDataFieldSkeleton extends Composite { } /** - * Returns the current name of the field - * - * @return + * Returns the current name of the field. + * + * @return the field name original */ public String getFieldNameOriginal() { @@ -929,28 +973,135 @@ public class MetaDataFieldSkeleton extends Composite { } /** - * Returns the current name of the field - * - * @return + * Returns the current name of the field. + * + * @return the field name qualified */ public String getFieldNameQualified() { - //see https://support.d4science.org/issues/23544 + // see https://support.d4science.org/issues/23544 if (field.getFieldId() != null) { return field.getFieldId(); } - //Using the getFieldNameFromCategory if the category is present in the model as cateogory:fieldName - if (field.getFieldNameFromCategory() != null && field.getFieldNameFromCategory().compareTo(field.getFieldName())!=0) { + // Using the getFieldNameFromCategory if the category is present in the model as + // cateogory:fieldName + if (field.getFieldNameFromCategory() != null + && field.getFieldNameFromCategory().compareTo(field.getFieldName()) != 0) { return field.getFieldNameFromCategory(); } - + return field.getFieldName(); } /** - * Freeze this widget (after on create) + * Erase the field + */ + private void erase() { + + if (field.isErasableField()) { + + switch (field.getType()) { + + case Boolean: + + ((CheckBox) holder).setValue(false); + break; + + case GeoJSON: + case Text: + + ((TextArea) holder).setText(""); + break; + + case Time: + + DataTimeBox dtbox = ((DataTimeBox) holder); + dtbox.setStartDate(null, null); + dtbox.setEndDate(null, null); + break; + + case Time_Interval: + + DataTimeBox dtboxTI = rangesList.get(0); + dtboxTI.setStartDate(null, null); + dtboxTI.setEndDate(null, null); + break; + + case Times_ListOf: + + for (DataTimeBox el : rangesList) { + el.setStartDate(null, null); + el.setEndDate(null, null); + } + + break; + + case Number: + + ((TextBox) holder).setText(""); + break; + + case String: + + if (holder.getClass().equals(ListBox.class)) { + ListBox tempListBox = (ListBox) holder; + // if it is not mandatory and not multi-selection, add a disabled option + // (placeholder) + if (!field.isMultiSelection()) { + listBoxSelectPlaceholder(tempListBox); + } else { + // TODO + } + } else + ((TextBox) holder).setText(""); + break; + + case File: + + if (holder.getClass().equals(MultipleDilaogUpload.class) + || holder.getClass().equals(DialogUpload.class)) { + DialogUpload dUpload = (DialogUpload) holder; + dUpload.eraseLastUpload(); + } + break; + default: + break; + + } + } + } + + /** + * List box select placeholder. + * + * @param listBox the list box + */ + private void listBoxSelectPlaceholder(ListBox listBox) { + + String placeholder = "Select " + field.getFieldName(); + if(listBox.getItemCount()==0) { + //create + listBox.addItem(placeholder); + }else { + //update + String itemText = listBox.getItemText(0); + if(itemText!=null && itemText.compareTo(placeholder)==0) { + listBox.removeItem(0); + listBox.setItemText(0, placeholder); + } + } + + listBox.setValue(0, ""); + listBox.getElement().getElementsByTagName("option").getItem(0).setAttribute("disabled", "disabled"); + listBox.setSelectedValue(placeholder); + } + + /** + * Freeze this widget (after on create). + * + * @param bool the bool */ public void freeze(boolean bool) { @@ -998,7 +1149,7 @@ public class MetaDataFieldSkeleton extends Composite { break; case File: - + if (holder.getClass().equals(MultipleDilaogUpload.class) || holder.getClass().equals(DialogUpload.class)) { DialogUpload dUpload = (DialogUpload) holder; dUpload.enableUpload(!bool); @@ -1011,20 +1162,26 @@ public class MetaDataFieldSkeleton extends Composite { } /** - * Get the original MetadataFieldWrapper object - * - * @return + * Get the original MetadataFieldWrapper object. + * + * @return the field */ public MetadataFieldWrapper getField() { return field; } + /** + * Removes the error. + */ public void removeError() { metafieldControlGroup.setType(ControlGroupType.NONE); } + /** + * Show error. + */ public void showError() { metafieldControlGroup.setType(ControlGroupType.ERROR); @@ -1032,10 +1189,10 @@ public class MetaDataFieldSkeleton extends Composite { } /** - * Build the range interval - * - * @param rangeValues - * @param tb + * Build the range interval. + * + * @param rangeValues the range values + * @param tb the tb */ private void setRangeTimeInTimeBox(String rangeValues, DataTimeBox tb) { // set time, if present @@ -1096,9 +1253,9 @@ public class MetaDataFieldSkeleton extends Composite { } /** - * Check if the group associated (if it exists) should be forced - * - * @return + * Check if the group associated (if it exists) should be forced. + * + * @return true, if is group to force */ public boolean isGroupToForce() { FieldAsGroup asGroup = field.getAsGroup(); @@ -1109,9 +1266,9 @@ public class MetaDataFieldSkeleton extends Composite { } /** - * Check if the propagateUp is set - * - * @return + * Check if the propagateUp is set. + * + * @return true, if is propagate up */ public boolean isPropagateUp() { FieldAsGroup asGroup = field.getAsGroup(); diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml index 136921f..06b25a8 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml @@ -1,15 +1,17 @@ - .note-container { - display: inline-block; + .right-container { float: right; - width: 5%; color: #aaaaaa; + display: inline-flex; + align-items: center; + flex-direction: row; } .note-field-text { @@ -22,6 +24,10 @@ .element-panel { display: inline-block; } + + .margin-right-erase { + margin-right: 15px; + } @@ -30,18 +36,26 @@ - - + + - - - - - - + + + + + + + + + + + diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java index 3202b76..c53bf2c 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/DialogUpload.java @@ -276,6 +276,22 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific fakeUploaders.clear(); } + public void eraseLastUpload() { + try { + if (upv != null) { + verticalMainPanel.remove(upv.getPanel()); + } + } catch (Exception e) { + + } + + if (timer != null) { + FileUploadingState upload = timer.getLastWorkspaceUploader(); + if (upload != null) + timer.resetLastWorkspaceUploader(); + } + } + /** * Gets the file uploading state. * diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/TimerUpload.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/TimerUpload.java index ff1b601..3166f2d 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/TimerUpload.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/upload/TimerUpload.java @@ -156,6 +156,10 @@ public class TimerUpload extends Timer{ public FileUploadingState getLastWorkspaceUploader() { return lastWorkspaceUploader; } + + protected void resetLastWorkspaceUploader() { + lastWorkspaceUploader = null; + } } diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/ErasableField.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/ErasableField.java new file mode 100644 index 0000000..ae362c1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/ErasableField.java @@ -0,0 +1,6 @@ +package org.gcube.portlets.widgets.mpformbuilder.shared.metadata; + +public interface ErasableField { + + public boolean isErasableField(); +} diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java index 9fe1a9b..c566275 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/shared/metadata/MetadataFieldWrapper.java @@ -11,7 +11,7 @@ import java.util.List; * * Mar 3, 2022 */ -public class MetadataFieldWrapper implements UpdatableField, Serializable { +public class MetadataFieldWrapper implements UpdatableField, ErasableField, Serializable { private static final long serialVersionUID = -8476731365884466698L; private String fieldId; @@ -362,6 +362,17 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable { return null; } + + + @Override + public boolean isErasableField() { + if(mandatory) + return false; + + return true; + + } + /** * To string. From 05dde21e02c0ccdbef07e3008193a0aa7a9664bf Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 24 May 2024 17:05:40 +0200 Subject: [PATCH 3/8] fixed DateBox, Select and File --- .../ui/metadata/MetaDataFieldSkeleton.java | 13 +++++++------ .../ui/metadata/MetaDataFieldSkeleton.ui.xml | 2 +- .../client/ui/timeandranges/DataTimeBox.java | 18 ++++++++++++++++-- .../client/ui/upload/DialogUpload.java | 14 +++++--------- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java index 777fca0..e9ff041 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java @@ -1084,18 +1084,19 @@ public class MetaDataFieldSkeleton extends Composite { if(listBox.getItemCount()==0) { //create listBox.addItem(placeholder); + listBox.setValue(0, ""); + listBox.getElement().getElementsByTagName("option").getItem(0).setAttribute("disabled", "disabled"); + listBox.setSelectedIndex(0); }else { //update String itemText = listBox.getItemText(0); + //if the first element is the placeholder, select it if(itemText!=null && itemText.compareTo(placeholder)==0) { - listBox.removeItem(0); - listBox.setItemText(0, placeholder); + listBox.setValue(0, ""); + listBox.getElement().getElementsByTagName("option").getItem(0).setAttribute("disabled", "disabled"); + listBox.setSelectedIndex(0); } } - - listBox.setValue(0, ""); - listBox.getElement().getElementsByTagName("option").getItem(0).setAttribute("disabled", "disabled"); - listBox.setSelectedValue(placeholder); } /** diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml index 06b25a8..0e0cda5 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml @@ -45,7 +45,7 @@ - + Date: Wed, 5 Jun 2024 17:28:31 +0200 Subject: [PATCH 4/8] updated dom structure --- .../ui/metadata/MetaDataFieldSkeleton.java | 12 ++++--- .../ui/metadata/MetaDataFieldSkeleton.ui.xml | 31 ++++++++++++------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java index e9ff041..9a92740 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java @@ -30,6 +30,7 @@ import com.github.gwtbootstrap.client.ui.TextBox; import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.ControlGroupType; import com.github.gwtbootstrap.client.ui.constants.IconType; +import com.github.gwtbootstrap.client.ui.constants.ResizeType; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.SpanElement; @@ -84,7 +85,7 @@ public class MetaDataFieldSkeleton extends Composite { @UiField SpanElement name; @UiField - SimplePanel elementPanel; + FlowPanel elementPanel; @UiField FlowPanel noteFieldContainer; @UiField @@ -194,6 +195,7 @@ public class MetaDataFieldSkeleton extends Composite { final TextArea textArea = new TextArea(); textArea.setWidth("100%"); + textArea.setResize(ResizeType.VERTICAL); if (field.getDefaultValue() != null) textArea.setText(field.getDefaultValue()); @@ -266,14 +268,16 @@ public class MetaDataFieldSkeleton extends Composite { case Text: holder = new TextArea(); + TextArea txtArea = ((TextArea) holder); + txtArea.setResize(ResizeType.VERTICAL); if (field.getDefaultValue() != null) - ((TextArea) holder).setText(field.getDefaultValue()); + txtArea.setText(field.getDefaultValue()); if (operation.equals(OPERATION.UPDATE)) { try { if (field.getCurrentSingleValue() != null) - ((TextArea) holder).setText((String) field.getCurrentSingleValue()); + txtArea.setText((String) field.getCurrentSingleValue()); } catch (Exception e) { // TODO: handle exception } @@ -523,7 +527,7 @@ public class MetaDataFieldSkeleton extends Composite { mandatorySymbol.getStyle().setDisplay(Display.NONE); // add to the elementPanel - elementPanel.add(holder); + elementPanel.insert(holder, 0); // set holder width if (holder.getClass().equals(ListBox.class)) diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml index 0e0cda5..205626c 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml @@ -7,11 +7,10 @@ .right-container { - float: right; color: #aaaaaa; - display: inline-flex; - align-items: center; - flex-direction: row; + display: inline-block; + vertical-align: middle; + height: 100%; } .note-field-text { @@ -25,9 +24,17 @@ display: inline-block; } + .flex-display-panel { + display: flex; + } + .margin-right-erase { margin-right: 15px; } + + .align-content-center { + align-content: center; + } @@ -37,16 +44,16 @@ - + styleName="{style.flex-display-panel}"> + - - - - + + + + From 7ae1367cedf070bee4288890a695ba922dbe0d43 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 6 Jun 2024 14:46:50 +0200 Subject: [PATCH 5/8] new UI built. Erase field facility implemented --- .../ui/metadata/MetaDataFieldSkeleton.java | 19 ++++- .../ui/metadata/MetaDataFieldSkeleton.ui.xml | 70 ++++++++++--------- .../ui/timeandranges/DataTimeBox.ui.xml | 27 ++++--- 3 files changed, 69 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java index 9a92740..bf5856b 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java @@ -531,9 +531,9 @@ public class MetaDataFieldSkeleton extends Composite { // set holder width if (holder.getClass().equals(ListBox.class)) - holder.setWidth("96%"); + holder.setWidth("99%"); else - holder.setWidth("95%"); + holder.setWidth("97%"); //If the field is erasable views the erase panel if(field.isErasableField()) { @@ -1000,7 +1000,7 @@ public class MetaDataFieldSkeleton extends Composite { } /** - * Erase the field + * Erase the field. Reset the field */ private void erase() { @@ -1053,6 +1053,19 @@ public class MetaDataFieldSkeleton extends Composite { ListBox tempListBox = (ListBox) holder; // if it is not mandatory and not multi-selection, add a disabled option // (placeholder) + + //selecting the default value of the list + if (field.getDefaultValue() != null) { + tempListBox.setSelectedValue(field.getDefaultValue()); + return; + } + + //selecting unique element of the list + if(tempListBox.getItemCount()==1) { + tempListBox.setSelectedValue(tempListBox.getItemText(0)); + return; + } + if (!field.isMultiSelection()) { listBoxSelectPlaceholder(tempListBox); } else { diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml index 205626c..d7cf057 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.ui.xml @@ -6,11 +6,10 @@ xmlns:b3="urn:import:com.github.gwtbootstrap.datepicker.client.ui"> - .right-container { + .button-container { color: #aaaaaa; - display: inline-block; - vertical-align: middle; height: 100%; + text-align: center; } .note-field-text { @@ -27,14 +26,6 @@ .flex-display-panel { display: flex; } - - .margin-right-erase { - margin-right: 15px; - } - - .align-content-center { - align-content: center; - } @@ -43,28 +34,41 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+
diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/timeandranges/DataTimeBox.ui.xml b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/timeandranges/DataTimeBox.ui.xml index 0e0d40a..6fd42e7 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/timeandranges/DataTimeBox.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/timeandranges/DataTimeBox.ui.xml @@ -1,29 +1,34 @@ .flow-panel-style { display: inline-block; } + + .margin-left-5 { + margin-left: 5px; + } - + + maxView="HOUR" startView="HOUR" language="en" width="25%" + ui:field="startRangeTime" addStyleNames="{style.margin-left-5}" /> - - + + + maxView="HOUR" startView="HOUR" language="en" width="25%" + ui:field="endRangeTime" addStyleNames="{style.margin-left-5}" /> From b1f4f68c04a09e0441da2e1bff9d352c9aa0e497 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 6 Jun 2024 15:17:58 +0200 Subject: [PATCH 6/8] removed selecting unique element of the list on erase field --- .../client/ui/metadata/MetaDataFieldSkeleton.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java index bf5856b..4e08892 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java @@ -1061,10 +1061,10 @@ public class MetaDataFieldSkeleton extends Composite { } //selecting unique element of the list - if(tempListBox.getItemCount()==1) { - tempListBox.setSelectedValue(tempListBox.getItemText(0)); - return; - } +// if(tempListBox.getItemCount()==1) { +// tempListBox.setSelectedValue(tempListBox.getItemText(0)); +// return; +// } if (!field.isMultiSelection()) { listBoxSelectPlaceholder(tempListBox); From 4705aaf933825f1e72f6e43bdda3fc9dcfb76d26 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 7 Jun 2024 10:25:19 +0200 Subject: [PATCH 7/8] removed selecting the default value of the list --- .../client/ui/metadata/MetaDataFieldSkeleton.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java index 4e08892..1bd7626 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/client/ui/metadata/MetaDataFieldSkeleton.java @@ -1055,10 +1055,10 @@ public class MetaDataFieldSkeleton extends Composite { // (placeholder) //selecting the default value of the list - if (field.getDefaultValue() != null) { - tempListBox.setSelectedValue(field.getDefaultValue()); - return; - } +// if (field.getDefaultValue() != null) { +// tempListBox.setSelectedValue(field.getDefaultValue()); +// return; +// } //selecting unique element of the list // if(tempListBox.getItemCount()==1) { From 15727874c18b93bc6614b61d85fa104bc19333c6 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 10 Jun 2024 15:25:27 +0200 Subject: [PATCH 8/8] Moved logs sessionDestroyed/sessionCreated of the `UploadedFileHttpSessionListener` from INFO to TRACE level --- CHANGELOG.md | 1 + .../server/UploadedFileHttpSessionListener.java | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de4422f..92a937d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Enhancements - [#27488] In edit mode allowed to erase (not mandatory) fields according to data type +- [#27627] Moved logs at TRACE level ## [v2.1.1] - 2024-03-19 diff --git a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/UploadedFileHttpSessionListener.java b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/UploadedFileHttpSessionListener.java index e609aee..4f1fe78 100644 --- a/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/UploadedFileHttpSessionListener.java +++ b/src/main/java/org/gcube/portlets/widgets/mpformbuilder/server/UploadedFileHttpSessionListener.java @@ -19,12 +19,12 @@ public class UploadedFileHttpSessionListener implements HttpSessionListener { @Override public void sessionDestroyed(HttpSessionEvent event) { - LOG.info("sessionDestroyed called"); + LOG.trace("sessionDestroyed called"); try { HttpSession httpSession = event.getSession(); if(httpSession!=null) { - LOG.info("Sesson id is: "+httpSession.getId()); + LOG.trace("Sesson id is: "+httpSession.getId()); List listFileUploaded = (List) httpSession.getAttribute(ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR); if(listFileUploaded!=null) { LOG.info("found file uploded in session, removing it"); @@ -41,6 +41,6 @@ public class UploadedFileHttpSessionListener implements HttpSessionListener { @Override public void sessionCreated(HttpSessionEvent arg0) { - LOG.info("sessionCreated called. Session id is: "+arg0.getSession().getId()); + LOG.trace("sessionCreated called. Session id is: "+arg0.getSession().getId()); } }