|
209 | 209 | },
|
210 | 210 | });
|
211 | 211 |
|
212 |
| - function areAllInputsEmptyOrUnchecked() { |
213 |
| - const isChecked = document.getElementById('current_user').checked; |
214 |
| - const searchText = document.getElementById('search_text').value.trim(); |
215 |
| - const tagValue = document.getElementById('tag_doc').value.trim(); |
216 |
| - const dateUpdateBlogAfter = document.getElementById('dateUpdateBlogAfter').value.trim(); |
217 |
| - const dateUpdateBlogBefore = document.getElementById('dateUpdateBlogBefore').value.trim(); |
218 |
| - const blogStatus = document.getElementById('blog_status').value.trim(); // Added blog_status |
| 212 | + // Check if all inputs are empty or unchecked |
219 | 213 |
|
220 |
| - return !isChecked && |
221 |
| - searchText === '' && |
222 |
| - tagValue === '' && |
223 |
| - dateUpdateBlogAfter === '' && |
224 |
| - dateUpdateBlogBefore === '' && |
225 |
| - blogStatus === '0'; // Adjusted to check for '0' status as well |
| 214 | + function areAllInputsEmptyOrUnchecked() { |
| 215 | + const isChecked = document.getElementById('current_user').checked; |
| 216 | + const searchText = document.getElementById('search_text').value.trim(); |
| 217 | + const tagValue = document.getElementById('tag_doc').selectedOptions.length > 0 |
| 218 | + const dateUpdateBlogAfter = document.getElementById('dateUpdateBlogAfter').value.trim(); |
| 219 | + const dateUpdateBlogBefore = document.getElementById('dateUpdateBlogBefore').value.trim(); |
| 220 | + const blogStatus = document.getElementById('unpublished').value; |
| 221 | +// Debug output |
| 222 | + console.log({ |
| 223 | + isChecked, |
| 224 | + searchText, |
| 225 | + tagValue, |
| 226 | + dateUpdateBlogAfter, |
| 227 | + dateUpdateBlogBefore, |
| 228 | + blogStatus |
| 229 | + }); |
| 230 | + return !isChecked && |
| 231 | + (searchText === '' || searchText === null) && |
| 232 | + !tagValue && |
| 233 | + (dateUpdateBlogAfter === '' || dateUpdateBlogAfter === null) && |
| 234 | + (dateUpdateBlogBefore === '' || dateUpdateBlogBefore === null) && |
| 235 | + (blogStatus === '0' || blogStatus === null); |
226 | 236 | }
|
227 | 237 |
|
228 | 238 | // Show/hide reset button based on input values
|
|
235 | 245 | btnReset.classList.toggle('d-none', areAllInputsEmptyOrUnchecked());
|
236 | 246 | });
|
237 | 247 |
|
| 248 | + // Add change event listener to the select elements |
| 249 | + document.getElementById('tag_doc').addEventListener('change', function() { |
| 250 | + btnReset.classList.toggle('d-none', areAllInputsEmptyOrUnchecked()); |
| 251 | + }); |
| 252 | + |
| 253 | + document.getElementById('unpublished').addEventListener('change', function() { |
| 254 | + btnReset.classList.toggle('d-none', areAllInputsEmptyOrUnchecked()); |
| 255 | + }); |
238 | 256 | });
|
239 | 257 | </script>
|
0 commit comments