Work on native gui. Display records and add missing tasks and measurements.
This commit is contained in:
+71
-16
@@ -5,12 +5,14 @@ from gi.repository import Gtk
|
||||
|
||||
from .view import View
|
||||
from yms import gtkutils, combobox, treeview
|
||||
from yms.lookup import Dropdown
|
||||
from yms.model import company
|
||||
|
||||
class CompaniesView(View):
|
||||
|
||||
def __init__(self, context):
|
||||
super().__init__(context, _("Companies"), "companies.ui")
|
||||
self.context = context
|
||||
|
||||
self.comp = company.Company(context.db) # current record
|
||||
self.newrecord = False
|
||||
@@ -20,7 +22,13 @@ class CompaniesView(View):
|
||||
self.comptype = dict(self.db.cur.fetchall())
|
||||
combobox.load_from_dict(self.combo['flt_type'], {-2: _("─── all ───")} | self.comptype, -2)
|
||||
|
||||
# companied
|
||||
self.dd_comptype = self.context.lookup.dropdown(Dropdown.COMPANY_TYPE)
|
||||
combobox.load_from_dict(self.combo['comptype'], self.dd_comptype)
|
||||
combobox.load_from_dict(self.combo['comptype2'], self.dd_comptype)
|
||||
|
||||
self.dd_flags = context.lookup.enum('company.flags')
|
||||
|
||||
# companies
|
||||
self.lst_companies = Gtk.ListStore(int, str, str, str)
|
||||
self.db.cur.execute("SELECT compid, compname, comptype, remarks FROM company ORDER BY compname")
|
||||
for row in self.db.cur.fetchall():
|
||||
@@ -31,30 +39,77 @@ class CompaniesView(View):
|
||||
treeview.add_column(self.tree['companies'], _('Remarks'), 3)
|
||||
self.tree['companies'].set_model(self.lst_companies)
|
||||
|
||||
def display_company(self, company):
|
||||
self.entry['compname'].set_text(company.compname)
|
||||
# Type
|
||||
# Type2
|
||||
self.entry['shortname'].set_text(company.shortname)
|
||||
self.entry['street'].set_text(company.street)
|
||||
self.entry['zip'].set_text(company.zip)
|
||||
self.entry['city'].set_text(company.city)
|
||||
self.entry['country'].set_text(company.country)
|
||||
self.entry['contact'].set_text(company.contact)
|
||||
self.entry['phone'].set_text(company.phone)
|
||||
self.entry['email'].set_text(company.email)
|
||||
self.entry['web'].set_text(company.web)
|
||||
self.entry['customerno'].set_text(company.customerno)
|
||||
self.entry['contractno'].set_text(company.contractno)
|
||||
def clear_record(self):
|
||||
self.entry['name'].set_text('')
|
||||
self.entry['shortname'].set_text('')
|
||||
self.entry['street'].set_text('')
|
||||
self.entry['zip'].set_text('')
|
||||
self.entry['city'].set_text('')
|
||||
self.entry['country'].set_text('')
|
||||
self.entry['contact'].set_text('')
|
||||
self.entry['phone'].set_text('')
|
||||
self.entry['email'].set_text('')
|
||||
self.entry['web'].set_text('')
|
||||
self.entry['customerno'].set_text('')
|
||||
self.entry['contractno'].set_text('')
|
||||
combobox.activate_row(self.combo['comptype'], -1)
|
||||
combobox.activate_row(self.combo['comptype2'], -1)
|
||||
|
||||
def display_record(self):
|
||||
self.label['name'].set_text(self.comp.compname)
|
||||
self.label['shortname'].set_text(self.comp.shortname or '')
|
||||
self.label['type'].set_text(self.dd_comptype.get(self.comp.comptype, ''))
|
||||
self.label['type2'].set_text(self.dd_comptype.get(self.comp.comptype2, ''))
|
||||
self.label['street'].set_text(self.comp.street or '')
|
||||
self.label['zip'].set_text(self.comp.zip or '')
|
||||
self.label['city'].set_text(self.comp.city or '')
|
||||
self.label['country'].set_text(self.comp.country or '')
|
||||
self.label['phone'].set_text(self.comp.phone or '')
|
||||
self.label['email'].set_text(self.comp.email or '')
|
||||
self.label['web'].set_text(self.comp.web or '')
|
||||
self.label['customerno'].set_text(self.comp.customerno or '')
|
||||
self.label['contractno'].set_text(self.comp.contractno or '')
|
||||
self.label['flags'].set_text(self.comp.flags or '')
|
||||
self.label['remarks'].set_text(self.comp.remarks or '')
|
||||
|
||||
def edit_record(self):
|
||||
self.entry['compname'].set_text(self.comp.compname)
|
||||
# Type self.dd_comptype.get(self.comp.comptype, -1)
|
||||
# Type2 self.dd_comptype.get(self.comp.comptype2, -1)
|
||||
self.entry['shortname'].set_text(self.comp.shortname or '')
|
||||
self.entry['street'].set_text(self.comp.street or '')
|
||||
self.entry['zip'].set_text(self.comp.zip or '')
|
||||
self.entry['city'].set_text(self.comp.city or '')
|
||||
self.entry['country'].set_text(self.comp.country or '')
|
||||
self.entry['contact'].set_text(self.comp.contact or '')
|
||||
self.entry['phone'].set_text(self.comp.phone or '')
|
||||
self.entry['email'].set_text(self.comp.email or '')
|
||||
self.entry['web'].set_text(self.comp.web or '')
|
||||
self.entry['customerno'].set_text(self.comp.customerno or '')
|
||||
self.entry['contractno'].set_text(self.comp.contractno or '')
|
||||
|
||||
# buttons on list page
|
||||
def on_but_new_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['comp_edit'])
|
||||
|
||||
def on_but_edit_clicked(self, widget):
|
||||
compid = treeview.get_value(self.tree['companies'], 0)
|
||||
if not compid:
|
||||
return
|
||||
self.topwidget.set_visible_child(self.box['comp_edit'])
|
||||
|
||||
def on_but_detail_clicked(self, widget):
|
||||
compid = treeview.get_value(self.tree['companies'], 0)
|
||||
if not compid:
|
||||
return
|
||||
self.comp.load(compid)
|
||||
self.display_record()
|
||||
self.topwidget.set_visible_child(self.box['comp_detail'])
|
||||
|
||||
def on_tvw_companies_row_activated(self, widget, path, column):
|
||||
compid = treeview.get_value(widget, 0)
|
||||
self.comp.load(compid)
|
||||
self.display_record()
|
||||
self.topwidget.set_visible_child(self.box['comp_detail'])
|
||||
|
||||
# buttons on detail page
|
||||
|
||||
Reference in New Issue
Block a user