65 lines
2.1 KiB
Python
65 lines
2.1 KiB
Python
# SPDX-License-Identifier: WTFPL
|
|
|
|
import os
|
|
from gi.repository import Gtk
|
|
|
|
from .view import View
|
|
from yms import gtkutils, combobox, treeview
|
|
from yms.model import maintenance
|
|
|
|
class MaintenanceView(View):
|
|
|
|
def __init__(self, context):
|
|
super().__init__(context, _("Maintenance"), "maintenance.ui")
|
|
|
|
self.maint = maintenance.Maintenance(context.db) # current record
|
|
self.newrecord = False
|
|
|
|
self.lst_maintenance = Gtk.ListStore(int, str, str, str)
|
|
sql = (
|
|
"SELECT m.maintid, m.activities, e.ename, m.remarks "
|
|
"FROM maintenance AS m LEFT OUTER JOIN equipment AS e USING (eid) "
|
|
"WHERE m.vid=%s "
|
|
"ORDER BY m.maintid"
|
|
)
|
|
self.db.cur.execute(sql, (context.vessel.vid,))
|
|
for row in self.db.cur.fetchall():
|
|
self.lst_maintenance.append(row)
|
|
|
|
treeview.add_column(self.tree['maintenance'], _('ID'), 0)
|
|
treeview.add_column(self.tree['maintenance'], _('Activities'), 1)
|
|
treeview.add_column(self.tree['maintenance'], _('Equipment'), 2)
|
|
treeview.add_column(self.tree['maintenance'], _('Remarks'), 3)
|
|
self.tree['maintenance'].set_model(self.lst_maintenance)
|
|
|
|
# buttons on list page
|
|
def on_but_new_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['maint_edit'])
|
|
|
|
def on_but_edit_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['maint_edit'])
|
|
|
|
def on_but_detail_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['maintv_detail'])
|
|
|
|
# buttons on detail page
|
|
# edit2 uses edit callback
|
|
def on_but_close_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['maintenance'])
|
|
|
|
def on_but_delete_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['maintenance'])
|
|
|
|
# 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['maintenance'])
|
|
|
|
def display_record(self):
|
|
pass
|
|
|
|
def edit_record(self):
|
|
pass
|