Implemented feature #21188
This commit is contained in:
parent
e51bc1c9b6
commit
a27a4772d7
|
@ -1,10 +1,37 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-module deploy-name="gcube-ckan-datacatalog-2.0.0-SNAPSHOT">
|
<wb-module deploy-name="gcube-ckan-datacatalog-2.0.0-SNAPSHOT">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<property name="context-root" value="gcube-ckan-datacatalog"/>
|
<property name="context-root" value="gcube-ckan-datacatalog"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
<property name="java-output-path" value="/gcube-ckan-datacatalog/target/gcube-ckan-datacatalog-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</project-modules>
|
</project-modules>
|
||||||
|
|
|
@ -5,6 +5,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).
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
|
||||||
|
## [v2.0.1-SNAPSHOT] - 2021-05-04
|
||||||
|
|
||||||
|
#### Enhancements
|
||||||
|
|
||||||
|
[#21188] Avoiding the catalogue widget window close if the user clicks outside it
|
||||||
|
|
||||||
|
|
||||||
## [v2.0.0] - 2021-04-12
|
## [v2.0.0] - 2021-04-12
|
||||||
|
|
||||||
#### Enhancements
|
#### Enhancements
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -14,7 +14,7 @@
|
||||||
<groupId>org.gcube.portlets.gcubeckan</groupId>
|
<groupId>org.gcube.portlets.gcubeckan</groupId>
|
||||||
<artifactId>gcube-ckan-datacatalog</artifactId>
|
<artifactId>gcube-ckan-datacatalog</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>2.0.0</version>
|
<version>2.0.1-SNAPSHOT</version>
|
||||||
<name>gCube CKAN Data Catalog</name>
|
<name>gCube CKAN Data Catalog</name>
|
||||||
<description>The gCube CKAN Data Catalog portlet</description>
|
<description>The gCube CKAN Data Catalog portlet</description>
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>maven-portal-bom</artifactId>
|
<artifactId>maven-portal-bom</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.6.1-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
|
|
|
@ -32,13 +32,10 @@ import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.view.GCubeCkanDa
|
||||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZendoPublisherWidget;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZendoPublisherWidget;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent;
|
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form.CreateDatasetForm;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form.CreateDatasetForm;
|
||||||
import org.gcube.portlets_widgets.catalogue_sharing_widget.client.ShareCatalogueWidget;
|
import org.gcube.portlets_widgets.catalogue_sharing_widget.client.ShareCatalogueWidget;
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.Modal;
|
import com.github.gwtbootstrap.client.ui.Modal;
|
||||||
import com.github.gwtbootstrap.client.ui.event.HideEvent;
|
|
||||||
import com.github.gwtbootstrap.client.ui.event.HideHandler;
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.dom.client.Element;
|
import com.google.gwt.dom.client.Element;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
|
@ -94,9 +91,9 @@ public class CkanEventHandlerManager {
|
||||||
eventBus.addHandler(InsertMetadataEvent.TYPE, new InsertMetadataEventHandler() {
|
eventBus.addHandler(InsertMetadataEvent.TYPE, new InsertMetadataEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInsertMetadata(InsertMetadataEvent loadSelecteReleaseEvent) {
|
public void onInsertMetadata(InsertMetadataEvent loadSelectedItemEvent) {
|
||||||
GWT.log("loadSelecteReleaseEvent: "+loadSelecteReleaseEvent);
|
GWT.log("onInsertMetadata: "+loadSelectedItemEvent);
|
||||||
final Modal modal = new Modal(true, true);
|
final Modal modal = new ExtModal(true, true);
|
||||||
|
|
||||||
modal.setTitle(WIDGET_CREATE_TITLE);
|
modal.setTitle(WIDGET_CREATE_TITLE);
|
||||||
modal.addStyleName("insert-metadata-modal-style");
|
modal.addStyleName("insert-metadata-modal-style");
|
||||||
|
@ -105,15 +102,22 @@ public class CkanEventHandlerManager {
|
||||||
modal.add(new CreateDatasetForm(eventBus));
|
modal.add(new CreateDatasetForm(eventBus));
|
||||||
modal.setCloseVisible(true);
|
modal.setCloseVisible(true);
|
||||||
|
|
||||||
// hide any popup panel opened
|
|
||||||
modal.addHideHandler(new HideHandler() {
|
|
||||||
|
|
||||||
@Override
|
// // hide any popup panel opened
|
||||||
public void onHide(HideEvent hideEvent) {
|
// modal.addHideHandler(new HideHandler() {
|
||||||
GWT.log("HideEvent on modal fired");
|
//
|
||||||
eventBus.fireEvent(new CloseCreationFormEvent());
|
// @Override
|
||||||
}
|
// public void onHide(HideEvent hideEvent) {
|
||||||
});
|
// GWT.log("HideEvent on modal fired");
|
||||||
|
// GWT.log(hideEvent.toDebugString());
|
||||||
|
// eventBus.fireEvent(new CloseCreationFormEvent());
|
||||||
|
//
|
||||||
|
// hideEvent.preventDefault();
|
||||||
|
// hideEvent.stopPropagation();
|
||||||
|
// return;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
GWT.log("show");
|
GWT.log("show");
|
||||||
modal.show();
|
modal.show();
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Modal;
|
||||||
|
import com.github.gwtbootstrap.client.ui.event.HideEvent;
|
||||||
|
import com.github.gwtbootstrap.client.ui.event.HideHandler;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.core.client.Scheduler;
|
||||||
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
|
import com.google.gwt.dom.client.Element;
|
||||||
|
import com.google.gwt.user.client.DOM;
|
||||||
|
import com.google.gwt.user.client.Event;
|
||||||
|
import com.google.gwt.user.client.EventListener;
|
||||||
|
import com.google.gwt.user.client.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class ExtModal.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Apr 29, 2021
|
||||||
|
*
|
||||||
|
* This Class extends the {{@link Modal} preventing the default close of
|
||||||
|
* the Modal Bootstrap when clicking outside of the modal Window
|
||||||
|
*/
|
||||||
|
public class ExtModal extends Modal {
|
||||||
|
|
||||||
|
private String elementId;
|
||||||
|
private String closeElementId;
|
||||||
|
private Boolean closeButtoClicked = false;
|
||||||
|
final private ExtModal INSTANCE = this;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new ext modal.
|
||||||
|
*/
|
||||||
|
public ExtModal() {
|
||||||
|
super();
|
||||||
|
setElementIds();
|
||||||
|
addDeferredCommandToPreventModalClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an empty, hidden widget with specified show behavior.
|
||||||
|
*
|
||||||
|
* @param animated <code>true</code> if the widget should be animated.
|
||||||
|
*/
|
||||||
|
public ExtModal(boolean animated) {
|
||||||
|
super(animated, false);
|
||||||
|
setElementIds();
|
||||||
|
addDeferredCommandToPreventModalClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an empty, hidden widget with specified show behavior.
|
||||||
|
*
|
||||||
|
* @param animated <code>true</code> if the widget should be animated.
|
||||||
|
* @param dynamicSafe <code>true</code> removes from RootPanel when hidden
|
||||||
|
*/
|
||||||
|
public ExtModal(boolean animated, boolean dynamicSafe) {
|
||||||
|
super(animated, dynamicSafe);
|
||||||
|
setElementIds();
|
||||||
|
addDeferredCommandToPreventModalClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDeferredCommandToPreventModalClose() {
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
((Element) INSTANCE.getElement().getChildNodes().getItem(0)).getFirstChildElement()
|
||||||
|
.setId(closeElementId);
|
||||||
|
preventModalCloseWhenClickingOutside();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the element id.
|
||||||
|
*/
|
||||||
|
private void setElementIds() {
|
||||||
|
this.elementId = "my-modal-publish-meta" + Random.nextInt();
|
||||||
|
this.getElement().setId(elementId);
|
||||||
|
|
||||||
|
this.closeElementId = "my-modal-close-button" + Random.nextInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent modal close when clicking outside.
|
||||||
|
*/
|
||||||
|
private void preventModalCloseWhenClickingOutside() {
|
||||||
|
|
||||||
|
com.google.gwt.user.client.Element buttonCloseElement = DOM.getElementById(this.closeElementId);
|
||||||
|
|
||||||
|
if (buttonCloseElement != null) {
|
||||||
|
|
||||||
|
Event.sinkEvents(buttonCloseElement, Event.ONCLICK);
|
||||||
|
Event.setEventListener(buttonCloseElement, new EventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBrowserEvent(Event event) {
|
||||||
|
System.out.println("ok");
|
||||||
|
if (Event.ONCLICK == event.getTypeInt()) {
|
||||||
|
GWT.log("close event clicked");
|
||||||
|
closeButtoClicked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
GWT.log("button close element not found");
|
||||||
|
closeButtoClicked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// hide any popup panel opened
|
||||||
|
this.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHide(HideEvent hideEvent) {
|
||||||
|
GWT.log("HideEvent on modal fired");
|
||||||
|
GWT.log(hideEvent.toDebugString());
|
||||||
|
GWT.log("CloseButtonClicked is: " + closeButtoClicked);
|
||||||
|
|
||||||
|
if (!closeButtoClicked) {
|
||||||
|
hideEvent.preventDefault();
|
||||||
|
hideEvent.stopPropagation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue