Add "between" verb for numeric grid filters
This commit is contained in:
		
							parent
							
								
									3e8924e7cc
								
							
						
					
					
						commit
						deed2111fb
					
				
					 3 changed files with 134 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,53 @@
 | 
			
		|||
 | 
			
		||||
const GridFilterNumericValue = {
 | 
			
		||||
    template: '#grid-filter-numeric-value-template',
 | 
			
		||||
    props: {
 | 
			
		||||
        value: String,
 | 
			
		||||
        wantsRange: Boolean,
 | 
			
		||||
    },
 | 
			
		||||
    data() {
 | 
			
		||||
        return {
 | 
			
		||||
            startValue: null,
 | 
			
		||||
            endValue: null,
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    mounted() {
 | 
			
		||||
        if (this.wantsRange) {
 | 
			
		||||
            if (this.value.includes('|')) {
 | 
			
		||||
                let values = this.value.split('|')
 | 
			
		||||
                if (values.length == 2) {
 | 
			
		||||
                    this.startValue = values[0]
 | 
			
		||||
                    this.endValue = values[1]
 | 
			
		||||
                } else {
 | 
			
		||||
                    this.startValue = this.value
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                this.startValue = this.value
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            this.startValue = this.value
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    methods: {
 | 
			
		||||
        focus() {
 | 
			
		||||
            this.$refs.startValue.focus()
 | 
			
		||||
        },
 | 
			
		||||
        startValueChanged(value) {
 | 
			
		||||
            if (this.wantsRange) {
 | 
			
		||||
                value += '|' + this.endValue
 | 
			
		||||
            }
 | 
			
		||||
            this.$emit('input', value)
 | 
			
		||||
        },
 | 
			
		||||
        endValueChanged(value) {
 | 
			
		||||
            value = this.startValue + '|' + value
 | 
			
		||||
            this.$emit('input', value)
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Vue.component('grid-filter-numeric-value', GridFilterNumericValue)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const GridFilterDateValue = {
 | 
			
		||||
    template: '#grid-filter-date-value-template',
 | 
			
		||||
    props: {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue