2012-07-31 01:09:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorMainMenuSearchView extends AphrontView {
|
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function getID() {
|
|
|
|
if (!$this->id) {
|
|
|
|
$this->id = celerity_generate_unique_node_id();
|
|
|
|
}
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
$user = $this->user;
|
|
|
|
|
2014-05-03 02:57:01 +02:00
|
|
|
$target_id = celerity_generate_unique_node_id();
|
2012-07-31 01:09:14 +02:00
|
|
|
$search_id = $this->getID();
|
2014-05-03 02:57:01 +02:00
|
|
|
$button_id = celerity_generate_unique_node_id();
|
2012-07-31 01:09:14 +02:00
|
|
|
|
2013-01-18 03:39:02 +01:00
|
|
|
$input = phutil_tag(
|
2012-07-31 01:09:14 +02:00
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'type' => 'text',
|
|
|
|
'name' => 'query',
|
2012-08-01 02:58:21 +02:00
|
|
|
'id' => $search_id,
|
|
|
|
'autocomplete' => 'off',
|
2012-07-31 01:09:14 +02:00
|
|
|
));
|
|
|
|
|
2013-01-25 21:57:17 +01:00
|
|
|
$target = javelin_tag(
|
2012-08-01 02:58:21 +02:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'id' => $target_id,
|
|
|
|
'class' => 'phabricator-main-menu-search-target',
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
|
2012-07-31 01:09:14 +02:00
|
|
|
Javelin::initBehavior(
|
2012-08-01 02:58:21 +02:00
|
|
|
'phabricator-search-typeahead',
|
2012-07-31 01:09:14 +02:00
|
|
|
array(
|
2012-08-01 02:58:21 +02:00
|
|
|
'id' => $target_id,
|
|
|
|
'input' => $search_id,
|
2014-05-03 02:57:01 +02:00
|
|
|
'button' => $button_id,
|
2012-08-01 02:58:21 +02:00
|
|
|
'src' => '/typeahead/common/mainsearch/',
|
|
|
|
'limit' => 10,
|
Replace "search scope" with selectable default behavior
Summary:
Fixes T4365. See discussion in D8123.
This implements the most conservative solution of approaches discussed in D8123. Basically:
- When you search in primary search, we overwrite "query" in your default (topmost) search filter, and execute that.
This doesn't implement any of the other "sticky" stuff, where the query sticks around. Maybe we'll do that eventually, but it gets messy and could be confusing. Practically, this addresses the major use case in the wild, which is to make the menu bar search mean "Open Tasks" by default.
This also removes the old, obsolete "search scope" stuff. A long time ago, searching from within Maniphest would search tasks, etc., but this was pretty weird and confusing and is no longer used, and no one complained when we got rid of it.
Test Plan: Dragged "Open Tasks" to my top search, searched for "asdf", got "asdf in open tasks" results.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: bigo, aran
Maniphest Tasks: T4365
Differential Revision: https://secure.phabricator.com/D8135
2014-02-03 23:29:49 +01:00
|
|
|
'placeholder' => pht('Search'),
|
2012-07-31 01:09:14 +02:00
|
|
|
));
|
|
|
|
|
Replace "search scope" with selectable default behavior
Summary:
Fixes T4365. See discussion in D8123.
This implements the most conservative solution of approaches discussed in D8123. Basically:
- When you search in primary search, we overwrite "query" in your default (topmost) search filter, and execute that.
This doesn't implement any of the other "sticky" stuff, where the query sticks around. Maybe we'll do that eventually, but it gets messy and could be confusing. Practically, this addresses the major use case in the wild, which is to make the menu bar search mean "Open Tasks" by default.
This also removes the old, obsolete "search scope" stuff. A long time ago, searching from within Maniphest would search tasks, etc., but this was pretty weird and confusing and is no longer used, and no one complained when we got rid of it.
Test Plan: Dragged "Open Tasks" to my top search, searched for "asdf", got "asdf in open tasks" results.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: bigo, aran
Maniphest Tasks: T4365
Differential Revision: https://secure.phabricator.com/D8135
2014-02-03 23:29:49 +01:00
|
|
|
$primary_input = phutil_tag(
|
2012-07-31 01:09:14 +02:00
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
Replace "search scope" with selectable default behavior
Summary:
Fixes T4365. See discussion in D8123.
This implements the most conservative solution of approaches discussed in D8123. Basically:
- When you search in primary search, we overwrite "query" in your default (topmost) search filter, and execute that.
This doesn't implement any of the other "sticky" stuff, where the query sticks around. Maybe we'll do that eventually, but it gets messy and could be confusing. Practically, this addresses the major use case in the wild, which is to make the menu bar search mean "Open Tasks" by default.
This also removes the old, obsolete "search scope" stuff. A long time ago, searching from within Maniphest would search tasks, etc., but this was pretty weird and confusing and is no longer used, and no one complained when we got rid of it.
Test Plan: Dragged "Open Tasks" to my top search, searched for "asdf", got "asdf in open tasks" results.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: bigo, aran
Maniphest Tasks: T4365
Differential Revision: https://secure.phabricator.com/D8135
2014-02-03 23:29:49 +01:00
|
|
|
'name' => 'search:primary',
|
|
|
|
'value' => 'true',
|
2012-07-31 01:09:14 +02:00
|
|
|
));
|
|
|
|
|
2013-02-13 23:50:15 +01:00
|
|
|
$form = phabricator_form(
|
2012-07-31 01:09:14 +02:00
|
|
|
$user,
|
|
|
|
array(
|
|
|
|
'action' => '/search/',
|
|
|
|
'method' => 'POST',
|
|
|
|
),
|
2013-11-09 19:48:19 +01:00
|
|
|
phutil_tag_div('phabricator-main-menu-search-container', array(
|
2013-02-13 23:50:15 +01:00
|
|
|
$input,
|
2014-05-03 02:57:01 +02:00
|
|
|
phutil_tag(
|
|
|
|
'button',
|
|
|
|
array('id' => $button_id),
|
|
|
|
pht('Search')),
|
Replace "search scope" with selectable default behavior
Summary:
Fixes T4365. See discussion in D8123.
This implements the most conservative solution of approaches discussed in D8123. Basically:
- When you search in primary search, we overwrite "query" in your default (topmost) search filter, and execute that.
This doesn't implement any of the other "sticky" stuff, where the query sticks around. Maybe we'll do that eventually, but it gets messy and could be confusing. Practically, this addresses the major use case in the wild, which is to make the menu bar search mean "Open Tasks" by default.
This also removes the old, obsolete "search scope" stuff. A long time ago, searching from within Maniphest would search tasks, etc., but this was pretty weird and confusing and is no longer used, and no one complained when we got rid of it.
Test Plan: Dragged "Open Tasks" to my top search, searched for "asdf", got "asdf in open tasks" results.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: bigo, aran
Maniphest Tasks: T4365
Differential Revision: https://secure.phabricator.com/D8135
2014-02-03 23:29:49 +01:00
|
|
|
$primary_input,
|
2013-11-09 19:48:19 +01:00
|
|
|
$target,
|
|
|
|
)));
|
2012-07-31 01:09:14 +02:00
|
|
|
|
2012-12-07 22:33:03 +01:00
|
|
|
return $form;
|
2012-07-31 01:09:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|