diff --git a/extensions/_example/src/index.js b/extensions/_example/src/index.js index 6d1e82bac..c061a44af 100644 --- a/extensions/_example/src/index.js +++ b/extensions/_example/src/index.js @@ -11,7 +11,10 @@ export default { * LIFECYCLE HOOKS */ - preRegistration({ serviceManager, configuration: extensionConfiguration }) {}, + preRegistration({ + servicesManager, + configuration: extensionConfiguration, + }) {}, /** * MODULE GETTERS diff --git a/extensions/cornerstone/src/index.js b/extensions/cornerstone/src/index.js index 5451f4041..6470382c9 100644 --- a/extensions/cornerstone/src/index.js +++ b/extensions/cornerstone/src/index.js @@ -24,8 +24,8 @@ export default { * @param {object} [configuration={}] * @param {object|array} [configuration.csToolsConfig] - Passed directly to `initCornerstoneTools` */ - preRegistration({ serviceManager, configuration = {} }) { - init({ serviceManager, configuration }); + preRegistration({ servicesManager, configuration = {} }) { + init({ servicesManager, configuration }); }, getViewportModule() { return OHIFCornerstoneViewport; diff --git a/extensions/cornerstone/src/init.js b/extensions/cornerstone/src/init.js index 0795e2034..aee850564 100644 --- a/extensions/cornerstone/src/init.js +++ b/extensions/cornerstone/src/init.js @@ -28,7 +28,7 @@ cornerstone.metaData.addProvider(fallbackMetaDataProvider, -1); * @param {object} configuration * @param {Object|Array} configuration.csToolsConfig */ -export default function init({ serviceManager, configuration = {} }) { +export default function init({ servicesManager, configuration = {} }) { const { csToolsConfig } = configuration; const { StackManager } = OHIF.utils; const metadataProvider = new OHIF.cornerstone.MetadataProvider(); diff --git a/platform/core/src/extensions/ExtensionManager.js b/platform/core/src/extensions/ExtensionManager.js index ddb702485..a6ceb7c36 100644 --- a/platform/core/src/extensions/ExtensionManager.js +++ b/platform/core/src/extensions/ExtensionManager.js @@ -68,7 +68,7 @@ export default class ExtensionManager { // preRegistrationHook if (extension.preRegistration) { extension.preRegistration({ - serviceManager: this._servicesManager, + servicesManager: this._servicesManager, configuration, }); } diff --git a/platform/core/src/index.js b/platform/core/src/index.js index 6cec02db8..cb482e505 100644 --- a/platform/core/src/index.js +++ b/platform/core/src/index.js @@ -19,7 +19,7 @@ import ui from './ui'; import user from './user.js'; import utils from './utils/'; -import { createUiNotificationService } from './services'; +import { createUINotificationService, createUIModalService } from './services'; const OHIF = { MODULE_TYPES, @@ -46,7 +46,8 @@ const OHIF = { measurements, hangingProtocols, // - createUiNotificationService, + createUINotificationService, + createUIModalService, }; export { @@ -73,7 +74,8 @@ export { measurements, hangingProtocols, // - createUiNotificationService, + createUINotificationService, + createUIModalService, }; export { OHIF }; diff --git a/platform/core/src/index.test.js b/platform/core/src/index.test.js index a017a8a39..b06073e12 100644 --- a/platform/core/src/index.test.js +++ b/platform/core/src/index.test.js @@ -10,7 +10,8 @@ describe('Top level exports', () => { 'HotkeysManager', 'ServicesManager', // - 'createUiNotificationService', + 'createUINotificationService', + 'createUIModalService', // 'utils', 'studies', diff --git a/platform/core/src/services/UIModalService/index.js b/platform/core/src/services/UIModalService/index.js new file mode 100644 index 000000000..b93bccdb8 --- /dev/null +++ b/platform/core/src/services/UIModalService/index.js @@ -0,0 +1,88 @@ +/** + * A UI Element + * + * @typedef {ReactElement|HTMLElement} Modal + */ + +/** + * UI Modal + * + * @typedef {Object} ModalProps + * @property {string} [header=null] - + * @property {string} [footer=null] - + * @property {string} [backdrop=false] - + * @property {string} [keyboard=false] - + * @property {number} [show=true] - + * @property {string} [closeButton=true] - + * @property {string} [title=null] - 'Modal Title' + * @property {boolean} [customClassName=null] - '.ModalClass' + */ + +const uiModalServicePublicAPI = { + name: 'UIModalService', + hide, + show, + setServiceImplementation, +}; + +const uiModalServiceImplementation = { + _hide: () => console.warn('hide() NOT IMPLEMENTED'), + _show: () => console.warn('show() NOT IMPLEMENTED'), +}; + +function createUIModalService() { + return uiModalServicePublicAPI; +} + +/** + * Show a new UI modal; + * + * @param {Modal} component React component + * @param {ModalProps} props { header, footer, backdrop, keyboard, show, closeButton, title, customClassName } + */ +function show( + component, + props = { + header: null, + footer: null, + backdrop: false, + keyboard: false, + show: true, + closeButton: true, + title: null, + customClassName: null, + } +) { + return uiModalServiceImplementation._show(component, props); +} + +/** + * Hides/dismisses the modal, if currently shown + * + * @returns void + */ +function hide() { + return uiModalServiceImplementation._hide(); +} + +/** + * + * + * @param {*} { + * hide: hideImplementation, + * show: showImplementation, + * } + */ +function setServiceImplementation({ + hide: hideImplementation, + show: showImplementation, +}) { + if (hideImplementation) { + uiModalServiceImplementation._hide = hideImplementation; + } + if (showImplementation) { + uiModalServiceImplementation._show = showImplementation; + } +} + +export default createUIModalService; diff --git a/platform/core/src/services/UINotificationService/index.js b/platform/core/src/services/UINotificationService/index.js index 97db61040..7538a6280 100644 --- a/platform/core/src/services/UINotificationService/index.js +++ b/platform/core/src/services/UINotificationService/index.js @@ -10,7 +10,7 @@ * @property {boolean} [autoClose=true] */ -const uiNotificationServicePublicApi = { +const uiNotificationServicePublicAPI = { name: 'UINotificationService', hide, show, @@ -22,8 +22,8 @@ const uiNotificationServiceImplementation = { _show: () => console.warn('show() NOT IMPLEMENTED'), }; -function createUiNotificationService() { - return uiNotificationServicePublicApi; +function createUINotificationService() { + return uiNotificationServicePublicAPI; } /** @@ -81,4 +81,4 @@ function setServiceImplementation({ } } -export default createUiNotificationService; +export default createUINotificationService; diff --git a/platform/core/src/services/index.js b/platform/core/src/services/index.js index ded69e822..033dee202 100644 --- a/platform/core/src/services/index.js +++ b/platform/core/src/services/index.js @@ -1,4 +1,5 @@ import ServicesManager from './ServicesManager.js'; -import createUiNotificationService from './UINotificationService'; +import createUINotificationService from './UINotificationService'; +import createUIModalService from './UIModalService'; -export { createUiNotificationService, ServicesManager }; +export { createUINotificationService, createUIModalService, ServicesManager }; diff --git a/platform/ui/src/components/ohifModal/OHIFModal.js b/platform/ui/src/components/ohifModal/OHIFModal.js index f69c9376e..483c650f9 100644 --- a/platform/ui/src/components/ohifModal/OHIFModal.js +++ b/platform/ui/src/components/ohifModal/OHIFModal.js @@ -13,7 +13,7 @@ const OHIFModal = ({ onHide, footer: Footer, header: Header, - children: Component, + children, }) => ( } )} - - {Component && } - + {children} {Footer && ( - {' '}