Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 - While in edit mode with annotations editor v2, toggle globalAppState.setIsEditing
  • Loading branch information
nickgros committed Feb 7, 2024
1 parent a85eb33 commit a464f99
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public interface Callback {
void run();
}

@JsFunction
public interface BooleanCallback {
void run(boolean value);
}

String entityId;
boolean show;

Expand All @@ -29,14 +34,18 @@ public interface Callback {
@JsNullable
Double versionNumber;

@JsNullable
BooleanCallback onEditModeChanged;

@JsOverlay
public static EntityModalProps create(
String entityId,
Long versionNumber,
boolean show,
Callback onClose,
String initialTab,
boolean showTabs
boolean showTabs,
BooleanCallback onEditModeChanged
) {
EntityModalProps props = new EntityModalProps();
props.entityId = entityId;
Expand All @@ -47,6 +56,7 @@ public static EntityModalProps create(
props.onClose = onClose;
props.initialTab = initialTab;
props.showTabs = showTabs;
props.onEditModeChanged = onEditModeChanged;
return props;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,15 +31,15 @@ public class EntityMetadataViewImpl
interface EntityMetadataViewImplUiBinder
extends UiBinder<Widget, EntityMetadataViewImpl> {}

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;
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a464f99

Please sign in to comment.