116 lines
2.7 KiB
QML
116 lines
2.7 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import QtQuick.Controls
|
|
import QtQuick.Controls.Fusion
|
|
import QtQuick.Dialogs
|
|
import "../js/qmldict.js" as JsLib
|
|
|
|
ColumnLayout
|
|
{
|
|
property var new_business: null
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
spacing: 15
|
|
Label
|
|
{
|
|
text: qsTr("Kunden anlegen")
|
|
horizontalAlignment: Text.AlignHCenter
|
|
Layout.fillWidth: true
|
|
font.pixelSize: 35
|
|
}
|
|
CheckBox
|
|
{
|
|
id: checkAddContact
|
|
text: qsTr("Ansprechpartner hinzufügen")
|
|
Layout.alignment: Qt.AlignRight
|
|
checked: false
|
|
onCheckStateChanged:
|
|
{
|
|
addContactLayout.visible = checked
|
|
checkFields()
|
|
}
|
|
}
|
|
|
|
RowLayout
|
|
{
|
|
id: addCustomer
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
spacing: 45
|
|
|
|
CustomerView
|
|
{
|
|
id: customerView
|
|
}
|
|
|
|
AddContact
|
|
{
|
|
id: addContactLayout
|
|
}
|
|
}
|
|
RowLayout
|
|
{
|
|
Layout.fillHeight: true
|
|
Layout.alignment: Qt.AlignRight
|
|
Button
|
|
{
|
|
text: qsTr("Abbrechen")
|
|
onClicked: appLoader.source = "CustomerTable.qml"
|
|
}
|
|
Button
|
|
{
|
|
id: saveBtn
|
|
text: qsTr("Speichern")
|
|
enabled: false
|
|
onClicked:
|
|
{
|
|
if (!checkAddContact.checked)
|
|
{
|
|
new_business = JsLib.addBusiness(customerView)
|
|
business_model.addBusiness(new_business, 0)
|
|
appLoader.source = "CustomerTable.qml"
|
|
}
|
|
else
|
|
{
|
|
new_business = JsLib.addBusiness(customerView)
|
|
var new_contact = JsLib.addBusiness(addContactLayout)
|
|
contact_model.addContact(new_contact)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Item
|
|
{
|
|
id: spacer3
|
|
Layout.fillHeight: true
|
|
}
|
|
|
|
//Component.onCompleted: contact_model.contactIdReady.connect(onContactId)
|
|
|
|
Connections
|
|
{
|
|
target: contact_model
|
|
onContactIdReady:
|
|
{
|
|
var con_id = arguments[0]
|
|
business_model.addBusiness(new_business, con_id)
|
|
appLoader.source = "CustomerTable.qml"
|
|
}
|
|
}
|
|
|
|
function checkFields()
|
|
{
|
|
if(checkAddContact.checked)
|
|
{
|
|
if(!customerView.checkBusinessField() || !addContactLayout.checkContactField())
|
|
saveBtn.enabled = false
|
|
else
|
|
saveBtn.enabled = true
|
|
}
|
|
else if (!customerView.checkBusinessField())
|
|
saveBtn.enabled = false
|
|
else
|
|
saveBtn.enabled = true
|
|
}
|
|
}
|