Add new modal service
This commit is contained in:
1 parent
81ad25b39f
commit
9104e7be50
8 files changed
+140
-17
No files matched your search
@@ -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 };
|
||||
|
||||
@@ -10,7 +10,8 @@ describe('Top level exports', () => {
|
||||
'HotkeysManager',
|
||||
'ServicesManager',
|
||||
//
|
||||
'createUiNotificationService',
|
||||
'createUINotificationService',
|
||||
'createUIModalService',
|
||||
//
|
||||
'utils',
|
||||
'studies',
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* A UI Element
|
||||
*
|
||||
* @typedef {HTMLElement} Modal
|
||||
*/
|
||||
|
||||
/**
|
||||
* UI Modal
|
||||
*
|
||||
* @typedef {Object} ModalProps
|
||||
* @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
|
||||
* @param {ModalProps} props { backdrop, keyboard, show, closeButton, title, customClassName }
|
||||
*/
|
||||
function show(component, props) {
|
||||
const {
|
||||
backdrop = false,
|
||||
keyboard = false,
|
||||
show = true,
|
||||
closeButton = true,
|
||||
title = null,
|
||||
customClassName = null,
|
||||
} = props;
|
||||
return uiModalServiceImplementation._show(component, {
|
||||
backdrop,
|
||||
keyboard,
|
||||
show,
|
||||
closeButton,
|
||||
title,
|
||||
customClassName,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
@@ -22,7 +22,7 @@ const uiNotificationServiceImplementation = {
|
||||
_show: () => console.warn('show() NOT IMPLEMENTED'),
|
||||
};
|
||||
|
||||
function createUiNotificationService() {
|
||||
function createUINotificationService() {
|
||||
return uiNotificationServicePublicApi;
|
||||
}
|
||||
|
||||
@@ -81,4 +81,4 @@ function setServiceImplementation({
|
||||
}
|
||||
}
|
||||
|
||||
export default createUiNotificationService;
|
||||
export default createUINotificationService;
|
||||
@@ -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 };
|
||||
Reference in new issue
Block a user