diff --git a/src/main/html/webapp/components/core/job/list/list.js b/src/main/html/webapp/components/core/job/list/list.js index 2df25c0d..7d86060b 100644 --- a/src/main/html/webapp/components/core/job/list/list.js +++ b/src/main/html/webapp/components/core/job/list/list.js @@ -105,13 +105,26 @@ export default Control.extend({ }, '.job-search keyup': function(el, ev) { - const searchText = $(el).val().trim().toLowerCase(); - + this.filterJobs(); + }, + + '.job-state-filter change': function(el, ev) { + this.filterJobs(); + }, + + filterJobs: function() { + const searchText = $('.job-search').val().trim().toLowerCase(); + const selectedState = $('.job-state-filter').val(); + $('.card').each(function() { const job = domData.get.call(this, 'job'); const jobId = job.attr('id').toString().toLowerCase(); + const jobState = job.attr('state').toString(); + + const matchesSearch = searchText === '' || jobId.includes(searchText); + const matchesState = selectedState === 'all' || jobState === selectedState; - if (searchText === '' || jobId.includes(searchText)) { + if (matchesSearch && matchesState) { $(this).show(); } else { $(this).hide(); diff --git a/src/main/html/webapp/components/core/job/list/list.stache b/src/main/html/webapp/components/core/job/list/list.stache index 1c0c2677..b409d95f 100644 --- a/src/main/html/webapp/components/core/job/list/list.stache +++ b/src/main/html/webapp/components/core/job/list/list.stache @@ -2,8 +2,17 @@

Jobs

{{jobs.count}} jobs submitted. -
+
+