Somewhat fix errors when adding an applicant

This commit is contained in:
Yuri Becker
2025-04-16 11:00:06 +02:00
parent f0382a960e
commit cf5822c950
5 changed files with 38 additions and 62 deletions

View File

@@ -13,11 +13,12 @@ ColumnLayout {
saveBtn.enabled = true;
}
function onAddNewEmployee(added) {
if (added)
if (added) {
console.log('addedsuccesfully');
else
contentStack.pop();
} else {
console.log('failedtoadd');
contentStack.pop();
}
}
Layout.fillHeight: true
@@ -36,33 +37,25 @@ ColumnLayout {
font.pixelSize: 35
text: qsTr("Mitarbeiter / Bewerber hinzufügen")
}
ButtonGroup {
buttons: radio.children
onClicked: {
checkFields();
personalData.requiredField();
}
}
RowLayout {
Layout.fillWidth: true
spacing: 50
spacing: Dimensions.l
Frame {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
Layout.horizontalStretchFactor: 1
//implicitWidth: parent.width
ApplicantPersonalData {
id: personalData
width: parent.width
implicitWidth: parent.width
}
}
Frame {
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
visible: radio.children[1].checked
Layout.horizontalStretchFactor: 1
ColumnLayout {
Layout.alignment: Qt.AlignTop
@@ -74,7 +67,6 @@ ColumnLayout {
}
ApplicantNationalInsurance {
id: nationalInsurance
}
ApplicantVarious {
id: applicantVarious
@@ -103,7 +95,7 @@ ColumnLayout {
onClicked: {
const new_applicant = JsLib.parseForm(personalData, bankAccount, nationalInsurance, applicantVarious);
employee_model.addEmployee(new_applicant, false);
employee_model.addEmployee(new_applicant);
}
}
}

View File

@@ -95,24 +95,33 @@ ColumnLayout {
id: street
label: qsTr("Straße")
mandatory: true
TextField {
implicitWidth: fieldM
placeholderText: qsTr("Musterstraße")
validator: NotEmptyValidator {
}
}
}
Field {
id: houseno
mandatory: true
label: qsTr("Hausnummer")
TextField {
implicitWidth: fieldS
placeholderText: qsTr("1a")
validator: NotEmptyValidator {
}
}
}
Field {
label: qsTr("PLZ")
mandatory: true
ComboBox {
id: postcode
@@ -125,6 +134,8 @@ ColumnLayout {
onActivated: currentValue
onCurrentIndexChanged: city.currentIndex = postcode.currentIndex
validator: NotEmptyValidator {}
}
}
Field {

View File

@@ -7,14 +7,10 @@ GridLayout {
id: personalData
function checkPersonalField() {
if (radio.children[0].checked) {
return (firstname.text.trim() && lastname.text.trim());
} else {
return (firstname.text.trim() && lastname.text.trim() && street.text.trim() && houseno.text.trim() && (postcode.editText.trim() || postcode.currentText.trim()) && (city.editText.trim() || city.currentText.trim()) && birthday.text.trim() && phonenumber.text.trim() && cellphone.text.trim() && email.text.trim() && jobdescription.text.trim() && contractstart.text.trim() && contractend.text.trim() && briefAnrede.text.trim());
}
return (firstname.text.trim() && lastname.text.trim() && street.text.trim() && houseno.text.trim() && (postcode.editText.trim() || postcode.currentText.trim()) && (city.editText.trim() || city.currentText.trim()) && birthday.text.trim() && phonenumber.text.trim() && cellphone.text.trim() && email.text.trim() && jobdescription.text.trim() && contractstart.text.trim() && contractend.text.trim() && briefAnrede.text.trim());
}
function requiredField() {
var pf = (radio.children[1].checked) ? "Pflichtfeld" : "";
const pf = "Pflichtfeld";
street.placeholderText = pf;
phonenumber.placeholderText = pf;
cellphone.placeholderText = pf;
@@ -131,7 +127,8 @@ GridLayout {
popup.height: 300
textRole: "display"
validator: PostcodeValidator {}
validator: PostcodeValidator {
}
onActivated: currentValue
onCurrentIndexChanged: city.currentIndex = postcode.currentIndex
@@ -160,7 +157,6 @@ GridLayout {
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Geburtsname")
visible: radio.children[1].checked
}
TextField {
id: birthname
@@ -169,14 +165,12 @@ GridLayout {
Layout.columnSpan: 3
Layout.fillWidth: true
visible: radio.children[1].checked
onTextChanged: checkFields()
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Geburtsdatum*")
visible: radio.children[1].checked
}
TextField {
id: birthday
@@ -185,7 +179,6 @@ GridLayout {
Layout.columnSpan: 3
Layout.fillWidth: true
visible: radio.children[1].checked
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}))/
@@ -204,7 +197,6 @@ GridLayout {
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Geburtsort*")
visible: radio.children[1].checked
}
TextField {
id: placeofbirth
@@ -213,7 +205,6 @@ GridLayout {
Layout.columnSpan: 3
Layout.fillWidth: true
visible: radio.children[1].checked
onTextChanged: checkFields()
}
@@ -269,14 +260,14 @@ GridLayout {
placeholderText: qsTr("beispiel@domain.de")
placeholderTextColor: "red"
validator: EmailAddressValidator {}
validator: EmailAddressValidator {
}
onTextChanged: checkFields()
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Familienstand")
visible: radio.children[1].checked
}
ComboBox {
id: maritalstatus
@@ -287,12 +278,10 @@ GridLayout {
Layout.fillWidth: true
editable: false
model: [qsTr("ledig"), qsTr("verheiratet"), qsTr("verwitwet"), qsTr("geschieden")]
visible: radio.children[1].checked
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Stundenlohn")
visible: radio.children[1].checked
}
TextField {
id: salary
@@ -302,14 +291,12 @@ GridLayout {
Layout.columnSpan: 3
Layout.fillWidth: true
placeholderTextColor: "red"
visible: radio.children[1].checked
onTextChanged: checkFields()
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Jobbeschreibung")
visible: radio.children[1].checked
}
TextField {
id: jobdescription
@@ -319,14 +306,12 @@ GridLayout {
Layout.columnSpan: 3
Layout.fillWidth: true
placeholderTextColor: "red"
visible: radio.children[1].checked
onTextChanged: checkFields()
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Vertragsbeginn")
visible: radio.children[1].checked
}
TextField {
id: contractstart
@@ -336,7 +321,6 @@ GridLayout {
Layout.columnSpan: 3
Layout.fillWidth: true
placeholderTextColor: "red"
visible: radio.children[1].checked
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}))/
@@ -355,7 +339,6 @@ GridLayout {
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Vertragsende")
visible: radio.children[1].checked
}
TextField {
id: contractend
@@ -365,7 +348,6 @@ GridLayout {
Layout.columnSpan: 3
Layout.fillWidth: true
placeholderTextColor: "red"
visible: radio.children[1].checked
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}))/
@@ -384,7 +366,6 @@ GridLayout {
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Arbeitszeiten Tage")
visible: radio.children[1].checked
}
ComboBox {
id: workdays
@@ -393,12 +374,10 @@ GridLayout {
Layout.fillWidth: true
model: ["1", "2", "3", "4", "5", "6", "7"]
visible: radio.children[1].checked
}
Label {
Layout.alignment: Qt.AlignRight
text: qsTr("Stunden")
visible: radio.children[1].checked
}
ComboBox {
id: workhours
@@ -407,7 +386,6 @@ GridLayout {
Layout.fillWidth: true
model: ["1", "2", "3", "4", "5", "6", "7", "8"]
visible: radio.children[1].checked
}
Label {
Layout.alignment: Qt.AlignRight