Re-write search process: checkboxes!
This commit is contained in:
parent
76e0dcd77a
commit
d4f7d860f7
4 changed files with 89 additions and 29 deletions
|
@ -28,20 +28,42 @@ public class SearchController {
|
|||
}
|
||||
|
||||
@GetMapping
|
||||
public String requestMethodName(@RequestParam String search, Model model) {
|
||||
public String requestMethodName(@RequestParam String search,
|
||||
@RequestParam(value = "title", required = false) Boolean title,
|
||||
@RequestParam(value = "series", required = false) Boolean series,
|
||||
@RequestParam(value = "author", required = false) Boolean author,
|
||||
Model model) {
|
||||
|
||||
if (search.trim().equals(""))
|
||||
return "search";
|
||||
|
||||
if (search.length() < 4){
|
||||
model.addAttribute("error", "Should be at least 4 chars");
|
||||
return "search";
|
||||
}
|
||||
|
||||
if (title != null){
|
||||
List<Book> books = inpEntryRepository.findByTitleContainingIgnoreCase(search);
|
||||
if (books.size() != 0)
|
||||
model.addAttribute("books", books);
|
||||
model.addAttribute("isTitle", true);
|
||||
}
|
||||
|
||||
if (series != null){
|
||||
List<Book> bookSeries = inpEntryRepository.findBySeriesContainingIgnoreCase(search);
|
||||
if (bookSeries.size() != 0)
|
||||
model.addAttribute("series", bookSeries);
|
||||
model.addAttribute("isSeries", true);
|
||||
}
|
||||
|
||||
if (author != null){
|
||||
List<Author> authors = authorRepository.findByAuthorNameContainingIgnoreCase(search);
|
||||
if (authors.size() != 0)
|
||||
model.addAttribute("authors", authors);
|
||||
model.addAttribute("isAuthor", true);
|
||||
}
|
||||
|
||||
return "search";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -121,6 +121,15 @@ header {
|
|||
padding: 0%;
|
||||
}
|
||||
|
||||
.search_line{
|
||||
margin-left: 2px;
|
||||
margin-right: 2px;
|
||||
margin-top: 7px;
|
||||
margin-bottom: 7px;
|
||||
flex-grow: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.ul_right_block {
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
|
@ -146,6 +155,20 @@ header {
|
|||
color: #74bfbd;
|
||||
}
|
||||
|
||||
.search_entry{
|
||||
text-decoration: none;
|
||||
font-variant: small-caps;
|
||||
font-size: 0.75em;
|
||||
text-shadow: -1px -1px 0 #1e1e1e, 1px -1px 0 #1e1e1e, -1px 1px 0 #1e1e1e, 1px 1px 0 #1e1e1e;
|
||||
color: #74bfbd;
|
||||
}
|
||||
|
||||
.search_checkbox{
|
||||
flex: auto;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
|
||||
.header_logo_link:link {
|
||||
color: #74bfbd;
|
||||
}
|
||||
|
@ -180,10 +203,10 @@ header {
|
|||
|
||||
|
||||
.button-header {
|
||||
margin: 1em 0;
|
||||
margin: 0 0.25em;
|
||||
font-family: sans-serif;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
font-variant: small-caps !important;
|
||||
background-color: #74bfbd !important;
|
||||
|
|
|
@ -58,18 +58,34 @@
|
|||
</div>
|
||||
</nav>
|
||||
|
||||
<nav id="header_menu_block" class="header_entry">
|
||||
<nav id="header_menu_block" class="search_entry wrapper">
|
||||
<ul class="ul_right_block">
|
||||
<li class="li_header_block">
|
||||
<form action="/search" method="get">
|
||||
<input type="text" name="search">
|
||||
<div class="wrapper">
|
||||
<input class="search_line" type="text" name="search">
|
||||
</div>
|
||||
<div class="wrapper" style="justify-content: space-evenly; align-items: baseline; ">
|
||||
<div class="search_checkbox">
|
||||
<input th:checked="${isTitle}" name="title" type="checkbox" />
|
||||
<label for="title">Title</label>
|
||||
</div>
|
||||
<div class="search_checkbox">
|
||||
<input th:checked="${isSeries}" name="series" type="checkbox" />
|
||||
<label for="series">Series</label>
|
||||
</div>
|
||||
<div class="search_checkbox">
|
||||
<input th:checked="${isAuthor}" name="author" type="checkbox" />
|
||||
<label for="author">Author</label>
|
||||
</div>
|
||||
<div class="" style="margin-right: auto;">
|
||||
<button class="button-header" type="submit">Search</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
</header>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
<div class="page">
|
||||
<div th:replace="~{fragments/header :: ${#authorization.expression('isAuthenticated()')} ? 'header-auth' : 'header-anon'}"></div>
|
||||
<div class="container base">
|
||||
<div th:if="${books} != null">
|
||||
<div class="validationError" th:if="${error != null}" th:text="${error}"></div>
|
||||
<div th:if="${books != null}">
|
||||
<h3>Titles</h3>
|
||||
<div th:each="book : ${books}">
|
||||
<a th:href="${'/book/' + book.id}">
|
||||
|
@ -33,10 +34,9 @@
|
|||
<span th:text="${' (' + book.fileExtension + ' ' + book.fileSizeForHumans + ')'}"></span>
|
||||
<p></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div th:if="${series} != null">
|
||||
<hr>
|
||||
</div>
|
||||
<div th:if="${series != null}">
|
||||
<h3>Series</h3>
|
||||
<div th:each="book : ${books}">
|
||||
<a th:href="${'/book/' + book.id}">
|
||||
|
@ -57,10 +57,9 @@
|
|||
<span th:text="${' (' + book.fileExtension + ' ' + book.fileSizeForHumans + ')'}"></span>
|
||||
<p></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div th:if="${authors} != null">
|
||||
<hr>
|
||||
</div>
|
||||
<div th:if="${authors != null}">
|
||||
<h3>Authors</h3>
|
||||
<div th:each="author : ${authors}">
|
||||
<a th:href="${'/author/' + author.id}">
|
||||
|
|
Loading…
Reference in a new issue