From a464f995015b9b237ad8a95b5daff2ce0b76e1e9 Mon Sep 17 00:00:00 2001 From: Nick Grosenbacher Date: Wed, 7 Feb 2024 16:03:51 -0500 Subject: [PATCH] PORTALS-2818 - While in edit mode with annotations editor v2, toggle globalAppState.setIsEditing --- .../client/jsinterop/EntityModalProps.java | 12 ++++- .../widget/entity/EntityMetadataViewImpl.java | 49 ++++++++++--------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/sagebionetworks/web/client/jsinterop/EntityModalProps.java b/src/main/java/org/sagebionetworks/web/client/jsinterop/EntityModalProps.java index 3112e0bf0a..608ec6368a 100644 --- a/src/main/java/org/sagebionetworks/web/client/jsinterop/EntityModalProps.java +++ b/src/main/java/org/sagebionetworks/web/client/jsinterop/EntityModalProps.java @@ -14,6 +14,11 @@ public interface Callback { void run(); } + @JsFunction + public interface BooleanCallback { + void run(boolean value); + } + String entityId; boolean show; @@ -29,6 +34,9 @@ public interface Callback { @JsNullable Double versionNumber; + @JsNullable + BooleanCallback onEditModeChanged; + @JsOverlay public static EntityModalProps create( String entityId, @@ -36,7 +44,8 @@ public static EntityModalProps create( boolean show, Callback onClose, String initialTab, - boolean showTabs + boolean showTabs, + BooleanCallback onEditModeChanged ) { EntityModalProps props = new EntityModalProps(); props.entityId = entityId; @@ -47,6 +56,7 @@ public static EntityModalProps create( props.onClose = onClose; props.initialTab = initialTab; props.showTabs = showTabs; + props.onEditModeChanged = onEditModeChanged; return props; } } diff --git a/src/main/java/org/sagebionetworks/web/client/widget/entity/EntityMetadataViewImpl.java b/src/main/java/org/sagebionetworks/web/client/widget/entity/EntityMetadataViewImpl.java index 359ef59b64..43b55a5e66 100644 --- a/src/main/java/org/sagebionetworks/web/client/widget/entity/EntityMetadataViewImpl.java +++ b/src/main/java/org/sagebionetworks/web/client/widget/entity/EntityMetadataViewImpl.java @@ -15,9 +15,8 @@ import org.gwtbootstrap3.client.ui.html.Paragraph; import org.gwtbootstrap3.client.ui.html.Span; import org.gwtbootstrap3.client.ui.html.Text; -import org.sagebionetworks.web.client.SynapseJSNIUtils; +import org.sagebionetworks.web.client.GlobalApplicationState; import org.sagebionetworks.web.client.context.SynapseReactClientFullContextPropsProvider; -import org.sagebionetworks.web.client.cookie.CookieProvider; import org.sagebionetworks.web.client.jsinterop.EntityModalProps; import org.sagebionetworks.web.client.jsinterop.React; import org.sagebionetworks.web.client.jsinterop.ReactNode; @@ -32,15 +31,15 @@ public class EntityMetadataViewImpl interface EntityMetadataViewImplUiBinder extends UiBinder {} - private static EntityMetadataViewImplUiBinder uiBinder = GWT.create( + private static final EntityMetadataViewImplUiBinder uiBinder = GWT.create( EntityMetadataViewImplUiBinder.class ); private Presenter presenter; private String entityId; private Long versionNumber; - private CookieProvider cookies; - private SynapseReactClientFullContextPropsProvider propsProvider; + private final SynapseReactClientFullContextPropsProvider propsProvider; + private final GlobalApplicationState globalApplicationState; @UiField HTMLPanel detailedMetadata; @@ -92,10 +91,11 @@ interface EntityMetadataViewImplUiBinder @Inject public EntityMetadataViewImpl( - final SynapseJSNIUtils jsniUtils, - final SynapseReactClientFullContextPropsProvider propsProvider + final SynapseReactClientFullContextPropsProvider propsProvider, + final GlobalApplicationState globalApplicationState ) { this.propsProvider = propsProvider; + this.globalApplicationState = globalApplicationState; initWidget(uiBinder.createAndBindUi(this)); idField.addClickHandler(event -> idField.selectAll()); annotationsContentCloseButton.addClickHandler(event -> @@ -137,21 +137,26 @@ public void setUploadDestinationText(String text) { @Override public void setAnnotationsModalVisible(boolean visible) { - boolean showTabs = false; - EntityModalProps props = EntityModalProps.create( - entityId, - versionNumber, - visible, - () -> setAnnotationsModalVisible(false), - "ANNOTATIONS", - showTabs - ); - ReactNode component = React.createElementWithSynapseContext( - SRC.SynapseComponents.EntityModal, - props, - propsProvider.getJsInteropContextProps() - ); - annotationsModalContainer.render(component); + if (visible) { + boolean showTabs = false; + EntityModalProps props = EntityModalProps.create( + entityId, + versionNumber, + visible, + () -> setAnnotationsModalVisible(false), + "ANNOTATIONS", + showTabs, + globalApplicationState::setIsEditing + ); + ReactNode component = React.createElementWithSynapseContext( + SRC.SynapseComponents.EntityModal, + props, + propsProvider.getJsInteropContextProps() + ); + annotationsModalContainer.render(component); + } else { + annotationsModalContainer.clear(); + } } @Override