diff --git a/src/contents/ui/main.qml b/src/contents/ui/main.qml index 83d2d51fc657b8879aec9c002d686b7f87541191..3e0718ae9f59c03a3f3126cff642e7884bba7d69 100644 --- a/src/contents/ui/main.qml +++ b/src/contents/ui/main.qml @@ -117,6 +117,15 @@ Kirigami.ApplicationWindow { title: qsTr("Add Vehicle") Layouts.ColumnLayout { anchors.fill: parent + Kirigami.InlineMessage { + Layouts.Layout.fillWidth: true + Layouts.Layout.leftMargin: 10 + Layouts.Layout.rightMargin: 10 + z: 9997 + type: Kirigami.MessageType.Error + showCloseButton: true + id: formError + } Kirigami.FormLayout { Layouts.Layout.alignment: Qt.AlignHCenter Layouts.Layout.fillWidth: true @@ -168,8 +177,13 @@ Kirigami.ApplicationWindow { text: qsTr("Add") highlighted: true onClicked: { - vehicleModel.addNewVehicle(nameField.text, makeField.text, modelField.text, parseInt(yearField.text), "", vinField.text); - router.popRoute(); + if(yearField.acceptableInput) { + vehicleModel.addNewVehicle(nameField.text, makeField.text, modelField.text, parseInt(yearField.text), "", vinField.text); + router.popRoute(); + } else { + formError.text = qsTr("Year is invalid!"); + formError.visible = true; + } } } @@ -247,6 +261,15 @@ Kirigami.ApplicationWindow { title: qsTr("Add Service Record") Layouts.ColumnLayout { anchors.fill: parent + Kirigami.InlineMessage { + Layouts.Layout.fillWidth: true + Layouts.Layout.leftMargin: 10 + Layouts.Layout.rightMargin: 10 + z: 9997 + type: Kirigami.MessageType.Error + showCloseButton: true + id: formError + } Kirigami.FormLayout { Layouts.Layout.alignment: Qt.AlignHCenter Layouts.Layout.fillWidth: true @@ -293,7 +316,7 @@ Kirigami.ApplicationWindow { inputMethodHints: Qt.ImhDigitsOnly validator: IntValidator { bottom: 0 - top: 400000 + top: 500000 } } @@ -309,8 +332,13 @@ Kirigami.ApplicationWindow { text: qsTr("Add") highlighted: true onClicked: { - recordModel.addNewRecord(providerField.text, typeField.text, -1, parseInt(milesField.text), notesField.text); //TODO: add proper date - router.popRoute(); + if(milesField.acceptableInput) { + recordModel.addNewRecord(providerField.text, typeField.text, -1, parseInt(milesField.text), notesField.text); //TODO: add proper date + router.popRoute(); + } else { + formError.text = qsTr("Invalid number of miles."); + formError.visible = true; + } } } Controls.Button {