Save Button AddCustomer fixed

This commit is contained in:
2024-12-12 12:27:26 +01:00
parent 89dc1d3010
commit 3858d7a46a
6 changed files with 58 additions and 44 deletions

View File

@@ -11,6 +11,8 @@ GridLayout
columns: 2 columns: 2
rowSpacing: 9 rowSpacing: 9
visible: false visible: false
property alias fname: firstname
property alias lname: lastname
Label Label
{ {
@@ -35,6 +37,7 @@ GridLayout
property string name: "firstname" property string name: "firstname"
id: firstname id: firstname
Layout.fillWidth: true Layout.fillWidth: true
onTextChanged: checkFields()
} }
Label Label
@@ -47,6 +50,7 @@ GridLayout
property string name: "lastname" property string name: "lastname"
id: lastname id: lastname
Layout.fillWidth: true Layout.fillWidth: true
onTextChanged: checkFields()
} }
Label Label
{ {
@@ -146,6 +150,17 @@ GridLayout
Layout.fillWidth: true Layout.fillWidth: true
editable: false editable: false
model: ["Nein", "Ja"] model: ["Nein", "Ja"]
}
function checkContactField()
{
if (!firstname.text.trim() || !lastname.text.trim())
{
return false
}
else
{
return true
}
} }
} }

View File

@@ -24,7 +24,11 @@ ColumnLayout
text: qsTr("Ansprechpartner hinzufügen") text: qsTr("Ansprechpartner hinzufügen")
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
checked: false checked: false
onCheckStateChanged: addContactLayout.visible = checked onCheckStateChanged:
{
addContactLayout.visible = checked
checkFields()
}
} }
RowLayout RowLayout
@@ -52,7 +56,6 @@ ColumnLayout
{ {
text: qsTr("Abbrechen") text: qsTr("Abbrechen")
onClicked: appLoader.source = "CustomerTable.qml" onClicked: appLoader.source = "CustomerTable.qml"
} }
Button Button
{ {
@@ -63,18 +66,17 @@ ColumnLayout
{ {
if (!checkAddContact.checked) if (!checkAddContact.checked)
{ {
new_business = JsLib.addBusiness(businessGrid) new_business = JsLib.addBusiness(customerView)
business_model.addBusiness(new_business, 0) business_model.addBusiness(new_business, 0)
appLoader.source = "CustomerTable.qml" appLoader.source = "CustomerTable.qml"
} }
else else
{ {
new_business = JsLib.addBusiness(businessGrid) new_business = JsLib.addBusiness(customerView)
var new_contact = JsLib.addBusiness(addContactLayout) var new_contact = JsLib.addBusiness(addContactLayout)
contact_model.addContact(new_contact) contact_model.addContact(new_contact)
} }
} }
} }
} }
Item Item
@@ -85,19 +87,19 @@ ColumnLayout
Component.onCompleted: contact_model.contactIdReady.connect(onContactId) Component.onCompleted: contact_model.contactIdReady.connect(onContactId)
function isEmptyField() function checkFields()
{ {
if (!firmenName.text.trim() || !streetid.text.trim()) if(checkAddContact.checked)
{ {
saveBtn.enabled = false if(!customerView.checkBusinessField() || !addContactLayout.checkContactField())
}
else
{
if (!postcode.editText.trim() || !postcode.currentText || !city.editText.trim() || !city.currentText)
saveBtn.enabled = false saveBtn.enabled = false
else else
saveBtn.enabled = true saveBtn.enabled = true
} }
else if (!customerView.checkBusinessField())
saveBtn.enabled = false
else
saveBtn.enabled = true
} }
function onContactId(con_id) function onContactId(con_id)

View File

@@ -4,12 +4,15 @@ import QtQuick.Layouts
GridLayout GridLayout
{ {
id: businessGrid id: customerView
columns: 2 columns: 2
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
rowSpacing: 9 rowSpacing: 9
property alias businesstxt: firmenName
property alias street: streetid
property alias postcodetxt: postcode
property alias citytxt: city
Label Label
{ {
id: lblFirmenName id: lblFirmenName
@@ -20,10 +23,11 @@ GridLayout
TextField TextField
{ {
property string name: "business" property string name: "business"
id: firmenName id: firmenName
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
onTextChanged: isEmptyField() onTextChanged: checkFields()
placeholderText: "Pflichtfeld" placeholderText: "Pflichtfeld"
placeholderTextColor: "red" placeholderTextColor: "red"
@@ -41,7 +45,7 @@ GridLayout
property string name: "street" property string name: "street"
id: streetid id: streetid
Layout.fillWidth: true Layout.fillWidth: true
onTextChanged: isEmptyField() onTextChanged: checkFields()
placeholderText: "Pflichtfeld" placeholderText: "Pflichtfeld"
placeholderTextColor: "red" placeholderTextColor: "red"
} }
@@ -57,8 +61,8 @@ GridLayout
id: postcode id: postcode
Layout.fillWidth: true Layout.fillWidth: true
editable: true editable: true
onCurrentTextChanged: isEmptyField() onCurrentTextChanged: checkFields()
onEditTextChanged: isEmptyField() onEditTextChanged: checkFields()
onActivated: currentValue onActivated: currentValue
model: address_model model: address_model
textRole: "display" textRole: "display"
@@ -79,8 +83,8 @@ GridLayout
id: city id: city
Layout.fillWidth: true Layout.fillWidth: true
editable: true editable: true
onEditTextChanged: isEmptyField() onEditTextChanged: checkFields()
onCurrentTextChanged: isEmptyField() onCurrentTextChanged: checkFields()
model: address_model model: address_model
textRole: "city" textRole: "city"
popup.height: 300 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
}
}
} }

View File

@@ -1,28 +1,13 @@
{ {
"files": [ "files": [
"Gui/firststart.qml",
"lib/ConfigLoader.py", "lib/ConfigLoader.py",
"lib/__init__.py", "lib/__init__.py",
"main.py", "main.py",
"Gui/main.qml",
"Gui/Dashboard.qml",
"js/qmldict.js",
"lib/Vermasseln.py", "lib/Vermasseln.py",
"Gui/SearchBar.qml",
"lib/DB/BusinessModel.py", "lib/DB/BusinessModel.py",
"Gui/AddCustomer.qml",
"pyqcrm.qrc", "pyqcrm.qrc",
"Gui/TopBar.qml",
"qml.qrc", "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", "lib/DB/DbManager.py",
"Gui/DbConfiguration.qml",
"lib/DB/UserManager.py", "lib/DB/UserManager.py",
"lib/PyqcrmFlags.py", "lib/PyqcrmFlags.py",
"lib/DB/UserDAO.py", "lib/DB/UserDAO.py",

View File

@@ -17,5 +17,6 @@
<file>fonts/HussarPrintA.otf</file> <file>fonts/HussarPrintA.otf</file>
<file>fonts/LittleBirdsRegular.ttf</file> <file>fonts/LittleBirdsRegular.ttf</file>
<file>fonts/ReginaldScript.ttf</file> <file>fonts/ReginaldScript.ttf</file>
<file>images/account.svg</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -1,9 +0,0 @@
PySide6
platformdirs
pycryptodome
psutil
toml
mariadb