LT-291: Allowing non-target removal
This commit is contained in:
parent
28b3b34cfe
commit
a715804880
@ -2,7 +2,7 @@
|
|||||||
<div id="{{this.id}}" class="modal fade" tabindex="-1" role="dialog">
|
<div id="{{this.id}}" class="modal fade" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog {{this.dialogClass}}" role="document">
|
<div class="modal-dialog {{this.dialogClass}}" role="document">
|
||||||
{{#form class='modal-content' hideValidationBox=true
|
{{#form class='modal-content' hideValidationBox=true
|
||||||
api=instance.api schema=this.schema
|
api=(extend instance.api instance.data.api) schema=this.schema
|
||||||
}}
|
}}
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
{{#button class='close' action='cancel'
|
{{#button class='close' action='cancel'
|
||||||
|
|||||||
@ -46,7 +46,7 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
|
|
||||||
function changeMeasurementLocationCallback(measurementData, eventData) {
|
function changeMeasurementLocationCallback(measurementData, eventData) {
|
||||||
showLocationDialog({
|
showLocationDialog({
|
||||||
title: 'Select Lesion Location',
|
title: 'Change Lesion Location',
|
||||||
measurementData,
|
measurementData,
|
||||||
eventData,
|
eventData,
|
||||||
edit: true
|
edit: true
|
||||||
@ -241,7 +241,7 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
|
|
||||||
// Draw the text
|
// Draw the text
|
||||||
if (data.measurementNumber) {
|
if (data.measurementNumber) {
|
||||||
|
|
||||||
var boundingBox = cornerstoneTools.drawTextBox(context, 'Non-Target ' + data.measurementNumber, canvasTextLocation.x, canvasTextLocation.y, color);
|
var boundingBox = cornerstoneTools.drawTextBox(context, 'Non-Target ' + data.measurementNumber, canvasTextLocation.x, canvasTextLocation.y, color);
|
||||||
data.handles.textBox.boundingBox = boundingBox;
|
data.handles.textBox.boundingBox = boundingBox;
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,16 @@
|
|||||||
<template name="dialogNonTargetMeasurement">
|
<template name="dialogNonTargetMeasurement">
|
||||||
{{#dialogForm (extend this dialogClass='modal-sm' schema=(choose this.schema instance.schema))}}
|
{{#dialogForm (extend this
|
||||||
|
dialogClass='modal-sm'
|
||||||
|
schema=(choose this.schema instance.schema)
|
||||||
|
api=instance.api
|
||||||
|
)}}
|
||||||
{{>inputSelect labelClass='form-group' key='location' hideSearch=true
|
{{>inputSelect labelClass='form-group' key='location' hideSearch=true
|
||||||
options=(clone placeholder='Choose a lesion location')}}
|
options=(clone placeholder='Choose a lesion location')}}
|
||||||
{{>inputSelect labelClass='form-group' key='response' hideSearch=true
|
{{>inputSelect labelClass='form-group' key='response' hideSearch=true
|
||||||
options=(clone placeholder='Choose a lesion location response')}}
|
options=(clone placeholder='Choose a lesion location response')}}
|
||||||
|
{{#if this.edit}}
|
||||||
|
<hr>
|
||||||
|
{{#button class='btn btn-danger' action='remove'}}Remove{{/button}}
|
||||||
|
{{/if}}
|
||||||
{{/dialogForm}}
|
{{/dialogForm}}
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -1,34 +1,64 @@
|
|||||||
import { Template } from 'meteor/templating';
|
import { Template } from 'meteor/templating';
|
||||||
import { Blaze } from 'meteor/blaze';
|
import { Blaze } from 'meteor/blaze';
|
||||||
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
|
||||||
import { _ } from 'meteor/underscore';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
import { FieldLesionLocation, FieldLesionLocationResponse } from 'meteor/ohif:lesiontracker/both/schema/fields';
|
import { FieldLesionLocation, FieldLesionLocationResponse } from 'meteor/ohif:lesiontracker/both/schema/fields';
|
||||||
|
|
||||||
Template.dialogNonTargetMeasurement.onCreated(() => {
|
Template.dialogNonTargetMeasurement.onCreated(() => {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
|
|
||||||
|
instance.measurementTypeId = 'nonTargets';
|
||||||
|
|
||||||
|
const measurementData = instance.data.measurementData;
|
||||||
|
|
||||||
instance.schema = new SimpleSchema({
|
instance.schema = new SimpleSchema({
|
||||||
location: FieldLesionLocation,
|
location: FieldLesionLocation,
|
||||||
response: FieldLesionLocationResponse
|
response: FieldLesionLocationResponse
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remove the measurement from the collection
|
||||||
|
instance.removeMeasurement = () => {
|
||||||
|
instance.viewerData.measurementApi.deleteMeasurements(instance.measurementTypeId, {
|
||||||
|
_id: measurementData._id
|
||||||
|
});
|
||||||
|
|
||||||
|
// Refresh the image with the measurement removed
|
||||||
|
cornerstone.updateImage(instance.cornerstoneElement);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Close the current dialog
|
||||||
|
instance.closeDialog = () => instance.$('.form-action.close').trigger('click');
|
||||||
|
|
||||||
|
instance.api = {
|
||||||
|
// Confirm the deletion of the current non-target measurement
|
||||||
|
remove() {
|
||||||
|
const dialogSettings = {
|
||||||
|
title: 'Remove Measurement',
|
||||||
|
message: 'Are you sure you want to remove this Non-Target measurement?'
|
||||||
|
};
|
||||||
|
|
||||||
|
OHIF.ui.showFormDialog('dialogConfirm', dialogSettings)
|
||||||
|
.then(instance.removeMeasurement);
|
||||||
|
|
||||||
|
instance.closeDialog();
|
||||||
|
}
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.dialogNonTargetMeasurement.onRendered(() => {
|
Template.dialogNonTargetMeasurement.onRendered(() => {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
|
|
||||||
const element = instance.data.eventData.element;
|
instance.cornerstoneElement = instance.data.eventData.element;
|
||||||
|
|
||||||
const form = instance.$('form').data('component');
|
const form = instance.$('form').data('component');
|
||||||
|
|
||||||
const viewerMain = $(element).closest('.viewerMain')[0];
|
const viewerMain = $(instance.cornerstoneElement).closest('.viewerMain')[0];
|
||||||
const viewerData = Blaze.getData(viewerMain);
|
instance.viewerData = Blaze.getData(viewerMain);
|
||||||
console.warn('>>>>dialogData/viewerData', instance.data, viewerData);
|
|
||||||
|
|
||||||
const measurementApi = viewerData.measurementApi;
|
const measurementApi = instance.viewerData.measurementApi;
|
||||||
|
|
||||||
const measurementTypeId = 'nonTargets';
|
|
||||||
const measurementData = instance.data.measurementData;
|
const measurementData = instance.data.measurementData;
|
||||||
const collection = measurementApi[measurementTypeId];
|
const collection = measurementApi[instance.measurementTypeId];
|
||||||
|
|
||||||
// Get the current inserted measurement from the collection
|
// Get the current inserted measurement from the collection
|
||||||
const currentMeasurement = collection.findOne({
|
const currentMeasurement = collection.findOne({
|
||||||
@ -42,7 +72,7 @@ Template.dialogNonTargetMeasurement.onRendered(() => {
|
|||||||
measurementData.measurementNumber = currentMeasurement.measurementNumber;
|
measurementData.measurementNumber = currentMeasurement.measurementNumber;
|
||||||
|
|
||||||
// Refresh the image with the measurement number
|
// Refresh the image with the measurement number
|
||||||
cornerstone.updateImage(element);
|
cornerstone.updateImage(instance.cornerstoneElement);
|
||||||
|
|
||||||
// Delete the measurement from collection when dialog is closed and not on edit mode
|
// Delete the measurement from collection when dialog is closed and not on edit mode
|
||||||
instance.data.promise.catch(() => {
|
instance.data.promise.catch(() => {
|
||||||
@ -50,12 +80,7 @@ Template.dialogNonTargetMeasurement.onRendered(() => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewerData.measurementApi.deleteMeasurements('nonTargets', {
|
instance.removeMeasurement();
|
||||||
_id: measurementData._id
|
|
||||||
});
|
|
||||||
|
|
||||||
// Refresh the image with the measurement removed
|
|
||||||
cornerstone.updateImage(element);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the location and response after confirming the dialog data
|
// Update the location and response after confirming the dialog data
|
||||||
|
|||||||
@ -97,6 +97,11 @@ class MeasurementApi {
|
|||||||
const entries = collection.find(filter).fetch();
|
const entries = collection.find(filter).fetch();
|
||||||
collection.remove(filter);
|
collection.remove(filter);
|
||||||
|
|
||||||
|
// Stop here if no entries were found
|
||||||
|
if (!entries.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If the filter doesn't have the measurement number, get it from the first entry
|
// If the filter doesn't have the measurement number, get it from the first entry
|
||||||
const measurementNumber = filter.measurementNumber || entries[0].measurementNumber;
|
const measurementNumber = filter.measurementNumber || entries[0].measurementNumber;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user