LT-331 Study list context menu behaviour issues
This commit is contained in:
parent
c89319344a
commit
9998323cfb
@ -2,17 +2,26 @@
|
||||
{{#dropdownForm}}
|
||||
<li><a id="viewStudies" type="button" title="View Studies">View</a></li>
|
||||
<li class="divider" role="separator"></li>
|
||||
<li>
|
||||
<a id="launchStudyAssociation" title="Launch Study Association">Associate</a>
|
||||
|
||||
{{#let classes=getAssociationClasses}}
|
||||
<li class="{{classes}}">
|
||||
<a id="launchStudyAssociation" class="{{classes}}" title="Launch Study Association">Associate</a>
|
||||
</li>
|
||||
<li><a id="launchRemoveAssociation"
|
||||
{{/let}}
|
||||
|
||||
{{#let classes=getRemoveAssociationClasses}}
|
||||
<li class="{{classes}}">
|
||||
<a id="launchRemoveAssociation"
|
||||
type="button"
|
||||
class="{{classes}}"
|
||||
data-toggle="modal"
|
||||
data-target="#confirmRemoveTimepointAssociation"
|
||||
title="Remove Timepoint Association">
|
||||
Remove Association
|
||||
</a>
|
||||
</li>
|
||||
{{/let}}
|
||||
|
||||
<li class="divider" role="separator"></li>
|
||||
<li>
|
||||
<a id="viewSeriesDetails" type="button"
|
||||
|
||||
@ -8,7 +8,61 @@ import { OHIF } from 'meteor/ohif:core';
|
||||
// See https://github.com/aldeed/meteor-template-extension
|
||||
const defaultTemplate = 'studyContextMenu';
|
||||
|
||||
function getAssociationAssessment() {
|
||||
// default result value
|
||||
const assessment = {
|
||||
selected: 0,
|
||||
associated: 0
|
||||
};
|
||||
// check if timepointApi is available
|
||||
const timepointApi = StudyList.timepointApi;
|
||||
if (timepointApi) {
|
||||
// Get a Cursor pointing to the selected Studies from the StudyList
|
||||
const selectedStudies = OHIF.studylist.getSelectedStudies();
|
||||
if (selectedStudies.length > 0) {
|
||||
assessment.selected = selectedStudies.length;
|
||||
// Loop through the selected Studies and return true if at least one study has no association.
|
||||
for (let i = selectedStudies.length - 1; i >= 0; --i) {
|
||||
let study = selectedStudies[i],
|
||||
timepoints = timepointApi.study(study.studyInstanceUid);
|
||||
if (timepoints && timepoints.length > 0) {
|
||||
assessment.associated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return assessment;
|
||||
}
|
||||
|
||||
Template.longitudinalStudyListContextMenu.helpers({
|
||||
|
||||
getAssociationClasses() {
|
||||
const disabledClass = 'disabled';
|
||||
let classList = '';
|
||||
|
||||
const assessment = getAssociationAssessment();
|
||||
if (assessment.selected < 1 || assessment.associated > 0) {
|
||||
classList += disabledClass;
|
||||
}
|
||||
|
||||
return classList;
|
||||
},
|
||||
|
||||
getRemoveAssociationClasses() {
|
||||
const disabledClass = 'disabled';
|
||||
let classList = '';
|
||||
|
||||
const assessment = getAssociationAssessment();
|
||||
if (assessment.selected < 1 || assessment.selected !== assessment.associated) {
|
||||
classList += disabledClass;
|
||||
}
|
||||
|
||||
return classList;
|
||||
}
|
||||
});
|
||||
|
||||
Template.longitudinalStudyListContextMenu.replaces(defaultTemplate);
|
||||
Template[defaultTemplate].inheritsHelpersFrom('longitudinalStudyListContextMenu');
|
||||
|
||||
StudyList.functions.launchStudyAssociation = () => OHIF.ui.showFormDialog('dialogStudyAssociation');
|
||||
StudyList.functions.removeTimepointAssociations = removeTimepointAssociations;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { $ } from 'meteor/jquery';
|
||||
|
||||
/**
|
||||
* This function is used inside the StudyList package to define a right click callback
|
||||
@ -55,12 +56,18 @@ function viewSeriesDetails() {
|
||||
|
||||
Template.studyContextMenu.events({
|
||||
'click a': function(e) {
|
||||
var study = Template.studyContextMenu.$study;
|
||||
var id = $(e.currentTarget).attr('id');
|
||||
var id, fn, target = $(e.currentTarget);
|
||||
|
||||
var fn = StudyList.functions[id];
|
||||
if (fn && typeof(fn) === 'function') {
|
||||
fn(study);
|
||||
if (target.hasClass('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
id = target.attr('id');
|
||||
if (id in StudyList.functions) {
|
||||
fn = StudyList.functions[id];
|
||||
if (typeof fn === 'function') {
|
||||
fn(Template.studyContextMenu.$study);
|
||||
}
|
||||
}
|
||||
|
||||
var dialog = $('#studyContextMenu');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user