Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 5 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<Job> 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";

}
}
27 changes: 27 additions & 0 deletions src/main/resources/templates/list-jobs.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,34 @@
<h1 th:text="${#strings.capitalizeWords(title)}"></h1>

<!-- TODO #1 - Use a loop to display job results in a table. -->
<th:block th:each="job:${jobs}">
<table class="job-listing">
<tr>

<td>ID</td>
<td th:text="${job.getId}"></td>
</tr>
<tr>
<td>Name</td>
<td th:text="${job.getName}"></td>
</tr>
<tr>
<td>Employer</td>
<td th:text="${job.getEmployer}"></td>
</tr>
<tr>
<td>Location</td>
<td th:text="${job.getLocation}"></td>
</tr>
<tr>
<td>Position Type</td>
<td th:text="${job.getPositionType}"></td>
</tr>
<tr>
<td>Skill</td>
<td th:text="${job.getCoreCompetency}"></td>
</tr>
</table>
</div>

</body>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h2 class = "centered">View Jobs By Category</h2>
<tr>
<!-- TODO #2: Complete the View Jobs By Category Table. -->

<td></td> <!-- Feel free to remove or modify this element if necessary. -->
<!-- Feel free to remove or modify this element if necessary. -->

<td th:each="category : ${tableChoices}">
<ul>
Expand Down
65 changes: 64 additions & 1 deletion src/main/resources/templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,70 @@ <h2>Search by:</h2>
<input type="submit" value="Search" />
</form>

<hr />
<hr/>


<!-- <table>-->
<!-- <tr th:each="job : ${jobs}">-->
<!-- <table class="job-listing">-->
<!-- <tr>-->
<!-- <td>ID</td>-->
<!-- <td th:text="${job.getId}"></td>-->
<!-- </tr>-->
<!-- <tr>-->
<!-- <td>Name</td>-->
<!-- <td th:text="${job.getName}"></td>-->
<!-- </tr>-->
<!-- <tr>-->
<!-- <td>Employer</td>-->
<!-- <td th:text="${job.getEmployer}"></td>-->
<!-- </tr>-->
<!-- <tr>-->
<!-- <td>Location</td>-->
<!-- <td th:text="${job.getLocation}"></td>-->
<!-- </tr>-->
<!-- <tr>-->
<!-- <td>Position Type</td>-->
<!-- <td th:text="${job.getPositionType}"></td>-->
<!-- </tr>-->
<!-- <tr>-->
<!-- <td type="header">Skill</td>-->
<!-- <td th:text="${job.getCoreCompetency}"></td>-->
<!-- </tr>-->
<!-- </table>-->
<!-- <br> &lt;!&ndash; Add a line break to separate each job's table &ndash;&gt;-->
<!-- </tr>-->
<!-- </table>-->
<th:block th:each="job:${jobs}">
<table class="job-listing">
<tr>

<td>ID</td>
<td th:text="${job.getId}"></td>
</tr>
<tr>
<td>Name</td>
<td th:text="${job.getName}"></td>
</tr>
<tr>
<td>Employer</td>
<td th:text="${job.getEmployer}"></td>
</tr>
<tr>
<td>Location</td>
<td th:text="${job.getLocation}"></td>
</tr>
<tr>
<td>Position Type</td>
<td th:text="${job.getPositionType}"></td>
</tr>
<tr>
<td>Skill</td>
<td th:text="${job.getCoreCompetency}"></td>
</tr>
</table>



<!-- TODO #4 - Loop over the search results to display all job fields. -->

Expand Down