aboutsummaryrefslogtreecommitdiffstats
path: root/app/javascript/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/helpers')
-rw-r--r--app/javascript/helpers/date_filters.js20
1 files changed, 7 insertions, 13 deletions
diff --git a/app/javascript/helpers/date_filters.js b/app/javascript/helpers/date_filters.js
index 621e163ad..53c9da641 100644
--- a/app/javascript/helpers/date_filters.js
+++ b/app/javascript/helpers/date_filters.js
@@ -1,11 +1,11 @@
export default function DateFilter(buttonId, message, ...inputIds) {
- this.buttonId = buttonId
+ this.button = document.getElementById(buttonId)
this.inputIds = inputIds
this.message = message
const getVal = (str, key) => {
let newStr = str.replace(/NUM/, key)
- return $(newStr).val()
+ return document.getElementById(newStr).value
}
const getDates = () => {
@@ -13,20 +13,14 @@ export default function DateFilter(buttonId, message, ...inputIds) {
let newIds = [1, 2, 3].map(key => getVal(id, key))
arr.push(...newIds)
return arr
- },[])
+ }, [])
}
- const allInputFilled = () => {
- return getDates().every(date => !!date)
- }
-
- const noInputFilled = () => {
- return getDates().every(date => !date)
- }
-
- const button = document.getElementById(this.buttonId)
+ const allInputFilled = () => getDates().every(date => !!date)
- button && button.addEventListener('click', (event) => {
+ const noInputFilled = () => getDates().every(date => !date)
+
+ this.button && this.button.addEventListener('click', (event) => {
if (!allInputFilled() && !noInputFilled()) {
event.preventDefault()
alert(this.message)