From 5c36074f8ad46c7a0ad68f881a3c8902402df089 Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Thu, 10 Nov 2016 15:33:42 -0200 Subject: [PATCH] LT-298: Implementing rename behavior for measurement table --- .../client/components/viewer/viewer.js | 3 +- .../components/caseProgress/caseProgress.js | 1 + .../components/measureFlow/measureFlow.js | 4 +++ .../measurementTableRow.js | 33 ++++++++++++++----- .../client/lib/toggleLabelButton.js | 7 ++-- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/LesionTracker/client/components/viewer/viewer.js b/LesionTracker/client/components/viewer/viewer.js index 9afdada52..7e93c7651 100644 --- a/LesionTracker/client/components/viewer/viewer.js +++ b/LesionTracker/client/components/viewer/viewer.js @@ -141,7 +141,8 @@ Template.viewer.events({ if (toolData.active) { OHIF.measurements.toggleLabelButton({ instance, - toolData, + measurementId: toolData._id, + toolType: toolData.toolType, element, measurementApi: instance.data.measurementApi, position: data.currentPoints.page diff --git a/Packages/ohif-measurements/client/components/caseProgress/caseProgress.js b/Packages/ohif-measurements/client/components/caseProgress/caseProgress.js index 8cd42a652..cf61cccd6 100644 --- a/Packages/ohif-measurements/client/components/caseProgress/caseProgress.js +++ b/Packages/ohif-measurements/client/components/caseProgress/caseProgress.js @@ -1,5 +1,6 @@ import { Template } from 'meteor/templating'; import { ReactiveVar } from 'meteor/reactive-var'; +import { OHIF } from 'meteor/ohif:core'; Template.caseProgress.onCreated(() => { const instance = Template.instance(); diff --git a/Packages/ohif-measurements/client/components/measureFlow/measureFlow.js b/Packages/ohif-measurements/client/components/measureFlow/measureFlow.js index 4e746de6e..0c3a373d0 100644 --- a/Packages/ohif-measurements/client/components/measureFlow/measureFlow.js +++ b/Packages/ohif-measurements/client/components/measureFlow/measureFlow.js @@ -81,6 +81,10 @@ Template.measureFlow.onRendered(() => { instance.$('.measure-flow').bounded(); instance.$('.btn-add').focus(); + + if (instance.data.autoClick) { + instance.$('.btn-add').hide().trigger('click'); + } }); Template.measureFlow.events({ diff --git a/Packages/ohif-measurements/client/components/measurementTable/measurementTableRow/measurementTableRow.js b/Packages/ohif-measurements/client/components/measurementTable/measurementTableRow/measurementTableRow.js index 93978d6bb..673cde108 100644 --- a/Packages/ohif-measurements/client/components/measurementTable/measurementTableRow/measurementTableRow.js +++ b/Packages/ohif-measurements/client/components/measurementTable/measurementTableRow/measurementTableRow.js @@ -1,3 +1,5 @@ +import { Meteor } from 'meteor/meteor'; +import { Template } from 'meteor/templating'; import { OHIF } from 'meteor/ohif:core'; function doneCallback(measurementData, deleteTool) { @@ -14,7 +16,7 @@ function doneCallback(measurementData, deleteTool) { } // Delete a lesion if Ctrl+D or DELETE is pressed while a lesion is selected -var keys = { +const keys = { D: 68, DELETE: 46 }; @@ -26,10 +28,25 @@ Template.measurementTableRow.events({ $row.toggleClass('active'); }, - 'dblclick .location': function() { + 'click .js-rename'(event, instance) { + OHIF.measurements.toggleLabelButton({ + instance, + measurementId: instance.data.rowItem.entries[0], + measurementTypeId: instance.data.rowItem.measurementTypeId, + element: document.body, + measurementApi: instance.data.measurementApi, + position: { + x: event.clientX, + y: event.clientY + }, + autoClick: true + }); + }, + + 'dblclick .location'() { OHIF.log.info('Double clicked on Lesion Location cell'); - var measurementData = this; + const measurementData = this; // TODO = Fix this weird issue? Need to set toolData's ID properly.. measurementData.id = this._id; @@ -37,13 +54,13 @@ Template.measurementTableRow.events({ changeLesionLocationCallback(measurementData, null, doneCallback); }, - 'keydown .location': function(e) { - var keyCode = e.which; + 'keydown .location'(event) { + const keyCode = event.which; if (keyCode === keys.DELETE || - (keyCode === keys.D && e.ctrlKey === true)) { - var currentMeasurement = this; - var options = { + (keyCode === keys.D && event.ctrlKey === true)) { + const currentMeasurement = this; + const options = { keyPressAllowed: false, title: 'Remove measurement?', text: 'Are you sure you would like to remove the entire measurement?' diff --git a/Packages/ohif-measurements/client/lib/toggleLabelButton.js b/Packages/ohif-measurements/client/lib/toggleLabelButton.js index b1b2a3326..71d1fc811 100644 --- a/Packages/ohif-measurements/client/lib/toggleLabelButton.js +++ b/Packages/ohif-measurements/client/lib/toggleLabelButton.js @@ -21,15 +21,16 @@ OHIF.measurements.toggleLabelButton = options => { removeButtonView(); } - const tool = toolMap[options.toolData.toolType]; + const tool = options.measurementTypeId || toolMap[options.toolType]; const toolCollection = options.measurementApi[tool]; - const measurement = toolCollection.findOne(options.toolData._id); + const measurement = toolCollection.findOne(options.measurementId); const data = { measurement, position: options.position, threeColumns: true, hideCommon: true, + autoClick: options.autoClick, doneCallback(location, description) { if (_.isFunction(options.callback)) { options.callback(options, location, description); @@ -44,6 +45,8 @@ OHIF.measurements.toggleLabelButton = options => { location, description } + }, { + multi: true }); removeButtonView();