feat(PanelService): Left or right side panel to auto start as closed but auto open when needed (#3212)
* feat(SidePanel) OHIF issue #3135 - Added a method to set a callback for a Panel to invoke when it is ready to be shown (e.g. its data is loaded). - Implemented such methods for both the segmentation and measurement panels. - The SidePanel component now adds a callback to Panel components so that it will automatically open a Panel that was initially closed and yet to be opened. - Updated the OHIF documentation accordingly. * PR feedback - added a PanelService that centralized much of the logic that existed in panel PanelModule - the SidePanel subscribes to PanelService.EVENTS.ACTIVATE_PANEL for each of its child panels * Removed the PanelMeasurementTableTracking setMeasurementPanelContentReadyCallback method. * Made the forceActive flag in the PanelService optional and defaulted it to false. * Fixed failing top level exports unit test. * - PanelService subscriptions are now per panel (id) so subscribers do not necessarily need to check the panel id in the event when it is fired - PanelService activate panel trigger subscriptions are now returned so that they can be (better) managed outside of the service - updated/created the various documentation for panels and PanelService * Clarified various documentation. Moved the code to add the activate panel triggers out of the extensions and into the longitudinal mode. * Removed the openWhenPanelActivated flag. PanelService now conforms to extending PubSubService like the other services. Updated various documentation. * Fixed failing e2e, mpr test. * Renamed the ActivatePanelTriggers type properties. The ExtensionManager now sets the id of various modules as a property on each of those modules.
This commit is contained in:
1 parent
e4e62e9e14
commit
5670a4d8d1
21 files changed
+294
-23
No files matched your search
@@ -25,6 +25,10 @@ optionally provide its own `context` value.
|
||||
The `getPanelModule` receives an object containing the `ExtensionManager`'s
|
||||
associated `ServicesManager` and `CommandsManager`.
|
||||
|
||||
An extension can also trigger to activate/open a panel via the `PanelService` -
|
||||
either by explicitly calling `PanelService.activatePanel` or triggering panel
|
||||
activation when some other event fires.
|
||||
|
||||
```jsx
|
||||
import PanelMeasurementTable from './PanelMeasurementTable.js';
|
||||
|
||||
@@ -64,7 +68,15 @@ providing the component with its.
|
||||
|
||||
New: You can easily add multiple panels to the left/right side of the viewer
|
||||
using the mode configuration. As seen below, the `leftPanels` and `rightPanels`
|
||||
accept an `Array` of the `IDs`.
|
||||
accept an `Array` of the `IDs`. The mode configuration also allows for either (or
|
||||
both) side panels to be closed by default. In the code below, the right panel
|
||||
is closed by default. The mode can optionally add event triggers to
|
||||
the `PanelService` that when fired will cause a side panel that was defaulted
|
||||
closed to open. In the code below, the right side panel, that contains the
|
||||
`trackedMeasurements` panel, is triggered to open when a measurement is added.
|
||||
Note that once a default closed side panel has been opened once,
|
||||
only a `PanelService.EVENTS.ACTIVATE_PANEL` event with `forceActive === true`
|
||||
will cause it open (again).
|
||||
|
||||
```js
|
||||
|
||||
@@ -79,6 +91,7 @@ const id = 'viewer'
|
||||
const version = '3.0.0
|
||||
|
||||
function modeFactory({ modeConfiguration }) {
|
||||
let _activatePanelTriggersSubscriptions = [];
|
||||
return {
|
||||
id,
|
||||
routes: [
|
||||
@@ -94,12 +107,35 @@ function modeFactory({ modeConfiguration }) {
|
||||
rightPanels: [
|
||||
'@ohif/extension-measurement-tracking.panelModule.trackedMeasurements',
|
||||
],
|
||||
rightPanelDefaultClosed: true,
|
||||
viewports,
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
onModeEnter: ({ servicesManager }) => {
|
||||
const {
|
||||
measurementService,
|
||||
panelService,
|
||||
} = servicesManager.services;
|
||||
|
||||
_activatePanelTriggersSubscriptions = [
|
||||
...panelService.addActivatePanelTriggers('@ohif/extension-measurement-tracking.panelModule.trackedMeasurements', [
|
||||
{
|
||||
sourcePubSubService: measurementService,
|
||||
sourceEvents: [
|
||||
measurementService.EVENTS.MEASUREMENT_ADDED,
|
||||
measurementService.EVENTS.RAW_MEASUREMENT_ADDED,
|
||||
],
|
||||
},
|
||||
]),
|
||||
];
|
||||
},
|
||||
onModeExit: () => {
|
||||
_activatePanelTriggersSubscriptions.forEach(sub => sub.unsubscribe());
|
||||
_activatePanelTriggersSubscriptions = [];
|
||||
},
|
||||
extensions: extensionDependencies
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
---
|
||||
sidebar_position: 8
|
||||
sidebar_label: Panel Service
|
||||
---
|
||||
|
||||
# Panel Service
|
||||
|
||||
## Overview
|
||||
|
||||
The Panel Service provides for activating/showing a panel that was registered
|
||||
via the `getPanelModule` extension method. Such panels can be either explicitly
|
||||
activated or implicitly triggered to activate when some other event occurs.
|
||||
|
||||
## Events
|
||||
|
||||
The following events are published in `PanelService`.
|
||||
|
||||
| Event | Description |
|
||||
| --------------------- | ------------------------------------------------------ |
|
||||
| ACTIVATE__PANEL | Fires a `ActivatePanelEvent` when a particular panel should be activated (i.e. shown). |
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### Panel Activation
|
||||
|
||||
- `activatePanel`: Fires the `ACTIVATE_PANEL` event for a particular panel (id).
|
||||
An optional `forceActive` flag can be passed that when `true` "forces" a
|
||||
panel to show. Ultimately, it is up to a panel's container whether it
|
||||
is appropriate to activate/show the panel. For instance, if the user opened and then
|
||||
closed a side panel that contains the panel to activate, that side panel
|
||||
may decide that the user knows best and will not open the panel (again).
|
||||
|
||||
- `addActivatePanelTriggers`: Creates and returns event subscriptions that when
|
||||
fired will activate the specified panel with an optional `forceActive` flag
|
||||
(see `activatePanel`). This allows for panel activation to be directly triggered
|
||||
by some other event(s). When the triggers are no longer needed, simply
|
||||
unsubscribe to the returned subscriptions. For example, a panel
|
||||
for tracking measurements might get activated every time the
|
||||
`MeasurementService` fires a `MEASUREMENT_ADDED` event like this:
|
||||
```js
|
||||
panelService.addActivatePanelTriggers('measurement-tracking-panel-id', [
|
||||
sourcePubSubService: measurementService,
|
||||
sourceEvents: [
|
||||
measurementService.EVENTS.MEASUREMENT_ADDED,
|
||||
measurementService.EVENTS.RAW_MEASUREMENT_ADDED,
|
||||
],
|
||||
]);
|
||||
```
|
||||
@@ -20,6 +20,7 @@ We maintain the following non-ui Services:
|
||||
- [Toolbar Service](../data/ToolBarService.md)
|
||||
- [Measurement Service](../data/MeasurementService.md)
|
||||
- [Customization Service](customization-service.md)
|
||||
- [Panel Service](../data/PanelService.md)
|
||||
|
||||
## Service Architecture
|
||||
|
||||
|
||||
Reference in new issue
Block a user