LT-331 Study list context menu behaviour issues
This commit is contained in:
parent
c89319344a
commit
9998323cfb
@ -2,17 +2,26 @@
|
|||||||
{{#dropdownForm}}
|
{{#dropdownForm}}
|
||||||
<li><a id="viewStudies" type="button" title="View Studies">View</a></li>
|
<li><a id="viewStudies" type="button" title="View Studies">View</a></li>
|
||||||
<li class="divider" role="separator"></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>
|
||||||
<li><a id="launchRemoveAssociation"
|
{{/let}}
|
||||||
|
|
||||||
|
{{#let classes=getRemoveAssociationClasses}}
|
||||||
|
<li class="{{classes}}">
|
||||||
|
<a id="launchRemoveAssociation"
|
||||||
type="button"
|
type="button"
|
||||||
|
class="{{classes}}"
|
||||||
data-toggle="modal"
|
data-toggle="modal"
|
||||||
data-target="#confirmRemoveTimepointAssociation"
|
data-target="#confirmRemoveTimepointAssociation"
|
||||||
title="Remove Timepoint Association">
|
title="Remove Timepoint Association">
|
||||||
Remove Association
|
Remove Association
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{{/let}}
|
||||||
|
|
||||||
<li class="divider" role="separator"></li>
|
<li class="divider" role="separator"></li>
|
||||||
<li>
|
<li>
|
||||||
<a id="viewSeriesDetails" type="button"
|
<a id="viewSeriesDetails" type="button"
|
||||||
|
|||||||
@ -8,7 +8,61 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
// See https://github.com/aldeed/meteor-template-extension
|
// See https://github.com/aldeed/meteor-template-extension
|
||||||
const defaultTemplate = 'studyContextMenu';
|
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.longitudinalStudyListContextMenu.replaces(defaultTemplate);
|
||||||
|
Template[defaultTemplate].inheritsHelpersFrom('longitudinalStudyListContextMenu');
|
||||||
|
|
||||||
StudyList.functions.launchStudyAssociation = () => OHIF.ui.showFormDialog('dialogStudyAssociation');
|
StudyList.functions.launchStudyAssociation = () => OHIF.ui.showFormDialog('dialogStudyAssociation');
|
||||||
StudyList.functions.removeTimepointAssociations = removeTimepointAssociations;
|
StudyList.functions.removeTimepointAssociations = removeTimepointAssociations;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
import { $ } from 'meteor/jquery';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used inside the StudyList package to define a right click callback
|
* This function is used inside the StudyList package to define a right click callback
|
||||||
@ -55,12 +56,18 @@ function viewSeriesDetails() {
|
|||||||
|
|
||||||
Template.studyContextMenu.events({
|
Template.studyContextMenu.events({
|
||||||
'click a': function(e) {
|
'click a': function(e) {
|
||||||
var study = Template.studyContextMenu.$study;
|
var id, fn, target = $(e.currentTarget);
|
||||||
var id = $(e.currentTarget).attr('id');
|
|
||||||
|
|
||||||
var fn = StudyList.functions[id];
|
if (target.hasClass('disabled')) {
|
||||||
if (fn && typeof(fn) === 'function') {
|
return;
|
||||||
fn(study);
|
}
|
||||||
|
|
||||||
|
id = target.attr('id');
|
||||||
|
if (id in StudyList.functions) {
|
||||||
|
fn = StudyList.functions[id];
|
||||||
|
if (typeof fn === 'function') {
|
||||||
|
fn(Template.studyContextMenu.$study);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var dialog = $('#studyContextMenu');
|
var dialog = $('#studyContextMenu');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user