Check and display for some invalid inputs.
This commit is contained in:
@@ -117,6 +117,15 @@ Kirigami.ApplicationWindow {
|
|||||||
title: qsTr("Add Vehicle")
|
title: qsTr("Add Vehicle")
|
||||||
Layouts.ColumnLayout {
|
Layouts.ColumnLayout {
|
||||||
anchors.fill: parent
|
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 {
|
Kirigami.FormLayout {
|
||||||
Layouts.Layout.alignment: Qt.AlignHCenter
|
Layouts.Layout.alignment: Qt.AlignHCenter
|
||||||
Layouts.Layout.fillWidth: true
|
Layouts.Layout.fillWidth: true
|
||||||
@@ -168,8 +177,13 @@ Kirigami.ApplicationWindow {
|
|||||||
text: qsTr("Add")
|
text: qsTr("Add")
|
||||||
highlighted: true
|
highlighted: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
vehicleModel.addNewVehicle(nameField.text, makeField.text, modelField.text, parseInt(yearField.text), "", vinField.text);
|
if(yearField.acceptableInput) {
|
||||||
router.popRoute();
|
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")
|
title: qsTr("Add Service Record")
|
||||||
Layouts.ColumnLayout {
|
Layouts.ColumnLayout {
|
||||||
anchors.fill: parent
|
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 {
|
Kirigami.FormLayout {
|
||||||
Layouts.Layout.alignment: Qt.AlignHCenter
|
Layouts.Layout.alignment: Qt.AlignHCenter
|
||||||
Layouts.Layout.fillWidth: true
|
Layouts.Layout.fillWidth: true
|
||||||
@@ -293,7 +316,7 @@ Kirigami.ApplicationWindow {
|
|||||||
inputMethodHints: Qt.ImhDigitsOnly
|
inputMethodHints: Qt.ImhDigitsOnly
|
||||||
validator: IntValidator {
|
validator: IntValidator {
|
||||||
bottom: 0
|
bottom: 0
|
||||||
top: 400000
|
top: 500000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,8 +332,13 @@ Kirigami.ApplicationWindow {
|
|||||||
text: qsTr("Add")
|
text: qsTr("Add")
|
||||||
highlighted: true
|
highlighted: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
recordModel.addNewRecord(providerField.text, typeField.text, -1, parseInt(milesField.text), notesField.text); //TODO: add proper date
|
if(milesField.acceptableInput) {
|
||||||
router.popRoute();
|
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 {
|
Controls.Button {
|
||||||
|
|||||||
Reference in New Issue
Block a user