Commit 379fe756028528554510b3d0a760463daed8eb97
1 parent
1414c269
Exists in
master
and in
39 other branches
Keeping value on filter inputs
Showing
2 changed files
with
75 additions
and
14 deletions
Show diff stats
src/search/views.py
| ... | ... | @@ -12,33 +12,94 @@ class ColabSearchView(SearchView): |
| 12 | 12 | 'wiki': { |
| 13 | 13 | 'icon': 'file', |
| 14 | 14 | 'name': _(u'Wiki'), |
| 15 | - 'fields': {'author': _(u'Author')}, | |
| 15 | + 'fields': ( | |
| 16 | + ('author', _(u'Author'), self.request.GET.get('author')), | |
| 17 | + ), | |
| 16 | 18 | }, |
| 17 | 19 | 'thread': { |
| 18 | 20 | 'icon': 'thread', |
| 19 | 21 | 'name': _(u'Discussion'), |
| 20 | - 'fields': {'author': _(u'Author'), 'list': _(u'Mailinglist')}, | |
| 22 | + 'fields': ( | |
| 23 | + ('author', _(u'Author'), self.request.GET.get('author')), | |
| 24 | + ( | |
| 25 | + 'list', | |
| 26 | + _(u'Mailinglist'), | |
| 27 | + self.request.GET.getlist('list') | |
| 28 | + ), | |
| 29 | + ), | |
| 21 | 30 | }, |
| 22 | 31 | 'ticket': { |
| 23 | 32 | 'icon': 'ticket', |
| 24 | 33 | 'name': _(u'Ticket'), |
| 25 | - 'fields': { | |
| 26 | - 'milestone': _(u'Milestone'), 'priority': _(u'Priority'), | |
| 27 | - 'component': _(u'Component'), 'severity': _(u'Severity'), | |
| 28 | - 'reporter': _(u'Reporter'), 'author': _(u'Author'), | |
| 29 | - 'tag': _(u'Status'), 'keywords': _(u'Keywords'), | |
| 30 | - 'collaborators': _(u'Collaborators'), | |
| 31 | - }, | |
| 34 | + 'fields': ( | |
| 35 | + ( | |
| 36 | + 'milestone', | |
| 37 | + _(u'Milestone'), | |
| 38 | + self.request.GET.get('milestone') | |
| 39 | + ), | |
| 40 | + ( | |
| 41 | + 'priority', | |
| 42 | + _(u'Priority'), | |
| 43 | + self.request.GET.get('priority') | |
| 44 | + ), | |
| 45 | + ( | |
| 46 | + 'component', | |
| 47 | + _(u'Component'), | |
| 48 | + self.request.GET.get('component') | |
| 49 | + ), | |
| 50 | + ( | |
| 51 | + 'severity', | |
| 52 | + _(u'Severity'), | |
| 53 | + self.request.GET.get('severity') | |
| 54 | + ), | |
| 55 | + ( | |
| 56 | + 'reporter', | |
| 57 | + _(u'Reporter'), | |
| 58 | + self.request.GET.get('reporter') | |
| 59 | + ), | |
| 60 | + ('author', _(u'Author'), self.request.GET.get('author')), | |
| 61 | + ('tag', _(u'Status'), self.request.GET.get('tag')), | |
| 62 | + ( | |
| 63 | + 'keywords', | |
| 64 | + _(u'Keywords'), | |
| 65 | + self.request.GET.get('keywords'), | |
| 66 | + ), | |
| 67 | + ( | |
| 68 | + 'collaborators', | |
| 69 | + _(u'Collaborators'), | |
| 70 | + self.request.GET.get('collaborators') | |
| 71 | + ), | |
| 72 | + ), | |
| 32 | 73 | }, |
| 33 | 74 | 'changeset': { |
| 34 | 75 | 'icon': 'changeset', |
| 35 | 76 | 'name': _(u'Changeset'), |
| 36 | - 'fields': {'author': _(u'Author'), 'repository_name': _(u'Repository')}, | |
| 77 | + 'fields': ( | |
| 78 | + ('author', _(u'Author'), self.request.GET.get('author')), | |
| 79 | + ( | |
| 80 | + 'repository_name', | |
| 81 | + _(u'Repository'), | |
| 82 | + self.request.GET.get('repository_name'), | |
| 83 | + ), | |
| 84 | + ) | |
| 37 | 85 | }, |
| 38 | 86 | 'user': { |
| 39 | 87 | 'icon': 'user', |
| 40 | 88 | 'name': _(u'User'), |
| 41 | - 'fields': {'username': _(u'Username'), 'name': _(u'Name'), 'institution': _(u'Institution'), 'role': _(u'Role')}, | |
| 89 | + 'fields': ( | |
| 90 | + ( | |
| 91 | + 'username', | |
| 92 | + _(u'Username'), | |
| 93 | + self.request.GET.get('username'), | |
| 94 | + ), | |
| 95 | + ('name', _(u'Name'), self.request.GET.get('name')), | |
| 96 | + ( | |
| 97 | + 'institution', | |
| 98 | + _(u'Institution'), | |
| 99 | + self.request.GET.get('institution'), | |
| 100 | + ), | |
| 101 | + ('role', _(u'Role'), self.request.GET.get('role')) | |
| 102 | + ), | |
| 42 | 103 | }, |
| 43 | 104 | } |
| 44 | 105 | ... | ... |
src/templates/search/search.html
| ... | ... | @@ -32,18 +32,18 @@ |
| 32 | 32 | <input type="hidden" name="q" value="{{ request.GET.q }}" /> |
| 33 | 33 | <input type="hidden" name="type" value="{{ type_chosen }}" /> |
| 34 | 34 | |
| 35 | - {% for field_lookup, field_display in filters.fields.items %} | |
| 35 | + {% for field_lookup, field_display, field_value in filters.fields %} | |
| 36 | 36 | <div class="form-group"> |
| 37 | 37 | <label for="{{ field_lookup }}">{{ field_display }}</label> |
| 38 | 38 | {% ifequal field_lookup "list" %} |
| 39 | 39 | <select name="{{ field_lookup }}" class="form-control" multiple> |
| 40 | 40 | {% for value, option in form.fields.list.choices %} |
| 41 | - <option value="{{ value }}">{{ option }}</option> | |
| 41 | + <option value="{{ value }}" {% if value in field_value %}selected{% endif %}>{{ option }}</option> | |
| 42 | 42 | {% endfor %} |
| 43 | 43 | </select> |
| 44 | 44 | {% else %} |
| 45 | 45 | <div class="input-group"> |
| 46 | - <input type="text" class="form-control" placeholder="{{ field_display }}" name="{{ field_lookup }}" value=""> | |
| 46 | + <input type="text" class="form-control" placeholder="{{ field_display }}" name="{{ field_lookup }}" {% if field_value %}value="{{ field_value }}"{% endif %}> | |
| 47 | 47 | </div> |
| 48 | 48 | {% endifequal %} |
| 49 | 49 | </div> | ... | ... |