From 06a983468898dc114329cb2c8a13f698c1ef4790 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Wed, 21 Oct 2026 17:16:55 +0200 Subject: [PATCH] Native gui first steps: storage, box and companies are editable --- .gitignore | 1 - locale/de.po | 473 +++++++++++++++++--------------- locale/de/LC_MESSAGES/ymsgui.mo | Bin 0 -> 16213 bytes yms/database.py | 11 +- yms/gtkutils.py | 49 ++++ yms/lookup.py | 174 ++++++++---- yms/model/box.py | 6 + yms/model/cable.py | 6 + yms/model/company.py | 12 + yms/model/dbrecord.py | 15 +- yms/model/equipment.py | 8 +- yms/model/fuse.py | 6 + yms/model/project.py | 6 + yms/model/storage.py | 10 +- yms/model/user.py | 14 + yms/model/vessel.py | 20 +- yms/ui/base.ui | 313 ++++++++++++--------- yms/ui/boxes.ui | 153 ++++++++--- yms/ui/cables.ui | 51 +++- yms/ui/companies.ui | 13 +- yms/ui/documents.ui | 234 +++++++++++++++- yms/ui/equipment.ui | 116 ++++++-- yms/ui/fuses.ui | 3 +- yms/ui/inventory.ui | 147 ++++++++-- yms/ui/main.ui | 2 +- yms/ui/maintenance.ui | 18 ++ yms/ui/measurement.ui | 89 +++++- yms/ui/provisions.ui | 106 ++++++- yms/ui/storage.ui | 28 +- yms/ui/tasks.ui | 110 +++++++- yms/view/base.py | 74 ++++- yms/view/boxes.py | 119 ++++++-- yms/view/cables.py | 91 ++++-- yms/view/companies.py | 87 +++++- yms/view/documents.py | 164 ++++++++--- yms/view/equipment.py | 179 +++++++++--- yms/view/fuses.py | 79 +++++- yms/view/inventory.py | 258 +++++++++++++---- yms/view/maintenance.py | 82 ++++-- yms/view/measurement.py | 104 ++++++- yms/view/projects.py | 80 +++++- yms/view/provisions.py | 100 +++++-- yms/view/status.py | 8 +- yms/view/storage.py | 103 +++++-- yms/view/tasks.py | 93 ++++++- yms/view/view.py | 112 +++++++- ymsgui.py | 75 +++-- 47 files changed, 3119 insertions(+), 883 deletions(-) create mode 100644 locale/de/LC_MESSAGES/ymsgui.mo diff --git a/.gitignore b/.gitignore index 927a525..85de01a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ __pycache__/ *.txt *.bak *.pot -*.mo compare_* # Debian package build artifacts diff --git a/locale/de.po b/locale/de.po index 159b188..0539e78 100644 --- a/locale/de.po +++ b/locale/de.po @@ -7,16 +7,17 @@ msgid "" msgstr "" "Project-Id-Version: YMS 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-10-17 08:14+0200\n" -"PO-Revision-Date: 2025-05-15 09:05+0200\n" +"POT-Creation-Date: 2026-10-21 06:03+0200\n" +"PO-Revision-Date: 2026-10-21 06:27+0200\n" "Last-Translator: Thomas Hooge \n" "Language-Team: de \n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.2.2\n" -#: ymsgui.py:213 +#: ymsgui.py:233 msgid "" "Configuration file '{}' not found.\n" "Default configuration has been created.\n" @@ -30,7 +31,7 @@ msgstr "" "\n" "Anschließend starten Sie dieses Programm neu." -#: ymsgui.py:241 +#: ymsgui.py:261 msgid "" "Database connection cannot be established.\n" "\n" @@ -45,19 +46,22 @@ msgstr "" "Fehler: {} ({})" #: yms/view/base.py:26 -#, fuzzy msgid "Base Data" msgstr "Basisdaten" #: yms/view/base.py:59 yms/view/base.py:85 yms/view/base.py:93 -#: yms/view/base.py:163 +#: yms/view/base.py:163 yms/view/boxes.py:31 yms/view/boxes.py:33 +#: yms/view/companies.py:22 yms/view/companies.py:24 yms/view/equipment.py:42 +#: yms/view/equipment.py:44 yms/view/equipment.py:46 yms/view/inventory.py:65 +#: yms/view/inventory.py:68 yms/view/inventory.py:71 yms/view/inventory.py:74 +#: yms/view/inventory.py:77 yms/view/storage.py:35 msgid "─── none ───" -msgstr "" +msgstr "─── keine ───" -#: yms/view/base.py:129 yms/view/boxes.py:32 yms/view/cables.py:35 -#: yms/view/companies.py:36 yms/view/documents.py:31 yms/view/equipment.py:32 -#: yms/view/fuses.py:36 yms/view/inventory.py:58 yms/view/maintenance.py:29 -#: yms/view/measurement.py:51 yms/view/projects.py:38 yms/view/provisions.py:39 +#: yms/view/base.py:129 yms/view/boxes.py:24 yms/view/cables.py:35 +#: yms/view/companies.py:32 yms/view/documents.py:32 yms/view/equipment.py:32 +#: yms/view/fuses.py:36 yms/view/inventory.py:51 yms/view/maintenance.py:29 +#: yms/view/measurement.py:51 yms/view/projects.py:38 yms/view/provisions.py:41 #: yms/view/storage.py:25 yms/view/tasks.py:38 msgid "ID" msgstr "" @@ -65,11 +69,11 @@ msgstr "" #: yms/view/base.py:130 #, fuzzy msgid "List" -msgstr "Listen" +msgstr "Liste" #: yms/view/base.py:131 msgid "Records" -msgstr "" +msgstr "Datensätze" #: yms/view/base.py:298 msgid "" @@ -79,12 +83,11 @@ msgid "" msgstr "" #: yms/view/base.py:333 -#, fuzzy msgid "" "Add new vessel.\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Neues Boot hinzufügen.\n" "Sind Sie sicher?" #: yms/view/base.py:441 @@ -97,163 +100,154 @@ msgstr "" #: yms/view/boxes.py:14 msgid "Boxes" -msgstr "" +msgstr "Kisten" -#: yms/view/boxes.py:33 yms/ui/boxes.ui:263 yms/ui/boxes.ui:561 +#: yms/view/boxes.py:25 yms/ui/boxes.ui:263 yms/ui/boxes.ui:561 msgid "Label" msgstr "" -#: yms/view/boxes.py:34 yms/ui/boxes.ui:310 yms/ui/boxes.ui:766 +#: yms/view/boxes.py:26 yms/ui/boxes.ui:310 yms/ui/boxes.ui:766 msgid "Content" msgstr "Inhalt" -#: yms/view/boxes.py:35 yms/view/companies.py:39 yms/view/equipment.py:38 -#: yms/view/inventory.py:63 yms/view/maintenance.py:32 yms/view/projects.py:43 +#: yms/view/boxes.py:27 yms/view/companies.py:35 yms/view/equipment.py:38 +#: yms/view/inventory.py:56 yms/view/maintenance.py:32 yms/view/projects.py:43 #: yms/view/storage.py:28 yms/ui/base.ui:388 yms/ui/base.ui:754 #: yms/ui/boxes.ui:285 yms/ui/boxes.ui:712 yms/ui/cables.ui:113 #: yms/ui/cables.ui:423 yms/ui/cables.ui:829 yms/ui/companies.ui:423 -#: yms/ui/companies.ui:903 yms/ui/documents.ui:413 yms/ui/documents.ui:607 -#: yms/ui/equipment.ui:455 yms/ui/equipment.ui:888 yms/ui/fuses.ui:98 +#: yms/ui/companies.ui:903 yms/ui/documents.ui:525 yms/ui/documents.ui:719 +#: yms/ui/equipment.ui:455 yms/ui/equipment.ui:903 yms/ui/fuses.ui:98 #: yms/ui/fuses.ui:353 yms/ui/fuses.ui:639 yms/ui/inventory.ui:378 -#: yms/ui/inventory.ui:786 yms/ui/maintenance.ui:359 yms/ui/maintenance.ui:650 +#: yms/ui/inventory.ui:801 yms/ui/maintenance.ui:359 yms/ui/maintenance.ui:650 #: yms/ui/projects.ui:105 yms/ui/projects.ui:349 yms/ui/projects.ui:628 -#: yms/ui/provisions.ui:486 yms/ui/provisions.ui:870 yms/ui/storage.ui:419 +#: yms/ui/provisions.ui:480 yms/ui/provisions.ui:903 yms/ui/storage.ui:419 #: yms/ui/storage.ui:827 yms/ui/tasks.ui:507 yms/ui/tasks.ui:716 msgid "Remarks" msgstr "Bemerkungen" -#: yms/view/boxes.py:100 +#: yms/view/boxes.py:117 msgid "Add new Box" -msgstr "" +msgstr "Neue Kiste hinzufügen" -#: yms/view/boxes.py:106 yms/ui/boxes.ui:539 -#, fuzzy +#: yms/view/boxes.py:123 yms/ui/boxes.ui:539 msgid "Edit Box" -msgstr "Bearbeiten" +msgstr "Kiste bearbeiten" -#: yms/view/boxes.py:140 -#, fuzzy +#: yms/view/boxes.py:157 msgid "" "Delete box!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Kiste!\n" "Sind Sie sicher?" #: yms/view/cables.py:14 msgid "Cables" msgstr "Kabel" -#: yms/view/cables.py:36 yms/view/companies.py:37 yms/view/equipment.py:33 -#: yms/view/fuses.py:37 yms/view/inventory.py:59 yms/view/projects.py:39 +#: yms/view/cables.py:36 yms/view/companies.py:33 yms/view/equipment.py:33 +#: yms/view/fuses.py:37 yms/view/inventory.py:52 yms/view/projects.py:39 #: yms/view/storage.py:26 yms/view/tasks.py:39 yms/ui/base.ui:567 #: yms/ui/boxes.ui:119 yms/ui/cables.ui:91 yms/ui/cables.ui:279 #: yms/ui/cables.ui:666 yms/ui/companies.ui:234 yms/ui/companies.ui:645 -#: yms/ui/equipment.ui:345 yms/ui/equipment.ui:718 yms/ui/fuses.ui:76 -#: yms/ui/inventory.ui:268 yms/ui/inventory.ui:667 yms/ui/measurement.ui:247 +#: yms/ui/equipment.ui:345 yms/ui/equipment.ui:733 yms/ui/fuses.ui:76 +#: yms/ui/inventory.ui:268 yms/ui/inventory.ui:682 yms/ui/measurement.ui:247 #: yms/ui/measurement.ui:579 yms/ui/projects.ui:83 yms/ui/projects.ui:272 -#: yms/ui/projects.ui:551 yms/ui/provisions.ui:255 yms/ui/provisions.ui:594 +#: yms/ui/projects.ui:551 yms/ui/provisions.ui:260 yms/ui/provisions.ui:627 #: yms/ui/storage.ui:257 yms/ui/storage.ui:544 yms/ui/tasks.ui:346 #: yms/ui/tasks.ui:677 msgid "Name" msgstr "" -#: yms/view/cables.py:37 yms/view/inventory.py:62 yms/ui/cables.ui:412 +#: yms/view/cables.py:37 yms/view/inventory.py:55 yms/ui/cables.ui:412 #: yms/ui/cables.ui:818 yms/ui/inventory.ui:92 yms/ui/inventory.ui:367 -#: yms/ui/inventory.ui:775 +#: yms/ui/inventory.ui:790 msgid "Condition" msgstr "Zustand" #: yms/view/cables.py:125 -#, fuzzy msgid "" "Delete cable!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Kabel!\n" "Sind Sie sicher?" #: yms/view/companies.py:14 msgid "Companies" msgstr "Firmen" -#: yms/view/companies.py:23 +#: yms/view/companies.py:22 msgid "─── all ───" msgstr "─── alle ───" -#: yms/view/companies.py:38 yms/view/documents.py:32 yms/ui/boxes.ui:96 +#: yms/view/companies.py:34 yms/view/documents.py:33 yms/ui/boxes.ui:96 #: yms/ui/boxes.ui:332 yms/ui/boxes.ui:575 yms/ui/cables.ui:301 #: yms/ui/cables.ui:692 yms/ui/companies.ui:50 yms/ui/companies.ui:220 -#: yms/ui/companies.ui:656 yms/ui/documents.ui:66 yms/ui/fuses.ui:287 -#: yms/ui/fuses.ui:578 yms/ui/inventory.ui:279 yms/ui/inventory.ui:681 -#: yms/ui/storage.ui:280 +#: yms/ui/companies.ui:656 yms/ui/documents.ui:178 yms/ui/fuses.ui:287 +#: yms/ui/fuses.ui:578 yms/ui/inventory.ui:279 yms/ui/storage.ui:280 msgid "Type" msgstr "Typ" -#: yms/view/companies.py:115 -#, fuzzy +#: yms/view/companies.py:119 msgid "Add new Company" -msgstr "Neue Ausrüstung hinzufügen" +msgstr "Neue Firma hinzufügen" -#: yms/view/companies.py:126 -#, fuzzy +#: yms/view/companies.py:130 msgid "Edit Company" -msgstr "Firmen" +msgstr "Firma bearbeiten" -#: yms/view/companies.py:151 -#, fuzzy +#: yms/view/companies.py:155 msgid "" "Delete company!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Firma!\n" "Sind Sie sicher?" -#: yms/view/documents.py:14 +#: yms/view/documents.py:15 msgid "Documents" msgstr "Dokumente" -#: yms/view/documents.py:33 yms/ui/documents.ui:275 yms/ui/documents.ui:596 +#: yms/view/documents.py:34 yms/ui/documents.ui:387 yms/ui/documents.ui:708 msgid "Filename" msgstr "Dateiname" -#: yms/view/documents.py:34 yms/ui/documents.ui:252 yms/ui/documents.ui:574 +#: yms/view/documents.py:35 yms/ui/documents.ui:364 yms/ui/documents.ui:686 msgid "Title" msgstr "Titel" -#: yms/view/documents.py:35 +#: yms/view/documents.py:36 msgid "References" msgstr "Referenzen" -#: yms/view/documents.py:116 -#, fuzzy +#: yms/view/documents.py:117 msgid "Add new Document" -msgstr "Neue Ausrüstung hinzufügen" +msgstr "Neues Dokument hinzufügen" -#: yms/view/documents.py:152 -#, fuzzy +#: yms/view/documents.py:153 msgid "" "Delete document!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Dokument!\n" "Sind Sie sicher?" #: yms/view/equipment.py:14 yms/view/maintenance.py:31 #: yms/view/measurement.py:55 yms/ui/fuses.ui:320 yms/ui/fuses.ui:617 -#: yms/ui/inventory.ui:312 yms/ui/inventory.ui:717 yms/ui/maintenance.ui:81 +#: yms/ui/inventory.ui:312 yms/ui/inventory.ui:732 yms/ui/maintenance.ui:81 #: yms/ui/maintenance.ui:270 yms/ui/maintenance.ui:570 yms/ui/measurement.ui:81 #: yms/ui/measurement.ui:270 yms/ui/measurement.ui:662 msgid "Equipment" msgstr "Ausrüstung" #: yms/view/equipment.py:34 yms/ui/cables.ui:401 yms/ui/cables.ui:807 -#: yms/ui/equipment.ui:87 yms/ui/equipment.ui:367 yms/ui/equipment.ui:760 +#: yms/ui/equipment.ui:87 yms/ui/equipment.ui:367 yms/ui/equipment.ui:775 msgid "Manufacturer" msgstr "Hersteller" #: yms/view/equipment.py:35 yms/ui/base.ui:86 yms/ui/base.ui:596 -#: yms/ui/base.ui:1848 yms/ui/equipment.ui:378 yms/ui/equipment.ui:771 +#: yms/ui/base.ui:1848 yms/ui/equipment.ui:378 yms/ui/equipment.ui:786 msgid "Model" msgstr "Modell" @@ -266,21 +260,32 @@ msgstr "Seriennummer" msgid "Age" msgstr "Alter" -#: yms/view/equipment.py:104 +#: yms/view/equipment.py:108 msgid "Add new Equipment" msgstr "Neue Ausrüstung hinzufügen" -#: yms/view/equipment.py:114 yms/ui/equipment.ui:698 +#: yms/view/equipment.py:118 yms/ui/equipment.ui:713 msgid "Edit Equipment" msgstr "Ausrüstung bearbeiten" -#: yms/view/equipment.py:141 -#, fuzzy +#: yms/view/equipment.py:146 +msgid "" +"Convert equipment to inventory?\n" +"Some properties will be lost!\n" +"\n" +"Are you sure?" +msgstr "" +"Ausrüstung in Inventar umwandeln?\n" +"Einige Eigenschaften werden verlorengehen!\n" +"\n" +"Sind Sie sicher?" + +#: yms/view/equipment.py:156 msgid "" "Delete equipment!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Ausrüstung!\n" "Sind Sie sicher?" #: yms/view/fuses.py:14 @@ -291,60 +296,75 @@ msgstr "Sicherungen" msgid "Current" msgstr "Stromstärke" -#: yms/view/fuses.py:39 yms/view/provisions.py:40 yms/ui/fuses.ui:342 +#: yms/view/fuses.py:39 yms/view/provisions.py:42 yms/ui/fuses.ui:342 #: yms/ui/fuses.ui:564 msgid "Description" msgstr "Beschreibung" #: yms/view/fuses.py:88 -#, fuzzy msgid "Add new Fuse" -msgstr "Neue Ausrüstung hinzufügen" +msgstr "Neue Sicherung hinzufügen" #: yms/view/fuses.py:97 yms/ui/fuses.ui:528 msgid "Edit Fuse" msgstr "Sicherung bearbeiten" #: yms/view/fuses.py:125 -#, fuzzy msgid "" "Delete fuse!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Sicherung!\n" "Sind Sie sicher?" -#: yms/view/inventory.py:37 +#: yms/view/inventory.py:38 msgid "Inventory" msgstr "Inventar" -#: yms/view/inventory.py:60 +#: yms/view/inventory.py:53 yms/ui/inventory.ui:696 msgid "Container" msgstr "" -#: yms/view/inventory.py:61 yms/view/provisions.py:41 yms/ui/fuses.ui:276 -#: yms/ui/fuses.ui:550 yms/ui/inventory.ui:323 yms/ui/inventory.ui:728 -#: yms/ui/provisions.ui:302 yms/ui/provisions.ui:674 +#: yms/view/inventory.py:54 yms/view/provisions.py:43 yms/ui/fuses.ui:276 +#: yms/ui/fuses.ui:550 yms/ui/inventory.ui:323 yms/ui/inventory.ui:743 +#: yms/ui/provisions.ui:307 yms/ui/provisions.ui:707 msgid "Number" msgstr "" -#: yms/view/inventory.py:144 -#, fuzzy +#: yms/view/inventory.py:186 msgid "Add new Inventory" -msgstr "Inventar" +msgstr "Neus Inventar hinzufügen" -#: yms/view/inventory.py:153 -#, fuzzy +#: yms/view/inventory.py:197 +msgid "" +"Record is locked!\n" +"Edit prohibited." +msgstr "" +"Datensatz ist gesperrt!\n" +"Bearbeiten nicht zulässig." + +#: yms/view/inventory.py:203 msgid "Edit Inventory" msgstr "Inventar bearbeiten" -#: yms/view/inventory.py:179 -#, fuzzy +#: yms/view/inventory.py:231 +msgid "" +"Convert inventory to equipment?\n" +"Some properties will be lost!\n" +"\n" +"Are you sure?" +msgstr "" +"Ausrüstung in Inventar umwandeln?\n" +"Einige Eigenschaften werden verlorengehen!\n" +"\n" +"Sind Sie sicher?" + +#: yms/view/inventory.py:241 msgid "" "Delete inventory!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Inventar!\n" "Sind Sie sicher?" #: yms/view/maintenance.py:13 @@ -361,12 +381,11 @@ msgid "Edit Maintenance" msgstr "Wartung bearbeiten" #: yms/view/maintenance.py:118 -#, fuzzy msgid "" "Delete maintenance!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Wartung!\n" "Sind Sie sicher?" #: yms/view/measurement.py:14 @@ -392,21 +411,19 @@ msgid "Note" msgstr "Notiz" #: yms/view/measurement.py:117 -#, fuzzy msgid "Add new Measurement" -msgstr "Maß/Messung bearbeiten" +msgstr "Maß/Messung hinzufügen" #: yms/view/measurement.py:123 yms/ui/measurement.ui:557 msgid "Edit Measurement" msgstr "Maß/Messung bearbeiten" #: yms/view/measurement.py:154 -#, fuzzy msgid "" "Delete measurement!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Maß/Messung!\n" "Sind Sie sicher?" #: yms/view/projects.py:13 @@ -430,63 +447,57 @@ msgid "Status" msgstr "" #: yms/view/projects.py:90 -#, fuzzy msgid "Add new Project" -msgstr "Projekt bearbeiten" +msgstr "Projekt hinzufügen" #: yms/view/projects.py:96 yms/ui/projects.ui:529 msgid "Edit Project" msgstr "Projekt bearbeiten" #: yms/view/projects.py:127 -#, fuzzy msgid "" "Delete project!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Projekt!\n" "Sind Sie sicher?" -#: yms/view/provisions.py:13 +#: yms/view/provisions.py:15 msgid "Provisions" msgstr "Verpflegung" -#: yms/view/provisions.py:42 yms/ui/measurement.ui:337 yms/ui/provisions.ui:338 -#: yms/ui/provisions.ui:707 yms/ui/storage.ui:868 +#: yms/view/provisions.py:44 yms/ui/measurement.ui:337 yms/ui/provisions.ui:343 +#: yms/ui/provisions.ui:740 yms/ui/storage.ui:868 msgid "Unit" msgstr "Einheit" -#: yms/view/provisions.py:43 -#, fuzzy +#: yms/view/provisions.py:45 msgid "Stored" msgstr "Gespeichert" -#: yms/view/provisions.py:44 +#: yms/view/provisions.py:46 msgid "Best before" msgstr "Haltbar bis" -#: yms/view/provisions.py:97 -#, fuzzy -msgid "Add new Provision" -msgstr "Verpflegung ansehen" - #: yms/view/provisions.py:103 -#, fuzzy +msgid "Add new Provision" +msgstr "Verpflegung hinzufügen" + +#: yms/view/provisions.py:109 msgid "Edit Provision" msgstr "Verpflegung bearbeiten" -#: yms/view/provisions.py:132 -#, fuzzy +#: yms/view/provisions.py:138 msgid "" "Delete provision!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Proviant!\n" "Sind Sie sicher?" #: yms/view/storage.py:14 yms/ui/boxes.ui:442 yms/ui/boxes.ui:864 -#: yms/ui/inventory.ui:81 yms/ui/inventory.ui:290 yms/ui/inventory.ui:695 -#: yms/ui/provisions.ui:280 yms/ui/provisions.ui:616 +#: yms/ui/inventory.ui:81 yms/ui/inventory.ui:290 yms/ui/inventory.ui:710 +#: yms/ui/provisions.ui:285 yms/ui/provisions.ui:649 msgid "Storage" msgstr "Stauraum" @@ -494,22 +505,20 @@ msgstr "Stauraum" msgid "Position" msgstr "" -#: yms/view/storage.py:122 -#, fuzzy +#: yms/view/storage.py:124 msgid "Add new Storage" -msgstr "Stauraum bearbeiten" +msgstr "Stauraum hinzufügen" -#: yms/view/storage.py:131 yms/ui/storage.ui:522 +#: yms/view/storage.py:133 yms/ui/storage.ui:522 msgid "Edit Storage" msgstr "Stauraum bearbeiten" -#: yms/view/storage.py:159 -#, fuzzy +#: yms/view/storage.py:161 msgid "" "Delete storage!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Stauraum!\n" "Sind Sie sicher?" #: yms/view/tasks.py:13 @@ -528,19 +537,18 @@ msgstr "Verantwortlich" #: yms/view/tasks.py:92 msgid "Add new Task" -msgstr "" +msgstr "Neue Aufgabe hinzufügen" #: yms/view/tasks.py:98 yms/ui/tasks.ui:655 msgid "Edit Task" msgstr "Aufgabe bearbeiten" #: yms/view/tasks.py:128 -#, fuzzy msgid "" "Delete task!\n" "Are you sure?" msgstr "" -"Lösche Benutzer!\n" +"Lösche Aufgabe!\n" "Sind Sie sicher?" #: yms/ui/base.ui:97 yms/ui/base.ui:816 @@ -552,7 +560,6 @@ msgid "LoA" msgstr "LüA" #: yms/ui/base.ui:119 -#, fuzzy msgid "Draught min" msgstr "Tiefgang min" @@ -562,7 +569,7 @@ msgstr "Tiefgang" #: yms/ui/base.ui:141 yms/ui/base.ui:976 msgid "Beam" -msgstr "" +msgstr "Breite" #: yms/ui/base.ui:152 msgid "LwL" @@ -574,39 +581,37 @@ msgstr "" #: yms/ui/base.ui:285 yms/ui/base.ui:839 msgid "Shipyard" -msgstr "" +msgstr "Werft" #: yms/ui/base.ui:308 yms/ui/base.ui:710 -#, fuzzy msgid "Displacement" -msgstr "Anzeigename" +msgstr "Verdrängung" #: yms/ui/base.ui:331 msgid "Belt position, bow" -msgstr "" +msgstr "Gurtposition, vorne" #: yms/ui/base.ui:342 yms/ui/base.ui:922 msgid "Belt position, aft" -msgstr "" +msgstr "Gurtposition, achtern" #: yms/ui/base.ui:377 yms/ui/base.ui:861 msgid "Hull shape" -msgstr "" +msgstr "Rumpfform" #: yms/ui/base.ui:426 yms/ui/base.ui:777 -#, fuzzy msgid "Default Storage" -msgstr "Stauraum" +msgstr "Standard-Stauraum" #: yms/ui/base.ui:449 yms/ui/base.ui:933 msgid "Hull number" -msgstr "" +msgstr "Rumpfnummer" #: yms/ui/base.ui:482 yms/ui/base.ui:1143 yms/ui/boxes.ui:474 -#: yms/ui/cables.ui:579 yms/ui/companies.ui:1041 yms/ui/documents.ui:486 +#: yms/ui/cables.ui:579 yms/ui/companies.ui:1041 yms/ui/documents.ui:598 #: yms/ui/equipment.ui:634 yms/ui/fuses.ui:461 yms/ui/inventory.ui:580 #: yms/ui/maintenance.ui:467 yms/ui/measurement.ui:490 yms/ui/projects.ui:462 -#: yms/ui/provisions.ui:906 yms/ui/storage.ui:455 yms/ui/tasks.ui:589 +#: yms/ui/provisions.ui:939 yms/ui/storage.ui:455 yms/ui/tasks.ui:589 msgid "Delete" msgstr "Löschen" @@ -616,12 +621,12 @@ msgstr "Hinzufügen" #: yms/ui/base.ui:511 yms/ui/base.ui:1474 yms/ui/boxes.ui:195 #: yms/ui/boxes.ui:489 yms/ui/cables.ui:209 yms/ui/cables.ui:594 -#: yms/ui/companies.ui:147 yms/ui/companies.ui:1056 yms/ui/documents.ui:184 -#: yms/ui/documents.ui:501 yms/ui/equipment.ui:277 yms/ui/equipment.ui:649 +#: yms/ui/companies.ui:147 yms/ui/companies.ui:1056 yms/ui/documents.ui:296 +#: yms/ui/documents.ui:613 yms/ui/equipment.ui:277 yms/ui/equipment.ui:649 #: yms/ui/fuses.ui:194 yms/ui/fuses.ui:476 yms/ui/inventory.ui:200 #: yms/ui/inventory.ui:595 yms/ui/maintenance.ui:179 yms/ui/maintenance.ui:482 #: yms/ui/measurement.ui:179 yms/ui/measurement.ui:505 yms/ui/projects.ui:203 -#: yms/ui/projects.ui:477 yms/ui/provisions.ui:185 yms/ui/provisions.ui:921 +#: yms/ui/projects.ui:477 yms/ui/provisions.ui:190 yms/ui/provisions.ui:954 #: yms/ui/storage.ui:189 yms/ui/storage.ui:470 yms/ui/tasks.ui:278 #: yms/ui/tasks.ui:604 msgid "Edit" @@ -641,7 +646,7 @@ msgstr "" #: yms/ui/base.ui:651 msgid "Draught, min" -msgstr "" +msgstr "Tiefgang, min" #: yms/ui/base.ui:827 yms/ui/base.ui:883 yms/ui/base.ui:897 yms/ui/boxes.ui:647 #: yms/ui/boxes.ui:662 yms/ui/boxes.ui:677 yms/ui/boxes.ui:788 @@ -652,11 +657,11 @@ msgstr "" #: yms/ui/base.ui:911 msgid "Belt position, front" -msgstr "" +msgstr "Gurtposition, vorne" #: yms/ui/base.ui:954 msgid "Hull type" -msgstr "" +msgstr "Rumpfform" #: yms/ui/base.ui:987 msgid "0,00" @@ -669,17 +674,17 @@ msgstr "Boot" #: yms/ui/base.ui:1039 yms/ui/base.ui:1387 yms/ui/base.ui:1662 #: yms/ui/boxes.ui:938 yms/ui/cables.ui:1011 yms/ui/companies.ui:575 -#: yms/ui/documents.ui:679 yms/ui/equipment.ui:973 yms/ui/fuses.ui:756 -#: yms/ui/inventory.ui:1015 yms/ui/maintenance.ui:781 yms/ui/measurement.ui:826 -#: yms/ui/projects.ui:744 yms/ui/provisions.ui:525 yms/ui/storage.ui:961 +#: yms/ui/documents.ui:792 yms/ui/equipment.ui:988 yms/ui/fuses.ui:756 +#: yms/ui/inventory.ui:1030 yms/ui/maintenance.ui:781 yms/ui/measurement.ui:826 +#: yms/ui/projects.ui:744 yms/ui/provisions.ui:558 yms/ui/storage.ui:961 #: yms/ui/tasks.ui:920 msgid "Save" msgstr "Speichern" #: yms/ui/base.ui:1053 yms/ui/boxes.ui:952 yms/ui/cables.ui:1025 -#: yms/ui/companies.ui:589 yms/ui/documents.ui:693 yms/ui/equipment.ui:987 -#: yms/ui/fuses.ui:770 yms/ui/inventory.ui:1029 yms/ui/maintenance.ui:795 -#: yms/ui/measurement.ui:840 yms/ui/projects.ui:758 yms/ui/provisions.ui:539 +#: yms/ui/companies.ui:589 yms/ui/documents.ui:806 yms/ui/equipment.ui:1002 +#: yms/ui/fuses.ui:770 yms/ui/inventory.ui:1044 yms/ui/maintenance.ui:795 +#: yms/ui/measurement.ui:840 yms/ui/projects.ui:758 yms/ui/provisions.ui:572 #: yms/ui/storage.ui:975 yms/ui/tasks.ui:934 msgid "Cancel" msgstr "Abbruch" @@ -693,9 +698,9 @@ msgid "Vessel" msgstr "Boot" #: yms/ui/base.ui:1129 yms/ui/boxes.ui:181 yms/ui/cables.ui:195 -#: yms/ui/companies.ui:133 yms/ui/documents.ui:170 yms/ui/equipment.ui:263 +#: yms/ui/companies.ui:133 yms/ui/documents.ui:282 yms/ui/equipment.ui:263 #: yms/ui/fuses.ui:180 yms/ui/inventory.ui:186 yms/ui/maintenance.ui:165 -#: yms/ui/measurement.ui:165 yms/ui/projects.ui:188 yms/ui/provisions.ui:171 +#: yms/ui/measurement.ui:165 yms/ui/projects.ui:188 yms/ui/provisions.ui:176 #: yms/ui/storage.ui:175 yms/ui/tasks.ui:264 msgid "New" msgstr "Neu" @@ -737,9 +742,9 @@ msgid "User" msgstr "Benutzer" #: yms/ui/base.ui:1461 yms/ui/boxes.ui:209 yms/ui/cables.ui:223 -#: yms/ui/companies.ui:161 yms/ui/documents.ui:198 yms/ui/equipment.ui:291 +#: yms/ui/companies.ui:161 yms/ui/documents.ui:310 yms/ui/equipment.ui:291 #: yms/ui/fuses.ui:208 yms/ui/inventory.ui:214 yms/ui/maintenance.ui:193 -#: yms/ui/measurement.ui:193 yms/ui/projects.ui:218 yms/ui/provisions.ui:199 +#: yms/ui/measurement.ui:193 yms/ui/projects.ui:218 yms/ui/provisions.ui:204 #: yms/ui/storage.ui:203 yms/ui/tasks.ui:292 msgid "Details" msgstr "" @@ -821,17 +826,17 @@ msgid "Restore" msgstr "" #: yms/ui/boxes.ui:61 yms/ui/cables.ui:56 yms/ui/companies.ui:24 -#: yms/ui/documents.ui:31 yms/ui/equipment.ui:41 yms/ui/fuses.ui:41 +#: yms/ui/documents.ui:143 yms/ui/equipment.ui:41 yms/ui/fuses.ui:41 #: yms/ui/inventory.ui:46 yms/ui/maintenance.ui:46 yms/ui/measurement.ui:46 -#: yms/ui/projects.ui:46 yms/ui/provisions.ui:95 yms/ui/storage.ui:71 +#: yms/ui/projects.ui:46 yms/ui/provisions.ui:100 yms/ui/storage.ui:71 #: yms/ui/tasks.ui:31 msgid "Clear" msgstr "Löschen" #: yms/ui/boxes.ui:74 yms/ui/cables.ui:69 yms/ui/companies.ui:36 -#: yms/ui/documents.ui:44 yms/ui/equipment.ui:54 yms/ui/fuses.ui:54 +#: yms/ui/documents.ui:156 yms/ui/equipment.ui:54 yms/ui/fuses.ui:54 #: yms/ui/inventory.ui:59 yms/ui/maintenance.ui:59 yms/ui/measurement.ui:59 -#: yms/ui/projects.ui:60 yms/ui/provisions.ui:108 yms/ui/storage.ui:84 +#: yms/ui/projects.ui:60 yms/ui/provisions.ui:113 yms/ui/storage.ui:84 #: yms/ui/tasks.ui:44 msgid "Apply" msgstr "Anwenden" @@ -842,9 +847,9 @@ msgid "Filter Box" msgstr "Filter Projekte" #: yms/ui/boxes.ui:231 yms/ui/cables.ui:245 yms/ui/companies.ui:183 -#: yms/ui/documents.ui:220 yms/ui/equipment.ui:313 yms/ui/fuses.ui:230 +#: yms/ui/documents.ui:332 yms/ui/equipment.ui:313 yms/ui/fuses.ui:230 #: yms/ui/inventory.ui:236 yms/ui/maintenance.ui:215 yms/ui/measurement.ui:215 -#: yms/ui/projects.ui:240 yms/ui/provisions.ui:221 yms/ui/storage.ui:225 +#: yms/ui/projects.ui:240 yms/ui/provisions.ui:226 yms/ui/storage.ui:225 #: yms/ui/tasks.ui:314 msgid "page0" msgstr "" @@ -860,35 +865,35 @@ msgstr "" #: yms/ui/boxes.ui:354 yms/ui/boxes.ui:701 yms/ui/cables.ui:368 #: yms/ui/cables.ui:774 yms/ui/equipment.ui:400 yms/ui/inventory.ui:334 -#: yms/ui/inventory.ui:742 yms/ui/provisions.ui:316 yms/ui/provisions.ui:685 +#: yms/ui/inventory.ui:757 yms/ui/provisions.ui:321 yms/ui/provisions.ui:718 #, fuzzy msgid "Weight" msgstr "Gewicht, kg" -#: yms/ui/boxes.ui:398 yms/ui/boxes.ui:742 yms/ui/provisions.ui:327 -#: yms/ui/provisions.ui:696 +#: yms/ui/boxes.ui:398 yms/ui/boxes.ui:742 yms/ui/provisions.ui:332 +#: yms/ui/provisions.ui:729 #, fuzzy msgid "Weight net" msgstr "Gewicht, kg" #: yms/ui/boxes.ui:420 yms/ui/boxes.ui:690 yms/ui/equipment.ui:411 -#: yms/ui/inventory.ui:345 yms/ui/inventory.ui:753 yms/ui/provisions.ui:824 +#: yms/ui/inventory.ui:345 yms/ui/inventory.ui:768 yms/ui/provisions.ui:857 #, fuzzy msgid "Price" msgstr "Preis, €" #: yms/ui/boxes.ui:503 yms/ui/cables.ui:608 yms/ui/companies.ui:1070 -#: yms/ui/documents.ui:515 yms/ui/equipment.ui:663 yms/ui/fuses.ui:490 -#: yms/ui/inventory.ui:609 yms/ui/maintenance.ui:496 yms/ui/measurement.ui:519 -#: yms/ui/projects.ui:491 yms/ui/provisions.ui:935 yms/ui/storage.ui:484 -#: yms/ui/tasks.ui:618 +#: yms/ui/documents.ui:45 yms/ui/documents.ui:627 yms/ui/equipment.ui:663 +#: yms/ui/fuses.ui:490 yms/ui/inventory.ui:609 yms/ui/maintenance.ui:496 +#: yms/ui/measurement.ui:519 yms/ui/projects.ui:491 yms/ui/provisions.ui:968 +#: yms/ui/storage.ui:484 yms/ui/tasks.ui:618 msgid "Close" msgstr "Schließen" #: yms/ui/boxes.ui:525 yms/ui/cables.ui:630 yms/ui/companies.ui:612 -#: yms/ui/documents.ui:537 yms/ui/equipment.ui:685 yms/ui/fuses.ui:512 -#: yms/ui/inventory.ui:631 yms/ui/maintenance.ui:518 yms/ui/measurement.ui:541 -#: yms/ui/projects.ui:513 yms/ui/provisions.ui:561 yms/ui/storage.ui:506 +#: yms/ui/documents.ui:649 yms/ui/equipment.ui:700 yms/ui/fuses.ui:512 +#: yms/ui/inventory.ui:646 yms/ui/maintenance.ui:518 yms/ui/measurement.ui:541 +#: yms/ui/projects.ui:513 yms/ui/provisions.ui:594 yms/ui/storage.ui:506 #: yms/ui/tasks.ui:640 msgid "page1" msgstr "" @@ -906,9 +911,9 @@ msgid "mm" msgstr "" #: yms/ui/boxes.ui:974 yms/ui/cables.ui:1047 yms/ui/companies.ui:1092 -#: yms/ui/documents.ui:715 yms/ui/equipment.ui:1010 yms/ui/fuses.ui:792 -#: yms/ui/inventory.ui:1051 yms/ui/maintenance.ui:817 yms/ui/measurement.ui:862 -#: yms/ui/projects.ui:780 yms/ui/provisions.ui:957 yms/ui/storage.ui:997 +#: yms/ui/documents.ui:858 yms/ui/equipment.ui:1025 yms/ui/fuses.ui:792 +#: yms/ui/inventory.ui:1066 yms/ui/maintenance.ui:817 yms/ui/measurement.ui:862 +#: yms/ui/projects.ui:780 yms/ui/provisions.ui:990 yms/ui/storage.ui:997 #: yms/ui/tasks.ui:956 msgid "page2" msgstr "" @@ -944,7 +949,7 @@ msgid "Cross section" msgstr "" #: yms/ui/cables.ui:390 yms/ui/cables.ui:796 yms/ui/equipment.ui:98 -#: yms/ui/equipment.ui:433 yms/ui/equipment.ui:866 +#: yms/ui/equipment.ui:433 yms/ui/equipment.ui:881 msgid "Supplier" msgstr "Lieferant" @@ -952,9 +957,9 @@ msgstr "Lieferant" msgid "Edit Cable" msgstr "" -#: yms/ui/companies.ui:61 yms/ui/documents.ui:88 yms/ui/equipment.ui:109 +#: yms/ui/companies.ui:61 yms/ui/documents.ui:200 yms/ui/equipment.ui:109 #: yms/ui/inventory.ui:103 yms/ui/maintenance.ui:92 yms/ui/measurement.ui:92 -#: yms/ui/provisions.ui:67 yms/ui/storage.ui:106 yms/ui/tasks.ui:88 +#: yms/ui/provisions.ui:72 yms/ui/storage.ui:106 yms/ui/tasks.ui:88 msgid "Text" msgstr "" @@ -972,7 +977,7 @@ msgid "Secondary type" msgstr "" #: yms/ui/companies.ui:291 yms/ui/companies.ui:678 yms/ui/equipment.ui:356 -#: yms/ui/equipment.ui:729 +#: yms/ui/equipment.ui:744 msgid "Short name" msgstr "Kurzname" @@ -1026,68 +1031,77 @@ msgid "Type secondary" msgstr "" #: yms/ui/companies.ui:1007 yms/ui/equipment.ui:120 yms/ui/equipment.ui:601 -#: yms/ui/inventory.ui:547 yms/ui/inventory.ui:925 +#: yms/ui/inventory.ui:547 yms/ui/inventory.ui:940 msgid "Flags" msgstr "" -#: yms/ui/documents.ui:77 +#: yms/ui/documents.ui:19 +msgid "Preview" +msgstr "" + +#: yms/ui/documents.ui:32 yms/ui/documents.ui:835 +msgid "Scan" +msgstr "" + +#: yms/ui/documents.ui:189 msgid "Reference" msgstr "Referenz" -#: yms/ui/documents.ui:131 +#: yms/ui/documents.ui:243 msgid "Filter Documents" msgstr "Filter Dokumente" -#: yms/ui/documents.ui:232 -#, fuzzy +#: yms/ui/documents.ui:344 msgid "Document Details" -msgstr "Ausrüstungsdetails" +msgstr "Dokumentdetails" -#: yms/ui/documents.ui:286 +#: yms/ui/documents.ui:398 msgid "Image extents" -msgstr "" +msgstr "Abmaße" -#: yms/ui/documents.ui:297 +#: yms/ui/documents.ui:409 msgid "Mimetype" msgstr "" -#: yms/ui/documents.ui:344 +#: yms/ui/documents.ui:456 msgid "File size" -msgstr "" +msgstr "Dateigröße" -#: yms/ui/documents.ui:355 +#: yms/ui/documents.ui:467 msgid "Upload date" msgstr "" -#: yms/ui/documents.ui:366 yms/ui/documents.ui:648 -#, fuzzy +#: yms/ui/documents.ui:478 yms/ui/documents.ui:760 msgid "Document type" -msgstr "Dokumente" +msgstr "Dokumentart" -#: yms/ui/documents.ui:439 +#: yms/ui/documents.ui:551 msgid "Role access" msgstr "" -#: yms/ui/documents.ui:552 -#, fuzzy +#: yms/ui/documents.ui:664 msgid "Edit Document" -msgstr "Filter Dokumente" +msgstr "Dokument bearbeiten" -#: yms/ui/equipment.ui:76 yms/ui/equipment.ui:444 yms/ui/equipment.ui:877 -#: yms/ui/inventory.ui:524 yms/ui/inventory.ui:904 yms/ui/measurement.ui:457 -#: yms/ui/measurement.ui:794 yms/ui/provisions.ui:269 yms/ui/provisions.ui:605 +#: yms/ui/documents.ui:820 +msgid "Upload" +msgstr "" + +#: yms/ui/equipment.ui:76 yms/ui/equipment.ui:444 yms/ui/equipment.ui:892 +#: yms/ui/inventory.ui:524 yms/ui/inventory.ui:919 yms/ui/measurement.ui:457 +#: yms/ui/measurement.ui:794 yms/ui/provisions.ui:274 yms/ui/provisions.ui:638 msgid "Category" msgstr "Kategorie" -#: yms/ui/equipment.ui:169 yms/ui/inventory.ui:955 +#: yms/ui/equipment.ui:169 yms/ui/inventory.ui:970 msgid "ordered" msgstr "bestellt" -#: yms/ui/equipment.ui:182 yms/ui/inventory.ui:969 +#: yms/ui/equipment.ui:182 yms/ui/inventory.ui:984 msgid "removed" msgstr "entfernt" -#: yms/ui/equipment.ui:195 yms/ui/inventory.ui:983 yms/ui/tasks.ui:184 +#: yms/ui/equipment.ui:195 yms/ui/inventory.ui:998 yms/ui/tasks.ui:184 msgid "deleted" msgstr "gelöscht" @@ -1099,7 +1113,7 @@ msgstr "Filter Ausrüstung" msgid "Equipment details" msgstr "Ausrüstungsdetails" -#: yms/ui/equipment.ui:389 yms/ui/equipment.ui:782 +#: yms/ui/equipment.ui:389 yms/ui/equipment.ui:797 msgid "Serial no." msgstr "Seriennummer" @@ -1107,15 +1121,19 @@ msgstr "Seriennummer" msgid "Date purchase" msgstr "Kaufdatum" -#: yms/ui/equipment.ui:793 +#: yms/ui/equipment.ui:677 yms/ui/inventory.ui:623 +msgid "Convert" +msgstr "Umwandeln" + +#: yms/ui/equipment.ui:808 msgid "Weight, kg" msgstr "Gewicht, kg" -#: yms/ui/equipment.ui:804 +#: yms/ui/equipment.ui:819 msgid "Price, €" msgstr "Preis, €" -#: yms/ui/equipment.ui:815 +#: yms/ui/equipment.ui:830 msgid "Date puchase" msgstr "Kaufdatum" @@ -1143,8 +1161,8 @@ msgstr "Filter Inventar" msgid "Inventory details" msgstr "Inventardetails" -#: yms/ui/inventory.ui:301 yms/ui/inventory.ui:706 yms/ui/provisions.ui:291 -#: yms/ui/provisions.ui:663 +#: yms/ui/inventory.ui:301 yms/ui/inventory.ui:721 yms/ui/provisions.ui:296 +#: yms/ui/provisions.ui:696 msgid "Box" msgstr "Kiste" @@ -1152,11 +1170,11 @@ msgstr "Kiste" msgid "Purchase Date" msgstr "Kaufdatum" -#: yms/ui/inventory.ui:645 +#: yms/ui/inventory.ui:660 msgid "Edit inventory" msgstr "Inventar bearbeiten" -#: yms/ui/inventory.ui:764 +#: yms/ui/inventory.ui:779 msgid "Puchase date" msgstr "Kaufdatum" @@ -1252,32 +1270,32 @@ msgstr "Tatsächliche Kosten" msgid "Duration days" msgstr "" -#: yms/ui/provisions.ui:44 +#: yms/ui/provisions.ui:49 msgid "Kategorie" msgstr "" -#: yms/ui/provisions.ui:132 +#: yms/ui/provisions.ui:137 #, fuzzy msgid "Filter Provisions" msgstr "Verpflegung ansehen" -#: yms/ui/provisions.ui:233 +#: yms/ui/provisions.ui:238 msgid "Edit provision" msgstr "Verpflegung bearbeiten" -#: yms/ui/provisions.ui:349 yms/ui/provisions.ui:718 +#: yms/ui/provisions.ui:354 yms/ui/provisions.ui:751 msgid "Storedate" msgstr "Einlagerdatum" -#: yms/ui/provisions.ui:360 yms/ui/provisions.ui:729 +#: yms/ui/provisions.ui:365 yms/ui/provisions.ui:762 msgid "Shelflife" msgstr "Haltbarkeit" -#: yms/ui/provisions.ui:574 +#: yms/ui/provisions.ui:607 msgid "View Provision" msgstr "Verpflegung ansehen" -#: yms/ui/provisions.ui:847 +#: yms/ui/provisions.ui:880 msgid "Target" msgstr "" @@ -1691,7 +1709,7 @@ msgstr "Exzellent" #: db/mariadb.sql:249 msgctxt "inventory.invcond" msgid "fair" -msgstr "" +msgstr "Normal" #: db/mariadb.sql:249 msgctxt "inventory.invcond" @@ -1818,6 +1836,17 @@ msgctxt "property.objtype" msgid "vessel" msgstr "Boot" +#: db/mariadb.sql:581 +msgctxt "revision.revtype" +msgid "dropdown" +msgstr "" + +#: db/mariadb.sql:581 +#, fuzzy +msgctxt "revision.revtype" +msgid "table" +msgstr "Kabel" + #: db/mariadb.sql:552 msgctxt "signalk.objtype" msgid "equipment" diff --git a/locale/de/LC_MESSAGES/ymsgui.mo b/locale/de/LC_MESSAGES/ymsgui.mo new file mode 100644 index 0000000000000000000000000000000000000000..8434dfa712f191777948a9138b9fecbbc482217d GIT binary patch literal 16213 zcmcJVd7Ky}QlM^ejCyNj882 z9)Jhn`yvRafNwxVQ4~Q@6m&UW5hWfdq97uO7q6fqulR!R_gDS&%tds%HpJfdyj%X`;6g zPKFo2-Qk7CtKsX3-vZUXZ$sJnK9rpw8Xtw*5r4w?3{*e=XnYaM{;N>sChebcN2vOz zLbZEeiysbUZvm7;7sBn~7UQE({d>~l&%u?%Uo>{%e6{ydC_i5VRsKdOyPvoC?ND~U z0awEZq1t&MPLqBH+y%~ovU4m{JC{M(dmEI!cS4538-z5$J0J4T`vgA+!LP$<@G*!B zyq7J$CyCREzsa~3lH`p-<-gM6Ux6z3i1B%-`gbCe`ndv`FSH$d)@=p?+-(jyTlhs^1GrKLbjCB$VAnPA+yQH9EP9@Koe7|JgnG5z&W`EG`)?{=vEejD=7+rp2^{RPVYKcMnYc|)q- z6{y03ab2Dq1tnTrS}?7hpHzso(0v;QK<44LzTbG;#Wi2x!&S8 zL$&{lQ2zQRRQ`J{{(U%!_>ZC5`Ka-6<5N)Oo`q`1bH*2quRyh9%FJ{=?F`kw{h{hP z#Nu<|B;rRy% z#Jk|0@H8m9XIcCri+>WTUAIH^=WeL?;{i*549d<6Q0-_tB(*aQs=Y@VPk^fDbg29l z)Q|FGAJ(4@;jsFSRojs@;1*m7fK7feYZbV5jLP%}?|11l6A1q3j<7&wz&+ zFM_i7TR0WI0w=>=7NqufhdUGB532m3@a=FORR1n9{pH3_LiOh+xEs6;%HDlY{do{- z{ri#eFUCENNcX1&kR{Ap16iWIb4-67WNY=tAWM<=jKz0;Q(CUWcrsMJip8&hYWJN` z{TPGl=N2fxJZbtrTKw;pKIOgP$u0Lm|ADEp&O{&*kU z6<%h%9_~T>OK>lEKYTrW-1L8jyA$8;&FOsI7b-pvDt|Xr`O{2aviJp-eg#zhx0wD; zsCIu3sy~lGwdZLlyDu7dcuVS^{h`iTv!Lo(X!;Y4ryFCadH60UKfE8R-j5kKL)CYy z@oP}|@3r_tP=5Uh)VTc8(*FeY-n;}ge_n;!hbJAC=HDL5?ygYw_Jb-v1Ipj?O@Azu zUl&8=Uk7D34`pu{YP?EN?WjW6AE^BAH(my1_iEz}Q2B0!^3zwL%0B?r|1D7Ee_{L$ zWU715Tl&m}Y5uuTc8`K8*9~Q_2dZ6XK-meQ#;;`hbD;8HVDU?!>c1Sy-Y1~S-DLVN zLHXzFQ02Z0HGh8!)sJVO@;?V<=Ow88-qC4%SEzFPLbdB)DF4ke&VjPC0IK}aP~+AO zFI6b}n~d+Z^h=CaLgl*-%H9p8zr}b5RR8aWvU5LF`?o-~TRhO)D##itn$GtPsmZy{8^PK&RAs&_S1y=yGJAG-cpdKIc4qsH^0{CY8z z-OHica}89#uZODVMku?tLY2SEcrTRwhb;aGR68EG_^&MecNYIMl%1DNzuj@Ey{X2% zq3WFmWp^f2{&tHW1v!>@T~PIOn|>KozLPEf4ybkx7-Q3~xA?oE>bcP3AA+v`(Dff` zo?Q>s|1UuK=}suS_nQ78sCNFu^uM(DvrzV)H@*aA=T%GJ;rO)NZcz62gZsc4a9?;d zR6iFXA4l}ujC=yQ6nQK1Frw#tR&e_C#ioPtU%_vk9|pyXSYt7vX;)Pg(p#_&o~?Gm$qU zHzCu^4nem^UI2fEydPn@cx+W}E&}&xfB%SuHCOLP9zzx*ZAkVc1ePH4kx@kNOZI%4 zz-N%RA#5?;YqCBOek0*a;E#}_;%!H2(PhsCc<&eJ?HTIW8@deeNI#V z`76Qwv2hJtflNaVM)pK^C;SPrKQhPac^~12kRKv@pnDXag>(>p2Rszf^9JI2_rHkj zWM!`-{9#1TZ;_42cNF2-BZc=%;~U@<%1wtyAb&?5MD%OI%^7TU>xe<94 z(K8$UzobELJHp2kz76??>4Xxp4w->WC(j7{6S5x3o>vI`C$b~ydioHZ5AQ}UL-s*` z0CET6HOLc)p1sf=2%kkhhqNOPAjcqj4o~5I9&SKhMqWbZBCkdCT%5w&!RkKQ;;*;( z-tcee=9zw$@t^QO(#GHd zBmZUzN5fN)gGsv=ZVz{dyIWnmz^jPw3SS40MD%5#(H?f*gkY0MXM% z*#Y<)7aRYxH_>-Bs4gP>XXJWh5ZR5gRX7z{i|En!^n2lFk=GH^G1^v|JeieyxVF8Q;xu`Nqpb`$s4U1f?5C)02s8GUFsfRTN3Kc>% z$Ip|Uc${~wQ)nO>G%$89&p=cN{X@?__fS7BRs4ZcHO_amb%z5%m5$|Hi7e|-P^P_M z?B|jY%jD~!1-K)m0>3g8P+r!8T&|Slqj=D-l;p{T`4HyI9c^uWLzGVFcaW$+RQ5-b z(qIx4JJhO5z~G6R86wlGLbF`r`Y>@y(GRofq8g%Xava~*TPlV!IYK6U;ctiv1)A*R zqRRBPrjexvXRKCU#%h-T&&JA?GTn~@hKt(hSs{oCR_O-gMT zq5JVisyT+O7D*anZWO$1sIyn2I~+_xrcrmuB%+*y-(T7|y~%x+lGA*hC@p>MCrHiP zA}~R6Z6qd0A7Fu)AgMN@6Qmb|NRv!2*F-t$%gY2gm}OdQCQeP4o(a+!el0{3q*hp# zCP<>w$<~wdj8!?8L?fC&UU$UOsI|{OY~yTybhf{VS&``&-Kfm`%%$sR8X1j)BI9j? z;&+FYAS#eEQ&dJr>dEMnpgK5I$>(@52=lawLgR-$fONYJE<&usLgWp6Rd zhx>7RhGKrUVYo=vgfvfmt8j^KpKzi2CgGy1>VupXY}_(j4)zDPUt|&6EL=2u9bCk1 z6E0MnS*b}TK~^YRk-S>_{Jgnvi5A6jv?=rya&9J2;q}jYR#u7>wZfS~-K(Y6duZ7k z`RXmsMFt<7%-#OgtAZ4+TsH7j)BNd6CKN zha0tWm%Zh@T*-PC!g_map_)@x2Jv83d-2MM)zVv8>O^vGPf}nw%!5HDRbw9;!nG!@ z3gYSj8wI;{;x&$OL%5!~?wzu?s+4DQJu%$iomgV2>j}!`4QyOq&rm5Q%KEL1-a>8$ z_asp+ob5k#!RI`Jr9``MHj9k4s%l;*kWP}a*ORWs>Fdx_O;_WzlGUL$O`k2X;Ces3 z%}uzGq%;)uN7`+@G)ox{glr?ZupW}K7$l72>aaXg;?377Vs(k1-e5gHVG;$5A={0D zOsU?XurN@F21px!;$D99jW3kc!t^<-8Oz zCVko=%Ah=4E0oT;J{BZ)q2h?w7gcC#-zXt1GpEF?2&b^rd250~HB5i~dB*w11>PEW zWb@WUoHuK3_SS|GE7NR$c+guLc&PslNmDkK$x4g$=!bJGR?Oq-3m)$o% zxj)Fa=<>LmgGqDNa3e=EUgy@7!BVN!3P<7=6G=D{M2S1_HCwO7!*OXt?B#~S+%Usm z>~JB@PMpgoyD(1QdTKTPpVE27tuQBxN=L51C{)79IUOapmf#w%mW<2JF^dMKdwj=0 zAs8%A=7r+afQfNh4th+IDCg8^hAd;g#9?xv1JOb@>e}(3IiaX^zgfv^ z$ zOBExLTiU!lr`kL-!W=yiZN$w@%5>%MYOd*EO|ePctg}hotgcV$<`g%no0Sa{xH&1C zz;*rj8Pcq0@nccTH#9!Y&o^FaJ$f9+yT-Rq2Yss4Cd*dTnrqrv>Ph2kZq{ctH|tw# zCP&So_1u}(T-usYcWP_e01H4vOEX)}+pW19{N0+EdEC7K>FKt^h0~WiuT5=&G`-&w zB$eX9lBW0s$?hwsSl?AU`1s>=mm8hT${rQiC&Hd`FtH7U$47iX->&rF(Vr& zU1HCkT<}^{Be}9y3HYcSs2OIFYgVO$)Ra#>Y*MBDYf`%2wdz_5yAjq8!M{PlypMa5yEAyYqedaTU=8@w&OLa*+X?z(rkP~z?}_h?M6*| zYlF%be5Xk`>`i7M_-u>QVot*`uUKYtX;78b&<0$TpQxr>aX}qSA zL|)d;r!GG){pSaKE7W3MEyUR~4jU4B(jB>ddA@y3nCMG&p?~VCUVm=KytdWh2q)3@ zRpr4b-`-UnEVuWS7W!>HC$+B*)1!2|4(1E}`E%zV**`}}$S+#?sxfAg%l^XJZO zTN#uq?R`lQmkR-V!9u@ps8r-9!LK4Q>49*8@+{mp==|M zlG|1-U$wa2>UkY=+ZLs_R_%QpVix)pzJ%tmGDh*yJ{K-YIjkIeO5c+9x772gb)4ec z7st7h#($yz7EbwXZ);zwlSA6@RnFHRtWdLaTzYYv-)uz}{TM&4l5~xXet6k%2-u*qpbw60o~ei{mo8PIp!Z z1_SQP8mm-7nM(z3(i+qqZM{*P_j@CKl&cS1^6KN8kA--c55mrP1Meixyw6H zg4;uHX*H=dT=wRMC>A$q*OwAD+VMG4-Ljxi>DO0CRQB8$rN6Paf`%9Dx3j-L;VY5Y zNU$lYFvJAit#8DqS|!L=yp>~jlxcVD_2!27!Wz4lpaxga#pfWyUnt-@HJ){A9k-1^ zocC5V-sX;vxo$>w4~$bP{$M!3Rd5*NEfwbbaJaF!zoE*3&F9VG#6MW+XzPk9OuBx) zvijw!*!eflmu7kk6#2Ru(8f-~^ZxQ7K4AUMn9FaDeKb`SwROhy%X*aeX>>BqP+8x2 zx-Bkpp;sjSdT3{Wr|vD6UV~?4h1@!I{-5pl1(ovHX1N8=`75|uW|)_TI(Ol3i?f39 zhnJX<(5$E=rDB+%UaeuSnf=&}H}An9M>Zx-#rocI z-JBM8_svVfp+b5OUAu5*qOAz31L>5jhnPJ{B~@kSA%L}tKEV%W{{Q)e;IuP~Kd9L|b#~LoHJNvmC(q6%g zW;e(uW1HEf$=Dfh;(jN+M$JYtU%RYMw=x{c#dR9yS}6+I8z`Cu-2HSGNpGu{jBPFy z(%sco%~nl!P-T~Jzq9>5ePZ$_KwIw8rMzMNb1QPtsK^@BsB4&Kjq2LOYE))3sZnQB zr%}~7R~q%%Hd|k!<=5IS+n~;7Kx64_du_)=D3=o(VXR}c}$yNdY7KHFN>S6vS_29GM)LTR#E1OEZw}od4NBI(s-{{ zZLKRc4GmdcEshLuZ_Z!((lFayu_449*Q{p)OE1i`8*~1un>9Z3Q11vI)kEoRIhI$B z-PP%x#4KORb#Isu=!}bDL5sSV_0w2u*)opVTHk4m9mCv9mz~MlyX_^iL~3ytV`bpvWQKdwN^_6|{|PQ?)R*xy%=!T`B*409#h^|CaW0NXZyR)6aF^@pq1fH7cLmim zgQ3LhS-CF#IB{oF4tuP_G@U~lvyW4-F6KC@EUi}Dtl~p2;I9!0r(*8>`$L^aD$L4c z7$tuJi1jxO3--G$#m#t5LnZ#NhWp&{P8t|+?aFqQW$9%z2RW~^pLtTt%t_TYp7ikT zjtPy+QSHsi=BoL$?l9*T9Gn}9-Bwg63^IlI-sVp;scISTL%+`NT~Q&=va!*%-i@%{ zQnjYhD~mU7a>GftaLLx)F>b?j2Q+VSTwy-oskVP?>-Gv&Lr2s#ct= zo}QpuHYd76@3;}mmdTc(b0ftkN9v}=%4^PA$s0LbJ0|?^%rZ0F`H9@__4AgM80!-8mEw@M@L%4+@Ug)5oHtCxBLYggQu^51f%AYlLi literal 0 HcmV?d00001 diff --git a/yms/database.py b/yms/database.py index d1c097b..e1c2ed3 100644 --- a/yms/database.py +++ b/yms/database.py @@ -1,5 +1,6 @@ import MySQLdb import secrets +from gettext import pgettext class Database: @@ -63,7 +64,6 @@ class Database: def load_enum(self, table, column): """ - TODO this is only an example! perhaps other keys needed Load an enum directly from a database table and provide it as a dictionary for use in, for example, selection lists. """ @@ -76,9 +76,10 @@ class Database: row = self.cur.fetchone() if not row: return {} + enumvals = row[0].replace("'", "").split(",") return { - i: _(value.strip("'")) - for i, value in enumerate(row[0].split(','), 1) + value: pgettext(f"{table}.{column}", value) + for value in enumvals } def lock_acquire(self, table, key, userid): @@ -94,7 +95,7 @@ class Database: return token except self.conn.IntegrityError as e: self.conn.rollback() - if e.errno != 1062: + if e.args[0] != 1062: raise # lazy locking: lock exists but is old, so we use it sql = ( @@ -112,7 +113,7 @@ class Database: def lock_refresh(self, token): sql = ( "UPDATE recordlock " - "SET last_seen=current_timestamp() " + "SET last_seen=CURRENT_TIMESTAMP " "WHERE token=%s" ) self.cur.execute(sql, (token,)) diff --git a/yms/gtkutils.py b/yms/gtkutils.py index 0ae453b..a6fa66a 100644 --- a/yms/gtkutils.py +++ b/yms/gtkutils.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: WTFPL + from gi.repository import Gtk def init_named_controls(window, builder): @@ -74,3 +76,50 @@ def get_text_contents(textview): """ buf = textview.get_buffer() return buf.get_text(buf.get_start_iter(), buf.get_end_iter(), True) + +class TouchPopup(): + """ + A pop-up window that can be closed again with another click. + The pop-up features a title in bold, as well as a list of labels and values. + """ + #TODO finish converting to GTK3 + def __init__(self, parent, title, data, width=None): + self.window = win = gtk.Window(Gtk.WindowType.POPUP) + win.set_position(Gtk.WindowPosition.MOUSE) + win.set_transient_for(parent) + win.set_modal(True) + if width: + win.set_size_request(width, -1) + #win.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#feffd0")) + win.override_background_color( + Gtk.StateFlags.NORMAL, + Gdk.RGBA(1.0, 1.0, 0.816, 1.0) # #feffd0 + ) + frame = Gtk.Frame() + frame.set_shadow_type(Gtk.ShadowType.ETCHED_OUT) + frame.set_border_width(2) + win.add(frame) + vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) + frame.add(vbox) + # Title + label = Gtk.Label("" + title + "") + label.set_use_markup(True) + label.set_alignment(0.0, 0.5) + vbox.pack_start(label) + # Data + sg = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) + for d in data: + hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0) + vbox.pack_start(hbox) + label = Gtk.Label(d[0]) + label.set_alignment(0.0, 0.5) + hbox.pack_start(label, False, False, 4) + sg.add_widget(label) + label = Gtk.Label(d[1]) + label.set_alignment(0.0, 0.5) + hbox.pack_start(label) + win.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) + win.connect('button-press-event', self.callback) + win.show_all() + def callback(self, window, event): + window.destroy() diff --git a/yms/lookup.py b/yms/lookup.py index 7da7a3e..4129a3e 100644 --- a/yms/lookup.py +++ b/yms/lookup.py @@ -1,14 +1,21 @@ # SPDX-License-Identifier: WTFPL -""" -Dropdowns and database enums +from enum import IntEnum - dropdowns can change +""" +Dropdowns, Database enums and Table numbers + + dropdowns contents can change enums are static + TBD + - language + - dateformat + - dimensions (measurement) + """ -class Dropdown: +class Dropdown(IntEnum): HULL_TYPE = 1 COMPANY_TYPE = 2 STORAGE_TYPE = 3 @@ -25,54 +32,73 @@ class Dropdown: BBN_VESSELDATA = 14 MEASUREMENT_CATEGORY = 15 - Dependencies = { - HULL_TYPE: ( - # unused - ), - COMPANY_TYPE: ( - ('company', 'comptype'), - ('company', 'comptype2') - ), - STORAGE_TYPE: ( - ('storage', 'stype'), - ), - EQUIPMENT_CATEGORY: ( - ('equipment', 'ecat'), - ), - PROVISION_CATEGORY: ( - ('provisions', 'provcat'), - ), - PROVISION_UNIT: ( - ('provisions', 'unit'), - ), - FUSE_TYPE: ( - ('fuse', 'ftype'), - ), - UNIT: ( - ('measurement', 'unit'), - ), - BOX_TYPE: ( - ('box', 'boxtype'), - ), - FUSE_BLOCK: ( - ('fuse', 'location'), - ), - CABLE_TYPE: ( - ('cable', 'cabletype'), - ), - CABLE_TECHNAME: ( - ('cable', 'techname'), - ), - INVENTORY_CATEGORY: ( - ('inventory', 'invcat'), - ), - BBN_VESSELDATA: ( - #unused - ), - MEASUREMENT_CATEGORY: ( - ('measurement', 'mcat'), - ) - } +DropdownDeps = { + Dropdown.HULL_TYPE: ( + # unused + ), + Dropdown.COMPANY_TYPE: ( + ('company', 'comptype'), + ('company', 'comptype2') + ), + Dropdown.STORAGE_TYPE: ( + ('storage', 'stype'), + ), + Dropdown.EQUIPMENT_CATEGORY: ( + ('equipment', 'ecat'), + ), + Dropdown.PROVISION_CATEGORY: ( + ('provisions', 'provcat'), + ), + Dropdown.PROVISION_UNIT: ( + ('provisions', 'unit'), + ), + Dropdown.FUSE_TYPE: ( + ('fuse', 'ftype'), + ), + Dropdown.UNIT: ( + ('measurement', 'unit'), + ), + Dropdown.BOX_TYPE: ( + ('box', 'boxtype'), + ), + Dropdown.FUSE_BLOCK: ( + ('fuse', 'location'), + ), + Dropdown.CABLE_TYPE: ( + ('cable', 'cabletype'), + ), + Dropdown.CABLE_TECHNAME: ( + ('cable', 'techname'), + ), + Dropdown.INVENTORY_CATEGORY: ( + ('inventory', 'invcat'), + ), + Dropdown.BBN_VESSELDATA: ( + #unused + ), + Dropdown.MEASUREMENT_CATEGORY: ( + ('measurement', 'mcat'), + ) +} + +class Table(IntEnum): + VESSEL = (1, "base") + USERS = (2, "base") + COMPANIES = (3, "companies") + STORAGE = (4, "storage") + BOXES = (5, "boxes") + EQUIPMENT = (6, "equipment") + #INVENTORY = (7, "inventory") + PROJECTS = (8, "projects") + CABLES = (9, "cables") + FUSES = (10, "fuses") + TAGS = (11, "tags") + + def __new__(cls, value, module): + obj = int.__new__(cls, value) + obj._value_ = value + obj.module = module + return obj class Lookup: @@ -80,6 +106,7 @@ class Lookup: self.db = db self._enums = {} self._dropdowns = {} + self._revision_ts = {} # tracking list revisions def load(self): self._load_enums() @@ -87,7 +114,7 @@ class Lookup: def _load_enums(self): """ - TODO translation via gettext needed + translation via gettext from db schema """ db_enums = { 'cable.cablecond': ('cable', 'cablecond'), @@ -98,8 +125,11 @@ class Lookup: 'document.doctype': ('document', 'doctype'), 'document.roleaccess': ('document', 'roleaccess'), 'dropdown.flags': ('dropdown', 'flags'), + 'equipment.econd': ('equipment', 'econd'), + 'equipment.flags': ('equipment', 'flags'), 'inventory.conttype': ('inventory', 'conttype'), 'inventory.invcond': ('inventory', 'invcond'), + 'inventory.flags': ('inventory', 'flags'), 'maintenance.maintstate': ('maintenance', 'maintstate'), 'measurement.accuracy': ('measurement', 'accuracy'), 'note.notetype': ('note', 'notetype'), @@ -138,12 +168,27 @@ class Lookup: self._dropdowns[ddid] = {} self._dropdowns[ddid][ddval] = ddtext + def reload_dropdown(self, ddid): + self._dropdowns[ddid] = {} + sql = ( + "SELECT ddval, ddtext " + "FROM dropdown " + "WHERE ddid=%s " + "ORDER BY sort, ddval" + ) + self.db.cur.execute(sql) + for ddval, ddtext in self.db.cur.fetchall(): + self._dropdowns[ddid][ddval] = ddtext + def enum(self, name): return self._enums[name] def dropdown(self, ddid): return self._dropdowns[ddid] + def iter_dropdowns(self): + yield from self._dropdowns.keys() + def user(self): self.db.cur.execute("SELECT userid, displayname FROM user ORDER BY displayname") return dict(self.db.cur.fetchall()) @@ -181,6 +226,19 @@ class Lookup: storagelist[row[0]] = "{} ({}) - {}".format(row[1], row[2], row[3]) return storagelist + def box(self, vid): + boxlist = {} + sql = ( + "SELECT b.boxid, b.label, b.content " + "FROM box AS b LEFT JOIN storage AS s USING (sid) " + "WHERE s.vid=%s OR s.vid IS NULL " + "ORDER BY b.label" + ) + self.db.cur.execute(sql, (vid,)) + for row in self.db.cur.fetchall(): + boxlist[row[0]] = "{} - {}".format(row[1], row[2]) + return boxlist + def equipment(self, vid): sql = ( "SELECT eid, ename " @@ -221,6 +279,16 @@ class Lookup: self.db.cur.execute(sql, (vid,)) return dict(self.db.cur.fetchall()) + def project(self, vid): + sql = ( + "SELECT projid, projname " + "FROM project " + "WHERE vid=%s " + "ORDER BY projname" + ) + self.db.cur.execute(sql, (vid,)) + return dict(self.db.cur.fetchall()) + def refresh(self): # TODO ugly hack please improve self._load_dropdowns() diff --git a/yms/model/box.py b/yms/model/box.py index 2c3cf7c..5bff792 100644 --- a/yms/model/box.py +++ b/yms/model/box.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: WTFPL from .dbrecord import DbRecord +from yms.lookup import Table class Box(DbRecord): @@ -12,3 +13,8 @@ class Box(DbRecord): def __init__(self, db, boxid=None): super().__init__(db, boxid) self.title = _("Box({})") + + def save(self, commit=True): + super().save(Table.BOXES) + if commit: + self.conn.commit() diff --git a/yms/model/cable.py b/yms/model/cable.py index 705cf41..e4522ba 100644 --- a/yms/model/cable.py +++ b/yms/model/cable.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: WTFPL from .dbrecord import DbRecord +from yms.lookup import Table class Cable(DbRecord): @@ -13,3 +14,8 @@ class Cable(DbRecord): def __init__(self, db, cableid=None): super().__init__(db, cableid) self.title = _("Cable({})") + + def save(self, commit=True): + super().save(Table.CABLES) + if commit: + self.conn.commit() diff --git a/yms/model/company.py b/yms/model/company.py index f302ee9..a8a9870 100644 --- a/yms/model/company.py +++ b/yms/model/company.py @@ -1,6 +1,13 @@ # SPDX-License-Identifier: WTFPL from .dbrecord import DbRecord +from yms.lookup import Table + +# names for fixed dropdown values +SUPPLIER = 1 +MANUFACTURER = 2 +SHIPYARD = 3 +MISC = 9 class Company(DbRecord): @@ -13,3 +20,8 @@ class Company(DbRecord): def __init__(self, db, compid=None): super().__init__(db, compid) self.title = _("Company({})") + + def save(self, commit=True): + super().save(Table.COMPANIES) + if commit: + self.conn.commit() diff --git a/yms/model/dbrecord.py b/yms/model/dbrecord.py index 03e5adc..d967c14 100644 --- a/yms/model/dbrecord.py +++ b/yms/model/dbrecord.py @@ -62,12 +62,21 @@ class DbRecord: self.clear() return False - def save(self): + def save(self, rev_id=None): self.last_update = datetime.now() if self.pk_value is not None: - return self._update() + ret = self._update() else: - return self._insert() + ret = self._insert() + if ret == True and rev_id is not None: + # set list change marker + sql = ( + "INSERT INTO revision (revtype, revid, changed) " + "VALUES ('table', %s, NOW()) " + "ON DUPLICATE KEY UPDATE changed = NOW()" + ) + self.cur.execute(sql, (rev_id,)) + return ret def _update(self): sqlfield = [] diff --git a/yms/model/equipment.py b/yms/model/equipment.py index b7b4ace..f67858a 100644 --- a/yms/model/equipment.py +++ b/yms/model/equipment.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: WTFPL from .dbrecord import DbRecord +from yms.lookup import Table class Equipment(DbRecord): @@ -8,8 +9,13 @@ class Equipment(DbRecord): pk_field = "eid" fields = ('eid', 'vid', 'ename', 'shortname', 'model', 'ecat', 'serial', 'supplier', 'manufacturer', 'purchdate', 'price', 'weight', 'remarks', - 'flags') + 'econd', 'flags') def __init__(self, db, eid=None): super().__init__(db, eid) self.title = _("Equipment({})") + + def save(self, commit=True): + super().save(Table.EQUIPMENT) + if commit: + self.conn.commit() diff --git a/yms/model/fuse.py b/yms/model/fuse.py index 493108d..d03bf36 100644 --- a/yms/model/fuse.py +++ b/yms/model/fuse.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: WTFPL from .dbrecord import DbRecord +from yms.lookup import Table class Fuse(DbRecord): @@ -12,3 +13,8 @@ class Fuse(DbRecord): def __init__(self, db, fuseid=None): super().__init__(db, fuseid) self.title = _("Fuse({})") + + def save(self, commit=True): + super().save(Table.FUSES) + if commit: + self.conn.commit() diff --git a/yms/model/project.py b/yms/model/project.py index 9ff470b..33d6c4c 100644 --- a/yms/model/project.py +++ b/yms/model/project.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: WTFPL from .dbrecord import DbRecord +from yms.lookup import Table class Project(DbRecord): @@ -12,3 +13,8 @@ class Project(DbRecord): def __init__(self, db, projid=None): super().__init__(db, projid) self.title = _("Project({})") + + def save(self, commit=True): + super().save(Table.PROJECTS) + if commit: + self.conn.commit() diff --git a/yms/model/storage.py b/yms/model/storage.py index d256fd8..c8d71a1 100644 --- a/yms/model/storage.py +++ b/yms/model/storage.py @@ -1,6 +1,12 @@ # SPDX-License-Identifier: WTFPL from .dbrecord import DbRecord +from yms.lookup import Table + +# names for fixed dropdown values +GENERIC = 0 +TANK = 1 +EXT = 2 class Storage(DbRecord): @@ -14,10 +20,10 @@ class Storage(DbRecord): self.title = _("Storage({})") def save(self, commit=True): - super().save() + super().save(Table.STORAGE) if commit: self.conn.commit() def delete(self): - # there must be no assiciated data! + # there must be no associated data! pass diff --git a/yms/model/user.py b/yms/model/user.py index dc85788..af7880e 100644 --- a/yms/model/user.py +++ b/yms/model/user.py @@ -104,6 +104,13 @@ class User(object): # create mandatory settings sql = "INSERT INTO settings (userid, sno, valint) VALUES (%s, 1, 0)" self.cur.execute(sql, (newid,)) + # set list change marker + sql = ( + "INSERT INTO revision (revtype, revid, changed) " + "VALUES ('table', 2, NOW()) " + "ON DUPLICATE KEY UPDATE changed = NOW()" + ) + self.db.cur.execute() self.conn.commit() return newid @@ -112,6 +119,13 @@ class User(object): self.cur.execute(sql, (self.user_id,)) sql = "DELETE FROM user WHERE userid=%s" self.cur.execute(sql, (self.user_id,)) + # set list change marker + sql = ( + "INSERT INTO revision (revtype, revid, changed) " + "VALUES ('table', 2, NOW()) " + "ON DUPLICATE KEY UPDATE changed = NOW()" + ) + self.db.cur.execute() self.conn.commit() def setpass(self, newpass): diff --git a/yms/model/vessel.py b/yms/model/vessel.py index 5a650fc..85a1344 100644 --- a/yms/model/vessel.py +++ b/yms/model/vessel.py @@ -6,8 +6,8 @@ class Vessel(DbRecord): table = "vessel" pk_field = "vid" - fields = ('vid', 'vtype', 'vesselname', 'model', 'shipyard', 'loa', 'lwl', - 'beam', 'draught', 'draught_min', 'displacement', 'ballast', + fields = ('vid', 'vtype', 'htype', 'vesselname', 'model', 'shipyard', 'hull_number', + 'loa', 'lwl', 'beam', 'draught', 'draught_min', 'displacement', 'ballast', 'beltpos_aft', 'beltpos_bow', 'shapefile', 'sid_default', 'year_built', 'remarks') @@ -32,8 +32,15 @@ class Vessel(DbRecord): self.clear() self.vid = self.pk_value self.vesselname = f"Vessel #{self.pk_value}" - self.vtype = 1 # monohull + self.htype = 'mono' self._insert() + # set list change marker + sql = ( + "INSERT INTO revision (revtype, revid, changed) " + "VALUES ('table', 1, NOW()) " + "ON DUPLICATE KEY UPDATE changed = NOW()" + ) + self.db.cur.execute() self.conn.commit() def save(self, commit=True): @@ -44,3 +51,10 @@ class Vessel(DbRecord): def delete(self): # there must be no assiciated data! pass + # set list change marker + sql = ( + "INSERT INTO revision (revtype, revid, changed) " + "VALUES ('table', 1, NOW()) " + "ON DUPLICATE KEY UPDATE changed = NOW()" + ) + self.db.cur.execute() diff --git a/yms/ui/base.ui b/yms/ui/base.ui index 68736e7..c71ecb4 100644 --- a/yms/ui/base.ui +++ b/yms/ui/base.ui @@ -17,7 +17,7 @@ 1 10 - + 100 1 10 @@ -74,34 +74,11 @@ True False vertical - - - True - False - Ghost - - - False - True - 0 - - True False - - - True - False - Name - - - 0 - 1 - - True @@ -110,7 +87,7 @@ 0 - 2 + 1 @@ -121,7 +98,7 @@ 0 - 3 + 2 @@ -132,7 +109,7 @@ 0 - 4 + 3 @@ -143,7 +120,7 @@ 0 - 8 + 7 @@ -154,7 +131,7 @@ 0 - 7 + 6 @@ -165,7 +142,7 @@ 0 - 6 + 5 @@ -176,7 +153,7 @@ 0 - 5 + 4 @@ -187,19 +164,7 @@ 0 - 10 - - - - - True - False - True - True - - - 1 - 1 + 9 @@ -211,7 +176,7 @@ 1 - 2 + 1 @@ -223,7 +188,7 @@ 1 - 3 + 2 @@ -235,7 +200,7 @@ 1 - 4 + 3 @@ -247,7 +212,7 @@ 1 - 5 + 4 @@ -259,7 +224,7 @@ 1 - 6 + 5 @@ -271,7 +236,7 @@ 1 - 7 + 6 @@ -283,7 +248,7 @@ 1 - 8 + 7 @@ -295,7 +260,7 @@ 1 - 10 + 9 @@ -321,7 +286,7 @@ 0 - 15 + 14 @@ -333,7 +298,7 @@ 1 - 15 + 14 @@ -344,7 +309,7 @@ 0 - 9 + 8 @@ -356,7 +321,7 @@ 1 - 9 + 8 @@ -367,7 +332,7 @@ 0 - 11 + 10 @@ -378,7 +343,7 @@ 0 - 12 + 11 @@ -390,7 +355,7 @@ 1 - 11 + 10 @@ -402,7 +367,7 @@ 1 - 12 + 11 @@ -413,7 +378,7 @@ 0 - 13 + 12 @@ -451,7 +416,7 @@ 1 - 13 + 12 @@ -462,7 +427,7 @@ 0 - 14 + 13 @@ -474,14 +439,37 @@ 1 - 14 + 13 + + + + + True + False + Hull number + + + 0 + 15 + + + + + True + False + True + True + + + 1 + 15 True True - 1 + 0 @@ -536,7 +524,7 @@ False True - 2 + 1 @@ -552,7 +540,7 @@ vertical 4 - + True False Ghost @@ -564,7 +552,7 @@ - + True False @@ -598,6 +586,7 @@ 1 0 + 3 @@ -619,6 +608,7 @@ 1 1 + 3 @@ -629,7 +619,7 @@ 0 - 3 + 5 @@ -639,18 +629,7 @@ LWL - 0 - 4 - - - - - True - False - Beam - - - 0 + 2 5 @@ -662,7 +641,7 @@ 0 - 6 + 7 @@ -672,7 +651,7 @@ Draught, min - 0 + 2 7 @@ -685,7 +664,7 @@ 1 - 3 + 5 @@ -696,19 +675,7 @@ 2 - 1 - 4 - - - - - True - True - adj_beam - 2 - - - 1 + 3 5 @@ -721,7 +688,7 @@ 1 - 6 + 7 @@ -732,7 +699,7 @@ 2 - 1 + 3 7 @@ -754,8 +721,8 @@ Ballast - 0 - 9 + 2 + 8 @@ -776,8 +743,8 @@ adj_ballast - 1 - 9 + 3 + 8 @@ -785,10 +752,11 @@ True False Remarks + 0 0 - 15 + 13 @@ -798,7 +766,8 @@ 1 - 14 + 12 + 3 @@ -809,7 +778,7 @@ 0 - 14 + 12 @@ -836,7 +805,8 @@ 1 - 15 + 13 + 3 @@ -847,7 +817,7 @@ 0 - 2 + 3 @@ -859,7 +829,7 @@ 1 - 2 + 3 @@ -870,7 +840,7 @@ 0 - 13 + 4 @@ -880,7 +850,8 @@ 1 - 13 + 4 + 3 @@ -891,7 +862,7 @@ 0 - 12 + 11 @@ -901,21 +872,22 @@ 1 - 12 + 11 + 3 - + True True 0 number - adj_belt_front + adj_belt_bow 2 1 - 10 + 9 @@ -928,8 +900,8 @@ 2 - 1 - 11 + 3 + 9 @@ -940,7 +912,7 @@ 0 - 10 + 9 @@ -950,10 +922,105 @@ Belt position, aft - 0 - 11 + 2 + 9 + + + True + False + Hull number + + + 2 + 3 + + + + + True + True + + + 3 + 3 + + + + + True + False + Hull type + + + 0 + 10 + + + + + True + False + + + 1 + 10 + 3 + + + + + True + False + Beam + + + 0 + 6 + + + + + True + True + 0,00 + adj_beam + 2 + + + 1 + 6 + + + + + True + False + Vessel type + + + 0 + 2 + + + + + True + False + + + 1 + 2 + 3 + + + + + + + + True @@ -1099,13 +1166,13 @@ - + True False vertical - + True False diff --git a/yms/ui/boxes.ui b/yms/ui/boxes.ui index 4246c89..e305a86 100644 --- a/yms/ui/boxes.ui +++ b/yms/ui/boxes.ui @@ -237,7 +237,7 @@ False vertical - + True False Box Details @@ -252,7 +252,7 @@ - + True False @@ -287,7 +287,7 @@ 0 - 7 + 8 @@ -300,7 +300,7 @@ 1 - 7 + 8 @@ -311,7 +311,7 @@ 0 - 1 + 2 @@ -322,7 +322,7 @@ 1 - 1 + 2 @@ -333,7 +333,7 @@ 0 - 2 + 3 @@ -344,7 +344,7 @@ 0 - 3 + 4 @@ -355,7 +355,7 @@ 0 - 4 + 5 @@ -366,7 +366,7 @@ 1 - 2 + 3 @@ -377,7 +377,7 @@ 1 - 3 + 4 @@ -388,7 +388,7 @@ 1 - 4 + 5 @@ -399,7 +399,7 @@ 0 - 5 + 6 @@ -410,7 +410,7 @@ 1 - 5 + 6 @@ -421,7 +421,7 @@ 0 - 6 + 7 @@ -432,7 +432,29 @@ 1 - 6 + 7 + + + + + True + False + Storage + + + 0 + 1 + + + + + True + False + True + + + 1 + 1 @@ -526,7 +548,7 @@ - + True False @@ -537,6 +559,9 @@ True False Label + + + 0 @@ -551,7 +576,7 @@ 0 - 1 + 2 @@ -572,7 +597,7 @@ 1 - 1 + 2 6 @@ -584,7 +609,7 @@ 0 - 3 + 4 @@ -597,7 +622,7 @@ 2 - 3 + 4 @@ -610,7 +635,7 @@ 4 - 3 + 4 @@ -625,7 +650,7 @@ 1 - 3 + 4 @@ -640,7 +665,7 @@ 3 - 3 + 4 @@ -655,7 +680,7 @@ 5 - 3 + 4 @@ -666,7 +691,7 @@ 0 - 5 + 6 @@ -677,7 +702,7 @@ 0 - 6 + 7 @@ -685,10 +710,11 @@ True False Remarks + 0 0 - 8 + 9 @@ -705,7 +731,7 @@ 1 - 8 + 9 6 @@ -717,7 +743,7 @@ 0 - 7 + 8 @@ -730,7 +756,7 @@ 6 - 3 + 4 @@ -741,7 +767,7 @@ 0 - 2 + 3 @@ -751,7 +777,7 @@ 1 - 2 + 3 6 @@ -764,7 +790,7 @@ 1 - 7 + 8 3 @@ -777,7 +803,7 @@ 1 - 6 + 7 3 @@ -790,7 +816,7 @@ 1 - 5 + 6 3 @@ -802,24 +828,63 @@ 0 - 4 + 5 - - #FFFFFF + True True - True - half - + + 1 - 4 - 3 + 5 + + + 64 + True + True + True + True + + + + 2 + 5 + + + + + True + False + Storage + + + + + + 0 + 1 + + + + + True + False + + + 1 + 1 + 6 + + + + + diff --git a/yms/ui/cables.ui b/yms/ui/cables.ui index 5d75925..79472ab 100644 --- a/yms/ui/cables.ui +++ b/yms/ui/cables.ui @@ -666,6 +666,7 @@ Name + @@ -691,6 +692,7 @@ Type + @@ -716,6 +718,7 @@ Length + @@ -730,6 +733,7 @@ Conductors + @@ -755,6 +759,7 @@ Cross section + @@ -906,16 +911,6 @@ 7 - - - True - True - - - 1 - 8 - - True @@ -963,6 +958,42 @@ 12 + + + True + False + 4 + + + True + True + + + True + True + 0 + + + + + 64 + True + True + True + True + + + False + True + 1 + + + + + 1 + 8 + + True diff --git a/yms/ui/companies.ui b/yms/ui/companies.ui index 5d78e95..d97540b 100644 --- a/yms/ui/companies.ui +++ b/yms/ui/companies.ui @@ -421,6 +421,7 @@ True False Remarks + 0 0 @@ -540,9 +541,17 @@ - + True True + True + in + + + True + True + + 1 @@ -626,7 +635,7 @@ - + True False diff --git a/yms/ui/documents.ui b/yms/ui/documents.ui index 8ff0d6c..fa6dd16 100644 --- a/yms/ui/documents.ui +++ b/yms/ui/documents.ui @@ -2,6 +2,159 @@ + + False + dialog + + + False + vertical + 2 + + + False + end + + + + + + Close + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + + + + + + False + dialog + + + False + vertical + 2 + + + False + end + + + Preview + True + True + True + + + True + True + 0 + + + + + Scan + True + True + True + + + True + True + 1 + + + + + Close + True + True + True + + + True + True + 2 + + + + + False + False + 0 + + + + + True + False + + + True + False + + + True + True + 0 + + + + + True + False + vertical + + + True + True + + + False + True + 0 + + + + + + + + + + + False + True + 1 + + + + + True + True + 1 + + + + + True False @@ -226,7 +379,7 @@ False vertical - + True False Document Details @@ -561,7 +714,7 @@ - + True False @@ -609,7 +762,7 @@ 0 - 3 + 4 @@ -638,7 +791,7 @@ 1 - 3 + 4 @@ -646,6 +799,9 @@ True False Document type + + + 0 @@ -662,6 +818,30 @@ 0 + + + True + False + Access level + + + + + + 0 + 3 + + + + + True + False + + + 1 + 3 + + True @@ -669,10 +849,22 @@ 1 + + + True + False + + + True + True + 2 + + True False + 2 end @@ -685,7 +877,7 @@ True True - 1 + 0 @@ -696,17 +888,47 @@ True + + True + True + 1 + + + + + Upload + True + True + True + + True True 2 + True + + + + + Scan + True + True + True + + + + True + True + 3 + True False True - 2 + 3 diff --git a/yms/ui/equipment.ui b/yms/ui/equipment.ui index 2748836..ebe29b5 100644 --- a/yms/ui/equipment.ui +++ b/yms/ui/equipment.ui @@ -334,7 +334,7 @@ - + True False @@ -457,7 +457,7 @@ 0 - 11 + 12 @@ -545,7 +545,7 @@ - + True False True @@ -591,7 +591,7 @@ 1 - 11 + 12 @@ -617,6 +617,29 @@ 10 + + + True + False + Condition + + + 0 + 11 + + + + + True + False + True + True + + + 1 + 11 + + True @@ -672,6 +695,21 @@ 2 + + + Convert + True + True + True + + + + True + True + 3 + True + + False @@ -692,7 +730,7 @@ False vertical - + True False Edit Equipment @@ -707,7 +745,7 @@ - + True False @@ -716,6 +754,9 @@ True False Name + + + 0 @@ -820,7 +861,7 @@ - + True False @@ -886,14 +927,15 @@ True False Remarks + 0 0 - 10 + 11 - + True False @@ -903,7 +945,7 @@ - + True False @@ -913,17 +955,7 @@ - - True - True - - - 1 - 10 - - - - + True True adj_weight @@ -935,7 +967,7 @@ - + True True adj_price @@ -946,6 +978,46 @@ 6 + + + True + True + True + True + in + + + True + True + + + + + 1 + 11 + + + + + True + False + Condition + + + 0 + 10 + + + + + True + False + + + 1 + 10 + + False diff --git a/yms/ui/fuses.ui b/yms/ui/fuses.ui index fc0bf05..9656e6b 100644 --- a/yms/ui/fuses.ui +++ b/yms/ui/fuses.ui @@ -252,7 +252,7 @@ - + True False 4 @@ -637,6 +637,7 @@ True False Remarks + 0 0 diff --git a/yms/ui/inventory.ui b/yms/ui/inventory.ui index 82cf922..e8c9a21 100644 --- a/yms/ui/inventory.ui +++ b/yms/ui/inventory.ui @@ -257,7 +257,7 @@ - + True False @@ -380,7 +380,7 @@ 0 - 11 + 12 @@ -514,7 +514,7 @@ 1 - 11 + 12 @@ -540,6 +540,29 @@ 10 + + + True + False + Flags + + + 0 + 11 + + + + + True + False + True + True + + + 1 + 11 + + True @@ -595,6 +618,21 @@ 2 + + + Convert + True + True + True + + + + True + True + 3 + True + + False @@ -631,7 +669,7 @@ - + True False @@ -655,7 +693,7 @@ True False - Type + Container @@ -761,10 +799,11 @@ True False Remarks + 0 0 - 11 + 12 @@ -779,17 +818,7 @@ - - True - True - - - 1 - 11 - - - - + True False @@ -799,7 +828,7 @@ - + True False @@ -839,7 +868,7 @@ - + True True @@ -904,6 +933,86 @@ 10 + + + True + False + Flags + + + 0 + 11 + + + + + True + True + in + + + True + True + + + + + 1 + 12 + + + + + True + False + + + ordered + True + True + False + True + + + False + True + 0 + + + + + removed + True + True + False + True + + + False + True + 1 + + + + + deleted + True + True + False + True + + + False + True + 2 + + + + + 1 + 11 + + False diff --git a/yms/ui/main.ui b/yms/ui/main.ui index 3ea4f32..d4c0fdc 100644 --- a/yms/ui/main.ui +++ b/yms/ui/main.ui @@ -4,7 +4,7 @@ False - YMS + YMS center 800 600 diff --git a/yms/ui/maintenance.ui b/yms/ui/maintenance.ui index b84196a..2efb356 100644 --- a/yms/ui/maintenance.ui +++ b/yms/ui/maintenance.ui @@ -2,6 +2,21 @@ + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + True False @@ -666,6 +681,7 @@ True True True + adj_series 1 @@ -677,6 +693,7 @@ True True True + adj_interval 1 @@ -688,6 +705,7 @@ True True True + adj_last 1 diff --git a/yms/ui/measurement.ui b/yms/ui/measurement.ui index d311e52..0efd067 100644 --- a/yms/ui/measurement.ui +++ b/yms/ui/measurement.ui @@ -236,7 +236,7 @@ - + True False @@ -361,7 +361,7 @@ 0 - 9 + 10 @@ -447,7 +447,7 @@ 1 - 9 + 10 @@ -458,7 +458,7 @@ 0 - 8 + 9 @@ -468,6 +468,29 @@ True True + + 1 + 9 + + + + + True + False + Date + + + 0 + 8 + + + + + True + False + True + True + 1 8 @@ -566,7 +589,7 @@ - + True False @@ -652,7 +675,7 @@ 0 - 6 + 7 @@ -663,7 +686,7 @@ 0 - 7 + 8 @@ -671,10 +694,11 @@ True False Note + 0 0 - 8 + 10 @@ -743,7 +767,7 @@ 1 - 6 + 7 @@ -754,7 +778,7 @@ 1 - 7 + 8 @@ -773,7 +797,7 @@ 1 - 8 + 10 @@ -786,6 +810,49 @@ 5 + + + True + False + Category + + + 0 + 9 + + + + + True + False + True + + + 1 + 9 + + + + + True + False + Unit + + + 0 + 6 + + + + + True + False + + + 1 + 6 + + True diff --git a/yms/ui/provisions.ui b/yms/ui/provisions.ui index 4575ef5..40b5fef 100644 --- a/yms/ui/provisions.ui +++ b/yms/ui/provisions.ui @@ -2,6 +2,26 @@ + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + True + False + x-office-calendar-symbolic + True False @@ -227,7 +247,7 @@ - + True False @@ -409,6 +429,7 @@ True True True + adj_number 1 @@ -420,6 +441,8 @@ True True True + adj_weight + 2 1 @@ -431,23 +454,14 @@ True True True + adj_weight_net + 2 1 6 - - - True - True - True - - - 1 - 8 - - True @@ -459,6 +473,74 @@ 9 + + + True + False + Remarks + 0 + + + 0 + 10 + + + + + True + True + in + + + True + True + + + + + 1 + 10 + + + + + True + False + 2 + + + True + True + True + 12 + 10 + + + False + True + 0 + + + + + True + True + True + img_calendar + True + + + False + True + 1 + + + + + 1 + 8 + + False diff --git a/yms/ui/storage.ui b/yms/ui/storage.ui index a6920c9..8b2c8c4 100644 --- a/yms/ui/storage.ui +++ b/yms/ui/storage.ui @@ -231,7 +231,7 @@ False vertical - + True False Storage Details @@ -247,7 +247,7 @@ - + True False @@ -895,10 +895,30 @@ - + + 64 + True + True + True + True + + + + 3 + 6 + - + + True + True + + + + + 2 + 6 + diff --git a/yms/ui/tasks.ui b/yms/ui/tasks.ui index 68ac0a1..30d52cd 100644 --- a/yms/ui/tasks.ui +++ b/yms/ui/tasks.ui @@ -320,7 +320,7 @@ False vertical - + True False Task Details @@ -664,7 +664,7 @@ - + True False @@ -675,6 +675,9 @@ True False Name + + + 0 @@ -682,7 +685,7 @@ - + True True True @@ -697,10 +700,13 @@ True False Responsible + + + 0 - 6 + 8 @@ -712,7 +718,7 @@ 0 - 7 + 9 @@ -731,7 +737,7 @@ 1 - 7 + 9 @@ -741,11 +747,11 @@ 1 - 6 + 8 - + True True @@ -755,7 +761,7 @@ - + True False @@ -780,6 +786,9 @@ True False Priority + + + 0 @@ -808,16 +817,91 @@ - + + True + False + Due Date + + + 0 + 4 + - + + True + True + + + 1 + 4 + - + + True + False + + + 1 + 7 + - + + True + False + Status + + + + + + 0 + 7 + + + + + True + False + Started + + + 0 + 5 + + + + + True + False + Finished + + + 0 + 6 + + + + + True + True + + + 1 + 5 + + + + + True + True + + + 1 + 6 + diff --git a/yms/view/base.py b/yms/view/base.py index ebea177..4d329d6 100644 --- a/yms/view/base.py +++ b/yms/view/base.py @@ -12,6 +12,8 @@ from gi.repository import GLib, Gtk, Gdk, Rsvg from datetime import datetime import subprocess import locale +import xml.etree.ElementTree as ET +import json from .view import View from yms import gtkutils, combobox, treeview @@ -76,19 +78,29 @@ class BaseView(View): self.context.vessel.vesselname = "Ghost" # default storage for current vessel - sql = "SELECT sid, sname FROM storage WHERE stype=0 AND vid=%s ORDER BY sname" - self.db.cur.execute(sql, (self.context.vessel.vid,)) - storages = dict(self.db.cur.fetchall()) + #sql = "SELECT sid, sname FROM storage WHERE stype=0 AND vid=%s ORDER BY sname" + #self.db.cur.execute(sql, (self.context.vessel.vid,)) + #storages = dict(self.db.cur.fetchall()) + storages = self.context.lookup.storage(self.context.vessel.vid) combobox.load_from_dict(self.combo['storage'], {-1: _("─── none ───")} | storages) + # Hull types + self.dd_htype = self.context.lookup.enum('vessel.htype') + combobox.load_from_dict(self.combo['htype'], self.dd_htype) + + # List of available shapes for combobox selection + shapes = self.load_shapes() + combobox.load_from_dict(self.combo['hull_shape'], {"-1": _("─── none ───")} | shapes) + # get list of vessels - vessellist = {} - self.db.dcur.execute("SELECT vid, vesselname, model FROM vessel ORDER BY vid") - for row in self.db.dcur.fetchall(): - vessellist[row['vid']] = ( - row['vesselname'] if row['model'] is None - else row['vesselname'] + " - " + row['model'] - ) + #vessellist = {} + #self.db.dcur.execute("SELECT vid, vesselname, model FROM vessel ORDER BY vid") + #for row in self.db.dcur.fetchall(): + # vessellist[row['vid']] = ( + # row['vesselname'] if row['model'] is None + # else row['vesselname'] + " - " + row['model'] + # ) + vessellist = self.context.lookup.vessel() combobox.load_from_dict(self.combo['vessel'], vessellist, self.context.vessel.vid) # vessel load triggered from combobox init @@ -138,6 +150,7 @@ class BaseView(View): #viewport.height = 240 #self._svg.render_document(ctx, viewport) + # WIP generic remarks handling self.text['vessel_remarks'].set_size_request(200, 70) @@ -149,6 +162,36 @@ class BaseView(View): storages = dict(self.db.cur.fetchall()) combobox.refresh_dict(self.combo['storage'], {-1: _("─── none ───")} | storages) + def load_shapes(self): + # TODO / WIP process shapeindex + # returns dict of filename: title + indexfile = os.path.join(self.context.cfg['docpath'], "shapeindex.json") + if os.path.isfile(indexfile): + # load json + with open(indexfile, "r", encoding="utf-8") as fh: + sflist = json.load(fh) + print("Shapefile found and loaded") + else: + # create shapeindex (first simple version) + sflist = {} + for fname in os.listdir(self.context.cfg['shapedir']): + if fname.lower().endswith(".svg"): + shapefile = os.path.join(self.context.cfg['shapedir'], fname) + try: + root = ET.parse(shapefile).getroot() + title_element = root.find("{http://www.w3.org/2000/svg}title") + if title_element is not None and title_element.text: + title = title_element.text.strip() + else: + title = os.path.splitext(fname)[0] + except ET.ParseError: + title = os.path.splitext(fname)[0] + sflist[fname] = title + with open(indexfile, "w", encoding="utf-8") as fh: + json.dump(sflist, fh, ensure_ascii=False, indent=4) + print("Created new shapeindex file") + return sflist + def find_usb_sticks(self): result = [] for name in os.listdir("/sys/block"): @@ -304,7 +347,6 @@ class BaseView(View): self.stack['vessel'].set_visible_child(self.box['vessel_edit']) def on_but_vessel_save_clicked(self, widget): - print("Save vessel") vessel = self.context.vessel vessel.vesselname = self.entry['vesselname'].get_text() vessel.model = self.entry['model'].get_text() @@ -316,6 +358,9 @@ class BaseView(View): vessel.draught_min = self.spin['draught_min'].get_value() vessel.displacement = self.spin['displacement'].get_value_as_int() vessel.ballast = self.spin['ballast'].get_value_as_int() + vessel.beltpos_bow = self.spin['belt_bow'].get_value() + vessel.beltpos_aft = self.spin['belt_aft'].get_value() + vessel.shapefile = combobox.get_list_value(self.combo['hull_shape']) vessel.remarks = gtkutils.get_text_contents(self.text['vessel_remarks']) vessel.save() self.stack['vessel'].set_visible_child(self.box['vessel']) @@ -337,6 +382,7 @@ class BaseView(View): self.label['model'].set_text(vessel.model or '') self.label['shipyard'].set_text(str(vessel.shipyard)) self.label['year_built'].set_text(self.format_int(vessel.year_built, False, default='n/a')) + self.label['hull_number'].set_text(vessel.hull_number or '') self.label['loa'].set_text(self.format_float(vessel.loa, 2, suffix="m")) self.label['lwl'].set_text(self.format_float(vessel.lwl, 2, suffix="m")) self.label['beam'].set_text(self.format_float(vessel.beam, 2, suffix="m")) @@ -361,9 +407,13 @@ class BaseView(View): self.spin['draught_min'].set_value(vessel.draught_min or 0) self.spin['displacement'].set_value(vessel.displacement or 0) self.spin['ballast'].set_value(vessel.ballast or 0) - self.text['vessel_remarks'].get_buffer().set_text(vessel.remarks or '') + self.spin['belt_bow'].set_value(vessel.beltpos_bow or 0) + self.spin['belt_aft'].set_value(vessel.beltpos_aft or 0) combobox.activate_row(self.combo['shipyard'], vessel.shipyard or -1) + self.entry['hull_number'].set_text(vessel.hull_number or '') + combobox.activate_row(self.combo['hull_shape'], vessel.shapefile or "-1") combobox.activate_row(self.combo['storage'], vessel.sid_default or -1) + self.text['vessel_remarks'].get_buffer().set_text(vessel.remarks or '') def display_user(self, user): self.entry['user_login'].set_text(user.login) diff --git a/yms/view/boxes.py b/yms/view/boxes.py index 52e2d15..de70a2c 100644 --- a/yms/view/boxes.py +++ b/yms/view/boxes.py @@ -19,15 +19,7 @@ class BoxesView(View): self.newrecord = False self.lst_box = Gtk.ListStore(int, str, str, str) - sql = ( - "SELECT b.boxid, b.label, b.content, b.remarks " - "FROM box AS b JOIN storage AS s USING (sid) " - "WHERE s.vid=%s " - "ORDER BY b.label" - ) - self.db.cur.execute(sql, (context.vessel.vid,)) - for row in self.db.cur.fetchall(): - self.lst_box.append(row) + self.load_list() treeview.add_column(self.tree['box'], _('ID'), 0) treeview.add_column(self.tree['box'], _('Label'), 1) @@ -35,25 +27,53 @@ class BoxesView(View): treeview.add_column(self.tree['box'], _('Remarks'), 3) self.tree['box'].set_model(self.lst_box) + self.dd_storage = self.context.lookup.storage(context.vessel.vid) + combobox.load_from_dict(self.combo['storage'], {-1: _("─── none ───")} | self.dd_storage) self.dd_boxtype = self.context.lookup.dropdown(Dropdown.BOX_TYPE) - combobox.load_from_dict(self.combo['type'], self.dd_boxtype) + combobox.load_from_dict(self.combo['type'], {-1: _("─── none ───")} | self.dd_boxtype) def load_list(self): - pass + selected_id = treeview.get_value(self.tree['box']) + self.lst_box.clear() + sql = ( + "SELECT b.boxid, b.label, b.content, b.remarks " + "FROM box AS b JOIN storage AS s USING (sid) " + "WHERE s.vid=%s " + "ORDER BY b.label" + ) + self.db.cur.execute(sql, (self.context.vessel.vid,)) + selection = self.tree['box'].get_selection() + for row in self.db.cur.fetchall(): + treeiter = self.lst_box.append(row) + if row[0] == selected_id: + # restore previous selected row + selection.select_iter(treeiter) def clear_record(self): self.entry['label'].set_text('') + combobox.activate_row(self.combo['storage'], 0) + combobox.activate_row(self.combo['type'], -1) self.entry['content'].set_text('') self.spin['wx'].set_value(0) self.spin['wy'].set_value(0) self.spin['wz'].set_value(0) + self.entry['color'].set_text('#000000') + rgba = Gdk.RGBA() + rgba.parse('#000000') + self.button['color'].set_rgba(rgba) + self.spin['price'].set_value(0) + self.spin['weight'].set_value(0) + self.spin['weight_net'].set_value(0) self.text['remarks'].get_buffer().set_text('') def display_record(self): self.label['label'].set_text(self.sbox.label) # storage sid self.label['content'].set_text(self.sbox.content or '') - self.label['type'].set_text(self.dd_boxtype[self.sbox.boxtype]) + if self.sbox.boxtype > 0: + self.label['type'].set_text(self.dd_boxtype[self.sbox.boxtype]) + else: + self.label['type'].set_text('') self.label['color'].set_text(self.sbox.color or '') if self.sbox.color: self.label['color'].set_markup(f'#{self.sbox.color} ●') @@ -66,23 +86,50 @@ class BoxesView(View): def edit_record(self): self.entry['label'].set_text(self.sbox.label) + combobox.activate_row(self.combo['storage'], self.sbox.sid) + combobox.activate_row(self.combo['type'], self.sbox.boxtype) self.entry['content'].set_text(self.sbox.content or '') self.spin['wx'].set_value(self.sbox.wx or 0) self.spin['wy'].set_value(self.sbox.wy or 0) self.spin['wz'].set_value(self.sbox.wz or 0) + self.entry['color'].set_text('#' + self.sbox.color) + rgba = Gdk.RGBA() + rgba.parse('#' + self.sbox.color) + self.button['color'].set_rgba(rgba) + self.spin['price'].set_value(self.sbox.price or 0) + self.spin['weight'].set_value(self.sbox.weight or 0) + self.spin['weight_net'].set_value(self.sbox.weight_net or 0) self.text['remarks'].get_buffer().set_text(self.sbox.remarks or '') + def save_record(self): + # fields must have been validated beforehand + self.sbox.label = self.entry['label'].get_text() + self.sbox.sid = combobox.get_list_value(self.combo['storage']) + self.sbox.boxtype = combobox.get_list_value(self.combo['type']) + self.sbox.content = self.entry['content'].get_text() + self.sbox.wx = int(self.spin['wx'].get_value()) + self.sbox.wy = int(self.spin['wy'].get_value()) + self.sbox.wz = int(self.spin['wz'].get_value()) + self.sbox.color = self.entry['color'].get_text().lstrip('#') + self.sbox.price = self.spin['price'].get_value() + self.sbox.weight = self.spin['weight'].get_value() + self.sbox.weight_net = self.spin['weight_net'].get_value() + self.sbox.remarks = gtkutils.get_text_contents(self.text['remarks']) + # buttons on list page def on_but_new_clicked(self, widget): self.newrecord = True - self.label['title_edit'].set_text("Add new Box") + self.label['title_edit'].set_text(_("Add new Box")) + self.clear_record() self.topwidget.set_visible_child(self.box['box_edit']) def on_but_edit_clicked(self, widget): self.newrecord = False - self.label['title_edit'].set_text("Edit Box") - sid = treeview.get_value(self.tree['box'], 0) - self.sbox.load(sid) + self.label['title_edit'].set_text(_("Edit Box")) + boxid = treeview.get_value(self.tree['box'], 0) + if not boxid: + return + self.sbox.load(boxid) self.edit_record() self.topwidget.set_visible_child(self.box['box_edit']) @@ -105,24 +152,48 @@ class BoxesView(View): # buttons on detail page # edit2 uses edit callback def on_but_close_clicked(self, widget): - boxid = treeview.get_value(self.tree['box'], 0) - if not boxid: - return self.topwidget.set_visible_child(self.box['box']) def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete box!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return self.topwidget.set_visible_child(self.box['box']) self.newrecord = False # buttons on edit page def on_but_save_clicked(self, widget): - print("save not implemented yet") + # check mandatory fields + if not self.entry['label'].get_text().strip(): + # TODO error marker + return + self.save_record() + print(self.sbox) + self.sbox.save() + if self.newrecord: + self.load_list() self.newrecord = False + self.display_record() + self.topwidget.set_visible_child(self.box['box_detail']) + + def on_but_color_set(self, button): + rgba = button.get_rgba() + r = round(rgba.red * 255) + g = round(rgba.green * 255) + b = round(rgba.blue * 255) + #self.last_valid_rgb = f"{r:02X}{g:02X}{b:02X}" + self.entry['color'].set_text(f"#{r:02X}{g:02X}{b:02X}") + + def on_ent_color_activate(self, entry): + self.set_color_from_entry(entry) + + def on_ent_color_focus_out_event(self, entry, event): + self.set_color_from_entry(entry) + return False def on_but_cancel_clicked(self, widget): self.topwidget.set_visible_child(self.box['box']) self.newrecord = False - - def on_but_color_clicked(self, widget): - pass - diff --git a/yms/view/cables.py b/yms/view/cables.py index 3586635..27c024e 100644 --- a/yms/view/cables.py +++ b/yms/view/cables.py @@ -40,6 +40,59 @@ class CablesView(View): self.dd_type = self.context.lookup.dropdown(Dropdown.CABLE_TYPE) self.dd_tech = self.context.lookup.dropdown(Dropdown.CABLE_TECHNAME) + def display_record(self): + self.label['name'].set_text(self.cable.cablename) + self.label['type'].set_text(self.dd_type[self.cable.cabletype]) + if self.cable.techname: + self.label['techname'].set_text(self.dd_tech[self.cable.techname]) + else: + self.label['techname'].set_text('') + self.label['length'].set_text(self.format_int(self.cable.length)) + self.label['conductors'].set_text(self.format_int(self.cable.conductors)) + self.label['diameter'].set_text(self.format_float(self.cable.diameter, 1)) + self.label['xsection'].set_text(self.format_float(self.cable.xsection, 1)) + self.label['weight'].set_text(self.format_float(self.cable.weight)) + if self.cable.color: + self.label['color'].set_markup(f'#{self.cable.color} ●') + else: + self.label['color'].set_text('') + self.label['supplier'].set_text(str(self.cable.supplier)) + self.label['manufacturer'].set_text(str(self.cable.manufacturer)) + self.label['condition'].set_text(self.cable.cablecond) + self.label['remarks'].set_text(self.cable.remarks or '') + + def edit_record(self): + # fill UI fields from database record + self.entry['name'].set_text(self.cable.cablename) + combobox.activate_row(self.combo['type'], self.cable.cabletype) + combobox.activate_row(self.combo['techname'], self.cable.techname) + self.spin['length'].set_value(self.cable.length or 0) + self.spin['consuctors'].set_value(self.cable.conductors or 0) + self.spin['diameter'].set_value(self.cable.diameter or 0) + self.spin['xsection'].set_value(self.cable.xsection or 0) + self.spin['weight'].set_value(self.cable.weight or 0) + self.entry['color'].set_text('#' + self.cable.color) + rgba = Gdk.RGBA() + rgba.parse('#' + self.cable.color) + self.button['color'].set_rgba(rgba) + combobox.activate_row(self.combo['supplier'], self.cable.supplier) + combobox.activate_row(self.combo['manufacturer'], self.cable.manufacturer) + combobox.activate_row(self.combo['consition'], self.cable.cablecond) + self.text['remarks'].get_buffer().set_text(self.sbox.remarks or '') + + def save_record(self): + # fields must have been validated beforehand + self.cable.cablename = self.entry['name'].get_text().strip() + self.cable.cabletype = combobox.get_list_value(self.combo['type']) + self.cable.length = int(self.spin['length'].get_value()) + self.cable.conductors = int(self.spin['conductors'].get_value()) + self.cable.diameter = self.spin['diameter'].get_value() + self.cable.xsection = self.spin['xsection'].get_value() + self.cable.weight = int(self.spin['weight'].get_value()) + self.cable.supplier = combobox.get_list_value(self.combo['supplier']) + self.cable.manufacturer = combobox.get_list_value(self.combo['manufacturer']) + self.cable.condition = combobox.get_list_value(self.combo['condition']) + # buttons on list page def on_but_new_clicked(self, widget): self.topwidget.set_visible_child(self.box['cable_edit']) @@ -68,35 +121,25 @@ class CablesView(View): self.topwidget.set_visible_child(self.box['cables']) def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete cable!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return self.topwidget.set_visible_child(self.box['cables']) # buttons on edit page def on_but_save_clicked(self, widget): - pass + # check mandatory fields: + # name, type, length, conductors, xsection + cname = self.entry['name'].get_text().strip() + if not cname: + # TODO error marker + return + self.save_record() + print(self.cable) def on_but_cancel_clicked(self, widget): self.topwidget.set_visible_child(self.box['cables']) - def display_record(self): - self.label['name'].set_text(self.cable.cablename) - self.label['type'].set_text(self.dd_type[self.cable.cabletype]) - if self.cable.techname: - self.label['techname'].set_text(self.dd_tech[self.cable.techname]) - else: - self.label['techname'].set_text('') - self.label['length'].set_text(self.format_int(self.cable.length)) - self.label['conductors'].set_text(self.format_int(self.cable.conductors)) - self.label['diameter'].set_text(self.format_float(self.cable.diameter, 1)) - self.label['xsection'].set_text(self.format_float(self.cable.xsection, 1)) - self.label['weight'].set_text(self.format_float(self.cable.weight)) - if self.cable.color: - self.label['color'].set_markup(f'#{self.cable.color} ●') - else: - self.label['color'].set_text('') - self.label['supplier'].set_text(str(self.cable.supplier)) - self.label['manufacturer'].set_text(str(self.cable.manufacturer)) - self.label['condition'].set_text(self.cable.cablecond) - self.label['remarks'].set_text(self.cable.remarks or '') - - def edit_record(self): - pass diff --git a/yms/view/companies.py b/yms/view/companies.py index 1861c35..1e23bda 100644 --- a/yms/view/companies.py +++ b/yms/view/companies.py @@ -18,29 +18,42 @@ class CompaniesView(View): self.newrecord = False # company types - self.db.cur.execute("SELECT ddval, ddtext FROM dropdown WHERE ddid=2 ORDER BY ddval") - self.comptype = dict(self.db.cur.fetchall()) - combobox.load_from_dict(self.combo['flt_type'], {-2: _("─── all ───")} | self.comptype, -2) - 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) + combobox.load_from_dict(self.combo['flt_type'], {-2: _("─── all ───"), -1: _("─── none ───")} | self.dd_comptype, -2) + combobox.load_from_dict(self.combo['comptype'], self.dd_comptype, company.SUPPLIER) + combobox.load_from_dict(self.combo['comptype2'], {-1: _("─── none ───")} | 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(): - self.lst_companies.append((row[0], row[1], self.comptype[row[2]], row[3])) + self.load_list() + treeview.add_column(self.tree['companies'], _('ID'), 0) treeview.add_column(self.tree['companies'], _('Name'), 1) treeview.add_column(self.tree['companies'], _('Type'), 2) treeview.add_column(self.tree['companies'], _('Remarks'), 3) self.tree['companies'].set_model(self.lst_companies) + def load_list(self): + selected_id = treeview.get_value(self.tree['companies']) + self.lst_companies.clear() + sql = ( + "SELECT compid, compname, comptype, remarks " + "FROM company " + "WHERE compid >= 0 " + "ORDER BY compname" + ) + self.db.cur.execute(sql) + selection = self.tree['companies'].get_selection() + for row in self.db.cur.fetchall(): + treeiter = self.lst_companies.append((row[0], row[1], self.dd_comptype[row[2]], row[3])) + if row[0] == selected_id: + # restore previous selected row + selection.select_iter(treeiter) + def clear_record(self): - self.entry['name'].set_text('') + self.entry['compname'].set_text('') self.entry['shortname'].set_text('') self.entry['street'].set_text('') self.entry['zip'].set_text('') @@ -52,7 +65,7 @@ class CompaniesView(View): 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['comptype'], company.SUPPLIER) combobox.activate_row(self.combo['comptype2'], -1) def display_record(self): @@ -76,6 +89,8 @@ class CompaniesView(View): 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) + combobox.activate_row(self.combo['comptype'], self.comp.comptype) + combobox.activate_row(self.combo['comptype2'], self.comp.comptype2) 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 '') @@ -87,15 +102,44 @@ class CompaniesView(View): 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 '') + self.text['remarks'].get_buffer().set_text(self.comp.remarks or '') + + def save_record(self): + # fields must have been validated beforehand + self.comp.compname = self.entry['compname'].get_text() + self.comp.comptype = combobox.get_list_value(self.combo['comptype']) + self.comp.comptype2 = combobox.get_list_value(self.combo['comptype2']) + if self.comp.comptype2 < 0: + self.comp.comptype2 = None + self.comp.shortname = self.entry['shortname'].get_text() + self.comp.street = self.entry['street'].get_text() + self.comp.zip = self.entry['zip'].get_text() + self.comp.city = self.entry['city'].get_text() + self.comp.country = self.entry['country'].get_text() + self.comp.contact = self.entry['contact'].get_text() + self.comp.phone = self.entry['phone'].get_text() + self.comp.email = self.entry['email'].get_text() + self.comp.web = self.entry['web'].get_text() + self.comp.customerno = self.entry['customerno'].get_text() + self.comp.conractno = self.entry['contractno'].get_text() + self.comp.remarks = gtkutils.get_text_contents(self.text['remarks']) # buttons on list page def on_but_new_clicked(self, widget): + self.newrecord = True + self.label['title_edit'].set_text(_("Add new Company")) + self.clear_record() self.topwidget.set_visible_child(self.box['comp_edit']) def on_but_edit_clicked(self, widget): + self.newrecord = False compid = treeview.get_value(self.tree['companies'], 0) if not compid: return + self.comp.load(compid) + self.edit_record() + self.label['title_edit'].set_text(_("Edit Company")) + self.topwidget.set_visible_child(self.box['comp_edit']) def on_but_detail_clicked(self, widget): @@ -118,11 +162,30 @@ class CompaniesView(View): self.topwidget.set_visible_child(self.box['companies']) def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete company!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return self.topwidget.set_visible_child(self.box['companies']) # buttons on edit page def on_but_save_clicked(self, widget): - pass + # check mandatory fields: + compname = self.entry['compname'].get_text().strip() + # TODO type + if not compname: + # TODO error marker + return + self.save_record() + print(self.comp) + self.comp.save() + if self.newrecord: + self.load_list() + self.newrecord = False + self.display_record() + self.topwidget.set_visible_child(self.box['comp_detail']) def on_but_cancel_clicked(self, widget): self.topwidget.set_visible_child(self.box['companies']) diff --git a/yms/view/documents.py b/yms/view/documents.py index 98d819c..f539e96 100644 --- a/yms/view/documents.py +++ b/yms/view/documents.py @@ -3,6 +3,7 @@ import os from gi.repository import GLib, Gtk, Gdk, GdkPixbuf, Rsvg import fitz +import sane from .view import View from yms import gtkutils, combobox, treeview @@ -17,6 +18,10 @@ class DocumentsView(View): self.doc = document.Document(context.db) # current record self.newrecord = False + self.scandialog = self.builder.get_object("dlg_scanner") + print(self.scandialog) + # TODO self.uploaddialog = self.builder.get_object("dlg_upload") + self.lst_documents = Gtk.ListStore(int, str, str, str, int) sql = ( "SELECT d.docid, d.doctype, d.filename, d.title, COUNT(r.drid) AS refcount " @@ -35,41 +40,20 @@ class DocumentsView(View): treeview.add_column(self.tree['documents'], _('References'), 3) self.tree['documents'].set_model(self.lst_documents) - # buttons on list page - def on_but_new_clicked(self, widget): - self.topwidget.set_visible_child(self.box['doc_edit']) + # Status + self.dd_type = self.context.lookup.enum('document.doctype') + combobox.load_from_dict(self.combo['doctype'], self.dd_type) + # Roleaccess + self.dd_access = self.context.lookup.enum('document.roleaccess') + combobox.load_from_dict(self.combo['accesslevel'], self.dd_access) - def on_but_edit_clicked(self, widget): - self.topwidget.set_visible_child(self.box['doc_edit']) - - def on_but_detail_clicked(self, widget): - docid = treeview.get_value(self.tree['documents'], 0) - self.doc.load(docid) - self.display_record() - self.topwidget.set_visible_child(self.box['doc_detail']) - self.button['close'].grab_focus() - - def on_tvw_documents_row_activated(self, widget, path, column): - docid = treeview.get_value(widget, 0) - self.doc.load(docid) - self.display_record() - self.topwidget.set_visible_child(self.box['doc_detail']) - self.button['close'].grab_focus() - - # buttons on detail page - # edit2 uses edit callback - def on_but_close_clicked(self, widget): - self.topwidget.set_visible_child(self.box['documents']) - - def on_but_delete_clicked(self, widget): - self.topwidget.set_visible_child(self.box['documents']) - - # 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['documents']) + def clear_record(self): + self.doc.clear() + combobox.activate_row(self.combo['doctype'], 'generic') + self.entry['title'].set_text('') + self.entry['filename'].set_text('') + combobox.activate_row(self.combo['accesslevel'], 'captain') + self.text['remarks'].get_buffer().set_text('') def pdf_to_pixbuf(self, filename, max_width=400, max_height=400): doc = fitz.open(filename) @@ -135,4 +119,116 @@ class DocumentsView(View): self.image['preview'].clear() def edit_record(self): + combobox.activate_row(self.combo['doctype'], self.doc.doctype) + self.entry['title'].set_text(self.doc.title or '') + self.entry['filename'].set_text(self.doc.filename or '') + + def save_record(self): + # fields must have been validated beforehand + self.doc.doctype = combobox.get_list_value(self.combo['type']) + self.doc.title = self.entry['title'].get_text() + self.doc.filename = self.entry['filename'].get_text() + self.doc.remarks = gtkutils.get_text_contents(self.text['remarks']) + + # buttons on list page + def on_but_new_clicked(self, widget): + self.newrecord = True + self.label['title_edit'].set_text(_("Add new Document")) + self.clear_record() + self.topwidget.set_visible_child(self.box['doc_edit']) + + def on_but_edit_clicked(self, widget): + self.newrecord = False + docid = treeview.get_value(self.tree['documents'], 0) + if docid is None: + return + self.doc.load(docid) + self.edit_record() + self.topwidget.set_visible_child(self.box['doc_edit']) + + def on_but_detail_clicked(self, widget): + docid = treeview.get_value(self.tree['documents'], 0) + if docid is None: + return + self.doc.load(docid) + self.display_record() + self.topwidget.set_visible_child(self.box['doc_detail']) + self.button['close'].grab_focus() + + def on_tvw_documents_row_activated(self, widget, path, column): + docid = treeview.get_value(widget, 0) + self.doc.load(docid) + self.display_record() + self.topwidget.set_visible_child(self.box['doc_detail']) + self.button['close'].grab_focus() + + # buttons on detail page + # edit2 uses edit callback + def on_but_close_clicked(self, widget): + self.topwidget.set_visible_child(self.box['documents']) + + def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete document!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return + self.topwidget.set_visible_child(self.box['documents']) + + def scan_progress(self, current_line, total_lines): + print(f"Fortschritt: {current_line} / {total_lines}") + + # buttons on edit page + def on_but_scan_clicked(self, widget): + """ + # python sane + tl-x: X-Koordinate der linken oberen Ecke + tl-y: Y-Koordinate der linken oberen Ecke + br-x: X-Koordinate der rechten unteren Ecke + br-y: Y-Koordinate der rechten unteren Ecke + verfügbarer bereich ist über constraints ermittelbar + verfügbare resolution auch über constraints + verfügbare modes auch über constraints + Einheit: sane.UNIT_MM + scanner.tl_x = 10.0 + scanner.tl_y = 10.0 + scanner.br_x = 100.0 + scanner.br_y = 150.0 + """ + + response = self.scandialog.run() + self.scandialog.hide() + if response == Gtk.ResponseType.OK: + print("OK") + else: + print("Not OK") + + # sane.init() + # devices = sane.get_devices() + # if more than one device: Show device selector + # device_name = devices[0][0] + # scanner = sane.open(device_name) + # scanner.get_options() + # Options: index, name, title, desc, opt_type, unit, size, cap, constraint + # option.is_active() + # option.is_settable() + # scanner.get_parameters() + # format, last_frame, (pixels_per_line, lines), depth = scanner.get_parameters() + # scanner.mode = "Color" + # scanner.resolution = 150 + # image = scanner.scan(progress=self.scan_progress) + # image.save("scan.png") + # scanner.close() + # sane.exit() pass + + def on_but_upload_clicked(self, widget): + pass + + def on_but_save_clicked(self, widget): + print(self.doc) + + def on_but_cancel_clicked(self, widget): + self.topwidget.set_visible_child(self.box['documents']) + diff --git a/yms/view/equipment.py b/yms/view/equipment.py index 180c309..64b143b 100644 --- a/yms/view/equipment.py +++ b/yms/view/equipment.py @@ -2,6 +2,7 @@ import os from gi.repository import GLib, Gtk, Gdk +from dateutil.parser import parse from .view import View from yms import gtkutils, combobox, treeview @@ -18,16 +19,7 @@ class EquipmentView(View): self.newrecord = False self.lst_equipment = Gtk.ListStore(int, str, str, str, str, str, str) - sql = ( - "SELECT e.eid, e.ename, c.compname, e.model, e.serial, " - "DATE_FORMAT(e.purchdate, '{}'), e.remarks " - "FROM equipment AS e LEFT OUTER JOIN company AS c ON (e.manufacturer=c.compid) " - "WHERE e.vid=%s " - "ORDER BY e.ename" - ).format("%%d.%%m.%%Y") # TODO format from settings via mapping - self.db.cur.execute(sql, (context.vessel.vid,)) - for row in self.db.cur.fetchall(): - self.lst_equipment.append(row) + self.load_list() treeview.add_column(self.tree['equipment'], _('ID'), 0) treeview.add_column(self.tree['equipment'], _('Name'), 1) @@ -38,23 +30,132 @@ class EquipmentView(View): treeview.add_column(self.tree['equipment'], _('Remarks'), 6) self.tree['equipment'].set_model(self.lst_equipment) + # Supplier + self.dd_supplier = self.context.lookup.company(1) + combobox.load_from_dict(self.combo['supplier'], {-1: _("─── none ───")} | self.dd_supplier) + # Manufacturer + self.dd_manufacturer = self.context.lookup.company(2) + combobox.load_from_dict(self.combo['manufacturer'], {-1: _("─── none ───")} | self.dd_manufacturer) + # Category self.dd_category = self.context.lookup.dropdown(Dropdown.EQUIPMENT_CATEGORY) - #combobox.load_from_dict(self.combo['unit'], self.dd_unit) + combobox.load_from_dict(self.combo['category'], {-1: _("─── none ───")} | self.dd_category) + # Condition + self.dd_condition = self.context.lookup.enum('equipment.econd') + combobox.load_from_dict(self.combo['condition'], self.dd_condition, 'unknown') + + def load_list(self): + self.lst_equipment.clear() + sql = ( + "SELECT e.eid, e.ename, c.compname, e.model, e.serial, " + "DATE_FORMAT(e.purchdate, '{}'), e.remarks " + "FROM equipment AS e LEFT OUTER JOIN company AS c ON (e.manufacturer=c.compid) " + "WHERE e.vid=%s " + "ORDER BY e.ename" + ).format(self.context.datefmt.replace('%', '%%')) + # ).format("%%d.%%m.%%Y") # TODO format from settings via mapping + self.db.cur.execute(sql, (self.context.vessel.vid,)) + for row in self.db.cur.fetchall(): + self.lst_equipment.append(row) + + def clear_record(self): + self.equip.clear() + self.entry['name'].set_text('') + self.entry['shortname'].set_text('') + combobox.activate_row(self.combo['manufacturer'], -1) + self.entry['model'].set_text('') + self.entry['serial'].set_text('') + self.spin['weight'].set_value(0) + self.spin['price'].set_value(0) + self.entry['purchdate'].set_text('') + combobox.activate_row(self.combo['supplier'], -1) + combobox.activate_row(self.combo['category'], -1) + combobox.activate_row(self.combo['condition'], 'unknown') + self.text['remarks'].get_buffer().set_text('') + + def display_record(self): + print(self.equip) + self.label['name'].set_text(self.equip.ename) + self.label['shortname'].set_text(self.equip.shortname or '') + if self.equip.manufacturer: + self.label['manufacturer'].set_text(self.dd_manufacturer[self.equip.manufacturer]) + else: + self.label['manufacturer'].set_text('') + self.label['model'].set_text(self.equip.model or '') + self.label['serial'].set_text(self.equip.serial or '') + self.label['weight'].set_text(self.format_float(self.equip.weight, 2, suffix='kg')) + self.label['price'].set_text(self.format_float(self.equip.price, 2, suffix='€')) + self.label['purchdate'].set_text(self.format_date(self.equip.purchdate)) + if self.equip.supplier: + self.label['supplier'].set_text(self.dd_supplier[self.equip.supplier]) + else: + self.label['supplier'].set_text('') + if self.equip.ecat: + self.label['category'].set_text(self.dd_category[self.equip.ecat]) + else: + self.label['category'].set_text('') + self.label['flags'].set_text(self.equip.flags or '') + self.label['remarks'].set_text(self.equip.remarks or '') + + def edit_record(self): + self.entry['name'].set_text(self.equip.ename) + self.entry['shortname'].set_text(self.equip.shortname or '') + combobox.activate_row(self.combo['manufacturer'], self.equip.manufacturer or -1) + self.entry['model'].set_text(self.equip.model or '') + self.entry['serial'].set_text(self.equip.serial or '') + self.spin['weight'].set_value(self.equip.weight or 0) + self.spin['price'].set_value(self.equip.price or 0) + self.entry['purchdate'].set_text(self.format_date(self.equip.purchdate)) + self.text['remarks'].get_buffer().set_text(self.equip.remarks or '') + combobox.activate_row(self.combo['supplier'], self.equip.supplier or -1) + combobox.activate_row(self.combo['category'], self.equip.ecat or -1) + combobox.activate_row(self.combo['condition'], self.equip.econd or 'unknown') + self.text['remarks'].get_buffer().set_text(self.equip.remarks or '') + print("Edit record") + print(self.equip) + + def save_record(self): + # fields must have been validated beforehand + print(self.equip) + self.equip.ename = self.entry['name'].get_text() + self.equip.shortname = self.entry['shortname'].get_text() + self.equip.manufacturer = combobox.get_list_value(self.combo['manufacturer']) + if self.equip.manufacturer < 0: + self.equip.manufacturer = None + self.equip.model = self.entry['model'].get_text() + self.equip.serial = self.entry['serial'].get_text() + self.equip.weight = self.spin['weight'].get_value() + self.equip.price = self.spin['price'].get_value() + self.equip.supplier = combobox.get_list_value(self.combo['supplier']) + if self.equip.supplier < 0: + self.equip.supplier = None + self.equip.ecat = combobox.get_list_value(self.combo['category']) + if self.equip.ecat < 0: + self.equip.ecat = None + self.equip.remarks = gtkutils.get_text_contents(self.text['remarks']) + print(self.equip) # buttons on list page def on_but_new_clicked(self, widget): self.newrecord = True - self.label['title_editor'].set_text(_("Add new Equipment")) + self.label['title_edit'].set_text(_("Add new Equipment")) self.clear_record() self.equip.vid = self.context.vessel.vid self.topwidget.set_visible_child(self.box['equip_edit']) def on_but_edit_clicked(self, widget): + self.newrecord = False + eid = treeview.get_value(self.tree['equipment'], 0) + if eid is None: + return self.label['title_edit'].set_text(_("Edit Equipment")) + self.equip.load(eid) + self.edit_record() self.topwidget.set_visible_child(self.box['equip_edit']) def on_but_detail_clicked(self, widget): eid = treeview.get_value(self.tree['equipment'], 0) + if eid is None: + return self.equip.load(eid) self.display_record() self.topwidget.set_visible_child(self.box['equip_detail']) @@ -71,34 +172,44 @@ class EquipmentView(View): def on_but_close_clicked(self, widget): self.topwidget.set_visible_child(self.box['equipment']) + def on_but_convert_clicked(self, widget): + # convert equipment to inventory + answer = gtkutils.questionbox( + _("Convert equipment to inventory?\n" + "Some properties will be lost!\n\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return + # TODO + def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete equipment!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return self.topwidget.set_visible_child(self.box['equipment']) # buttons on edit page def on_but_save_clicked(self, widget): - pass + # check mandatory fields + if not self.entry['name'].get_text().strip(): + # TODO error marker + return + self.save_record() + print(self.equip) + self.equip.save() + if self.newrecord: + self.load_list() + else: + pass + # TODO aktuelle Listenzeile aktualisieren! + self.newrecord = False + self.display_record() + self.topwidget.set_visible_child(self.box['equip_detail']) def on_but_cancel_clicked(self, widget): self.topwidget.set_visible_child(self.box['equipment']) - def display_record(self): - print(self.equip) - self.label['name'].set_text(self.equip.ename) - self.label['shortname'].set_text(self.equip.shortname or '') - #lookup self.label['manufacturer'].set_text(self.equip.manufacturer) - self.label['model'].set_text(self.equip.model or '') - self.label['serial'].set_text(self.equip.serial or '') - self.label['weight'].set_text(self.format_float(self.equip.weight, 2, suffix='kg')) - self.label['price'].set_text(self.format_float(self.equip.price, 2, suffix='€')) - self.label['date_purch'].set_text(self.equip.purchdate or '') - #lookup self.label['supplier'].set_text(self.equip.supplier) - self.label['category'].set_text(self.dd_category[self.equip.ecat]) - self.label['flags'].set_text(self.equip.flags or '') - self.label['remarks'].set_text(self.equip.remarks or '') - - def edit_record(self): - self.entry['sname'].set_text(self.storage.sname) - self.spin['x'].set_value(self.storage.x) - self.spin['y'].set_value(self.storage.y) - self.spin['z'].set_value(self.storage.z) - self.text['remarks'].get_buffer().set_text(self.storage.remarks or '') diff --git a/yms/view/fuses.py b/yms/view/fuses.py index bbddd89..ad40ba0 100644 --- a/yms/view/fuses.py +++ b/yms/view/fuses.py @@ -39,13 +39,72 @@ class FusesView(View): treeview.add_column(self.tree['fuses'], _('Description'), 3) self.tree['fuses'].set_model(self.lst_fuses) - self.dd_type = self.context.lookup.dropdown(Dropdown.FUSE_TYPE) + # Fuse Type + self.dd_ftype = self.context.lookup.dropdown(Dropdown.FUSE_TYPE) + combobox.load_from_dict(self.combo['ftype'], self.dd_ftype) + # Cables + self.dd_cable = self.context.lookup.cable(context.vessel.vid) + combobox.load_from_dict(self.combo['cable'], {-1: _("─── none ───")} | self.dd_cable) + # Equipment + self.dd_equipment = self.context.lookup.equipment(context.vessel.vid) + combobox.load_from_dict(self.combo['equipment'], {-1: _("─── none ───")} | self.dd_equipment) + + def clear_record(self): + self.fuse.clear() + self.spin['fnumber'].set_value(0) + self.entry['description'].set_text('') + combobox.activate_row(self.combo['ftype'], -1) + self.spin['current'].set_value(0) + combobox.activate_row(self.combo['cable'], -1) + combobox.activate_row(self.combo['equipment'], -1) + self.entry['location'].set_text('') + self.text['remarks'].get_buffer().set_text('') + + def display_record(self): + self.label['fnumber'].set_text(f"F{self.fuse.fnumber}") + self.label['type'].set_text(self.dd_type[self.fuse.ftype]) + self.label['current'].set_text(self.format_float(self.fuse.current, 2, suffix="A")) + self.label['cable'].set_text(str(self.fuse.cableid)) + self.label['equipment'].set_text(str(self.fuse.eid)) + self.label['location'].set_text(str(self.fuse.location)) + self.label['description'].set_text(str(self.fuse.description or '')) + self.label['remarks'].set_text(str(self.fuse.remarks or '')) + + def edit_record(self): + self.spin['fnumber'].set_value(self.fuse.fnumber) + self.entry['description'].set_text(self.fuse.description) + combobox.activate_row(self.combo['ftype'], self.fuse.ftype) + self.spin['current'].set_value(self.fuse.current) + combobox.activate_row(self.combo['cable'], self.fuse.cableid) + combobox.activate_row(self.combo['equipment'], self.fuse.eid) + self.entry['location'].set_text(self.fuse.location) + self.text['remarks'].get_buffer().set_text(self.prov.remarks or '') + + def save_record(self): + # fields must have been validated beforehand + self.fuse.number = int(self.spin['fnumber'].get_value()) + self.fuse.description = self.entry['description'].get_text() + self.fuse.ftype = combobox.get_list_value(self.combo['ftype']) + self.fuse.cableid = combobox.get_list_value(self.combo['cable']) + self.fuse.eid = combobox.get_list_value(self.combo['equipment']) + self.fuse.location = self.entry['location'].get_text() + self.fuse.remarks = gtkutils.get_text_contents(self.text['remarks']) # buttons on list page def on_but_new_clicked(self, widget): + self.newrecord = True + self.label['title_edit'].set_text(_("Add new Fuse")) + self.clear_record() self.topwidget.set_visible_child(self.box['fuse_edit']) def on_but_edit_clicked(self, widget): + self.newrecord = False + fuseid = treeview.get_value(self.tree['fuses'], 0) + if fuseid is None: + return + self.label['title_edit'].set_text(_("Edit Fuse")) + self.fuse.load(fuseid) + self.edit_record() self.topwidget.set_visible_child(self.box['fuse_edit']) def on_but_detail_clicked(self, widget): @@ -70,6 +129,12 @@ class FusesView(View): self.topwidget.set_visible_child(self.box['fuses']) def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete fuse!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return self.topwidget.set_visible_child(self.box['fuses']) # buttons on edit page @@ -79,15 +144,3 @@ class FusesView(View): def on_but_cancel_clicked(self, widget): self.topwidget.set_visible_child(self.box['fuses']) - def display_record(self): - self.label['fnumber'].set_text(f"F{self.fuse.fnumber}") - self.label['type'].set_text(self.dd_type[self.fuse.ftype]) - self.label['current'].set_text(self.format_float(self.fuse.current, 2, suffix="A")) - self.label['cable'].set_text(str(self.fuse.cableid)) - self.label['equipment'].set_text(str(self.fuse.eid)) - self.label['location'].set_text(str(self.fuse.location)) - self.label['description'].set_text(str(self.fuse.description or '')) - self.label['remarks'].set_text(str(self.fuse.remarks or '')) - - def edit_record(self): - pass diff --git a/yms/view/inventory.py b/yms/view/inventory.py index ab7bbda..e457a2e 100644 --- a/yms/view/inventory.py +++ b/yms/view/inventory.py @@ -1,12 +1,16 @@ # SPDX-License-Identifier: WTFPL + + import os from gi.repository import GLib, Gtk, Gdk +from dateutil.parser import parse from .view import View from yms import gtkutils, combobox, treeview from yms.lookup import Dropdown from yms.model import inventory +from yms.model import equipment class InventoryView(View): @@ -15,22 +19,14 @@ class InventoryView(View): self.inv = inventory.Inventory(context.db) # current record self.newrecord = False + self.token = None # record locking + self.timer_id = None # Inventory gets vessel assignment via # - storage direct # - or via box which is assigned to a storage self.lst_inventory = Gtk.ListStore(int, str, str, int, str, str) - sql = ( - "SELECT i.invid, i.invname, s.sname AS container, i.number, i.invcond, i.remarks " - "FROM inventory AS i JOIN storage AS s ON (i.conttype='storage' AND i.sid=s.sid) " - "WHERE s.vid=%s " - "UNION SELECT i.invid, i.invname, b.label AS container, i.number, i.invcond, i.remarks " - "FROM inventory AS i JOIN box AS b ON (i.conttype='box' AND i.boxid=b.boxid) JOIN storage AS s ON (b.sid=s.sid) " - "WHERE s.vid=%s" - ) - self.db.cur.execute(sql, (context.vessel.vid, context.vessel.vid)) - for row in self.db.cur.fetchall(): - self.lst_inventory.append(row) + self.load_list() treeview.add_column(self.tree['inventory'], _('ID'), 0) treeview.add_column(self.tree['inventory'], _('Name'), 1) @@ -40,42 +36,60 @@ class InventoryView(View): treeview.add_column(self.tree['inventory'], _('Remarks'), 5) self.tree['inventory'].set_model(self.lst_inventory) + # Container type + self.dd_conttype = self.context.lookup.enum('inventory.conttype') + combobox.load_from_dict(self.combo['conttype'], self.dd_conttype) + # Inventory category self.dd_category = self.context.lookup.dropdown(Dropdown.INVENTORY_CATEGORY) + combobox.load_from_dict(self.combo['category'], {-1: _("─── none ───")} | self.dd_category) + # Storage + self.dd_storage = self.context.lookup.storage(context.vessel.vid) + combobox.load_from_dict(self.combo['storage'], {-1: _("─── none ───")} | self.dd_storage) + # Box + self.dd_box = self.context.lookup.box(context.vessel.vid) + combobox.load_from_dict(self.combo['box'], {-1: _("─── none ───")} | self.dd_box) + # Equipment + self.dd_equipment = self.context.lookup.equipment(context.vessel.vid) + combobox.load_from_dict(self.combo['equipment'], {-1: _("─── none ───")} | self.dd_equipment) + # Condition + self.dd_condition = self.context.lookup.enum('inventory.invcond') + combobox.load_from_dict(self.combo['condition'], {"-1": _("─── none ───")} | self.dd_condition) - # buttons on list page - def on_but_new_clicked(self, widget): - self.topwidget.set_visible_child(self.box['inv_edit']) + def load_list(self): + self.lst_inventory.clear() + sql = ( + "SELECT i.invid, i.invname, s.sname AS container, i.number, i.invcond, i.remarks " + "FROM inventory AS i JOIN storage AS s ON (i.conttype='storage' AND i.sid=s.sid) " + "WHERE s.vid=%s " + "UNION SELECT i.invid, i.invname, b.label AS container, i.number, i.invcond, i.remarks " + "FROM inventory AS i JOIN box AS b ON (i.conttype='box' AND i.boxid=b.boxid) JOIN storage AS s ON (b.sid=s.sid) " + "WHERE s.vid=%s" + ) + self.db.cur.execute(sql, (self.context.vessel.vid, self.context.vessel.vid)) + for row in self.db.cur.fetchall(): + self.lst_inventory.append(row) - def on_but_edit_clicked(self, widget): - self.topwidget.set_visible_child(self.box['inv_edit']) + def lock_timer(self): + self.context.db.lock_refresh(self.token) + return True # continue timer - def on_but_detail_clicked(self, widget): - invid = treeview.get_value(self.tree['inventory'], 0) - self.inv.load(invid) - self.display_record() - self.topwidget.set_visible_child(self.box['inv_detail']) - self.button['close'].grab_focus() + def on_page_activated(self): + print("Inventory activated") - def on_tvw_inventory_row_activated(self, widget, path, column): - invid = treeview.get_value(widget, 0) - self.inv.load(invid) - self.display_record() - self.topwidget.set_visible_child(self.box['inv_detail']) - - # buttons on detail page - # edit2 uses edit callback - def on_but_close_clicked(self, widget): - self.topwidget.set_visible_child(self.box['inventory']) - - def on_but_delete_clicked(self, widget): - self.topwidget.set_visible_child(self.box['inventory']) - - # 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['inventory']) + def clear_record(self): + self.inv.clear() + self.entry['name'].set_text('') + combobox.activate_row(self.combo['conttype'], -1) + combobox.activate_row(self.combo['storage'], -1) + combobox.activate_row(self.combo['box'], -1) + combobox.activate_row(self.combo['equipment'], -1) + self.spin['number'].set_value(1) + self.spin['weight'].set_value(0) + self.spin['price'].set_value(0) + self.entry['purchdate'].set_text('') + combobox.activate_row(self.combo['condition'], 'unknown') + combobox.activate_row(self.combo['category'], -1) + self.text['remarks'].get_buffer().set_text('') def display_record(self): # TODO nice formatting @@ -93,13 +107,159 @@ class InventoryView(View): self.label['category'].set_text(self.dd_category[self.inv.icat]) else: self.label['category'].set_text('') + self.label['flags'].set_text(self.inv.flags) self.label['remarks'].set_text(self.inv.remarks or '') def edit_record(self): - self.entry['user_login'].set_text(user.login) - self.entry['user_displayname'].set_text(user.displayname) - combobox.activate_row(self.combo['user_role'], user.role) - combobox.activate_row(self.combo['user_lang'], user.language) - self.check['user_locked'].set_active('locked' in user.flags) - self.check['user_deleted'].set_active('deleted' in user.flags) - self.entry['user_pass'].set_text('') + self.entry['name'].set_text(self.inv.invname) + combobox.activate_row(self.combo['conttype'], self.inv.conttype) + combobox.activate_row(self.combo['storage'], self.inv.sid) + combobox.activate_row(self.combo['box'], self.inv.boxid) + combobox.activate_row(self.combo['equipment'], self.inv.eid) + self.spin['number'].set_value(self.inv.number) + self.spin['weight'].set_value(self.inv.weight or 0) + self.spin['price'].set_value(self.inv.price or 0) + self.entry['purchdate'].set_text(self.inv.purchdate or '') + combobox.activate_row(self.combo['condition'], self.inv.invcond) + combobox.activate_row(self.combo['category'], self.inv.icat) + flags = self.inv.flags.split(',') + for flag in self.context.lookup.enum('inventory.flags'): + self.check[flag].set_active(flag in flags) + self.text['remarks'].get_buffer().set_text(self.inv.remarks or '') + + def save_record(self): + # fields must have been validated beforehand + self.inv.invname = self.entry['name'].get_text() + self.inv.conttype = combobox.get_list_value(self.combo['conttype']) + self.inv.sid = combobox.get_list_value(self.combo['storage']) + if self.inv.sid < 0: + self.inv.sid = None + self.inv.boxid = combobox.get_list_value(self.combo['box']) + if self.inv.boxid < 0: + self.inv.boxid = None + self.inv.eid = combobox.get_list_value(self.combo['equipment']) + if self.inv.eid < 0: + self.inv.eid = None + self.inv.number = self.spin['number'].get_value() + self.inv.weight = self.spin['weight'].get_value() + self.inv.price = self.spin['price'].get_value() + try: + # TODO respect configured date format + self.inv.purchdate = parse(self.entry['purchdate'].get_text(), dayfirst=True) + except ValueError: + self.inv.purchdate = None + self.inv.invcond = combobox.get_list_value(self.combo['condition']) + self.inv.icat = combobox.get_list_value(self.combo['category']) + # TODO this could be a generic function operating on a list + # of check controls + flags = [] + if self.check['ordered'].get_active(): flags.append('ordered') + if self.check['removed'].get_active(): flags.append('removed') + if self.check['deleted'].get_active(): flags.append('deleted') + self.inv.flags = ','.join(flags) + self.inv.remarks = gtkutils.get_text_contents(self.text['remarks']) + + # buttons on list page + def on_but_new_clicked(self, widget): + self.newrecord = True + self.label['title_edit'].set_text(_("Add new Inventory")) + self.clear_record() + self.topwidget.set_visible_child(self.box['inv_edit']) + + def on_but_edit_clicked(self, widget): + invid = treeview.get_value(self.tree['inventory'], 0) + if invid is None: + return + self.token = self.context.db.lock_acquire('inventory', invid, self.user.user_id) + if self.token is None: + gtkutils.messagebox( + _("Record is locked!\n" + "Edit prohibited."), title="YMS" + ) + return + self.timer_id = GLib.timeout_add(120000, self.lock_timer) # 2 minutes lock refresh timer + self.newrecord = False + self.label['title_edit'].set_text(_("Edit Inventory")) + self.inv.load(invid) + self.edit_record() + self.topwidget.set_visible_child(self.box['inv_edit']) + # TODO start timer to refresh record lock + + def on_but_detail_clicked(self, widget): + invid = treeview.get_value(self.tree['inventory'], 0) + self.inv.load(invid) + print(self.inv) + self.display_record() + self.topwidget.set_visible_child(self.box['inv_detail']) + self.button['close'].grab_focus() + + def on_tvw_inventory_row_activated(self, widget, path, column): + invid = treeview.get_value(widget, 0) + self.inv.load(invid) + self.display_record() + self.topwidget.set_visible_child(self.box['inv_detail']) + + # buttons on detail page + # edit2 uses edit callback + def on_but_close_clicked(self, widget): + self.topwidget.set_visible_child(self.box['inventory']) + + def on_but_convert_clicked(self, widget): + # convert equipment to inventory + answer = gtkutils.questionbox( + _("Convert inventory to equipment?\n" + "Some properties will be lost!\n\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return + # TODO / WIP + """ + lost fields: icat number conttype sid boxid + """ + equip = equipment.Equipment(self.context.db) + equip.ename = self.inv.name + equip.shortname = '' + equip.manufacturer = None + equip.model = '' + equip.serial = '' + equip.weight = self.inv.weight + equip.price = self.inv.price + equip.purchdate = self.inv.purchdate + equip.supplier = None + equip.ecat = None + equip.econd = self.inv.invcond + equip.remarks = self.inv.remarks + equip.flags = self.inv.flags + print(equip) + + def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete inventory!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return + self.topwidget.set_visible_child(self.box['inventory']) + + # buttons on edit page + def on_but_save_clicked(self, widget): + # check mandatory fields + if not self.entry['name'].get_text().strip(): + # TODO error marker + return + self.save_record() + print(self.inv) + self.inv.save() + self.context.db.conn.commit() + + def on_but_cancel_clicked(self, widget): + if not self.newrecord: + if self.timer_id is not None: + # remove locking timer + GLib.source_remove(self.timer_id) + self.timer_id = None + if not self.token is None: + if not self.context.db.lock_release(self.token): + print("Error while releasing lock!") + self.topwidget.set_visible_child(self.box['inventory']) diff --git a/yms/view/maintenance.py b/yms/view/maintenance.py index 8311ce7..a1135f6 100644 --- a/yms/view/maintenance.py +++ b/yms/view/maintenance.py @@ -32,11 +32,64 @@ class MaintenanceView(View): treeview.add_column(self.tree['maintenance'], _('Remarks'), 3) self.tree['maintenance'].set_model(self.lst_maintenance) + def clear_record(self): + self.maint.clear() + self.entry['activities'].set_text('') + combobox.activate_row(self.combo['equipment'], -1) + self.spin['series'].set_value(0) + self.spin['interval'].set_value(0) + self.spin['last'].set_value(0) + self.entry['plandate'].set_text('') + self.entry['completion'].set_text('') + combobox.activate_row(self.combo['status'], 'new') + self.text['remarks'].get_buffer().set_text('') + + def display_record(self): + self.label['activities'].set_text(self.maint.activities) + self.label['equipment'].set_text(str(self.maint.eid)) + self.label['series'].set_text(str(self.maint.series)) + self.label['interval'].set_text(self.format_int(self.maint.interval_hours)) + self.label['last'].set_text(self.format_int(self.maint.last_hours)) + self.label['plandate'].set_text(self.format_date(self.maint.plan_date)) + self.label['completion'].set_text(self.format_date(self.maint.completion_date)) + self.label['status'].set_text(self.maint.maintstate) + self.label['remarks'].set_text(self.maint.remarks or '') + + def edit_record(self): + self.entry['activities'].set_text(self.maint.activities) + combobox.activate_row(self.combo['equipment'], self.maint.eid) + self.spin['series'].set_value(self.maint.series or 0) + self.spin['interval'].set_value(self.maint.interval_hours or 0) + self.spin['last'].set_value(self.maint.last_hours or 0) + self.entry['plandate'].set_text(self.maint.plan_date) + self.entry['completion'].set_text(self.maint.completion_date) + combobox.activate_row(self.combo['status'], self.maint.maintstate) + self.text['remarks'].get_buffer().set_text(self.maint.remarks or '') + + def save_record(self): + # fields must have been validated beforehand + self.maint.activities = self.entry['activities'].get_text() + self.maint.eid = combobox.get_list_value(self.combo['equipment']) + self.maint.series = int(self.spin['series'].get_value()) + self.maint.interval_hours = int(self.spin['interval'].get_value()) + self.maint.last_hours = int(self.spin['last'].get_value()) + self.maint.plan_date = self.entry['plandate'].get_text() + self.maint.completion_date = self.entry['completion'].get_text() + self.maint.maintstate = combobox.get_list_value(self.combo['status']) + self.maint.remarks = gtkutils.get_text_contents(self.text['remarks']) + # 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.newrecord = False + self.label['title_edit'].set_text(_("Edit Maintenance")) + maintid = treeview.get_value(self.tree['maintenance'], 0) + if not maintid: + return + self.maint.load(maintid) + self.edit_record() self.topwidget.set_visible_child(self.box['maint_edit']) def on_but_detail_clicked(self, widget): @@ -61,26 +114,23 @@ class MaintenanceView(View): self.topwidget.set_visible_child(self.box['maintenance']) def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete maintenance!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return self.topwidget.set_visible_child(self.box['maintenance']) # buttons on edit page def on_but_save_clicked(self, widget): - pass + # check mandatory fields + if not self.entry['activities'].get_text().strip(): + # TODO error marker + return + self.save_record() + print(self.maint) + self.maint.save() def on_but_cancel_clicked(self, widget): self.topwidget.set_visible_child(self.box['maintenance']) - - def display_record(self): - self.label['activities'].set_text(self.maint.activities) - self.label['equipment'].set_text(str(self.maint.eid)) - self.label['series'].set_text(str(self.maint.series)) - self.label['interval'].set_text(self.format_int(self.maint.interval_hours)) - self.label['last'].set_text(self.format_int(self.maint.last_hours)) - self.label['plandate'].set_text(self.format_date(self.maint.plan_date)) - self.label['completion'].set_text(self.format_date(self.maint.completion_date)) - self.label['status'].set_text(self.maint.maintstate) - self.label['remarks'].set_text(self.maint.remarks or '') - - - def edit_record(self): - pass diff --git a/yms/view/measurement.py b/yms/view/measurement.py index e84ec44..b11d458 100644 --- a/yms/view/measurement.py +++ b/yms/view/measurement.py @@ -16,8 +16,26 @@ class MeasurementView(View): self.measure = measurement.Measurement(context.db) # current record self.newrecord = False + # dimensions + self.dd_dimensions = { 1: "1D", 2: "2D", 3: "3D"} + combobox.load_from_dict(self.combo['dimensions'], self.dd_dimensions, 1) + + # accuracy + self.dd_accuracy = self.context.lookup.enum('measurement.accuracy') + combobox.load_from_dict(self.combo['accuracy'], {"-1": _("─── none ───")} | self.dd_accuracy) + # measurement units self.dd_unit = self.context.lookup.dropdown(Dropdown.UNIT) + print("Unit: {self.dd_unit}") + combobox.load_from_dict(self.combo['unit'], self.dd_unit, 1) + + # equipment + self.dd_equipment = self.context.lookup.equipment(context.vessel.vid) + combobox.load_from_dict(self.combo['equipment'], {-1: _("─── none ───")} | self.dd_equipment) + + # category + self.dd_category = self.context.lookup.dropdown(Dropdown.MEASUREMENT_CATEGORY) + combobox.load_from_dict(self.combo['category'], {-1: _("─── none ───")} | self.dd_category) self.lst_measurement = Gtk.ListStore(int, str, str, str, str, str) sql = ( @@ -56,11 +74,76 @@ class MeasurementView(View): treeview.add_column(self.tree['measurement'], _('Note'), 5) self.tree['measurement'].set_model(self.lst_measurement) + def clear_record(self): + self.measure.clear() + self.entry['name'].set_text('') + combobox.activate_row(self.combo['dimensions'], -1) + self.spin['val1'].set_value(0) + self.spin['val2'].set_value(0) + self.spin['val3'].set_value(0) + combobox.activate_row(self.combo['accuracy'], 'unknown') + self.entry['date'].set_text('') + combobox.activate_row(self.combo['equipment'], -1) + combobox.activate_row(self.combo['category'], -1) + self.text['note'].get_buffer().set_text('') + + def display_record(self): + self.label['name'].set_text(self.measure.mname) + self.label['dimensions'].set_text(self.measure.nval) + self.label['val1'].set_text(self.measure.val1) + if self.measure.nval >= 2: + self.label['val2'].set_text(self.measure.val2 or '') + else: + self.label['val2'].set_text('n/a') + if self.measure.nval == 3: + self.label['val3'].set_text(self.measure.val3 or '') + else: + self.label['val3'].set_text('n/a') + # TODO + # unit + # accuracy + # category + + def edit_record(self): + self.entry['name'].set_text(self.measure.mname) + combobox.activate_row(self.combo['dimensions'], self.measure.nval) + self.spin['val1'].set_value(self.measure.val1) + self.spin['val2'].set_value(self.measure.val2 or 0) + self.spin['val3'].set_value(self.measure.val3 or 0) + combobox.activate_row(self.combo['accuracy'], self.measure.accuracy) + self.entry['date'].set_text(self.measure.mdate) + combobox.activate_row(self.combo['equipment'], self.measure.eid) + combobox.activate_row(self.combo['category'], self.measure.mcat) + self.text['note'].get_buffer().set_text(self.task.note or '') + + def save_record(self): + # fields must have been validated beforehand + self.measure.mname = self.entry['name'].get_text() + self.measure.nval = combobox.get_list_value(self.combo['dimensions']) + self.measure.val1 = int(self.spin['val1'].get_value()) + self.measure.val2 = int(self.spin['val2'].get_value()) + self.measure.val3 = int(self.spin['val3'].get_value()) + self.measure.accuracy = combobox.get_list_value(self.combo['accurace']) + self.measure.mdate = self.entry['date'].get_text() + self.measure.eid = combobox.get_list_value(self.combo['equipment']) + self.measure.mcat = combobox.get_list_value(self.combo['category']) + self.measure.note = gtkutils.get_text_contents(self.text['note']) + # buttons on list page def on_but_new_clicked(self, widget): + self.newrecord = True + self.label['title_edit'].set_text(_("Add new Measurement")) + self.clear_record() self.topwidget.set_visible_child(self.box['measure_edit']) def on_but_edit_clicked(self, widget): + self.newrecord = False + self.label['title_edit'].set_text(_("Edit Measurement")) + mid = treeview.get_value(self.tree['measurement'], 0) + if not mid: + return + self.measure.load(mid) + self.edit_record() self.topwidget.set_visible_child(self.box['measure_edit']) def on_but_detail_clicked(self, widget): @@ -85,18 +168,23 @@ class MeasurementView(View): self.topwidget.set_visible_child(self.box['measurement']) def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete measurement!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return self.topwidget.set_visible_child(self.box['measurement']) # buttons on edit page def on_but_save_clicked(self, widget): - pass + # check mandatory fields + if not self.entry['mname'].get_text().strip(): + # TODO error marker + return + self.save_record() + print(self.measure) + self.measure.save() def on_but_cancel_clicked(self, widget): self.topwidget.set_visible_child(self.box['measurement']) - - def display_record(self): - self.label['name'].set_text(self.measure.mname) - self.label['note'].set_text(self.measure.note or '') - - def edit_record(self): - pass diff --git a/yms/view/projects.py b/yms/view/projects.py index fba0beb..0b666cb 100644 --- a/yms/view/projects.py +++ b/yms/view/projects.py @@ -43,14 +43,67 @@ class ProjectsView(View): treeview.add_column(self.tree['projects'], _('Remarks'), 5) self.tree['projects'].set_model(self.lst_projects) + # Responsible self.dd_user = context.lookup.user() + combobox.load_from_dict(self.combo['responsible'], self.dd_user) + + # Status self.dd_state = self.context.lookup.enum('project.projstate') + combobox.load_from_dict(self.combo['status'], self.dd_state) + + def clear_record(self): + self.project.clear() + self.entry['name'].set_text('') + combobox.activate_row(self.combo['responsible'], 0) + self.entry['date_start'].set_text('') + self.spin['costs_plan'].set_value(0) + self.spin['costs_final'].set_value(0) + combobox.activate_row(self.combo['status'], 'new') + self.text['remarks'].get_buffer().set_text('') + + def display_record(self): + self.label['name'].set_text(self.project.projname) + self.label['responsible'].set_text(self.dd_user[self.project.responsible]) + self.label['date_start'].set_text(self.format_date(self.project.startdate)) + self.label['duration'].set_text(self.format_int(self.project.duration, suffix="Days")) + self.label['costs_plan'].set_text(self.format_float(self.project.costs_plan, 2, suffix="€")) + self.label['costs_final'].set_text(self.format_float(self.project.costs_final, 2, suffix="€")) + self.label['status'].set_text(self.project.projstate) + self.label['remarks'].set_text(self.project.remarks or '') + + def edit_record(self): + self.entry['name'].set_text(self.project.projname) + combobox.activate_row(self.combo['responsible'], self.project.responsible) + self.entry['date_start'].set_text(self.project.startdate) + self.spin['costs_plan'].set_value(self.project.costs_plan) + self.spin['costs_final'].set_value(self.project.costs_final) + combobox.activate_row(self.combo['status'], self.project.projstate) + self.text['remarks'].get_buffer().set_text(self.project.remarks or '') + + def save_record(self): + # fields must have been validated beforehand + self.project.projname = self.entry['name'].get_text() + self.project.responsible = combobox.get_list_value(self.combo['responsible']) + self.project.costs_plan = int(self.spin['costs_plan'].get_value()) + self.project.costs_final = int(self.spin['costs_final'].get_value()) + self.project.projstate = combobox.get_list_value(self.combo['status']) + self.project.remarks = gtkutils.get_text_contents(self.text['remarks']) # buttons on list page def on_but_new_clicked(self, widget): + self.newrecord = True + self.label['title_edit'].set_text(_("Add new Project")) + self.clear_record() self.topwidget.set_visible_child(self.box['proj_edit']) def on_but_edit_clicked(self, widget): + self.newrecord = False + self.label['title_edit'].set_text(_("Edit Project")) + projid = treeview.get_value(self.tree['projects'], 0) + if not projidid: + return + self.measure.load(mid) + self.edit_record() self.topwidget.set_visible_child(self.box['proj_edit']) def on_but_detail_clicked(self, widget): @@ -75,24 +128,23 @@ class ProjectsView(View): self.topwidget.set_visible_child(self.box['projects']) def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete project!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return self.topwidget.set_visible_child(self.box['projects']) # buttons on edit page def on_but_save_clicked(self, widget): - pass + # check mandatory fields + if not self.entry['projname'].get_text().strip(): + # TODO error marker + return + self.save_record() + print(self.project) + self.project.save() def on_but_cancel_clicked(self, widget): self.topwidget.set_visible_child(self.box['projects']) - - def display_record(self): - self.label['name'].set_text(self.project.projname) - self.label['responsible'].set_text(self.dd_user[self.project.responsible]) - self.label['date_start'].set_text(self.format_date(self.project.startdate)) - self.label['duration'].set_text(self.format_int(self.project.duration, suffix="Days")) - self.label['costs_plan'].set_text(self.format_float(self.project.costs_plan, 2, suffix="€")) - self.label['costs_final'].set_text(self.format_float(self.project.costs_final, 2, suffix="€")) - self.label['status'].set_text(self.project.projstate) - self.label['remarks'].set_text(self.project.remarks or '') - - def edit_record(self): - pass diff --git a/yms/view/provisions.py b/yms/view/provisions.py index 87535ea..499d00a 100644 --- a/yms/view/provisions.py +++ b/yms/view/provisions.py @@ -2,8 +2,10 @@ import os from gi.repository import Gtk +from dateutil.parser import parse +from datetime import datetime -from .view import View +from .view import View, DatePicker from yms import gtkutils, combobox, treeview from yms.model import provision @@ -44,15 +46,72 @@ class ProvisionsView(View): treeview.add_column(self.tree['provisions'], _('Best before'), 5) self.tree['provisions'].set_model(self.lst_provisions) + # TODO Date format + self.entry['storedate'].set_placeholder_text("TT.MM.JJJJ") + self.dt_storedate = DatePicker(self.entry['storedate'], self.button['storedate'], context.datefmt) + + def clear_record(self): + self.prov.clear() + + def display_record(self): + self.label['name'].set_text(self.prov.provname) + self.label['category'].set_text(str(self.prov.provcat)) + self.label['storage'].set_text(str(self.prov.sid)) + self.label['box'].set_text(str(self.prov.boxid)) + self.label['number'].set_text(str(self.prov.number)) + self.label['unit'].set_text(str(self.prov.unit)) + self.label['target'].set_text(str(self.prov.target)) + self.label['weight'].set_text(self.format_float(self.prov.weight, 2, suffix='kg')) + self.label['weight_net'].set_text(self.format_float(self.prov.weight_net, 2, suffix='kg')) + self.label['price'].set_text(self.format_float(self.prov.price, 2, suffix='€')) + self.label['remarks'].set_text(self.prov.remarks or '') + + def edit_record(self): + self.entry['name'].set_text(self.prov.provname) + combobox.activate_row(self.combo['category'], self.prov.provcat) + combobox.activate_row(self.combo['storage'], self.prov.sid) + combobox.activate_row(self.combo['box'], self.prov.boxid) + self.spin['number'].set_value(self.prov.number) + self.spin['weight'].set_value(self.prov.weight or 0) + self.spin['weight_net'].set_value(self.prov.weight_net or 0) + combobox.activate_row(self.combo['unit'], self.prov.unit) + self.entry['storedate'].set_text(self.prov.storedate or '') + self.entry['shelflife'].set_text(self.prov.shelflife or '') + self.text['remarks'].get_buffer().set_text(self.prov.remarks or '') + + def save_record(self): + # fields must have been validated beforehand + self.prov.provname = self.entry['name'].get_text() + self.prov.provcat = combobox.get_list_value(self.combo['category']) + self.prov.sid = combobox.get_list_value(self.combo['storage']) + self.prov.boxid = combobox.get_list_value(self.combo['box']) + self.prov.number = int(self.spin['number'].get_value()) + self.prov.weight = self.spin['weight'].get_value() + self.prov.weight_net = self.spin['wehigt_net'].get_value() + self.prov.unit = combobox.get_list_value(self.combo['unit']) + self.prov.storedate = self.entry['storedate'].get_text() + self.prov.shelflife = self.entry['shelflife'].get_text() + self.prov.remarks = gtkutils.get_text_contents(self.text['remarks']) + def load_dropdown(self): self.db.cur.execute("SELECT ddval, ddtext FROM dropdown WHERE ddid=6 ORDER BY ddval") self.prov_unit = dict(self.db.cur.fetchall()) # buttons on list page def on_but_new_clicked(self, widget): + self.newrecord = True + self.label['title_edit'].set_text(_("Add new Provision")) + self.clear_record() self.topwidget.set_visible_child(self.box['prov_edit']) def on_but_edit_clicked(self, widget): + self.newrecord = False + self.label['title_edit'].set_text(_("Edit Provision")) + provid = treeview.get_value(self.tree['provisions'], 0) + if not provid: + return + self.prov.load(provid) + self.edit_record() self.topwidget.set_visible_child(self.box['prov_edit']) def on_but_detail_clicked(self, widget): @@ -75,28 +134,31 @@ class ProvisionsView(View): self.topwidget.set_visible_child(self.box['provisions']) def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete provision!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return self.topwidget.set_visible_child(self.box['provisions']) # buttons on edit page + def on_but_storedate_clicked(self, widget): + try: + curdate = parse(self.entry['storedate'].get_text()) + except: + curdate = datetime.date.today() + selected_date = self.calendar_dialog(None, self.entry['storedate'], curdate) + self.entry['storedate'].set_text(self.format_date(selected_date, curdate)) + def on_but_save_clicked(self, widget): - pass + # check mandatory fields + if not self.entry['provname'].get_text().strip(): + # TODO error marker + return + self.save_record() + print(self.prov) + self.prov.save() def on_but_cancel_clicked(self, widget): self.topwidget.set_visible_child(self.box['provisions']) - - def display_record(self): - print(self.prov) - self.label['name'].set_text(self.prov.provname) - self.label['category'].set_text(str(self.prov.provcat)) - self.label['storage'].set_text(str(self.prov.sid)) - self.label['box'].set_text(str(self.prov.boxid)) - self.label['number'].set_text(str(self.prov.number)) - self.label['unit'].set_text(str(self.prov.unit)) - self.label['target'].set_text(str(self.prov.target)) - self.label['weight'].set_text(self.format_float(self.prov.weight, 2, suffix='kg')) - self.label['weight_net'].set_text(self.format_float(self.prov.weight_net, 2, suffix='kg')) - self.label['price'].set_text(self.format_float(self.prov.price, 2, suffix='€')) - self.label['remarks'].set_text(self.prov.remarks or '') - - def edit_record(self): - pass diff --git a/yms/view/status.py b/yms/view/status.py index 79d91c5..4ef0d89 100644 --- a/yms/view/status.py +++ b/yms/view/status.py @@ -105,6 +105,10 @@ class StatusView: print("No centerline with id='centerline' found!") def on_drw_status_draw(self, area, cr): + if self.context.vessel.pk_value is None: + # no vessel defined + return + cr.set_source_rgb(0.92, 0.97, 1.0) cr.paint() @@ -136,9 +140,9 @@ class StatusView: # Detect all tables in database sql= ("SELECT table_name " "FROM information_schema.tables " - "WHERE table_schema='yms' AND table_type='BASE TABLE' " + "WHERE table_schema=%s AND table_type='BASE TABLE' " "ORDER BY table_name") - self.context.db.cur.execute(sql) + self.context.db.cur.execute(sql, (self.context.db.schema,)) tables = [row[0] for row in self.context.db.cur.fetchall()] # Loop over tables and get current record count records = [] diff --git a/yms/view/storage.py b/yms/view/storage.py index 2a6a122..f46652f 100644 --- a/yms/view/storage.py +++ b/yms/view/storage.py @@ -17,6 +17,8 @@ class StorageView(View): self.storage = storage.Storage(context.db) # current record self.newrecord = False + self.last_valid_rgb = "#3498DB" + self.lst_storage = Gtk.ListStore(int, str, str, str) self.load_list() @@ -27,29 +29,39 @@ class StorageView(View): self.tree['storage'].set_model(self.lst_storage) self.dd_stype = self.context.lookup.dropdown(Dropdown.STORAGE_TYPE) - combobox.load_from_dict(self.combo['type'], self.dd_stype) + combobox.load_from_dict(self.combo['type'], self.dd_stype, storage.GENERIC) self.dd_unit = self.context.lookup.enum('storage.capaunit') - combobox.load_from_dict(self.combo['unit'], self.dd_unit) + combobox.load_from_dict(self.combo['unit'], {"-1": _("─── none ───")} | self.dd_unit) def add_row(self): pass def refresh_row(self): pass + treeview.set_value(self.tree['storage'], 1, self.storage.name) + position = f"({self.storage.x}, {self.storage.y}, {self.storage.z})" + treeview.set_value(self.tree['storage'], 2, position) + treeview.set_value(self.tree['storage'], 3, self.storage.remarks) def load_list(self): + selected_id = treeview.get_value(self.tree['storage']) self.lst_storage.clear() sql = ( - "SELECT sid, sname, CONCAT(x, ',', y, ',', z) AS position, remarks " + "SELECT sid, sname, CONCAT(x, ',', y, ',', z) AS position, " + " IF(CHAR_LENGTH(remarks)>40, CONCAT(LEFT(remarks, 40), '\u2026'), remarks) AS remarks " "FROM storage " "WHERE vid=%s " "ORDER BY sname" ) self.db.cur.execute(sql, (self.context.vessel.vid,)) + selection = self.tree['storage'].get_selection() for row in self.db.cur.fetchall(): - self.lst_storage.append(row) - + treeiter = self.lst_storage.append(row) + if row[0] == selected_id: + # restore previous selected row + selection.select_iter(treeiter) + def clear_record(self): self.storage.clear() self.entry['sname'].set_text('') @@ -61,8 +73,8 @@ class StorageView(View): self.spin['wz'].set_value(0) self.spin['angle'].set_value(0) self.spin['capacity'].set_value(0) - combobox.activate_row(self.combo['type'], -1) - combobox.activate_row(self.combo['unit'], -1) + combobox.activate_row(self.combo['type'], storage.GENERIC) + combobox.activate_row(self.combo['unit'], "-1") self.text['remarks'].get_buffer().set_text('') def display_record(self): @@ -79,6 +91,7 @@ class StorageView(View): self.label['remarks'].set_text(self.storage.remarks or '') def edit_record(self): + self.last_valid_rgb = self.storage.color self.entry['sname'].set_text(self.storage.sname) self.spin['x'].set_value(self.storage.x) self.spin['y'].set_value(self.storage.y) @@ -87,17 +100,38 @@ class StorageView(View): self.spin['wy'].set_value(self.storage.wy) self.spin['wz'].set_value(self.storage.wz) self.spin['angle'].set_value(self.storage.angle) - self.spin['capacity'].set_value(self.storage.capacity) + self.spin['capacity'].set_value(self.storage.capacity or 0) combobox.activate_row(self.combo['type'], self.storage.stype) - combobox.activate_row(self.combo['unit'], self.storage.capaunit) - # flags + combobox.activate_row(self.combo['unit'], self.storage.capaunit or -1) + self.entry['color'].set_text('#' + (self.storage.color or '000000')) + rgba = Gdk.RGBA() + rgba.parse('#' + (self.storage.color or '000000')) + self.button['color'].set_rgba(rgba) self.text['remarks'].get_buffer().set_text(self.storage.remarks or '') + def save_record(self): + # fields must have been validated beforehand + self.storage.sname = self.entry['sname'].get_text() + self.storage.stype = combobox.get_list_value(self.combo['type']) + self.storage.x = self.spin['x'].get_value_as_int() + self.storage.y = self.spin['y'].get_value_as_int() + self.storage.z = self.spin['z'].get_value_as_int() + self.storage.wx = self.spin['wx'].get_value_as_int() + self.storage.wy = self.spin['wy'].get_value_as_int() + self.storage.wz = self.spin['wz'].get_value_as_int() + self.storage.angle = self.spin['angle'].get_value_as_int() + self.storage.capacity = self.spin['capacity'].get_value_as_int() + self.storage.capaunit = combobox.get_list_value(self.combo['unit']) + if self.storage.capaunit == '-1': + self.storage.capaunit = None + self.storage.color = self.entry['color'].get_text().lstrip('#') + self.storage.remarks = gtkutils.get_text_contents(self.text['remarks']) + # buttons on list page def on_but_new_clicked(self, widget): self.newrecord = True - self.label['title_edit'].set_text("Add new Storage") self.clear_record() + self.label['title_edit'].set_text(_("Add new Storage")) self.storage.vid = self.context.vessel.vid self.topwidget.set_visible_child(self.box['stor_edit']) @@ -106,7 +140,7 @@ class StorageView(View): if sid is None: return self.newrecord = False - self.label['title_edit'].set_text("Edit Storage") + self.label['title_edit'].set_text(_("Edit Storage")) self.storage.load(sid) self.edit_record() self.topwidget.set_visible_child(self.box['stor_edit']) @@ -133,34 +167,47 @@ class StorageView(View): self.topwidget.set_visible_child(self.box['storage']) def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete storage!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return self.topwidget.set_visible_child(self.box['storage']) self.newrecord = False # buttons on edit page def on_but_save_clicked(self, widget): # check mandatory fields - sname = self.entry['sname'].get_text().strip() - if not sname: + if not self.entry['sname'].get_text().strip(): # TODO error marker return - # get fields from ui form - self.storage.sname = sname - self.storage.stype = combobox.get_list_value(self.combo['type']) - self.storage.x = self.spin['x'].get_value() - self.storage.y = self.spin['y'].get_value() - self.storage.z = self.spin['z'].get_value() - self.storage.wx = self.spin['wx'].get_value() - self.storage.wy = self.spin['wy'].get_value() - self.storage.wz = self.spin['wz'].get_value() - self.storage.angle = self.spin['angle'].get_value() - self.storage.capacity = self.spin['capacity'].get_value() - self.storage.capaunit = combobox.get_list_value(self.combo['unit']) - self.storage.remarks = gtkutils.get_text_contents(self.text['remarks']) + self.save_record() + print(self.storage) self.storage.save() if self.newrecord: self.load_list() + else: + pass + # TODO aktuelle Listenzeile aktualisieren! self.newrecord = False - self.topwidget.set_visible_child(self.box['storage']) + self.display_record() + self.topwidget.set_visible_child(self.box['stor_detail']) + + def on_but_color_set(self, button): + rgba = button.get_rgba() + r = round(rgba.red * 255) + g = round(rgba.green * 255) + b = round(rgba.blue * 255) + self.last_valid_rgb = f"{r:02X}{g:02X}{b:02X}" + self.entry['color'].set_text(f"#{r:02X}{g:02X}{b:02X}") + + def on_ent_color_activate(self, entry): + self.set_color_from_entry(entry) + + def on_ent_color_focus_out_event(self, entry, event): + self.set_color_from_entry(entry) + return False def on_but_cancel_clicked(self, widget): self.topwidget.set_visible_child(self.box['storage']) diff --git a/yms/view/tasks.py b/yms/view/tasks.py index 081f6fd..1df5a45 100644 --- a/yms/view/tasks.py +++ b/yms/view/tasks.py @@ -42,11 +42,81 @@ class TasksView(View): treeview.add_column(self.tree['tasks'], _('Responsible'), 4) self.tree['tasks'].set_model(self.lst_tasks) + # Project + self.dd_project = context.lookup.project(self.context.vessel.vid) + combobox.load_from_dict(self.combo['project'], {-1: _("─── none ───")} | self.dd_project) + + # Priority + self.dd_priority = self.context.lookup.enum('task.priority') + combobox.load_from_dict(self.combo['priority'], self.dd_priority) + + # Status + self.dd_state = self.context.lookup.enum('task.taskstate') + combobox.load_from_dict(self.combo['status'], self.dd_state) + + # Responsible + self.dd_user = context.lookup.user() + combobox.load_from_dict(self.combo['responsible'], self.dd_user) + + def clear_record(self): + self.task.clear() + self.entry['name'].set_text('') + combobox.activate_row(self.combo['project'], -1) + combobox.activate_row(self.combo['priority'], -1) + self.entry['plandate'].set_text('') + self.entry['duedate'].set_text('') + self.entry['started'].set_text('') + self.entry['finished'].set_text('') + combobox.activate_row(self.combo['status'], 'new') + combobox.activate_row(self.combo['responsible'], 0) + self.text['remarks'].get_buffer().set_text('') + + 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): + self.entry['name'].set_text(self.task.taskname) + combobox.activate_row(self.combo['project'], self.task.projid) + combobox.activate_row(self.combo['priority'], self.task.priority) + self.entry['plandate'].set_text(self.task.plandate) + self.entry['duedate'].set_text(self.task.duedate) + self.entry['started'].set_text(self.task.started) + self.entry['finished'].set_text(self.task.finsihed) + 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 '') + + def save_record(self): + # fields must have been validated beforehand + self.task.taskname = self.entry['name'].get_text() + self.task.projid = combobox.get_list_value(self.combo['project']) + self.task.priority = combobox.get_list_value(self.combo['project']) + self.task.plandate = self.entry['plandate'].get_text() + self.task.duedate = self.entry['duedate'].get_text() + self.task.started = self.entry['started'].get_text() + self.task.finished = self.entry['finished'].get_text() + self.task.taskstate = combobox.get_list_value(self.combo['taskstate']) + self.task.resposible = combobox.get_list_value(self.combo['responsible']) + self.project.remarks = gtkutils.get_text_contents(self.text['remarks']) + # buttons on list page def on_but_new_clicked(self, widget): + self.newrecord = True + self.label['title_edit'].set_text(_("Add new Task")) + self.clear_record() self.topwidget.set_visible_child(self.box['task_edit']) def on_but_edit_clicked(self, widget): + self.newrecord = False + self.label['title_edit'].set_text(_("Edit Task")) + taskid = treeview.get_value(self.tree['tasks'], 0) + if not taskid: + return + self.task.load(taskid) + self.edit_record() self.topwidget.set_visible_child(self.box['task_edit']) def on_but_detail_clicked(self, widget): @@ -70,20 +140,23 @@ class TasksView(View): self.topwidget.set_visible_child(self.box['tasks']) def on_but_delete_clicked(self, widget): + answer = gtkutils.questionbox( + _("Delete task!\n" + "Are you sure?"), title="YMS" + ) + if answer == False: + return self.topwidget.set_visible_child(self.box['tasks']) # buttons on edit page def on_but_save_clicked(self, widget): - pass + # check mandatory fields + if not self.entry['taskname'].get_text().strip(): + # TODO error marker + return + self.save_record() + print(self.task) + self.task.save() 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 diff --git a/yms/view/view.py b/yms/view/view.py index 8b15c2c..78d65db 100644 --- a/yms/view/view.py +++ b/yms/view/view.py @@ -2,12 +2,14 @@ """ Generic view object +- with own glade ui file -SPDX-License-Identifier: WTFPL """ + import os import locale from gi.repository import GLib, Gtk, Gdk +from datetime import date, datetime from yms import gtkutils class View: @@ -18,12 +20,31 @@ class View: self.vessel = context.vessel self.user = context.user self._title = title - builder = Gtk.Builder() - builder.set_translation_domain(context.textdomain) - builder.add_from_file(os.path.join(context.ui_path, ui_file)) - builder.connect_signals(self) - self.topwidget = builder.get_object("topobject") - gtkutils.init_named_controls(self, builder) + + locale.bindtextdomain(context.textdomain, context.localedir) + locale.textdomain(context.textdomain) + + self.builder = Gtk.Builder() + self.builder.set_translation_domain(context.textdomain) + self.builder.add_from_file(os.path.join(context.ui_path, ui_file)) + self.builder.connect_signals(self) + + self.topwidget = self.builder.get_object("topobject") + gtkutils.init_named_controls(self, self.builder) + + css = Gtk.CssProvider() + css.load_from_data(b""" + .invalid { + color: #cc0000; + background-color: #ffdddd; + } + """) + + Gtk.StyleContext.add_provider_for_screen( + Gdk.Screen.get_default(), + css, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + ) def format_int(self, ival, separator=True, suffix=None, default=''): if ival is None: @@ -104,3 +125,80 @@ class View: buf.delete(sel_start, sel_end) buf.insert_at_cursor(text) return True + + def set_entry_valid(self, entry, valid): + context = entry.get_style_context() + if valid: + context.remove_class("invalid") + else: + context.add_class("invalid") + + def set_color_from_entry(self, entry): + text = entry.get_text().strip() + rgba = Gdk.RGBA() + if len(text) == 7 and rgba.parse(text): + self.last_valid_rgb = text.lstrip('#') + self.entry['color'].set_text(text) + self.button['color'].set_rgba(rgba) + self.set_entry_valid(self.entry['color'], True) + else: + self.set_entry_valid(self.entry['color'], False) + +class DatePicker: + def __init__(self, entry, button, datefmt='"%d.%m.%Y"'): + self.entry = entry + self.button = button + self.datefmt = datefmt + self.popover = Gtk.Popover.new(self.button) + self.popover.set_position(Gtk.PositionType.BOTTOM) + content = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8) + content.set_border_width(10) + self.calendar = Gtk.Calendar() + self.calendar.set_display_options( + Gtk.CalendarDisplayOptions.SHOW_HEADING + | Gtk.CalendarDisplayOptions.SHOW_DAY_NAMES + | Gtk.CalendarDisplayOptions.SHOW_WEEK_NUMBERS + ) + content.pack_start(self.calendar, True, True, 0) + buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6) + buttons.set_halign(Gtk.Align.END) + self.but_cancel = Gtk.Button(label="Abbrechen") + self.but_apply = Gtk.Button(label="Übernehmen") + buttons.pack_start(self.but_cancel, False, False, 0) + buttons.pack_start(self.but_apply, False, False, 0) + content.pack_start(buttons, False, False, 0) + self.popover.add(content) + self.button.connect("clicked", self._on_open) + self.but_apply.connect("clicked", self._on_apply) + self.but_cancel.connect("clicked", self._on_cancel) + self.popover.show_all() + self.popover.hide() + + def get_date(self): + """Liefert datetime.date oder None bei ungültiger Eingabe.""" + try: + return datetime.strptime(self.entry.get_text().strip(), self.datefmt).date() + except ValueError: + return None + + def set_date(self, value): + """Setzt das Datum mit einem datetime.date-Objekt.""" + if isinstance(value, date): + self.entry.set_text(value.strftime(self.datefmt)) + + def _on_open(self, button): + selected = self.get_date() or date.today() + self.calendar.select_month( + selected.month - 1, + selected.year + ) + self.calendar.select_day(selected.day) + self.popover.show_all() + + def _on_apply(self, button): + year, month, day = self.calendar.get_date() + self.set_date(date(year, month + 1, day)) + self.popover.popdown() + + def _on_cancel(self, button): + self.popover.popdown() diff --git a/ymsgui.py b/ymsgui.py index 384035d..4140cd9 100755 --- a/ymsgui.py +++ b/ymsgui.py @@ -37,7 +37,7 @@ from yms import database from yms import gtkutils, combobox, treeview from yms.model import user from yms.model import vessel -from yms.lookup import Lookup +from yms.lookup import Lookup, Table from yms.view.base import BaseView from yms.view.storage import StorageView @@ -90,7 +90,8 @@ class AppContext: self.user = None self.vessel = None self.ui_path = os.path.join(self.get_sharepath(), "yms", "ui") - self.textdomain = "ymsgui" + self.textdomain = "ymsgui" # static here for early initialization + self.localedir = "locale" self.datefmt = '%d.%m.%Y' # system settings stored in database self.curr_sym = '€' @@ -131,7 +132,17 @@ class AppContext: class Frontend: def __init__(self, context): + self.initializing = True + self.context = context self.db = context.db + builder = Gtk.Builder() + builder.set_translation_domain(context.textdomain) + ui_path = os.path.join(context.ui_path) + builder.add_from_file(os.path.join(ui_path, "main.ui")) + builder.connect_signals(self) + self.window = builder.get_object("wnd_main") + self.notebook = builder.get_object("ntb_modules") + self.modules = { "base": BaseView(context), "storage": StorageView(context), @@ -149,34 +160,61 @@ class Frontend: "documents": DocumentsView(context), "status": StatusView(context) } - builder = Gtk.Builder() - builder.set_translation_domain(context.textdomain) - ui_path = os.path.join(context.ui_path) - builder.add_from_file(os.path.join(ui_path, "main.ui")) - builder.connect_signals(self) - self.window = builder.get_object("wnd_main") - self.notebook = builder.get_object("ntb_modules") + self.moduleindex = {} for module in self.modules.values(): - self.notebook.append_page(module.topwidget, Gtk.Label(label=module._title)) + pageno = self.notebook.append_page(module.topwidget, Gtk.Label(label=module._title)) + self.moduleindex[pageno] = module self.db_poll_ts = context.db.get_timestamp() GLib.timeout_add_seconds(30, self.db_change_poller) + self.initializing = False def run(self): - #self.label['vessel'].set_text(self._vessel.vesselname) self.window.show_all() Gtk.main() def db_change_poller(self): - # get all list ids which changes since last query - print("db list change poller") - #sql = "SELECT revid FROM revision WHERE changed>%s" + # dynamic combobox data refresh + + # look for dropdown entries newer than last check + sql = "SELECT revid FROM revision WHERE revtype='dropdown' AND changed>%s" + self.db.cur.execute(sql, (self.db_poll_ts,)) + for row in self.db.cur.fetchall(): + print(f"refresh dropdown list no.{row[0]}") + self.lookup.reload_dropdown(row[0]) + + # look for table list entries newer than last check + sql = "SELECT revid FROM revision WHERE revtype='table' AND changed>%s" + self.db.cur.execute(sql, (self.db_poll_ts,)) + for row in self.db.cur.fetchall(): + print(f"refresh table based list #{row[0]}") + # TODO get module name für changes in table + modulemap = { + #Table.VESSEL: "base", + #Table.USERS: "base", + Table.COMPANIES: "companies", + Table.STORAGE: "storage", + Table.BOXES: "box", + Table.EQUIPMENT: "equipment", + ##Table.INVENTORY: "inventory" + Table.PROJECTS: "projects", + Table.CABLES: "cables", + Table.FUSES: "fuses", + Table.TAGS: "tags" + } + # execute method from module + self.modules[modulemap[row[0]]].load_list() + self.db_poll_ts = self.db.get_timestamp() return True def on_ntb_modules_switch_page(self, notebook, page, page_num): - print("Neue Seite:", page_num) - # TODO here re-load lists + # signal handler: call view method for e.g. list refresh + if self.initializing: + return + callback = getattr(self.moduleindex[page_num], "on_page_activated", None) + if callable(callback): + callback() def on_destroy(self, widget, data=None): Gtk.main_quit() @@ -199,11 +237,10 @@ def create_config(cfg, cfgfile): if __name__ == "__main__": context = AppContext() - locale.setlocale(locale.LC_ALL, '') - gettext.bindtextdomain(context.textdomain, 'locale') + gettext.bindtextdomain(context.textdomain, context.localedir) gettext.textdomain(context.textdomain) - gettext.install(context.textdomain, 'locale') + gettext.install(context.textdomain, context.localedir) config = configparser.ConfigParser() cfgfile = os.path.expanduser(context.cfg['cfgfile'])