Fixing flashButton wrong deactivation issue

This commit is contained in:
Bruno Alves de Faria 2018-01-05 08:04:41 -02:00
parent 68991df87c
commit 1983ee18a1
2 changed files with 22 additions and 16 deletions

View File

@ -8,7 +8,6 @@ Template.toolbarSectionButton.onCreated(() => {
instance.isActive = activeToolId => { instance.isActive = activeToolId => {
OHIF.commands.last.dep.depend(); OHIF.commands.last.dep.depend();
const instance = Template.instance();
const subTools = instance.data.subTools; const subTools = instance.data.subTools;
const currentId = instance.data.id; const currentId = instance.data.id;
const isCurrentTool = currentId === activeToolId; const isCurrentTool = currentId === activeToolId;
@ -52,7 +51,12 @@ Template.toolbarSectionButton.onCreated(() => {
$element.addClass('active'); $element.addClass('active');
setTimeout(() => { setTimeout(() => {
if ($element.hasClass('expandable') && $element.find('.toolbarSectionButton.active').length) return; if ($element.hasClass('expandable') && $element.find('.toolbarSectionButton.active').length) return;
$element.removeClass('active');
const activeToolId = Session.get('ToolManagerActiveTool');
const isActive = instance.isActive(activeToolId);
if (!isActive) {
$element.removeClass('active');
}
}, 100); }, 100);
}; };

View File

@ -4,6 +4,7 @@ import { $ } from 'meteor/jquery';
import { _ } from 'meteor/underscore'; import { _ } from 'meteor/underscore';
// Local Modules // Local Modules
import { OHIF } from 'meteor/ohif:core'; import { OHIF } from 'meteor/ohif:core';
import { cornerstone, cornerstoneTools } from 'meteor/ohif:cornerstone';
import { updateOrientationMarkers } from './updateOrientationMarkers'; import { updateOrientationMarkers } from './updateOrientationMarkers';
import { getInstanceClassDefaultViewport } from './instanceClassSpecificViewport'; import { getInstanceClassDefaultViewport } from './instanceClassSpecificViewport';
@ -170,11 +171,11 @@ const clearTools = () => {
const linkStackScroll = () => { const linkStackScroll = () => {
const synchronizer = OHIF.viewer.stackImagePositionOffsetSynchronizer; const synchronizer = OHIF.viewer.stackImagePositionOffsetSynchronizer;
if(!synchronizer) { if (!synchronizer) {
return; return;
} }
if(synchronizer.isActive()) { if (synchronizer.isActive()) {
synchronizer.deactivate(); synchronizer.deactivate();
} else { } else {
synchronizer.activate(); synchronizer.activate();
@ -185,15 +186,17 @@ const linkStackScroll = () => {
// and has been moved here to avoid circular dependency issues. // and has been moved here to avoid circular dependency issues.
const toggleDialog = (element, closeAction) => { const toggleDialog = (element, closeAction) => {
const $element = $(element); const $element = $(element);
if($element.is('dialog')) { if ($element.is('dialog')) {
if (element.hasAttribute('open')) { if (element.hasAttribute('open')) {
if (closeAction) closeAction(); if (closeAction) {
closeAction();
}
element.close(); element.close();
} else { } else {
element.show(); element.show();
} }
} } else {
else {
const isClosed = $element.hasClass('dialog-open'); const isClosed = $element.hasClass('dialog-open');
$element.toggleClass('dialog-closed', isClosed); $element.toggleClass('dialog-closed', isClosed);
$element.toggleClass('dialog-open', !isClosed); $element.toggleClass('dialog-open', !isClosed);
@ -262,7 +265,7 @@ const isPlaying = () => {
// Get the clip state // Get the clip state
const clipState = toolState.data[0]; const clipState = toolState.data[0];
if(clipState) { if (clipState) {
// Return true if the clip is playing // Return true if the clip is playing
return !_.isUndefined(clipState.intervalId); return !_.isUndefined(clipState.intervalId);
} }
@ -279,8 +282,8 @@ const hasMultipleFrames = () => {
const activeViewport = getActiveViewportElement(); const activeViewport = getActiveViewportElement();
// No active viewport yet: disable button // No active viewport yet: disable button
if(!activeViewport || !$(activeViewport).find('canvas').length) { if (!activeViewport || !$(activeViewport).find('canvas').length) {
return true; return true;
} }
// Get images in the stack // Get images in the stack
@ -296,8 +299,8 @@ const hasMultipleFrames = () => {
const nImages = stackData.imageIds && stackData.imageIds.length ? stackData.imageIds.length : 1; const nImages = stackData.imageIds && stackData.imageIds.length ? stackData.imageIds.length : 1;
// Stack has just one image, so disable button // Stack has just one image, so disable button
if(nImages === 1) { if (nImages === 1) {
return true; return true;
} }
return false; return false;
@ -306,7 +309,7 @@ const hasMultipleFrames = () => {
// Stop clips on all non-empty elements // Stop clips on all non-empty elements
const stopAllClips = () => { const stopAllClips = () => {
const elements = $('.imageViewerViewport').not('.empty'); const elements = $('.imageViewerViewport').not('.empty');
elements.each( (index, element) => { elements.each((index, element) => {
if ($(element).find('canvas').length) { if ($(element).find('canvas').length) {
cornerstoneTools.stopClip(element); cornerstoneTools.stopClip(element);
} }
@ -319,8 +322,7 @@ const stopActiveClip = () => {
if ($(activeElement).find('canvas').length) { if ($(activeElement).find('canvas').length) {
cornerstoneTools.stopClip(activeElement); cornerstoneTools.stopClip(activeElement);
} }
} };
const isStackScrollLinkingDisabled = () => { const isStackScrollLinkingDisabled = () => {
let linkableViewportsCount = 0; let linkableViewportsCount = 0;