Skip to content

Commit 9114d9c

Browse files
ManssourBlhseboo
authored andcommitted
LUT-27822: Ensure reset button displays correctly based on all input fields
1 parent b3ad766 commit 9114d9c

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

webapp/WEB-INF/templates/admin/plugins/blog/manage_blogs.html

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,30 @@
209209
},
210210
});
211211

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
219213

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);
226236
}
227237

228238
// Show/hide reset button based on input values
@@ -235,5 +245,13 @@
235245
btnReset.classList.toggle('d-none', areAllInputsEmptyOrUnchecked());
236246
});
237247

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+
});
238256
});
239257
</script>

0 commit comments

Comments
 (0)