aboutsummaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorIlya Kitaev <mbg033@gmail.com>2016-11-06 19:11:19 +0300
committerIlya Kitaev <mbg033@gmail.com>2016-11-11 00:06:56 +0300
commit02503e44ee1cdac01f48cbc180abb9b8cfcf0bcd (patch)
treeacbfd0bf825a70db102a6a8c1743e686c825beb2 /pages
parent328b7b05d88ad8e7070a2bfd0014c1a0fe5433ec (diff)
downloadmonzero-gui-02503e44ee1cdac01f48cbc180abb9b8cfcf0bcd.tar.gz
monzero-gui-02503e44ee1cdac01f48cbc180abb9b8cfcf0bcd.tar.xz
monzero-gui-02503e44ee1cdac01f48cbc180abb9b8cfcf0bcd.zip
History: amount and date filters validation
Diffstat (limited to 'pages')
-rw-r--r--pages/History.qml51
1 files changed, 49 insertions, 2 deletions
diff --git a/pages/History.qml b/pages/History.qml
index b4764e1c..f9fa9df7 100644
--- a/pages/History.qml
+++ b/pages/History.qml
@@ -66,6 +66,20 @@ Rectangle {
}
}
+ function onFilterChanged() {
+ var datesValid = fromDatePicker.currentDate <= toDatePicker.currentDate
+ var amountsValid = amountFromLine.text === "" ? true :
+ amountToLine.text === "" ? true:
+ parseFloat(amountFromLine.text) <= parseFloat(amountToLine.text)
+
+ // reset error state if amount filter valid
+ if (amountsValid) {
+ amountFromLine.error = amountToLine.error = false
+ }
+
+ filterButton.enabled = datesValid && amountsValid
+ }
+
Text {
id: filterHeaderText
@@ -141,6 +155,9 @@ Rectangle {
anchors.rightMargin: 17
anchors.topMargin: 5
placeholderText: qsTr("16 or 64 hexadecimal characters") + translationManager.emptyString
+ validator: RegExpValidator {
+ regExp: /[0-9a-fA-F]+/
+ }
}
@@ -190,6 +207,10 @@ Rectangle {
anchors.leftMargin: 17
anchors.topMargin: 5
z: 2
+ onCurrentDateChanged: {
+ error = currentDate > toDatePicker.currentDate
+ onFilterChanged()
+ }
}
// DateTo picker
@@ -211,8 +232,14 @@ Rectangle {
anchors.leftMargin: 17
anchors.topMargin: 5
z: 2
+ onCurrentDateChanged: {
+ error = currentDate < fromDatePicker.currentDate
+ onFilterChanged()
+ }
}
+
+
StandardButton {
id: filterButton
anchors.bottom: toDatePicker.bottom
@@ -226,9 +253,15 @@ Rectangle {
pressedColor: "#4D0051"
onClicked: {
// Apply filter here;
+
model.paymentIdFilter = paymentIdLine.text
- model.dateFromFilter = fromDatePicker.currentDate
- model.dateToFilter = toDatePicker.currentDate
+
+ if (fromDatePicker.currentDate > toDatePicker.currentDate) {
+ console.error("Invalid date filter set: ", fromDatePicker.currentDate, toDatePicker.currentDate)
+ } else {
+ model.dateFromFilter = fromDatePicker.currentDate
+ model.dateToFilter = toDatePicker.currentDate
+ }
if (advancedFilteringCheckBox.checked) {
if (amountFromLine.text.length) {
@@ -325,7 +358,14 @@ Rectangle {
validator: DoubleValidator {
locale: "C"
notation: DoubleValidator.StandardNotation
+ bottom: 0
}
+ onTextChanged: {
+ // indicating error
+ amountFromLine.error = amountFromLine.text === "" ? false : parseFloat(amountFromLine.text) > parseFloat(amountToLine.text)
+ onFilterChanged()
+ }
+
}
Label {
@@ -350,6 +390,13 @@ Rectangle {
validator: DoubleValidator {
locale: "C"
notation: DoubleValidator.StandardNotation
+ bottom: 0.0
+ }
+
+ onTextChanged: {
+ // indicating error
+ amountToLine.error = amountToLine.text === "" ? false : parseFloat(amountFromLine.text) > parseFloat(amountToLine.text)
+ onFilterChanged()
}
}