Use combo box instead of textfield for service type. Put in some starting items.
This commit is contained in:
@@ -286,12 +286,25 @@ Kirigami.ApplicationWindow {
|
||||
Kirigami.FormData.label: qsTr("Service Provider")+":"
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
Controls.ComboBox {
|
||||
id: typeField
|
||||
selectByMouse: true
|
||||
model: [qsTr("Oil and Filter Change"), qsTr("Windshield Wiper Replacement"), qsTr("Coolant Change"), qsTr("Tire Rotation"), qsTr("Timing Belt Change"), qsTr("Serpentine Belt Changed"), qsTr("Other")]
|
||||
onActivated: {
|
||||
if(currentText === qsTr("Other")) {
|
||||
customTypeField.visible = true;
|
||||
} else {
|
||||
customTypeField.visible = false;
|
||||
}
|
||||
}
|
||||
Kirigami.FormData.label: qsTr("Service Type")+":"
|
||||
}
|
||||
|
||||
Controls.TextField {
|
||||
id: customTypeField
|
||||
visible: false
|
||||
Kirigami.FormData.label: qsTr("Custom Service Type")+":"
|
||||
}
|
||||
|
||||
Layouts.RowLayout {
|
||||
Kirigami.FormData.label: qsTr("Date")+":"
|
||||
Controls.TextField {
|
||||
@@ -333,8 +346,12 @@ Kirigami.ApplicationWindow {
|
||||
highlighted: true
|
||||
onClicked: {
|
||||
var dateObj = Date.fromLocaleDateString(Qt.locale(), dateField.text);
|
||||
var typeText = typeField.currentText;
|
||||
if(typeField.currentText === qsTr("Other")) {
|
||||
typeText = customTypeField.text;
|
||||
}
|
||||
if(milesField.acceptableInput) {
|
||||
recordModel.addNewRecord(providerField.text, typeField.text, dateObj.toISOString(), parseInt(milesField.text), notesField.text);
|
||||
recordModel.addNewRecord(providerField.text, typeText, dateObj.toISOString(), parseInt(milesField.text), notesField.text);
|
||||
router.popRoute();
|
||||
} else {
|
||||
formError.text = qsTr("Invalid number of miles.");
|
||||
|
||||
Reference in New Issue
Block a user