Add a header to record views.

If one is using shortcut keys, it can be hard to determine if one is
adding a record or searching.  Add a header to make it easier to
distinguish between the two.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
This commit is contained in:
brian m. carlson 2015-11-15 16:19:28 +00:00
parent ce8bed3006
commit 0c7f4e7990
No known key found for this signature in database
GPG key ID: BF535D811F52F68B

View file

@ -380,13 +380,14 @@ class AboutView(StandardView):
class RecordView(StandardView):
def __init__(self, button, record=None):
def __init__(self, title, button, record=None):
dbd = DatabaseData()
if record is None:
self.rec = filemanip.Record([None] * dbd.schema().nfields())
else:
self.rec = record
self.button_name = button
self.title = title
def _compute_titles_from_table(self, table):
titles = []
@ -467,15 +468,19 @@ class RecordView(StandardView):
def _render_standard(self, loop):
self.loop = loop
head = self.text(self.title, "header")
# We need a box widget for the frame, but GridFlow is a flow widget.
pile = urwid.Pile([self._render_record(self.rec),
self._render_buttons()])
return urwid.Filler(pile, valign="top")
filler = urwid.Filler(pile, valign="top")
return urwid.Frame(filler, head)
class DisplayRecordView(RecordView):
def __init__(self, record=None):
super().__init__(_("Commit"), record)
def __init__(self, title=None, record=None):
if title is None:
title = _("Add Record")
super().__init__(title, _("Commit"), record)
def _build_record(self):
fields = [i.widget_list[1].get_edit_text() for i in self.cells]
@ -543,7 +548,8 @@ class DisplayRecordView(RecordView):
class SearchRecordView(RecordView):
def __init__(self, record=None):
super().__init__(_("Select Display Template"), record)
super().__init__(_("Search Records"), _("Select Display Template"),
record)
def _get_fields(self):
return [i.widget_list[1].get_edit_text() for i in self.cells]
@ -591,7 +597,7 @@ class SearchRecordView(RecordView):
class DisplayTemplateRecordView(RecordView):
def __init__(self, table, records):
super().__init__(_("Search"))
super().__init__(_("Display Template"), _("Search"))
self.records = records
self.table = table
@ -652,7 +658,7 @@ class DisplayTemplateRecordView(RecordView):
class SortingTemplateRecordView(RecordView):
def __init__(self, table, records, selected):
super().__init__(_("Search"))
super().__init__(_("Sorting Template"), _("Search"))
self.records = records
self.table = table
self.selected = selected
@ -868,7 +874,7 @@ class RecordListView(ListView):
cur = self._current_item()
if cur is None:
return
self.session.render_view(DisplayRecordView(cur))
self.session.render_view(DisplayRecordView(_("Current Record"), cur))
class TableContentsListView(RecordListView):