Replacing studyListContextMenu for dropdown

This commit is contained in:
Bruno Alves de Faria committed 2017-03-21 10:16:47 -03:00
1 parent 4daf7d8bf8
commit 485f82f64c
22 files changed
+250 -325

No files matched your search

@@ -1,89 +1,23 @@
import { Template } from 'meteor/templating';
import { Meteor } from 'meteor/meteor';
import { OHIF } from 'meteor/ohif:core';
import { $ } from 'meteor/jquery';
/**
* This function is used inside the StudyList package to define a right click callback
*
* @param event
*/
openStudyContextMenu = event => {
if (!OHIF.uiSettings.studyListFunctionsEnabled) {
return;
}
StudyList.functions.exportSelectedStudies = exportSelectedStudies;
StudyList.functions.viewSeriesDetails = viewSeriesDetails;
Template.studyContextMenu.$study = $(event.currentTarget);
const dropdown = OHIF.ui.showFormDropdown('studyContextMenu');
const $dropdown = $(dropdown);
const $dropdownMenu = $dropdown.children('.dropdown-menu');
dropdown.oncontextmenu = () => false;
$dropdownMenu.css({
visibility: 'hidden',
position: 'fixed',
'z-index': 10000,
}).bounded().focus();
// Postpone position change to allow boundaries restriction
Meteor.defer(() => {
$dropdownMenu.css({
visibility: 'visible',
left: `${event.clientX}px`,
top: `${event.clientY}px`
}).trigger('spatialChanged');
});
};
/**
* Exports all selected studies on the studylist
*/
function exportSelectedStudies($study, event) {
const selectedStudies = OHIF.studylist.getSelectedStudies();
const studiesCount = selectedStudies.length;
const studyText = studiesCount > 1 ? 'Studies' : 'Study';
OHIF.ui.showDialog('dialogConfirm', {
element: event.element,
title: `Export ${studyText}`,
message: `Would you like to export ${studiesCount} ${studyText.toLowerCase()}?`
}).then(() => {
OHIF.studylist.exportStudies(selectedStudies);
});
}
/**
* Display series details of study in modal
*/
function viewSeriesDetails() {
const selectedStudies = OHIF.studylist.getSelectedStudies();
if (!selectedStudies) {
return;
}
OHIF.ui.showDialog('seriesDetailsModal', { selectedStudies });
}
Template.studyContextMenu.events({
'click a'(event, instance) {
const $target = $(event.currentTarget);
if ($target.hasClass('disabled')) {
return;
}
const id = $target.attr('id');
if (id in StudyList.functions) {
const fn = StudyList.functions[id];
if (typeof fn === 'function') {
fn(Template.studyContextMenu.$study, event);
}
}
}
Meteor.startup(() => {
OHIF.studylist.dropdown.setItems([{
action: OHIF.studylist.viewSeriesDetails,
text: 'View Series Details'
}, {
text: 'Anonymize',
disabled: true
}, {
text: 'Send',
disabled: true,
separatorAfter: true
}, {
text: 'Delete',
disabled: true
}, {
action: OHIF.studylist.exportSelectedStudies,
text: 'Export',
title: 'Export Selected Studies'
}]);
});