More work on native gui. Make data editable.
This commit is contained in:
1 parent
5641e1706f
commit
7aa5d2af3b
43 files changed
+2686
-1037
No files matched your search
+43
-18
@@ -17,23 +17,7 @@ class TasksView(View):
|
||||
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)
|
||||
self.load_list()
|
||||
|
||||
treeview.add_column(self.tree['tasks'], _('ID'), 0)
|
||||
treeview.add_column(self.tree['tasks'], _('Name'), 1)
|
||||
@@ -58,6 +42,25 @@ class TasksView(View):
|
||||
self.dd_user = context.lookup.user()
|
||||
combobox.load_from_dict(self.combo['responsible'], self.dd_user)
|
||||
|
||||
def load_list(self):
|
||||
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, (self.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)
|
||||
|
||||
def clear_record(self):
|
||||
self.task.clear()
|
||||
self.entry['name'].set_text('')
|
||||
@@ -70,6 +73,7 @@ class TasksView(View):
|
||||
combobox.activate_row(self.combo['status'], 'new')
|
||||
combobox.activate_row(self.combo['responsible'], 0)
|
||||
self.text['remarks'].get_buffer().set_text('')
|
||||
self.entry['name'].grab_focus()
|
||||
|
||||
def display_record(self):
|
||||
self.label['name'].set_text(self.task.taskname)
|
||||
@@ -88,6 +92,7 @@ class TasksView(View):
|
||||
combobox.activate_row(self.combo['taskstate'], self.task.taskstate)
|
||||
combobox.activate_row(self.combo['responsible'], self.task.responsible)
|
||||
self.text['remarks'].get_buffer().set_text(self.task.remarks or '')
|
||||
self.entry['name'].grab_focus()
|
||||
|
||||
def save_record(self):
|
||||
# fields must have been validated beforehand
|
||||
@@ -151,12 +156,32 @@ class TasksView(View):
|
||||
# buttons on edit page
|
||||
def on_but_save_clicked(self, widget):
|
||||
# check mandatory fields
|
||||
if not self.entry['taskname'].get_text().strip():
|
||||
if not self.entry['name'].get_text().strip():
|
||||
# TODO error marker
|
||||
return
|
||||
self.save_record()
|
||||
print(self.task)
|
||||
self.task.save()
|
||||
if self.newrecord:
|
||||
self.load_list()
|
||||
self.newrecord = False
|
||||
else:
|
||||
pass
|
||||
# TODO aktuelle Listenzeile aktualisieren!
|
||||
self.display_record()
|
||||
self.topwidget.set_visible_child(self.box['task_detail'])
|
||||
|
||||
def on_but_plandate_clicked(self, widget):
|
||||
pass
|
||||
|
||||
def on_but_duedate_clicked(self, widget):
|
||||
pass
|
||||
|
||||
def on_but_started_clicked(self, widget):
|
||||
pass
|
||||
|
||||
def on_but_finished_clicked(self, widget):
|
||||
pass
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['tasks'])
|
||||
Reference in new issue
Block a user