From d5ecfbdd394ce427b766b18fd09cc1fccbd4779b Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Thu, 18 Aug 2016 08:49:00 -0300 Subject: [PATCH] LT-275: Adding fixed common labels to open source version --- .../components/measureFlow/measureFlow.js | 46 ++++++++++++------- .../bootstrap/input/selectTree.html | 4 +- .../components/bootstrap/input/selectTree.js | 21 --------- .../bootstrap/input/selectTreeCommon.js | 32 +++++++++++++ 4 files changed, 64 insertions(+), 39 deletions(-) diff --git a/Packages/lesiontracker/client/components/measureFlow/measureFlow.js b/Packages/lesiontracker/client/components/measureFlow/measureFlow.js index be7157d4d..4e92b488e 100644 --- a/Packages/lesiontracker/client/components/measureFlow/measureFlow.js +++ b/Packages/lesiontracker/client/components/measureFlow/measureFlow.js @@ -56,30 +56,24 @@ Template.measureFlow.onCreated(() => { const items = [ 'Adrenal', - 'Bladder', - 'Bone', - 'Brain', - 'Breast', - 'Colon', - 'Esophagus', - 'Extremities', - 'Gallbladder', - 'Kidney', - 'Liver', - 'Lung', - 'Lymph Node', 'Muscle', + 'Bladder', 'Neck', - 'Other: Soft Tissue', + 'Bone', + 'Other Soft Tissue', + 'Brain', 'Ovary', + 'Breast', 'Pancreas', - 'Pelvis', - 'Peritoneum/Omentum', + 'Colon', 'Prostate', - 'Retroperitoneum', + 'Esophagus', 'Small Bowel', + 'Extremities', 'Spleen', + 'Gallbladder', 'Stomach', + 'Kidney', 'Subcutaneous' ]; @@ -90,6 +84,25 @@ Template.measureFlow.onCreated(() => { value: item }); }); + + const commonItems = [ + 'Abdomen/Chest Wall', + 'Lung', + 'Lymph Node', + 'Liver', + 'Mediastinum/Hilum', + 'Pelvis', + 'Peritoneum/Omentum', + 'Retroperitoneum' + ]; + + instance.commonItems = []; + _.each(commonItems, item => { + instance.commonItems.push({ + label: item, + value: item + }); + }); }); Template.measureFlow.onRendered(() => { @@ -116,6 +129,7 @@ Template.measureFlow.events({ const data = { key: 'label', items: instance.items, + commonItems: instance.commonItems, label: 'Assign label', searchPlaceholder: 'Search labels', storageKey: 'measureLabelCommon', diff --git a/Packages/ohif-core/client/components/bootstrap/input/selectTree.html b/Packages/ohif-core/client/components/bootstrap/input/selectTree.html index 633547864..85dbbe921 100644 --- a/Packages/ohif-core/client/components/bootstrap/input/selectTree.html +++ b/Packages/ohif-core/client/components/bootstrap/input/selectTree.html @@ -45,8 +45,8 @@ {{/let}} - {{#if (and (not this.root) this.storageKey)}} - {{>selectTreeCommon (clone this component=this.component)}} + {{#if (and (not this.root) (or this.storageKey this.commonItems))}} + {{>selectTreeCommon (clone this component=this.component treeInstance=instance)}} {{/if}} {{/group}} diff --git a/Packages/ohif-core/client/components/bootstrap/input/selectTree.js b/Packages/ohif-core/client/components/bootstrap/input/selectTree.js index ee2db68cf..dbdf85056 100644 --- a/Packages/ohif-core/client/components/bootstrap/input/selectTree.js +++ b/Packages/ohif-core/client/components/bootstrap/input/selectTree.js @@ -250,27 +250,6 @@ Template.selectTree.events({ currentInstance = currentInstance.component.parent.templateInstance; } } - }, - - 'click .select-tree-common label'(event, instance) { - // Get the clicked label - const $target = $(event.currentTarget); - - // Build the input selector based on the label target - const inputSelector = '#' + $target.attr('for'); - - // Check if the input is not rendered - if (!$(inputSelector).length) { - // Change the search terms with the clicked label string - - instance.$('.tree-search input').val($target.text()).trigger('input'); - // Wait for options rerendering - - Tracker.afterFlush(() => { - // Wait for components initialization - Meteor.defer(() => $(inputSelector).click()); - }); - } } }); diff --git a/Packages/ohif-core/client/components/bootstrap/input/selectTreeCommon.js b/Packages/ohif-core/client/components/bootstrap/input/selectTreeCommon.js index b2f7feee4..9acecd500 100644 --- a/Packages/ohif-core/client/components/bootstrap/input/selectTreeCommon.js +++ b/Packages/ohif-core/client/components/bootstrap/input/selectTreeCommon.js @@ -2,11 +2,43 @@ import { OHIF } from 'meteor/ohif:core'; import { Template } from 'meteor/templating'; import { _ } from 'meteor/underscore'; +Template.selectTreeCommon.events({ + 'click .select-tree-common label'(event, instance) { + // Get the clicked label + const $target = $(event.currentTarget); + + // Build the input selector based on the label target + const inputSelector = '#' + $target.attr('for'); + + // Get the tree instance + const treeInstance = instance.data.treeInstance; + + // Check if the input is not rendered + if (!$(inputSelector).length) { + // Change the search terms with the clicked label string + + treeInstance.$('.tree-search input').val($target.text()).trigger('input'); + // Wait for options rerendering + + Tracker.afterFlush(() => { + // Wait for components initialization + Meteor.defer(() => $(inputSelector).click()); + }); + } + } +}); + + Template.selectTreeCommon.helpers({ // Get the common items ordered by use history items() { const instance = Template.instance(); + // Return the common items if given + if (instance.data.commonItems) { + return instance.data.commonItems; + } + // Get all the tree leaves const leaves = instance.data.component.getLeaves();