Add basic support for "between" verb, for date range grid filter

this seems to be complete, but we'll see in practice if i forgot something..
This commit is contained in:
Lance Edgar 2019-08-29 17:23:32 -05:00
parent 14778757d9
commit d97f95fb92
4 changed files with 177 additions and 10 deletions

View file

@ -14,6 +14,7 @@ const TailboneDatepicker = {
':value="value ? parseDate(value) : null"',
'@input="dateChanged"',
':disabled="disabled"',
'ref="trueDatePicker"',
'>',
'</b-datepicker>'
].join(' '),
@ -49,7 +50,11 @@ const TailboneDatepicker = {
dateChanged(date) {
this.$emit('input', this.formatDate(date))
}
},
focus() {
this.$refs.trueDatePicker.focus()
},
}
}

View file

@ -1,4 +1,53 @@
const GridFilterDateValue = {
template: '#grid-filter-date-value-template',
props: {
value: String,
dateRange: Boolean,
},
data() {
return {
startDate: null,
endDate: null,
}
},
mounted() {
if (this.dateRange) {
if (this.value.includes('|')) {
let values = this.value.split('|')
if (values.length == 2) {
this.startDate = values[0]
this.endDate = values[1]
} else {
this.startDate = this.value
}
} else {
this.startDate = this.value
}
} else {
this.startDate = this.value
}
},
methods: {
focus() {
this.$refs.startDate.focus()
},
startDateChanged(value) {
if (this.dateRange) {
value += '|' + this.endDate
}
this.$emit('input', value)
},
endDateChanged(value) {
value = this.startDate + '|' + value
this.$emit('input', value)
},
},
}
Vue.component('grid-filter-date-value', GridFilterDateValue)
const GridFilter = {
template: '#grid-filter-template',
props: {
@ -14,6 +63,23 @@ const GridFilter = {
})
},
valuedVerb() {
/* this returns true if the filter's current verb should expose value input(s) */
// if filter has no "valueless" verbs, then all verbs should expose value inputs
if (!this.filter.valueless_verbs) {
return true
}
// if filter *does* have valueless verbs, check if "current" verb is valueless
if (this.filter.valueless_verbs.includes(this.filter.verb)) {
return false
}
// current verb is *not* valueless
return true
},
focusValue: function() {
this.$refs.valueInput.focus()
// this.$refs.valueInput.select()