From 8fdf9c2b1c99aa0a1eeed89c43bfd26a5c2002da Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Thu, 18 Aug 2016 17:15:59 -0300 Subject: [PATCH] LT-275: Enabling labels selection by the common section --- .../design/styles/components/selectTree.styl | 2 +- .../components/measureFlow/measureFlow.js | 27 ++++++--- .../components/measureFlow/measureFlow.styl | 9 +++ .../components/bootstrap/input/selectTree.js | 56 +++++++++++++++++++ .../bootstrap/input/selectTreeCommon.js | 39 +------------ .../components/playground/playground.html | 2 +- 6 files changed, 87 insertions(+), 48 deletions(-) diff --git a/Packages/design/styles/components/selectTree.styl b/Packages/design/styles/components/selectTree.styl index 543f5ed92..42e870c45 100644 --- a/Packages/design/styles/components/selectTree.styl +++ b/Packages/design/styles/components/selectTree.styl @@ -217,7 +217,7 @@ $gray6 = #303030 .content margin-left: 0 - &.interacted + &.interacted, &.selected .select-tree-common z-index: 1 diff --git a/Packages/lesiontracker/client/components/measureFlow/measureFlow.js b/Packages/lesiontracker/client/components/measureFlow/measureFlow.js index 4e92b488e..f6df8dee1 100644 --- a/Packages/lesiontracker/client/components/measureFlow/measureFlow.js +++ b/Packages/lesiontracker/client/components/measureFlow/measureFlow.js @@ -55,25 +55,33 @@ Template.measureFlow.onCreated(() => { }]; const items = [ + 'Abdomen/Chest Wall', 'Adrenal', - 'Muscle', 'Bladder', - 'Neck', 'Bone', - 'Other Soft Tissue', 'Brain', - 'Ovary', 'Breast', - 'Pancreas', 'Colon', - 'Prostate', 'Esophagus', - 'Small Bowel', 'Extremities', - 'Spleen', 'Gallbladder', - 'Stomach', 'Kidney', + 'Liver', + 'Lung', + 'Lymph Node', + 'Mediastinum/Hilum', + 'Muscle', + 'Neck', + 'Other Soft Tissue', + 'Ovary', + 'Pancreas', + 'Pelvis', + 'Peritoneum/Omentum', + 'Prostate', + 'Retroperitoneum', + 'Small Bowel', + 'Spleen', + 'Stomach', 'Subcutaneous' ]; @@ -130,6 +138,7 @@ Template.measureFlow.events({ key: 'label', items: instance.items, commonItems: instance.commonItems, + hideCommon: instance.data.hideCommon, label: 'Assign label', searchPlaceholder: 'Search labels', storageKey: 'measureLabelCommon', diff --git a/Packages/lesiontracker/client/components/measureFlow/measureFlow.styl b/Packages/lesiontracker/client/components/measureFlow/measureFlow.styl index 4cd2c0556..20ab85271 100644 --- a/Packages/lesiontracker/client/components/measureFlow/measureFlow.styl +++ b/Packages/lesiontracker/client/components/measureFlow/measureFlow.styl @@ -121,6 +121,15 @@ .select-tree-root + &.interacted .select-tree-common .content + animation-name: none + + &.selected .select-tree-common .content + animation-name: selectTreeCommonCloseLeft + + .tree-search input + display: none + .select-tree-common padding-left: 0 padding-right: 6px diff --git a/Packages/ohif-core/client/components/bootstrap/input/selectTree.js b/Packages/ohif-core/client/components/bootstrap/input/selectTree.js index dbdf85056..2a1bb6741 100644 --- a/Packages/ohif-core/client/components/bootstrap/input/selectTree.js +++ b/Packages/ohif-core/client/components/bootstrap/input/selectTree.js @@ -11,6 +11,45 @@ import transition from 'meteor/ohif:core/client/lib/third-party/transition-to-fr Template.selectTree.onCreated(() => { const instance = Template.instance(); + // Return the common items + instance.getCommonItems = () => { + 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(); + + // Generate an object with encoded keys from the tree leaves + leavesObject = {}; + _.each(leaves, leaf => { + leavesObject[OHIF.string.encodeId(leaf.value)] = leaf; + }); + + // Get the current items ranking + const ranking = OHIF.user.getData(instance.data.storageKey); + + // Sort the items based on how many times each one was used + const sorted = []; + _.each(ranking, (count, key) => sorted.push([key, count])); + sorted.sort((a, b) => b[1] - a[1]); + + // Create the result and push every item respecting the ranking order + const result = []; + _.each(sorted, item => { + const current = leavesObject[item[0]]; + if (current) { + result.push(current); + } + }); + + // Return the resulting array + return result; + }; + // Create a reactive variable to control the search instance.searchTerm = new ReactiveVar(''); }); @@ -270,6 +309,23 @@ Template.selectTree.helpers({ // Filter only the tree leaves items = _.filter(items, item => !item.items); + } else if (instance.data.hideCommon) { + // Get the values of common items + const commonValues = _.pluck(instance.getCommonItems(), 'value'); + + // Filter only the items that are not common + items = _.filter(items, item => !_.contains(commonValues, item.value)); + } + + // Return the items sorted for tree columns + if (instance.data.treeColumns) { + const begin = items.splice(0, Math.ceil(items.length / 2)); + const sortedItems = []; + _.each(begin, (item, index) => { + sortedItems.push(item); + items[index] && sortedItems.push(items[index]); + }); + items = sortedItems; } // Return the tree items diff --git a/Packages/ohif-core/client/components/bootstrap/input/selectTreeCommon.js b/Packages/ohif-core/client/components/bootstrap/input/selectTreeCommon.js index 9acecd500..534aec32a 100644 --- a/Packages/ohif-core/client/components/bootstrap/input/selectTreeCommon.js +++ b/Packages/ohif-core/client/components/bootstrap/input/selectTreeCommon.js @@ -28,44 +28,9 @@ Template.selectTreeCommon.events({ } }); - Template.selectTreeCommon.helpers({ - // Get the common items ordered by use history + // Get the common items 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(); - - // Generate an object with encoded keys from the tree leaves - leavesObject = {}; - _.each(leaves, leaf => { - leavesObject[OHIF.string.encodeId(leaf.value)] = leaf; - }); - - // Get the current items ranking - const ranking = OHIF.user.getData(instance.data.storageKey); - - // Sort the items based on how many times each one was used - const sorted = []; - _.each(ranking, (count, key) => sorted.push([key, count])); - sorted.sort((a, b) => b[1] - a[1]); - - // Create the result and push every item respecting the ranking order - const result = []; - _.each(sorted, item => { - const current = leavesObject[item[0]]; - if (current) { - result.push(current); - } - }); - - // Return the resulting array - return result; + return Template.instance().data.treeInstance.getCommonItems(); } }); diff --git a/Packages/ohif-core/client/components/playground/playground.html b/Packages/ohif-core/client/components/playground/playground.html index 8dcd60861..b72f3c364 100644 --- a/Packages/ohif-core/client/components/playground/playground.html +++ b/Packages/ohif-core/client/components/playground/playground.html @@ -1,6 +1,6 @@