diff --git a/Gui/AddContact.qml b/Gui/AddContact.qml index ee198cc..165611b 100644 --- a/Gui/AddContact.qml +++ b/Gui/AddContact.qml @@ -4,187 +4,190 @@ import QtQuick.Layouts Frame { + id: addContactFrame + property alias contactGrid: addContactLayout Layout.alignment: Qt.AlignTop Layout.fillWidth: true -GridLayout -{ - id: addContactLayout - anchors.fill: parent - // Layout.fillWidth: true - // Layout.fillHeight: true - // Layout.alignment: Qt.AlignTop - columns: 2 - rowSpacing: 9 - property alias fname: firstname - property alias lname: lastname + GridLayout + { + id: addContactLayout + anchors.fill: parent + // Layout.fillWidth: true + // Layout.fillHeight: true + // Layout.alignment: Qt.AlignTop + columns: 2 + rowSpacing: 9 + property alias fname: firstname + property alias lname: lastname - Label - { - text: qsTr("Anrede") - Layout.alignment: Qt.AlignRight - } - ComboBox - { - property string name: "title" - id: title - Layout.fillWidth: true - editable: false - model: ["Herr", "Frau"] - } - Label - { - text: qsTr("Vorname") - Layout.alignment: Qt.AlignRight - } - TextField - { - property string name: "firstname" - id: firstname - Layout.fillWidth: true - onTextChanged: checkFields() - } - - Label - { - text: qsTr("Nachname") - Layout.alignment: Qt.AlignRight - } - TextField - { - property string name: "lastname" - id: lastname - Layout.fillWidth: true - onTextChanged: checkFields() - } - Label - { - text: qsTr("Position") - Layout.alignment: Qt.AlignRight - } - ComboBox - { - property string name: "jobdescription" - id: jobdescription - Layout.fillWidth: true - editable: true - } - Label - { - text: qsTr("E-Mail") - Layout.alignment: Qt.AlignRight - } - TextField - { - property string name: "email" - id: emailcontact - Layout.fillWidth: true - placeholderText: qsTr("beispiel@domain.de") - validator: RegularExpressionValidator + Label { - regularExpression: /([\+!#$%&‘\*\–\/\=?\^_`\.{|}\~0-9A-Za-z]{1,185})@([0-9A-Za-z\.]{1,64})\.([a-zA-z]{2,5})/ + text: qsTr("Anrede") + Layout.alignment: Qt.AlignRight } - } - - Label - { - text: qsTr("Telefon") - Layout.alignment: Qt.AlignRight - } - TextField - { - property string name: "telephonecontact" - id: telephonecontact - Layout.fillWidth: true - validator: RegularExpressionValidator + ComboBox { - regularExpression: /([+0-9]{1})([0-9]{1,17})/ + property string name: "title" + id: title + Layout.fillWidth: true + editable: false + model: ["Herr", "Frau"] } - } - - Label - { - text: qsTr("Handy") - Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - } - TextField - { - property string name: "cellphone" - id: cellphone - Layout.fillWidth: true - validator: RegularExpressionValidator + Label { - regularExpression: /([+0-9]{1})([0-9]{1,17})/ + text: qsTr("Vorname") + Layout.alignment: Qt.AlignRight } - } - Label - { - text: qsTr("Geburtsdatum") - Layout.alignment: Qt.AlignRight - } - - TextField - { - property string name: "birthday" - id: birthday - Layout.fillWidth: true - placeholderText: qsTr("TT.MM.JJJJ") - validator: RegularExpressionValidator - + TextField { - regularExpression: /((^|)(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]))\.((^|)(0[1-9]{1}|1[0-2]{1}))\.((^|)(196[0-9]{1}|19[7-9]{1}[0-9]{1}|20[0-9]{2}))/ + property string name: "firstname" + id: firstname + Layout.fillWidth: true + onTextChanged: checkFields() } - Keys.onPressed: (event)=> + + Label { - if (event.key !== Qt.Key_Backspace) + text: qsTr("Nachname") + Layout.alignment: Qt.AlignRight + } + TextField + { + property string name: "lastname" + id: lastname + Layout.fillWidth: true + onTextChanged: checkFields() + } + Label + { + text: qsTr("Position") + Layout.alignment: Qt.AlignRight + } + ComboBox + { + property string name: "jobdescription" + id: jobdescription + Layout.fillWidth: true + editable: true + } + Label + { + text: qsTr("E-Mail") + Layout.alignment: Qt.AlignRight + } + TextField + { + property string name: "email" + id: emailcontact + Layout.fillWidth: true + placeholderText: qsTr("beispiel@domain.de") + validator: RegularExpressionValidator { - var len = birthday.length - var bd = birthday.text - if (len === 2 || len === 5) birthday.text = bd + "." + regularExpression: /([\+!#$%&‘\*\–\/\=?\^_`\.{|}\~0-9A-Za-z]{1,185})@([0-9A-Za-z\.]{1,64})\.([a-zA-z]{2,5})/ + } + } + + Label + { + text: qsTr("Telefon") + Layout.alignment: Qt.AlignRight + } + TextField + { + property string name: "telephonecontact" + id: telephonecontact + Layout.fillWidth: true + validator: RegularExpressionValidator + { + regularExpression: /([+0-9]{1})([0-9]{1,17})/ + } + } + + Label + { + text: qsTr("Handy") + Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + } + TextField + { + property string name: "cellphone" + id: cellphone + Layout.fillWidth: true + validator: RegularExpressionValidator + { + regularExpression: /([+0-9]{1})([0-9]{1,17})/ + } + } + Label + { + text: qsTr("Geburtsdatum") + Layout.alignment: Qt.AlignRight + } + + TextField + { + property string name: "birthday" + id: birthday + Layout.fillWidth: true + placeholderText: qsTr("TT.MM.JJJJ") + validator: RegularExpressionValidator + + { + regularExpression: /((^|)(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]))\.((^|)(0[1-9]{1}|1[0-2]{1}))\.((^|)(196[0-9]{1}|19[7-9]{1}[0-9]{1}|20[0-9]{2}))/ + } + Keys.onPressed: (event)=> + { + if (event.key !== Qt.Key_Backspace) + { + var len = birthday.length + var bd = birthday.text + if (len === 2 || len === 5) birthday.text = bd + "." + } + } } - } - - Label - { - text: qsTr("Priorität") - Layout.alignment: Qt.AlignRight - } - ComboBox - { - property string name: "rank" - id: rank - Layout.fillWidth: true - editable: false - model: ["Nein", "Ja"] - } - Label - { - text: qsTr("Rechnung") - Layout.alignment: Qt.AlignRight - } - ComboBox - { - property string name: "invoice" - id: invoice - Layout.fillWidth: true - editable: false - objectName: "combo" - model: ["Nein", "Ja"] - } - Label - { - text: qsTr("Mahnung") - Layout.alignment: Qt.AlignRight - } - ComboBox - { - property string name: "due" - id: due - Layout.fillWidth: true - editable: false - model: ["Nein", "Ja"] + Label + { + text: qsTr("Priorität") + Layout.alignment: Qt.AlignRight + } + ComboBox + { + property string name: "rank" + id: rank + Layout.fillWidth: true + editable: false + model: ["Nein", "Ja"] + } + Label + { + text: qsTr("Rechnung") + Layout.alignment: Qt.AlignRight + } + ComboBox + { + property string name: "invoice" + id: invoice + Layout.fillWidth: true + editable: false + objectName: "combo" + model: ["Nein", "Ja"] + } + Label + { + text: qsTr("Mahnung") + Layout.alignment: Qt.AlignRight + } + ComboBox + { + property string name: "due" + id: due + Layout.fillWidth: true + editable: false + model: ["Nein", "Ja"] + } } function checkContactField() @@ -199,4 +202,3 @@ GridLayout } } } -} diff --git a/Gui/AddCustomer.qml b/Gui/AddCustomer.qml index c89e416..49244ad 100644 --- a/Gui/AddCustomer.qml +++ b/Gui/AddCustomer.qml @@ -49,7 +49,7 @@ ColumnLayout AddContact { - //id: addContactLayout + id: addContactFrame visible: checkAddContact.checked } } @@ -78,7 +78,7 @@ ColumnLayout else { new_business = JsLib.addBusiness(customerView) - var new_contact = JsLib.addBusiness(addContactLayout) + var new_contact = JsLib.addBusiness(addContactFrame.contactGrid) contact_model.addContact(new_contact) } } @@ -108,7 +108,7 @@ ColumnLayout { if(checkAddContact.checked) { - if(!customerView.checkBusinessField() || !addContactLayout.checkContactField()) + if(!customerView.checkBusinessField() || !addContactFrame.checkContactField()) saveBtn.enabled = false else saveBtn.enabled = true