##// END OF EJS Templates
quick-search: use smart group search when browsing inside a repository group....
marcink -
r2804:0f04cf5e default
parent child Browse files
Show More
@@ -29,7 +29,7 b' from rhodecode.lib import helpers as h'
29 from rhodecode.lib.auth import (
29 from rhodecode.lib.auth import (
30 LoginRequired, NotAnonymous, HasRepoGroupPermissionAnyDecorator)
30 LoginRequired, NotAnonymous, HasRepoGroupPermissionAnyDecorator)
31 from rhodecode.lib.index import searcher_from_config
31 from rhodecode.lib.index import searcher_from_config
32 from rhodecode.lib.utils2 import safe_unicode, str2bool
32 from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int
33 from rhodecode.lib.ext_json import json
33 from rhodecode.lib.ext_json import json
34 from rhodecode.model.db import (
34 from rhodecode.model.db import (
35 func, or_, in_filter_generator, Repository, RepoGroup, User, UserGroup)
35 func, or_, in_filter_generator, Repository, RepoGroup, User, UserGroup)
@@ -326,6 +326,20 b' class HomeView(BaseAppView):'
326 'url': h.route_path(
326 'url': h.route_path(
327 'search', _query={'q': query})
327 'search', _query={'q': query})
328 })
328 })
329 repo_group_id = safe_int(self.request.GET.get('repo_group_id'))
330 if repo_group_id:
331 repo_group = RepoGroup.get(repo_group_id)
332 composed_hint = '{}/{}'.format(repo_group.group_name, query)
333 show_hint = not query.startswith(repo_group.group_name)
334 if repo_group and show_hint:
335 hint = u'Group search: `{}`'.format(composed_hint)
336 res.append({
337 'id': -1,
338 'value': composed_hint,
339 'value_display': hint,
340 'type': 'hint',
341 'url': ""
342 })
329
343
330 repo_groups = self._get_repo_group_list(query)
344 repo_groups = self._get_repo_group_list(query)
331 for serialized_repo_group in repo_groups:
345 for serialized_repo_group in repo_groups:
@@ -523,7 +523,10 b' commit:efced4, to search for commits'
523
523
524 var icon = '';
524 var icon = '';
525
525
526 if (searchType === 'search') {
526 if (searchType === 'hint') {
527 icon += '<i class="icon-folder-close"></i> ';
528 }
529 else if (searchType === 'search') {
527 icon += '<i class="icon-more"></i> ';
530 icon += '<i class="icon-more"></i> ';
528 }
531 }
529 else if (searchType === 'repo') {
532 else if (searchType === 'repo') {
@@ -561,7 +564,12 b' commit:efced4, to search for commits'
561 };
564 };
562
565
563 var handleSelect = function(element, suggestion) {
566 var handleSelect = function(element, suggestion) {
564 window.location = suggestion['url'];
567 if (suggestion.type === "hint") {
568 // we skip action
569 $('#main_filter').focus();
570 } else {
571 window.location = suggestion['url'];
572 }
565 };
573 };
566 var autocompleteMainFilterResult = function (suggestion, originalQuery, queryLowerCase) {
574 var autocompleteMainFilterResult = function (suggestion, originalQuery, queryLowerCase) {
567 if (queryLowerCase.split(':').length === 2) {
575 if (queryLowerCase.split(':').length === 2) {
@@ -572,6 +580,7 b' commit:efced4, to search for commits'
572
580
573 $('#main_filter').autocomplete({
581 $('#main_filter').autocomplete({
574 serviceUrl: pyroutes.url('goto_switcher_data'),
582 serviceUrl: pyroutes.url('goto_switcher_data'),
583 params: {"repo_group_id": templateContext.repo_group_id},
575 minChars:2,
584 minChars:2,
576 maxHeight:400,
585 maxHeight:400,
577 deferRequestBy: 300, //miliseconds
586 deferRequestBy: 300, //miliseconds
@@ -8,6 +8,9 b" if hasattr(c, 'rhodecode_db_repo'):"
8 c.template_context['repo_type'] = c.rhodecode_db_repo.repo_type
8 c.template_context['repo_type'] = c.rhodecode_db_repo.repo_type
9 c.template_context['repo_landing_commit'] = c.rhodecode_db_repo.landing_rev[1]
9 c.template_context['repo_landing_commit'] = c.rhodecode_db_repo.landing_rev[1]
10
10
11 if getattr(c, 'repo_group', None):
12 c.template_context['repo_group_id'] = c.repo_group.group_id
13
11 if getattr(c, 'rhodecode_user', None) and c.rhodecode_user.user_id:
14 if getattr(c, 'rhodecode_user', None) and c.rhodecode_user.user_id:
12 c.template_context['rhodecode_user']['username'] = c.rhodecode_user.username
15 c.template_context['rhodecode_user']['username'] = c.rhodecode_user.username
13 c.template_context['rhodecode_user']['email'] = c.rhodecode_user.email
16 c.template_context['rhodecode_user']['email'] = c.rhodecode_user.email
General Comments 0
You need to be logged in to leave comments. Login now