Working cornerstone tools buttons, needs UI updates + onClicks wrapped in toolbarService

This commit is contained in:
James A. Petts committed 2020-05-20 18:49:17 +02:00
commit a3e1c216c4
13 files changed
+179 -219

No files matched your search

@@ -1,5 +1,9 @@
import pubSubServiceInterface from '../pubSubServiceInterface';
const EVENTS = {
TOOL_BAR_MODIFIED: 'event::toolBarService:toolBarModified',
};
export default class ToolBarService {
constructor() {
this.displaySets = {};
@@ -26,6 +30,23 @@ export default class ToolBarService {
});
}
/**
* Broadcasts displaySetService changes.
*
* @param {string} eventName The event name
* @return void
*/
_broadcastChange = (eventName, callbackProps) => {
const hasListeners = Object.keys(this.listeners).length > 0;
const hasCallbacks = Array.isArray(this.listeners[eventName]);
if (hasListeners && hasCallbacks) {
this.listeners[eventName].forEach(listener => {
listener.callback(callbackProps);
});
}
};
setToolBarLayout(layouts) {
const toolBarLayout = [];
@@ -51,6 +72,8 @@ export default class ToolBarService {
toolBarLayout.push(toolBarDefinitions);
});
// TODO -> Change this to a service. => emit an event to subscribers to update the toolbar layout.
this.toolBarLayout = toolBarLayout;
this._broadcastChange(this.EVENTS.TOOL_BAR_MODIFIED, toolBarLayout);
}
}
@@ -0,0 +1,8 @@
import ToolBarService from './ToolBarService';
export default {
name: 'ToolBarService',
create: ({ configuration = {} }) => {
return new ToolBarService();
},
};
+2
View File
@@ -5,6 +5,7 @@ import UIModalService from './UIModalService';
import UINotificationService from './UINotificationService';
import UIViewportDialogService from './UIViewportDialogService';
import DisplaySetService from './DisplaySetService';
import ToolBarSerivce from './ToolBarService';
export {
MeasurementService,
@@ -14,4 +15,5 @@ export {
UINotificationService,
UIViewportDialogService,
DisplaySetService,
ToolBarSerivce,
};