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 bool expanded: false
|
||||||
property date currentDate
|
property date currentDate
|
||||||
property bool showCurrentDate: true
|
property bool showCurrentDate: true
|
||||||
|
property color backgroundColor : "#FFFFFF"
|
||||||
|
property color errorColor : "#FFDDDD"
|
||||||
|
property bool error: false
|
||||||
|
|
||||||
height: 37
|
height: 37
|
||||||
width: 156
|
width: 156
|
||||||
|
|
||||||
|
@ -56,7 +60,6 @@ Item {
|
||||||
Item {
|
Item {
|
||||||
id: head
|
id: head
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
@ -64,6 +67,7 @@ Item {
|
||||||
//radius: 4
|
//radius: 4
|
||||||
y: 0
|
y: 0
|
||||||
color: "#DBDBDB"
|
color: "#DBDBDB"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -74,7 +78,7 @@ Item {
|
||||||
anchors.rightMargin: datePicker.expanded ? 1 : 0
|
anchors.rightMargin: datePicker.expanded ? 1 : 0
|
||||||
//radius: 4
|
//radius: 4
|
||||||
y: 1
|
y: 1
|
||||||
color: "#FFFFFF"
|
color: datePicker.error ? datePicker.errorColor : datePicker.backgroundColor
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
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 {
|
Text {
|
||||||
id: filterHeaderText
|
id: filterHeaderText
|
||||||
|
@ -162,6 +176,9 @@ Rectangle {
|
||||||
anchors.rightMargin: 17
|
anchors.rightMargin: 17
|
||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
placeholderText: qsTr("16 or 64 hexadecimal characters") + translationManager.emptyString
|
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.leftMargin: 17
|
||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
z: 2
|
z: 2
|
||||||
|
onCurrentDateChanged: {
|
||||||
|
error = currentDate > toDatePicker.currentDate
|
||||||
|
onFilterChanged()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DateTo picker
|
// DateTo picker
|
||||||
|
@ -232,8 +253,14 @@ Rectangle {
|
||||||
anchors.leftMargin: 17
|
anchors.leftMargin: 17
|
||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
z: 2
|
z: 2
|
||||||
|
onCurrentDateChanged: {
|
||||||
|
error = currentDate < fromDatePicker.currentDate
|
||||||
|
onFilterChanged()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
StandardButton {
|
StandardButton {
|
||||||
id: filterButton
|
id: filterButton
|
||||||
anchors.bottom: toDatePicker.bottom
|
anchors.bottom: toDatePicker.bottom
|
||||||
|
@ -247,15 +274,29 @@ Rectangle {
|
||||||
pressedColor: "#4D0051"
|
pressedColor: "#4D0051"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// Apply filter here;
|
// Apply filter here;
|
||||||
|
|
||||||
model.paymentIdFilter = paymentIdLine.text
|
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 (advancedFilteringCheckBox.checked) {
|
||||||
if (amountFromLine.text.length) {
|
if (amountFromLine.text.length) {
|
||||||
model.amountFromFilter = parseFloat(amountFromLine.text)
|
model.amountFromFilter = parseFloat(amountFromLine.text)
|
||||||
|
} else {
|
||||||
|
// negative value disables filter here;
|
||||||
|
model.amountFromFilter = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amountToLine.text.length) {
|
if (amountToLine.text.length) {
|
||||||
model.amountToFilter = parseFloat(amountToLine.text)
|
model.amountToFilter = parseFloat(amountToLine.text)
|
||||||
|
} else {
|
||||||
|
// negative value disables filter here;
|
||||||
|
model.amountToFilter = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var directionFilter = transactionsModel.get(transactionTypeDropdown.currentIndex).value
|
var directionFilter = transactionsModel.get(transactionTypeDropdown.currentIndex).value
|
||||||
|
@ -264,7 +305,6 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedAmount.text = getSelectedAmount()
|
selectedAmount.text = getSelectedAmount()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,6 +376,17 @@ Rectangle {
|
||||||
anchors.leftMargin: 17
|
anchors.leftMargin: 17
|
||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
width: 156
|
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 {
|
Label {
|
||||||
|
@ -357,6 +408,18 @@ Rectangle {
|
||||||
anchors.leftMargin: 17
|
anchors.leftMargin: 17
|
||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
width: 156
|
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 {
|
Item {
|
||||||
|
|
Loading…
Reference in a new issue