77 lines
2.4 KiB
Python
77 lines
2.4 KiB
Python
# SPDX-License-Identifier: WTFPL
|
|
|
|
import os
|
|
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 project
|
|
|
|
class ProjectsView(View):
|
|
|
|
def __init__(self, context):
|
|
super().__init__(context, _("Projects"), "projects.ui")
|
|
|
|
self.project = project.Project(context.db) # current record
|
|
self.newrecord = False
|
|
|
|
self.lst_projects = Gtk.ListStore(int, str, str, int, str, str)
|
|
sql = (
|
|
"SELECT projid, projname, startdate, duration, projstate, remarks "
|
|
"FROM project "
|
|
"WHERE vid=%s "
|
|
"ORDER BY projid"
|
|
)
|
|
self.db.dcur.execute(sql, (context.vessel.vid,))
|
|
for row in self.db.dcur.fetchall():
|
|
data = (
|
|
row['projid'],
|
|
row['projname'],
|
|
self.format_date(row['startdate']),
|
|
row['duration'],
|
|
row['projstate'],
|
|
row['remarks']
|
|
)
|
|
self.lst_projects.append(data)
|
|
|
|
treeview.add_column(self.tree['projects'], _('ID'), 0)
|
|
treeview.add_column(self.tree['projects'], _('Name'), 1)
|
|
treeview.add_column(self.tree['projects'], _('Start date'), 2)
|
|
treeview.add_column(self.tree['projects'], _('Duration'), 3)
|
|
treeview.add_column(self.tree['projects'], _('Status'), 4)
|
|
treeview.add_column(self.tree['projects'], _('Remarks'), 5)
|
|
self.tree['projects'].set_model(self.lst_projects)
|
|
|
|
# buttons on list page
|
|
def on_but_new_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['proj_edit'])
|
|
|
|
def on_but_edit_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['proj_edit'])
|
|
|
|
def on_but_detail_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['proj_detail'])
|
|
|
|
# buttons on detail page
|
|
# edit2 uses edit callback
|
|
def on_but_close_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['projects'])
|
|
|
|
def on_but_delete_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['projects'])
|
|
|
|
# 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['projects'])
|
|
|
|
def display_record(self):
|
|
pass
|
|
|
|
def edit_record(self):
|
|
pass
|