##// END OF EJS Templates
quick-search: improve styling of search input and results.
dan -
r3443:6236d000 default
parent child Browse files
Show More
@@ -32,7 +32,13 b' def assert_and_get_main_filter_content(r'
32
32
33 if data_item['type'] == 'search':
33 if data_item['type'] == 'search':
34 display_val = data_item['value_display']
34 display_val = data_item['value_display']
35 assert 'Search for:' in display_val, display_val
35 if data_item['id'] == -1:
36 assert 'File search for:' in display_val, display_val
37 elif data_item['id'] == -2:
38 assert 'Commit search for:' in display_val, display_val
39 else:
40 assert False, 'No Proper ID returned {}'.format(data_item['id'])
41
36 elif data_item['type'] == 'repo':
42 elif data_item['type'] == 'repo':
37 repos.append(data_item)
43 repos.append(data_item)
38 elif data_item['type'] == 'repo_group':
44 elif data_item['type'] == 'repo_group':
@@ -263,19 +263,30 b' class HomeView(BaseAppView):'
263 'commit_id:{}*'.format(commit_hash), 'commit', auth_user,
263 'commit_id:{}*'.format(commit_hash), 'commit', auth_user,
264 raise_on_exc=False)
264 raise_on_exc=False)
265
265
266 return [
266 commits = []
267 {
267 for entry in result['results']:
268 repo_data = {
269 'repository_id': entry.get('repository_id'),
270 'repository_type': entry.get('repo_type'),
271 'repository_name': entry.get('repository'),
272 }
273
274 commit_entry = {
268 'id': entry['commit_id'],
275 'id': entry['commit_id'],
269 'value': org_query,
276 'value': org_query,
270 'value_display': 'repo `{}` commit: {}'.format(
277 'value_display': '`{}` commit: {}'.format(
271 entry['repository'], entry['commit_id']),
278 entry['repository'], entry['commit_id']),
272 'type': 'commit',
279 'type': 'commit',
273 'repo': entry['repository'],
280 'repo': entry['repository'],
281 'repo_data': repo_data,
282
274 'url': h.route_path(
283 'url': h.route_path(
275 'repo_commit',
284 'repo_commit',
276 repo_name=entry['repository'], commit_id=entry['commit_id'])
285 repo_name=entry['repository'], commit_id=entry['commit_id'])
277 }
286 }
278 for entry in result['results']]
287
288 commits.append(commit_entry)
289 return commits
279
290
280 @LoginRequired()
291 @LoginRequired()
281 @view_config(
292 @view_config(
@@ -373,7 +384,7 b' class HomeView(BaseAppView):'
373 label = u'Commit search for `{}` in this repository.'.format(query)
384 label = u'Commit search for `{}` in this repository.'.format(query)
374 queries.append(
385 queries.append(
375 {
386 {
376 'id': -10,
387 'id': -20,
377 'value': query,
388 'value': query,
378 'value_display': label,
389 'value_display': label,
379 'type': 'search',
390 'type': 'search',
@@ -392,7 +403,7 b' class HomeView(BaseAppView):'
392 label = u'File search for `{}` in this repository group'.format(query)
403 label = u'File search for `{}` in this repository group'.format(query)
393 queries.append(
404 queries.append(
394 {
405 {
395 'id': -20,
406 'id': -30,
396 'value': query,
407 'value': query,
397 'value_display': label,
408 'value_display': label,
398 'type': 'search',
409 'type': 'search',
@@ -410,7 +421,7 b' class HomeView(BaseAppView):'
410 label = u'Commit search for `{}` in this repository group'.format(query)
421 label = u'Commit search for `{}` in this repository group'.format(query)
411 queries.append(
422 queries.append(
412 {
423 {
413 'id': -20,
424 'id': -40,
414 'value': query,
425 'value': query,
415 'value_display': label,
426 'value_display': label,
416 'type': 'search',
427 'type': 'search',
@@ -425,16 +436,16 b' class HomeView(BaseAppView):'
425 {
436 {
426 'id': -1,
437 'id': -1,
427 'value': query,
438 'value': query,
428 'value_display': u'Commit search for: `{}`'.format(query),
439 'value_display': u'File search for: `{}`'.format(query),
429 'type': 'search',
440 'type': 'search',
430 'url': h.route_path('search',
441 'url': h.route_path('search',
431 _query={'q': query, 'type': 'content'})
442 _query={'q': query, 'type': 'content'})
432 })
443 })
433 queries.append(
444 queries.append(
434 {
445 {
435 'id': -1,
446 'id': -2,
436 'value': query,
447 'value': query,
437 'value_display': u'File search for: `{}`'.format(query),
448 'value_display': u'Commit search for: `{}`'.format(query),
438 'type': 'search',
449 'type': 'search',
439 'url': h.route_path('search',
450 'url': h.route_path('search',
440 _query={'q': query, 'type': 'commit'})
451 _query={'q': query, 'type': 'commit'})
@@ -636,8 +636,10 b' ul#context-pages {'
636 border-bottom: 1px solid @grey4;
636 border-bottom: 1px solid @grey4;
637 display: inline-block;
637 display: inline-block;
638 vertical-align: top;
638 vertical-align: top;
639 margin-left: -7px;
639 background: inherit;
640 background: @grey3;
640 position: absolute;
641 right: 8px;
642 top: 9px;
641 }
643 }
642
644
643 .main_filter_input_box {
645 .main_filter_input_box {
@@ -652,20 +654,32 b' ul#context-pages {'
652 background: @grey3;
654 background: @grey3;
653 border: 1px solid black;
655 border: 1px solid black;
654 position: absolute;
656 position: absolute;
655 white-space: pre-wrap;
657 white-space: pre;
656 z-index: 9999;
658 z-index: 9999;
657 color: @nav-grey;
659 color: @nav-grey;
658 margin: 1px 7px;
660 margin: 1px 7px;
659 padding: 0 2px;
661 padding: 0 10px;
660 }
662 }
661
663
662 .main_filter_input {
664 .main_filter_input {
663 padding: 5px;
665 padding: 5px;
664 min-width: 220px;
666 min-width: 260px;
665 color: @nav-grey;
667 color: @nav-grey;
666 background: @grey3;
668 background: @grey3;
667 min-height: 18px;
669 min-height: 18px;
670
671
672 &:active {
673 color: @grey2 !important;
674 background: white !important;
668 }
675 }
676 &:focus {
677 color: @grey2 !important;
678 background: white !important;
679 }
680 }
681
682
669
683
670 .main_filter_input::placeholder {
684 .main_filter_input::placeholder {
671 color: @nav-grey;
685 color: @nav-grey;
@@ -492,17 +492,17 b''
492 </div>
492 </div>
493
493
494 <div id="main_filter_help" style="display: none">
494 <div id="main_filter_help" style="display: none">
495 Use '/' key to quickly access this field.
495 - Use '/' key to quickly access this field.
496 Enter name of repository, or repository group for quick search.
497
496
498 Prefix query to allow special search:
497 - Enter a name of repository, or repository group for quick search.
498
499 - Prefix query to allow special search:
499
500
500 user:admin, to search for usernames
501 user:admin, to search for usernames
501
502
502 user_group:devops, to search for user groups
503 user_group:devops, to search for user groups
503
504
504 commit:efced4, to search for commits
505 commit:efced4, to search for commits
505
506 </div>
506 </div>
507 </li>
507 </li>
508
508
@@ -630,6 +630,19 b' commit:efced4, to search for commits'
630 };
630 };
631 var pattern = '(' + escapeRegExChars(value) + ')';
631 var pattern = '(' + escapeRegExChars(value) + ')';
632
632
633 var getRepoIcon = function(repo_type) {
634 if (repo_type === 'hg') {
635 return '<i class="icon-hg"></i> ';
636 }
637 else if (repo_type === 'git') {
638 return '<i class="icon-git"></i> ';
639 }
640 else if (repo_type === 'svn') {
641 return '<i class="icon-svn"></i> ';
642 }
643 return ''
644 };
645
633 // highlight match
646 // highlight match
634 valueDisplay = Select2.util.escapeMarkup(valueDisplay);
647 valueDisplay = Select2.util.escapeMarkup(valueDisplay);
635 valueDisplay = valueDisplay.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
648 valueDisplay = valueDisplay.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
@@ -639,19 +652,16 b' commit:efced4, to search for commits'
639 if (searchType === 'hint') {
652 if (searchType === 'hint') {
640 icon += '<i class="icon-folder-close"></i> ';
653 icon += '<i class="icon-folder-close"></i> ';
641 }
654 }
655 // full text search
642 else if (searchType === 'search') {
656 else if (searchType === 'search') {
643 icon += '<i class="icon-more"></i> ';
657 icon += '<i class="icon-more"></i> ';
644 }
658 }
659 // repository
645 else if (searchType === 'repo') {
660 else if (searchType === 'repo') {
646 if (data['repo_type'] === 'hg') {
661
647 icon += '<i class="icon-hg"></i> ';
662 var repoIcon = getRepoIcon(data['repo_type']);
648 }
663 icon += repoIcon;
649 else if (data['repo_type'] === 'git') {
664
650 icon += '<i class="icon-git"></i> ';
651 }
652 else if (data['repo_type'] === 'svn') {
653 icon += '<i class="icon-svn"></i> ';
654 }
655 if (data['private']) {
665 if (data['private']) {
656 icon += '<i class="icon-lock" ></i> ';
666 icon += '<i class="icon-lock" ></i> ';
657 }
667 }
@@ -659,18 +669,27 b' commit:efced4, to search for commits'
659 icon += '<i class="icon-unlock-alt"></i> ';
669 icon += '<i class="icon-unlock-alt"></i> ';
660 }
670 }
661 }
671 }
672 // repository groups
662 else if (searchType === 'repo_group') {
673 else if (searchType === 'repo_group') {
663 icon += '<i class="icon-folder-close"></i> ';
674 icon += '<i class="icon-folder-close"></i> ';
664 }
675 }
676 // user group
665 else if (searchType === 'user_group') {
677 else if (searchType === 'user_group') {
666 icon += '<i class="icon-group"></i> ';
678 icon += '<i class="icon-group"></i> ';
667 }
679 }
668 else if (searchType === 'user') {
680 else if (searchType === 'user') {
669 icon += '<img class="gravatar" src="{0}"/>'.format(data['icon_link']);
681 icon += '<img class="gravatar" src="{0}"/>'.format(data['icon_link']);
670 }
682 }
683 // commit
671 else if (searchType === 'commit') {
684 else if (searchType === 'commit') {
685 var repo_data = data['repo_data'];
686 var repoIcon = getRepoIcon(repo_data['repository_type']);
687 if (repoIcon) {
688 icon += repoIcon;
689 } else {
672 icon += '<i class="icon-tag"></i>';
690 icon += '<i class="icon-tag"></i>';
673 }
691 }
692 }
674
693
675 var tmpl = '<div class="ac-container-wrap">{0}{1}</div>';
694 var tmpl = '<div class="ac-container-wrap">{0}{1}</div>';
676 return tmpl.format(icon, valueDisplay);
695 return tmpl.format(icon, valueDisplay);
@@ -715,7 +734,7 b' commit:efced4, to search for commits'
715
734
716 showMainFilterBox = function () {
735 showMainFilterBox = function () {
717 $('#main_filter_help').toggle();
736 $('#main_filter_help').toggle();
718 }
737 };
719
738
720 </script>
739 </script>
721 <script src="${h.asset('js/rhodecode/base/keyboard-bindings.js', ver=c.rhodecode_version_hash)}"></script>
740 <script src="${h.asset('js/rhodecode/base/keyboard-bindings.js', ver=c.rhodecode_version_hash)}"></script>
General Comments 0
You need to be logged in to leave comments. Login now