Work on native gui. Display records and add missing tasks and measurements.
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
# 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 task
|
||||
|
||||
class TasksView(View):
|
||||
|
||||
def __init__(self, context):
|
||||
super().__init__(context, _("Tasks"), "tasks.ui")
|
||||
self.context = context
|
||||
|
||||
self.task = task.Task(context.db) # current record
|
||||
self.newrecord = False
|
||||
|
||||
self.lst_tasks = Gtk.ListStore(int, str, str, str, str)
|
||||
sql = (
|
||||
"SELECT t.taskid, t.taskname, t.priority, t.taskstate, "
|
||||
"u.displayname AS responsible "
|
||||
"FROM task AS t JOIN user AS u ON (t.responsible=u.userid)"
|
||||
"WHERE t.vid=%s "
|
||||
"ORDER BY t.taskid"
|
||||
)
|
||||
self.db.dcur.execute(sql, (context.vessel.vid,))
|
||||
for row in self.db.dcur.fetchall():
|
||||
data = (
|
||||
row['taskid'],
|
||||
row['taskname'],
|
||||
row['priority'],
|
||||
row['taskstate'],
|
||||
row['responsible']
|
||||
)
|
||||
self.lst_tasks.append(data)
|
||||
|
||||
treeview.add_column(self.tree['tasks'], _('ID'), 0)
|
||||
treeview.add_column(self.tree['tasks'], _('Name'), 1)
|
||||
treeview.add_column(self.tree['tasks'], _('Priority'), 2)
|
||||
treeview.add_column(self.tree['tasks'], _('Status'), 3)
|
||||
treeview.add_column(self.tree['tasks'], _('Responsible'), 4)
|
||||
self.tree['tasks'].set_model(self.lst_tasks)
|
||||
|
||||
# buttons on list page
|
||||
def on_but_new_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['task_edit'])
|
||||
|
||||
def on_but_edit_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['task_edit'])
|
||||
|
||||
def on_but_detail_clicked(self, widget):
|
||||
taskid = treeview.get_value(self.tree['tasks'], 0)
|
||||
if not taskid:
|
||||
return
|
||||
self.task.load(taskid)
|
||||
self.display_record()
|
||||
self.topwidget.set_visible_child(self.box['task_detail'])
|
||||
self.button['close'].grab_focus()
|
||||
|
||||
def on_tvw_tasks_row_activated(self, widget, path, column):
|
||||
taskid = treeview.get_value(widget, 0)
|
||||
self.task.load(taskid)
|
||||
self.display_record()
|
||||
self.topwidget.set_visible_child(self.box['task_detail'])
|
||||
|
||||
# buttons on detail page
|
||||
# edit2 uses edit callback
|
||||
def on_but_close_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['tasks'])
|
||||
|
||||
def on_but_delete_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['tasks'])
|
||||
|
||||
# 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['tasks'])
|
||||
|
||||
def display_record(self):
|
||||
self.label['name'].set_text(self.task.taskname)
|
||||
self.label['responsible'].set_text('')
|
||||
self.label['status'].set_text(self.task.taskstate)
|
||||
self.label['remarks'].set_text(self.task.remarks or '')
|
||||
|
||||
def edit_record(self):
|
||||
pass
|
||||
Reference in New Issue
Block a user