Adding util function to navigate over lesions

This commit is contained in:
Bruno Alves de Faria 2017-10-02 16:24:56 -03:00
parent 7641d6e9af
commit f486724643
2 changed files with 31 additions and 0 deletions

View File

@ -9,5 +9,6 @@ import './getTimepointName';
import './hangingProtocolCustomizations';
import './MeasurementHandlers';
import './MeasurementManager';
import './navigateOverLesions';
import './syncMeasurementAndToolData';
import './toggleLabelButton';

View File

@ -0,0 +1,30 @@
import { OHIF } from 'meteor/ohif:core';
/**
* Method to go select the next or previous lesion on measurements table
*
* @param {Boolean} isNextLesion Determine if it will navigate to the next or previous lesion
*/
OHIF.measurements.navigateOverLesions = isNextLesion => {
const $table = $('#measurementTableContainer');
if (!$table.length) return;
const $lesions = $table.find('.measurementTableRow');
if (!$lesions.length) return;
const $activeLesion = $lesions.filter('.active');
const activeIndex = $lesions.index($activeLesion);
const step = isNextLesion ? 1 : -1;
let newIndex = 0;
if (activeIndex !== -1) {
newIndex = activeIndex + step;
if (newIndex >= $lesions.length) {
newIndex = 0;
} else if (newIndex < 0) {
newIndex = $lesions.length - 1;
}
}
$lesions.eq(newIndex).find('.measurementRowSidebar').trigger('click');
};