From 3858d7a46a27f38d22a29e6098456cadc6e60f8e6f689532406d5710bccda6bc Mon Sep 17 00:00:00 2001 From: Daniel Stoppek Date: Thu, 12 Dec 2024 12:27:26 +0100 Subject: [PATCH] Save Button AddCustomer fixed --- Gui/AddContact.qml | 15 +++++++++++++++ Gui/AddCustomer.qml | 26 ++++++++++++++------------ Gui/CustomerView.qml | 36 ++++++++++++++++++++++++++++-------- pyqcrm.pyproject | 15 --------------- pyqcrm.qrc | 1 + requirements.txt | 9 --------- 6 files changed, 58 insertions(+), 44 deletions(-) delete mode 100644 requirements.txt diff --git a/Gui/AddContact.qml b/Gui/AddContact.qml index e05bde2..410ceb4 100644 --- a/Gui/AddContact.qml +++ b/Gui/AddContact.qml @@ -11,6 +11,8 @@ GridLayout columns: 2 rowSpacing: 9 visible: false + property alias fname: firstname + property alias lname: lastname Label { @@ -35,6 +37,7 @@ GridLayout property string name: "firstname" id: firstname Layout.fillWidth: true + onTextChanged: checkFields() } Label @@ -47,6 +50,7 @@ GridLayout property string name: "lastname" id: lastname Layout.fillWidth: true + onTextChanged: checkFields() } Label { @@ -146,6 +150,17 @@ GridLayout Layout.fillWidth: true editable: false model: ["Nein", "Ja"] + } + function checkContactField() + { + if (!firstname.text.trim() || !lastname.text.trim()) + { + return false + } + else + { + return true + } } } diff --git a/Gui/AddCustomer.qml b/Gui/AddCustomer.qml index 8015e9c..bced2c1 100644 --- a/Gui/AddCustomer.qml +++ b/Gui/AddCustomer.qml @@ -24,7 +24,11 @@ ColumnLayout text: qsTr("Ansprechpartner hinzufügen") Layout.alignment: Qt.AlignRight checked: false - onCheckStateChanged: addContactLayout.visible = checked + onCheckStateChanged: + { + addContactLayout.visible = checked + checkFields() + } } RowLayout @@ -52,7 +56,6 @@ ColumnLayout { text: qsTr("Abbrechen") onClicked: appLoader.source = "CustomerTable.qml" - } Button { @@ -63,18 +66,17 @@ ColumnLayout { if (!checkAddContact.checked) { - new_business = JsLib.addBusiness(businessGrid) + new_business = JsLib.addBusiness(customerView) business_model.addBusiness(new_business, 0) appLoader.source = "CustomerTable.qml" } else { - new_business = JsLib.addBusiness(businessGrid) + new_business = JsLib.addBusiness(customerView) var new_contact = JsLib.addBusiness(addContactLayout) contact_model.addContact(new_contact) } } - } } Item @@ -85,19 +87,19 @@ ColumnLayout Component.onCompleted: contact_model.contactIdReady.connect(onContactId) - function isEmptyField() + function checkFields() { - if (!firmenName.text.trim() || !streetid.text.trim()) + if(checkAddContact.checked) { - saveBtn.enabled = false - } - else - { - if (!postcode.editText.trim() || !postcode.currentText || !city.editText.trim() || !city.currentText) + if(!customerView.checkBusinessField() || !addContactLayout.checkContactField()) saveBtn.enabled = false else saveBtn.enabled = true } + else if (!customerView.checkBusinessField()) + saveBtn.enabled = false + else + saveBtn.enabled = true } function onContactId(con_id) diff --git a/Gui/CustomerView.qml b/Gui/CustomerView.qml index cb841f3..943b7ab 100644 --- a/Gui/CustomerView.qml +++ b/Gui/CustomerView.qml @@ -4,12 +4,15 @@ import QtQuick.Layouts GridLayout { - id: businessGrid + id: customerView columns: 2 Layout.fillWidth: true Layout.fillHeight: true rowSpacing: 9 - + property alias businesstxt: firmenName + property alias street: streetid + property alias postcodetxt: postcode + property alias citytxt: city Label { id: lblFirmenName @@ -20,10 +23,11 @@ GridLayout TextField { property string name: "business" + id: firmenName Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter - onTextChanged: isEmptyField() + onTextChanged: checkFields() placeholderText: "Pflichtfeld" placeholderTextColor: "red" @@ -41,7 +45,7 @@ GridLayout property string name: "street" id: streetid Layout.fillWidth: true - onTextChanged: isEmptyField() + onTextChanged: checkFields() placeholderText: "Pflichtfeld" placeholderTextColor: "red" } @@ -57,8 +61,8 @@ GridLayout id: postcode Layout.fillWidth: true editable: true - onCurrentTextChanged: isEmptyField() - onEditTextChanged: isEmptyField() + onCurrentTextChanged: checkFields() + onEditTextChanged: checkFields() onActivated: currentValue model: address_model textRole: "display" @@ -79,8 +83,8 @@ GridLayout id: city Layout.fillWidth: true editable: true - onEditTextChanged: isEmptyField() - onCurrentTextChanged: isEmptyField() + onEditTextChanged: checkFields() + onCurrentTextChanged: checkFields() model: address_model textRole: "city" popup.height: 300 @@ -203,4 +207,20 @@ GridLayout } } } + function checkBusinessField() + { + if (!firmenName.text.trim() || !streetid.text.trim()) + { + return false + + } + else + { + if (!postcode.editText.trim() || !postcode.currentText || !city.editText.trim() || !city.currentText) + return false + else + return true + } + + } } diff --git a/pyqcrm.pyproject b/pyqcrm.pyproject index d605242..32eac10 100644 --- a/pyqcrm.pyproject +++ b/pyqcrm.pyproject @@ -1,28 +1,13 @@ { "files": [ - "Gui/firststart.qml", "lib/ConfigLoader.py", "lib/__init__.py", "main.py", - "Gui/main.qml", - "Gui/Dashboard.qml", - "js/qmldict.js", "lib/Vermasseln.py", - "Gui/SearchBar.qml", "lib/DB/BusinessModel.py", - "Gui/AddCustomer.qml", "pyqcrm.qrc", - "Gui/TopBar.qml", "qml.qrc", - "images/account.svg", - "images/add.svg", - "images/addbusiness.svg", - "images/addperson.svg", - "images/filter.svg", - "images/menu.svg", - "images/search.svg", "lib/DB/DbManager.py", - "Gui/DbConfiguration.qml", "lib/DB/UserManager.py", "lib/PyqcrmFlags.py", "lib/DB/UserDAO.py", diff --git a/pyqcrm.qrc b/pyqcrm.qrc index 80cb98a..ce334d8 100644 --- a/pyqcrm.qrc +++ b/pyqcrm.qrc @@ -17,5 +17,6 @@ fonts/HussarPrintA.otf fonts/LittleBirdsRegular.ttf fonts/ReginaldScript.ttf + images/account.svg diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index b95e0fa..0000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -PySide6 -platformdirs -pycryptodome -psutil -toml -mariadb - - -