From 99466c6ceb848cf8147645f25deea89804b7b279 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 10 Oct 2021 21:21:06 +0200 Subject: Filter payments by start and end date --- assets/main.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'assets') diff --git a/assets/main.js b/assets/main.js index 3dd4b6e..1b5620f 100644 --- a/assets/main.js +++ b/assets/main.js @@ -9,6 +9,7 @@ if (path == '/login') { } else if (path == '/') { // Payment table allow_select_reset() + allow_date_reset() } else if (path == '/payment') { // Payment creation @@ -67,6 +68,7 @@ function allow_select_reset() { button.className = 'g-Form__ResetSelect' button.onclick = function() { select.selectedIndex = 0 + button.style = 'visibility: hidden' } if (select.selectedIndex === 0) { button.style = 'visibility: hidden' @@ -79,6 +81,26 @@ function allow_select_reset() { }) } +function allow_date_reset() { + document.querySelectorAll('input[type="date"]').forEach(input => { + const button = document.createElement('input') + button.type = 'button' + button.value = 'Effacer' + button.className = 'g-Form__ResetSelect' + button.onclick = function() { + input.value = '' + button.style = 'visibility: hidden' + } + if (input.value === '') { + button.style = 'visibility: hidden' + } + input.onchange = function() { + button.style = 'visibility: visible' + } + input.parentNode.appendChild(button) + }) +} + function control_remove_button() { const removeInput = document.getElementsByName('remove-input')[0] const removeButton = document.getElementById('remove-button') -- cgit v1.2.3