import QtQuick import QtQuick.Controls import QtQuick.Layouts import "../js/qmldict.js" as JsLib ColumnLayout { id: colPar anchors.fill: parent Label { Layout.alignment: Qt.AlignHCenter | Qt.AlignTop id: headline text: qsTr("Mitarbeiter / Bewerber hinzufügen") font.pixelSize: 35 } ButtonGroup { buttons: radio.children onClicked: { checkFields() personalData.requiredField() } } Row { Layout.fillWidth: true id: radio Layout.columnSpan: 2 RadioButton { checked: true text: qsTr("Bewerber") } RadioButton { text: qsTr("Mitarbeiter") } } RowLayout { Layout.fillWidth: true spacing: 50 Frame { Layout.alignment: Qt.AlignTop Layout.fillWidth: true ApplicantPersonalData { id: personalData width: parent.width } } Frame { Layout.alignment: Qt.AlignTop Layout.fillWidth: true visible: radio.children[1].checked ColumnLayout { Layout.alignment: Qt.AlignTop width: parent.width ApplicantBankData { id: bankAccount } ApplicantNationalInsurance { id: nationalInsurance } ApplicantVarious { id: applicantVarious } } } } RowLayout { Layout.fillHeight: true Layout.alignment: Qt.AlignRight Button { text: qsTr("Abbrechen") onClicked: appLoader.source = "EmployeeTable.qml" } Button { id: saveBtn text: qsTr("Speichern") enabled: false onClicked: { var new_applicant if (radio.children[0].checked) { // Ein Bewerber new_applicant = JsLib.parseForm(personalData) employee_model.addEmployee(new_applicant, false) // appLoader.source = "EmployeeTable.qml" // console.log(JSON.stringify (new_applicant)) } else { // Ein Mitarbeiter // console.log(personalData, bankAccount, nationalInsurance, applicantVarious) new_applicant = JsLib.parseForm(personalData, bankAccount, nationalInsurance, applicantVarious) employee_model.addEmployee(new_applicant, true) // var new_contact = JsLib.addApplicant(addContactLayout) // contact_model.addContact(new_contact) // console.log(JSON.stringify (new_applicant)) } } } } Item { Layout.fillHeight: true } function checkFields() { if(radio.children[1].checked) { if(!personalData.checkPersonalField()) saveBtn.enabled = false else saveBtn.enabled = true } else if (!personalData.checkPersonalField()) saveBtn.enabled = false else saveBtn.enabled = true } }