From 1c6487197f5508497feaa6e9addfcbb4756ef5da Mon Sep 17 00:00:00 2001 From: tuomaspelkonen Date: Tue, 5 Apr 2011 14:16:49 -0700 Subject: [PATCH] Object selector does live-updates without requiring user to hit 'search' Summary: Editing Maniphest tasks for a Differential Revision required user to hit 'search' every time he changed search parameters. Now select and text input changes trigger search automatically. Test Plan: Tested that changing the select and entering text automatically gave the correct results. Reviewed By: epriestley Reviewers: epriestley, jungejason Commenters: jungejason CC: epriestley, jungejason Differential Revision: 102 --- .../PhabricatorObjectSelectorDialog.php | 3 -- .../core/behavior-object-selector.js | 41 +++++++++++-------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/view/control/objectselector/PhabricatorObjectSelectorDialog.php b/src/view/control/objectselector/PhabricatorObjectSelectorDialog.php index a35983caa9..466058bc26 100644 --- a/src/view/control/objectselector/PhabricatorObjectSelectorDialog.php +++ b/src/view/control/objectselector/PhabricatorObjectSelectorDialog.php @@ -101,9 +101,6 @@ class PhabricatorObjectSelectorDialog { - - - '); $result_box = diff --git a/webroot/rsrc/js/application/core/behavior-object-selector.js b/webroot/rsrc/js/application/core/behavior-object-selector.js index 72be21dd7a..eeebfdbf83 100644 --- a/webroot/rsrc/js/application/core/behavior-object-selector.js +++ b/webroot/rsrc/js/application/core/behavior-object-selector.js @@ -12,6 +12,8 @@ JX.behavior('phabricator-object-selector', function(config) { phids[k] = true; } var attach_list = {}; + var query_timer = null; + var query_delay = 50; var phid_input = JX.DOM.find( JX.$(config.form), @@ -94,6 +96,7 @@ JX.behavior('phabricator-object-selector', function(config) { } function sendQuery() { + query_timer = null; JX.DOM.setContent(JX.$(config.results), renderNote('Loading...')) new JX.Request(config.uri, JX.bind(null, onreceive, ++n)) .setData({ @@ -103,24 +106,6 @@ JX.behavior('phabricator-object-selector', function(config) { .send(); } - JX.DOM.listen( - JX.$(config.search), - 'submit', - null, - function(e) { - e.kill(); - sendQuery(); - }); - JX.DOM.listen( - JX.$(config.search), - 'click', - 'tag:button', - function(e) { - e.kill(); - sendQuery(); - }); - - JX.DOM.listen( JX.$(config.results), 'click', @@ -162,6 +147,26 @@ JX.behavior('phabricator-object-selector', function(config) { redrawAttached(); }); + JX.DOM.listen( + JX.$(config.filter), + 'change', + null, + function(e) { + e.kill(); + sendQuery(); + }); + + JX.DOM.listen( + JX.$(config.query), + 'keydown', + null, + function(e) { + if (query_timer) { + query_timer.stop(); + } + query_timer = JX.defer(sendQuery, query_delay); + }); + sendQuery(); redrawAttached();