mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-17 00:07:51 +00:00
Merge pull request #120
02503e4
History: amount and date filters validation (Ilya Kitaev)328b7b0
History: amount filter: empty line disables filter (Ilya Kitaev)69b4d46
DatePicker: 'error' property for indicating invalid input (Ilya Kitaev)ead7ac8
Historty: DoubleValidator applied to "amount filter" fields (Ilya Kitaev)
This commit is contained in:
commit
fc5fba23d6
2 changed files with 72 additions and 5 deletions
|
@ -35,6 +35,10 @@ Item {
|
|||
property bool expanded: false
|
||||
property date currentDate
|
||||
property bool showCurrentDate: true
|
||||
property color backgroundColor : "#FFFFFF"
|
||||
property color errorColor : "#FFDDDD"
|
||||
property bool error: false
|
||||
|
||||
height: 37
|
||||
width: 156
|
||||
|
||||
|
@ -56,7 +60,6 @@ Item {
|
|||
Item {
|
||||
id: head
|
||||
anchors.fill: parent
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
@ -64,6 +67,7 @@ Item {
|
|||
//radius: 4
|
||||
y: 0
|
||||
color: "#DBDBDB"
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
@ -74,7 +78,7 @@ Item {
|
|||
anchors.rightMargin: datePicker.expanded ? 1 : 0
|
||||
//radius: 4
|
||||
y: 1
|
||||
color: "#FFFFFF"
|
||||
color: datePicker.error ? datePicker.errorColor : datePicker.backgroundColor
|
||||
}
|
||||
|
||||
Item {
|
||||
|
|
|
@ -87,6 +87,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
|
||||
|
@ -162,6 +176,9 @@ Rectangle {
|
|||
anchors.rightMargin: 17
|
||||
anchors.topMargin: 5
|
||||
placeholderText: qsTr("16 or 64 hexadecimal characters") + translationManager.emptyString
|
||||
validator: RegExpValidator {
|
||||
regExp: /[0-9a-fA-F]+/
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -211,6 +228,10 @@ Rectangle {
|
|||
anchors.leftMargin: 17
|
||||
anchors.topMargin: 5
|
||||
z: 2
|
||||
onCurrentDateChanged: {
|
||||
error = currentDate > toDatePicker.currentDate
|
||||
onFilterChanged()
|
||||
}
|
||||
}
|
||||
|
||||
// DateTo picker
|
||||
|
@ -232,7 +253,13 @@ Rectangle {
|
|||
anchors.leftMargin: 17
|
||||
anchors.topMargin: 5
|
||||
z: 2
|
||||
onCurrentDateChanged: {
|
||||
error = currentDate < fromDatePicker.currentDate
|
||||
onFilterChanged()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
StandardButton {
|
||||
id: filterButton
|
||||
|
@ -247,15 +274,29 @@ Rectangle {
|
|||
pressedColor: "#4D0051"
|
||||
onClicked: {
|
||||
// Apply filter here;
|
||||
|
||||
model.paymentIdFilter = paymentIdLine.text
|
||||
|
||||
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) {
|
||||
model.amountFromFilter = parseFloat(amountFromLine.text)
|
||||
} else {
|
||||
// negative value disables filter here;
|
||||
model.amountFromFilter = -1;
|
||||
}
|
||||
|
||||
if (amountToLine.text.length) {
|
||||
model.amountToFilter = parseFloat(amountToLine.text)
|
||||
} else {
|
||||
// negative value disables filter here;
|
||||
model.amountToFilter = -1;
|
||||
}
|
||||
|
||||
var directionFilter = transactionsModel.get(transactionTypeDropdown.currentIndex).value
|
||||
|
@ -264,7 +305,6 @@ Rectangle {
|
|||
}
|
||||
|
||||
selectedAmount.text = getSelectedAmount()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,6 +376,17 @@ Rectangle {
|
|||
anchors.leftMargin: 17
|
||||
anchors.topMargin: 5
|
||||
width: 156
|
||||
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 {
|
||||
|
@ -357,6 +408,18 @@ Rectangle {
|
|||
anchors.leftMargin: 17
|
||||
anchors.topMargin: 5
|
||||
width: 156
|
||||
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()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Item {
|
||||
|
|
Loading…
Reference in a new issue