From c0c1d78e513a214cd791f68e4c70ac240cbfd107 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Fri, 19 May 2023 00:07:49 +0000 Subject: [PATCH 1/5] Setting up GitHub Classroom Feedback From 6c30f14edd6c92afa5fa69bf5dbe3f6d012c2c6e Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Fri, 19 May 2023 00:08:02 +0000 Subject: [PATCH 2/5] Update GitHub Classroom Autograding From 35ef51c719d66bd71aeaa9a8436bc4aaa8ebfc04 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Fri, 19 May 2023 00:08:03 +0000 Subject: [PATCH 3/5] Update GitHub Classroom Autograding Workflow From 8b08271e2b4ada9eec1c1b8903dec904bc6ecb89 Mon Sep 17 00:00:00 2001 From: AuroraRaven <125933407+AuroraRaven@users.noreply.github.com> Date: Mon, 22 May 2023 16:27:19 -0500 Subject: [PATCH 4/5] have questions but i think it works... --- .../mvc/controllers/ListController.java | 2 ++ .../mvc/controllers/SearchController.java | 18 +++++++++++++++ src/main/resources/templates/list-jobs.html | 23 ++++++++++++++++++- src/main/resources/templates/list.html | 2 +- src/main/resources/templates/search.html | 23 +++++++++++++++++++ .../launchcode/techjobs/mvc/TestTaskFour.java | 2 +- 6 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/launchcode/techjobs/mvc/controllers/ListController.java b/src/main/java/org/launchcode/techjobs/mvc/controllers/ListController.java index 71cb0cd..8a0cb60 100644 --- a/src/main/java/org/launchcode/techjobs/mvc/controllers/ListController.java +++ b/src/main/java/org/launchcode/techjobs/mvc/controllers/ListController.java @@ -29,12 +29,14 @@ public ListController () { columnChoices.put("positionType", "Position Type"); columnChoices.put("coreCompetency", "Skill"); + tableChoices.put("all","All Jobs"); tableChoices.put("employer", JobData.getAllEmployers()); tableChoices.put("location", JobData.getAllLocations()); tableChoices.put("positionType", JobData.getAllPositionTypes()); tableChoices.put("coreCompetency", JobData.getAllCoreCompetency()); } + @GetMapping(value = "") public String list(Model model) { model.addAttribute("columns", columnChoices); diff --git a/src/main/java/org/launchcode/techjobs/mvc/controllers/SearchController.java b/src/main/java/org/launchcode/techjobs/mvc/controllers/SearchController.java index d75fd42..ab63643 100644 --- a/src/main/java/org/launchcode/techjobs/mvc/controllers/SearchController.java +++ b/src/main/java/org/launchcode/techjobs/mvc/controllers/SearchController.java @@ -1,9 +1,15 @@ package org.launchcode.techjobs.mvc.controllers; +import org.launchcode.techjobs.mvc.models.Job; +import org.launchcode.techjobs.mvc.models.JobData; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.ArrayList; import static org.launchcode.techjobs.mvc.controllers.ListController.columnChoices; @@ -22,5 +28,17 @@ public String search(Model model) { } // TODO #3 - Create a handler to process a search request and render the updated search view. +@PostMapping(value="results") + public String displaySearchResults(Model model, @RequestParam String searchType, @RequestParam String searchTerm){ + ArrayList jobs; + if(searchTerm.equalsIgnoreCase("all")|| searchTerm.isEmpty()){ + jobs= JobData.findAll(); + }else{ + jobs=JobData.findByColumnAndValue(searchType, searchTerm); + } + model.addAttribute("jobs",jobs); + model.addAttribute("columns", columnChoices); + return "search"; } +} diff --git a/src/main/resources/templates/list-jobs.html b/src/main/resources/templates/list-jobs.html index 9cd974d..3cb2526 100644 --- a/src/main/resources/templates/list-jobs.html +++ b/src/main/resources/templates/list-jobs.html @@ -11,7 +11,28 @@

- + + + + + + + + + + + + + + + + + + + + + +
IDJob NameEmployerLocationPosition TypeCore Competency
diff --git a/src/main/resources/templates/list.html b/src/main/resources/templates/list.html index 9bb81de..ae813b8 100644 --- a/src/main/resources/templates/list.html +++ b/src/main/resources/templates/list.html @@ -20,7 +20,7 @@

View Jobs By Category

- +