import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

GridLayout
{
    id: newObject

    columns: 4
    Layout.fillWidth: true
    Layout.fillHeight: true
    rowSpacing: 9

    //New Grid
    Label
    {
        text: qsTr("Objekt:")
        Layout.alignment: Qt.AlignRight
        font: Typography.h2


    }
    Item
    {
        Layout.columnSpan: 3
    }

    //New grid row
    Label
    {
        text: qsTr("Objekt-Nr.")
        Layout.alignment: Qt.AlignRight
    }
    TextField
    {
        property string name: "objectno"
        id: objectno
        Layout.fillWidth: true
        Layout.alignment: Qt.AlignVCenter
    }

    Button
    {
        text: qsTr("Objekt hinzufügen")
        icon.source: "qrc:/images/PlusCircle.svg"
    }
    Item
    {

    }


    //// New grid row

    Label
    {
        text: qsTr("Straße")
        Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
    }

    TextField
    {
        property string name: "street"
        id: street
        Layout.fillWidth: true
        Layout.alignment: Qt.AlignVCenter
        // onTextChanged: checkFields()
    }

    Label
    {
        text: qsTr("Nr.*")
        Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
    }

    TextField
    {
        property string name: "houseno"
        id: houseno
        Layout.fillWidth: true
        Layout.alignment: Qt.AlignVCenter
        // onTextChanged: checkFields()
    }

    // New grid row
    Label
    {
        text: qsTr("PLZ")
        Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
    }

    ComboBox
    {
        property string name: "postcode"
        id: postcode
        Layout.fillWidth: true
        editable: true
        // onCurrentTextChanged: checkFields()
        // onEditTextChanged: checkFields()
        onActivated: currentValue
        model: address_model
        textRole: "display"
        popup.height: 300
        currentIndex: -1
        onCurrentIndexChanged: city.currentIndex = postcode.currentIndex

        validator: RegularExpressionValidator
        {
            regularExpression: /([0-9]{1,5})/
        }
    }

    Label
    {
        text: qsTr("Ort")
        Layout.alignment: Qt.AlignRight

    }

    ComboBox
    {
        property string name: "city"
        id: city
        Layout.fillWidth: true
        editable: true
        // onEditTextChanged: checkFields()
        // onCurrentTextChanged: checkFields()
        model: address_model
        textRole: "city"
        popup.height: 300
        currentIndex: -1
    }

    //New Grid
    Label
    {
        text: qsTr("Kunde:")
        Layout.alignment: Qt.AlignRight
        font: Typography.h2


    }
    Item
    {
        Layout.columnSpan: 3
    }

    //New grid row
    Label
    {
        text: qsTr("Kunden-Nr.")
        Layout.alignment: Qt.AlignRight
    }

    TextField
    {
        property string name: "customerno"
        id: customerno
        Layout.fillWidth: true
        Layout.alignment: Qt.AlignVCenter
    }
    Button
    {
        text: qsTr("Kunde hinzufügen")
        icon.source: "qrc:/images/PlusCircle.svg"
    }
    Item
    {

    }


    // New grid row
    Label
    {
        text: qsTr("Kunden-Name")
        Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
    }

    TextField
    {

        id: customerName
        Layout.fillWidth: true
        Layout.alignment: Qt.AlignVCenter
    }



    Item
    {
        Layout.fillHeight: true
    }

    // function checkObjectField()
    // {

    //     return  street.text.trim() && houseno.text.trim() &&

    //             (postcode.editText.trim() || postcode.currentText.trim()) &&
    //             (city.editText.trim() || city.currentText.trim()) &&
    //             cleaningproducts.text.trim()
    // }
}









