Supply a default query on search
When opening the search dialog from a change list, use the current query as the default value. This lets you iterate on a query without needing to type or copy it repeatedly. However, it does mean that you need to clear out the field if you want a completely different query. Change-Id: I1f31db1cde0b86c5a7b214866f1df686dd901c7c
This commit is contained in:
parent
574c9b36f5
commit
c69d9e9536
@ -128,7 +128,7 @@ class StatusHeader(urwid.WidgetWrap):
|
||||
|
||||
class SearchDialog(mywid.ButtonDialog):
|
||||
signals = ['search', 'cancel']
|
||||
def __init__(self, app):
|
||||
def __init__(self, app, default):
|
||||
self.app = app
|
||||
search_button = mywid.FixedButton('Search')
|
||||
cancel_button = mywid.FixedButton('Cancel')
|
||||
@ -139,6 +139,7 @@ class SearchDialog(mywid.ButtonDialog):
|
||||
super(SearchDialog, self).__init__("Search",
|
||||
"Enter a change number or search string.",
|
||||
entry_prompt="Search: ",
|
||||
entry_text=default,
|
||||
buttons=[search_button,
|
||||
cancel_button])
|
||||
|
||||
@ -435,8 +436,8 @@ class App(object):
|
||||
except gertty.view.DisplayError as e:
|
||||
return self.error(e.message)
|
||||
|
||||
def searchDialog(self):
|
||||
dialog = SearchDialog(self)
|
||||
def searchDialog(self, default):
|
||||
dialog = SearchDialog(self, default)
|
||||
urwid.connect_signal(dialog, 'cancel',
|
||||
lambda button: self.backScreen())
|
||||
urwid.connect_signal(dialog, 'search',
|
||||
@ -514,7 +515,11 @@ class App(object):
|
||||
elif keymap.QUIT in commands:
|
||||
self.quit()
|
||||
elif keymap.CHANGE_SEARCH in commands:
|
||||
self.searchDialog()
|
||||
if hasattr(self.loop.widget, 'getQueryString'):
|
||||
default = self.loop.widget.getQueryString()
|
||||
else:
|
||||
default = ''
|
||||
self.searchDialog(default)
|
||||
elif keymap.LIST_HELD in commands:
|
||||
self.doSearch("status:open is:held")
|
||||
elif key in self.config.dashboards:
|
||||
|
@ -290,6 +290,11 @@ class ChangeListView(urwid.WidgetWrap):
|
||||
row = self.change_rows[key]
|
||||
del self.change_rows[key]
|
||||
|
||||
def getQueryString(self):
|
||||
if self.project_key is not None:
|
||||
return "project:%s %s" % (self.query_desc, self.app.config.project_change_list_query)
|
||||
return self.query
|
||||
|
||||
def _threadChanges(self, changes):
|
||||
ret = []
|
||||
prefixes = {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user