LT-275: Adding fixed common labels to open source version

This commit is contained in:
Bruno Alves de Faria committed 2016-08-18 08:49:00 -03:00
1 parent 82b23f4368
commit d5ecfbdd39
4 files changed
+64 -39

No files matched your search

@@ -45,8 +45,8 @@
</div>
{{/let}}
</div>
{{#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}}
</template>
@@ -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());
});
}
}
});
@@ -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();