Skip to content

Commit 27702d2

Browse files
committed
Alter Search behavior to update when project and date inputs change.
This change causes the Summary view to update when: * The Project dropdown changes * The start date changes * The end date changes This allows users to change the summary view without the extra Search button click. This change also alters how the related HTML elements are discovered in the DOM. Each element is queried before event execution, which means they do not need to be queried every time the Search events fire.
1 parent e4970a6 commit 27702d2

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/summaryView.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -549,27 +549,35 @@ export class SummaryViewProvider implements vscode.WebviewViewProvider {
549549
}
550550
});
551551
552-
document.getElementById('search-button').addEventListener('click', () => {
553-
const startDate = document.getElementById('start-date-search').value;
554-
const endDate = document.getElementById('end-date-search').value;
555-
const project = document.getElementById('project-search').value;
552+
const startDateElem = document.getElementById('start-date-search');
553+
const endDateElem = document.getElementById('end-date-search');
554+
const projectSearchElem = document.getElementById('project-search');
555+
556+
function changeSearchSelection() {
557+
const startDate = startDateElem.value;
558+
const endDate = endDateElem.value;
559+
const project = projectSearchElem.value;
556560
vscode.postMessage({ command: 'search', startDate, endDate, project });
557-
});
561+
};
562+
563+
startDateElem.addEventListener('input', changeSearchSelection);
564+
endDateElem.addEventListener('input', changeSearchSelection);
565+
projectSearchElem.addEventListener('change', changeSearchSelection);
566+
document.getElementById('search-button').addEventListener('click', changeSearchSelection);
558567
559568
// Add event listener for the reload button
560569
document.getElementById('reload-button').addEventListener('click', () => {
561570
// Reset date fields
562-
document.getElementById('start-date-search').value = '';
563-
document.getElementById('end-date-search').value = '';
571+
startDateSearch.value = '';
572+
endDateSearch.value = '';
564573
// Reset project dropdown
565-
document.getElementById('project-search').value = '';
574+
projectSearch.value = '';
566575
// Send refresh command
567576
vscode.postMessage({ command: 'refresh' });
568577
});
569578
570579
function updateProjectDropdown(projects) {
571-
const dropdown = document.getElementById('project-search');
572-
dropdown.innerHTML = '<option value="">All Projects</option>' +
580+
projectSearch.innerHTML = '<option value="">All Projects</option>' +
573581
projects.map(project => \`<option value="\${project}">\${project}</option>\`).join('');
574582
}
575583

0 commit comments

Comments
 (0)