LT-275: Fixing common section selection for inner levels

This commit is contained in:
Bruno Alves de Faria 2016-08-15 16:35:50 -03:00
parent 9e61bdf300
commit a2c8d0627e
2 changed files with 23 additions and 2 deletions

View File

@ -140,7 +140,7 @@ Template.selectTree.events({
'change .select-tree:first>.tree-content>.tree-options>.tree-inputs>label>input'(event, instance) {
const component = instance.component;
const $target = $(event.target);
const $target = $(event.currentTarget);
const $label = $target.closest('label');
const eventComponent = $target.data('component');
const rootComponent = instance.data.root || component;
@ -229,6 +229,27 @@ 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());
});
}
}
});

View File

@ -7,7 +7,7 @@ OHIF.string = {};
// Search for some string inside any object or array
OHIF.string.search = (object, query, property=null, result=[]) => {
// Create the search pattern
const pattern = new RegExp($.trim(query).replace(/\s/gi, '|'), 'i');
const pattern = new RegExp($.trim(query), 'i');
_.each(object, item => {
// Stop here if item is empty