Native gui: implement data lists for all modules
This commit is contained in:
+64
-8
@@ -5,15 +5,71 @@ import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .view import View
|
||||
from yms import gtkutils, combobox, treeview
|
||||
from yms.model import provision
|
||||
|
||||
class ProvisionsView:
|
||||
class ProvisionsView(View):
|
||||
|
||||
def __init__(self, context):
|
||||
self.title = _("Provisions")
|
||||
builder = Gtk.Builder()
|
||||
builder.set_translation_domain(context.textdomain)
|
||||
builder.add_from_file(os.path.join(context.ui_path, "provisions.ui"))
|
||||
builder.connect_signals(self)
|
||||
self.topwidget = builder.get_object("topobject")
|
||||
gtkutils.init_named_controls(self, builder)
|
||||
super().__init__(context, _("Provisions"), "provisions.ui")
|
||||
|
||||
self.prov = provision.Provision(context.db) # current record
|
||||
self.newrecord = False
|
||||
|
||||
self.load_dropdown()
|
||||
|
||||
self.lst_provisions = Gtk.ListStore(int, str, int, str, str, str)
|
||||
sql = (
|
||||
"SELECT p.provid, p.provname, p.number, p.unit, p.storedate, p.shelflife "
|
||||
"FROM provisions AS p LEFT OUTER JOIN storage AS s USING (sid) "
|
||||
"WHERE s.vid=%s"
|
||||
)
|
||||
self.db.dcur.execute(sql, (context.vessel.vid,))
|
||||
for row in self.db.dcur.fetchall():
|
||||
data = (
|
||||
row['provid'],
|
||||
row['provname'],
|
||||
row['number'],
|
||||
self.prov_unit[row['unit']],
|
||||
self.format_date(row['storedate']),
|
||||
self.format_date(row['shelflife'])
|
||||
)
|
||||
self.lst_provisions.append(data)
|
||||
|
||||
treeview.add_column(self.tree['provisions'], _('ID'), 0)
|
||||
treeview.add_column(self.tree['provisions'], _('Description'), 1)
|
||||
treeview.add_column(self.tree['provisions'], _('Number'), 2)
|
||||
treeview.add_column(self.tree['provisions'], _('Unit'), 3)
|
||||
treeview.add_column(self.tree['provisions'], _('Stored'), 4)
|
||||
treeview.add_column(self.tree['provisions'], _('Best before'), 5)
|
||||
self.tree['provisions'].set_model(self.lst_provisions)
|
||||
|
||||
def load_dropdown(self):
|
||||
self.db.cur.execute("SELECT ddval, ddtext FROM dropdown WHERE ddid=6 ORDER BY ddval")
|
||||
self.prov_unit = dict(self.db.cur.fetchall())
|
||||
|
||||
# buttons on list page
|
||||
def on_but_new_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['prov_edit'])
|
||||
|
||||
def on_but_edit_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['prov_edit'])
|
||||
|
||||
def on_but_detail_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['prov_detail'])
|
||||
|
||||
# buttons on detail page
|
||||
# edit2 uses edit callback
|
||||
def on_but_close_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['provisions'])
|
||||
|
||||
def on_but_delete_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['provisions'])
|
||||
|
||||
# buttons on edit page
|
||||
def on_but_save_clicked(self, widget):
|
||||
pass
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['provisions'])
|
||||
|
||||
Reference in New Issue
Block a user