Browse Source

Update web forms due to new Author entity

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.2-alpha
Pekka Helenius 4 years ago
parent
commit
a09ec7c17d
4 changed files with 212 additions and 66 deletions
  1. +77
    -17
      bookstore/src/main/resources/templates/apiref.html
  2. +59
    -24
      bookstore/src/main/resources/templates/bookadd.html
  3. +59
    -24
      bookstore/src/main/resources/templates/bookedit.html
  4. +17
    -1
      bookstore/src/main/resources/templates/booklist.html

+ 77
- 17
bookstore/src/main/resources/templates/apiref.html View File

@ -17,6 +17,10 @@
page.title.webform.apiref page.title.webform.apiref
</h1> </h1>
<p th:text="${#messages.msgOrNull('page.text.apiref.warning')} ?: 'page.text.apiref.warning'">
page.text.apiref.warning
</p>
<table class="table table-striped"> <table class="table table-striped">
<tbody> <tbody>
<tr> <tr>
@ -57,6 +61,18 @@
</a> </a>
</td> </td>
</tr> </tr>
<tr>
<td class="apiref-table-right">
<code th:text="${baseUrl} + 'api/authors/'">placeholder</code>
</td>
<td>
<a th:text="${#messages.msgOrNull('page.text.apiref.link')} ?: 'page.text.apiref.link'"
th:href="${baseUrl} + 'api/authors/'"
>
page.text.apiref.link
</a>
</td>
</tr>
<tr> <tr>
<th class="apiref-table-right apiref-table-title"> <th class="apiref-table-right apiref-table-title">
@ -90,11 +106,23 @@
</a> </a>
</td> </td>
</tr> </tr>
<tr>
<td class="apiref-table-right">
<code th:text="${baseUrl} + 'api/authors/search/author?firstname=Angela&lastname=Carter'">placeholder</code>
</td>
<td>
<a th:text="${#messages.msgOrNull('page.text.apiref.link')} ?: 'page.text.apiref.link'"
th:href="${baseUrl} + 'api/authors/search/author?firstname=Angela&lastname=Carter'"
>
page.text.apiref.link
</a>
</td>
</tr>
<tr> <tr>
<th class="apiref-table-right apiref-table-title"> <th class="apiref-table-right apiref-table-title">
<h3 th:text="${#messages.msgOrNull('page.text.apiref.get')} ?: 'page.text.apiref.get'">
page.text.apiref.get
<h3 th:text="${#messages.msgOrNull('page.text.apiref.book.get')} ?: 'page.text.apiref.book.get'">
page.text.apiref.book.get
</h3> </h3>
</th> </th>
<th></th> <th></th>
@ -103,44 +131,50 @@
<td class="apiref-table-right"> <td class="apiref-table-right">
<code th:text="'curl --request GET ' + ${baseUrl} + 'api/booklist/2'"></code> <code th:text="'curl --request GET ' + ${baseUrl} + 'api/booklist/2'"></code>
<br> <br>
<small th:text="${#messages.msgOrNull('page.text.apiref.edit.info')} ?: 'page.text.apiref.edit.info'">page.text.apiref.edit.info</small>
<small th:text="${#messages.msgOrNull('page.text.apiref.book.edit.info')} ?: 'page.text.apiref.book.edit.info'">page.text.apiref.book.edit.info</small>
<br>
<small th:text="${#messages.msgOrNull('page.text.apiref.unix.info')} ?: 'page.text.apiref.unix.info'">page.text.apiref.unix.info</small>
</td> </td>
</tr> </tr>
<tr> <tr>
<th class="apiref-table-right apiref-table-title"> <th class="apiref-table-right apiref-table-title">
<h3 th:text="${#messages.msgOrNull('page.text.apiref.add')} ?: 'page.text.apiref.add'">
page.text.apiref.add
<h3 th:text="${#messages.msgOrNull('page.text.apiref.book.add')} ?: 'page.text.apiref.book.add'">
page.text.apiref.book.add
</h3> </h3>
</th> </th>
<th></th> <th></th>
</tr> </tr>
<tr> <tr>
<td class="apiref-table-right"> <td class="apiref-table-right">
<code th:text="'curl --include --request POST --header &quot;Content-Type: application/json&quot; --data \'{&quot;title&quot;:&quot;The Witcher: Blood of Elves&quot;,&quot;author&quot;:&quot;Andrzej Sapkowski&quot;,&quot;year&quot;:1994,&quot;isbn&quot;:&quot;5474512-543&quot;,&quot;price&quot;:22.49}\' ' + ${baseUrl} + 'api/booklist'"></code>
<code th:text="'curl --include --request POST --header &quot;Content-Type: application/json&quot; --data \'{&quot;title&quot;:&quot;The Witcher: Blood of Elves&quot;,&quot;year&quot;:1994,&quot;isbn&quot;:&quot;5474512-543&quot;,&quot;price&quot;:22.49}\' ' + ${baseUrl} + 'api/booklist'"></code>
<br>
<small th:text="${#messages.msgOrNull('page.text.apiref.unix.info')} ?: 'page.text.apiref.unix.info'">page.text.apiref.unix.info</small>
</td> </td>
</tr> </tr>
<tr> <tr>
<th class="apiref-table-right apiref-table-title"> <th class="apiref-table-right apiref-table-title">
<h3 th:text="${#messages.msgOrNull('page.text.apiref.edit')} ?: 'page.text.apiref.edit'">
page.text.apiref.edit
<h3 th:text="${#messages.msgOrNull('page.text.apiref.book.edit')} ?: 'page.text.apiref.book.edit'">
page.text.apiref.book.edit
</h3> </h3>
</th> </th>
<th></th> <th></th>
</tr> </tr>
<tr> <tr>
<td class="apiref-table-right"> <td class="apiref-table-right">
<code th:text="'curl --include --request PUT --header &quot;Content-Type: application/json&quot; --data \'{&quot;title&quot;:&quot;The Witcher: Blood of Elves&quot;,&quot;author&quot;:&quot;Andrzej Sapkowski&quot;,&quot;year&quot;:1999,&quot;isbn&quot;:&quot;3213221-3&quot;,&quot;price&quot;:22.49}\' ' + ${baseUrl} + 'api/booklist/2'"></code>
<code th:text="'curl --include --request PUT --header &quot;Content-Type: application/json&quot; --data \'{&quot;title&quot;:&quot;The Witcher: Blood of Elves&quot;,&quot;year&quot;:1999,&quot;isbn&quot;:&quot;3213221-3&quot;,&quot;price&quot;:22.49}\' ' + ${baseUrl} + 'api/booklist/2'"></code>
<br> <br>
<small th:text="${#messages.msgOrNull('page.text.apiref.edit.info')} ?: 'page.text.apiref.edit.info'">page.text.apiref.edit.info</small>
<small th:text="${#messages.msgOrNull('page.text.apiref.book.edit.info')} ?: 'page.text.apiref.book.edit.info'">page.text.apiref.book.edit.info</small>
<br>
<small th:text="${#messages.msgOrNull('page.text.apiref.unix.info')} ?: 'page.text.apiref.unix.info'">page.text.apiref.unix.info</small>
</td> </td>
</tr> </tr>
<tr> <tr>
<th class="apiref-table-right apiref-table-title"> <th class="apiref-table-right apiref-table-title">
<h3 th:text="${#messages.msgOrNull('page.text.apiref.delete')} ?: 'page.text.apiref.delete'">
page.text.apiref.delete
<h3 th:text="${#messages.msgOrNull('page.text.apiref.book.delete')} ?: 'page.text.apiref.book.delete'">
page.text.apiref.book.delete
</h3> </h3>
</th> </th>
<th></th> <th></th>
@ -149,16 +183,42 @@
<td class="apiref-table-right"> <td class="apiref-table-right">
<code th:text="'curl --request DELETE ' + ${baseUrl} + 'api/booklist/2'"></code> <code th:text="'curl --request DELETE ' + ${baseUrl} + 'api/booklist/2'"></code>
<br> <br>
<small th:text="${#messages.msgOrNull('page.text.apiref.edit.info')} ?: 'page.text.apiref.edit.info'">page.text.apiref.edit.info</small>
<small th:text="${#messages.msgOrNull('page.text.apiref.book.edit.info')} ?: 'page.text.apiref.book.edit.info'">page.text.apiref.book.edit.info</small>
<br>
<small th:text="${#messages.msgOrNull('page.text.apiref.unix.info')} ?: 'page.text.apiref.unix.info'">page.text.apiref.unix.info</small>
</td>
</tr>
<tr>
<th class="apiref-table-right apiref-table-title">
<h3 th:text="${#messages.msgOrNull('page.text.apiref.author.edit')} ?: 'page.text.apiref.author.edit'">
page.text.apiref.author.edit
</h3>
</th>
<th></th>
</tr>
<tr>
<td class="apiref-table-right">
<code th:text="'curl --include --request PUT --header &quot;Content-Type: application/json&quot; --data \'{&quot;firstName&quot;:&quot;Tanya&quot;,&quot;lastName&quot;:&quot;Rose&quot;}\' ' + ${baseUrl} + 'api/authors/1'"></code>
<br>
<small th:text="${#messages.msgOrNull('page.text.apiref.author.edit.info')} ?: 'page.text.apiref.author.edit.info'">page.text.apiref.author.edit.info</small>
<br>
<small th:text="${#messages.msgOrNull('page.text.apiref.unix.info')} ?: 'page.text.apiref.unix.info'">page.text.apiref.unix.info</small>
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tr>
<td>
<a class="btn btn-success" th:href="@{__${listpage}__}"
th:text="${#messages.msgOrNull('button.page.list.return')} ?: 'button.page.list.return'">
button.page.list.return
</a>
</td>
<td></td>
</tr>
</table> </table>
<a class="btn btn-success" th:href="@{__${listpage}__}"
th:text="${#messages.msgOrNull('button.page.list.return')} ?: 'button.page.list.return'">
button.page.list.return
</a>
</body> </body>
</html> </html>

+ 59
- 24
bookstore/src/main/resources/templates/bookadd.html View File

@ -20,30 +20,65 @@
<form th:object="${book}" action="#" th:action="@{__${addpage}__}" method="post"> <form th:object="${book}" action="#" th:action="@{__${addpage}__}" method="post">
<div class="form-group bookform-section">
<label for="BookAuthor"
th:text="${#messages.msgOrNull('book.author')} ?: 'book.author'">
book.author
</label>
<input class="form-control" type="text" th:field="*{author}" placeholder="Book author"/>
<small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.author')} ?: 'book.desc.set.author'">
book.desc.set.author
</small>
<small style="display: inline-block;" class="form-text text-info"
th:text="(${#messages.msgOrNull('book.desc.example.headertext')} ?: 'book.desc.example.headertext') + ': '">
book.desc.example.headertext
</small>
<small style="display: inline-block;" class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.example.author')} ?: 'book.desc.example.author'">
book.desc.example.author
</small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('author')}"
th:errors="*{author}">Invalid author value</div>
<div class="bookform-section">
<div>
<h3 th:text="${#messages.msgOrNull('book.author')} ?: 'book.author'">
book.author
</h3>
</div>
<div class="form-group row">
<div class="col">
<label for="BookAuthorFirstName"
th:text="${#messages.msgOrNull('book.author.firstName')} ?: 'book.author.firstName'">
book.author.firstName
</label>
<input class="form-control" type="text" th:field="*{author.firstName}" placeholder="Book author first name"/>
<small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.author.firstname')} ?: 'book.desc.set.author.firstname'">
book.desc.set.author.firstname
</small>
<small style="display: inline-block;" class="form-text text-info"
th:text="(${#messages.msgOrNull('book.desc.example.headertext')} ?: 'book.desc.example.headertext') + ': '">
book.desc.example.headertext
</small>
<small style="display: inline-block;" class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.example.author.firstname')} ?: 'book.desc.example.author.firstname'">
book.desc.example.author.firstname
</small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('author.firstName')}"
th:errors="*{author.firstName}">Invalid author first name value</div>
</div>
<div class="col">
<label for="BookAuthorLastName"
th:text="${#messages.msgOrNull('book.author.lastName')} ?: 'book.author.lastName'">
book.author.lastName
</label>
<input class="form-control" type="text" th:field="*{author.lastName}" placeholder="Book author last name"/>
<small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.author.lastname')} ?: 'book.desc.set.author.lastname'">
book.desc.set.author.lastname
</small>
<small style="display: inline-block;" class="form-text text-info"
th:text="(${#messages.msgOrNull('book.desc.example.headertext')} ?: 'book.desc.example.headertext') + ': '">
book.desc.example.headertext
</small>
<small style="display: inline-block;" class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.example.author.lastname')} ?: 'book.desc.example.author.lastname'">
book.desc.example.author.lastname
</small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('author.lastName')}"
th:errors="*{author.lastName}">Invalid author last name value</div>
</div>
</div>
</div> </div>
<div class="form-group bookform-section"> <div class="form-group bookform-section">


+ 59
- 24
bookstore/src/main/resources/templates/bookedit.html View File

@ -20,30 +20,65 @@
<form th:object="${book}" action="#" th:action="@{{id}(id=${book.id})}" method="post"> <form th:object="${book}" action="#" th:action="@{{id}(id=${book.id})}" method="post">
<div class="form-group bookform-section">
<label for="BookAuthor"
th:text="${#messages.msgOrNull('book.author')} ?: 'book.author'">
book.author
</label>
<input class="form-control" type="text" th:field="*{author}" placeholder="Book author"/>
<small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.author')} ?: 'book.desc.set.author'">
book.desc.set.author
</small>
<small style="display: inline-block;" class="form-text text-info"
th:text="(${#messages.msgOrNull('book.desc.example.headertext')} ?: 'book.desc.example.headertext') + ': '">
book.desc.example.headertext
</small>
<small style="display: inline-block;" class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.example.author')} ?: 'book.desc.example.author'">
book.desc.example.author
</small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('author')}"
th:errors="*{author}">Invalid author value</div>
<div class="bookform-section">
<div>
<h3 th:text="${#messages.msgOrNull('book.author')} ?: 'book.author'">
book.author
</h3>
</div>
<div class="form-group row">
<div class="col">
<label for="BookAuthor"
th:text="${#messages.msgOrNull('book.author.firstName')} ?: 'book.author.firstName'">
book.author.firstName
</label>
<input class="form-control" type="text" th:field="*{author.firstName}" placeholder="Book author first name"/>
<small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.author.firstname')} ?: 'book.desc.set.author.firstname'">
book.desc.set.author.firstname
</small>
<small style="display: inline-block;" class="form-text text-info"
th:text="(${#messages.msgOrNull('book.desc.example.headertext')} ?: 'book.desc.example.headertext') + ': '">
book.desc.example.headertext
</small>
<small style="display: inline-block;" class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.example.author.firstname')} ?: 'book.desc.example.author.firstname'">
book.desc.example.author.firstname
</small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('author.firstName')}"
th:errors="*{author.firstName}">Invalid author first name value</div>
</div>
<div class="col">
<label for="BookAuthor"
th:text="${#messages.msgOrNull('book.author.lastName')} ?: 'book.author.lastName'">
book.author.lastName
</label>
<input class="form-control" type="text" th:field="*{author.lastName}" placeholder="Book author last name"/>
<small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.author.lastname')} ?: 'book.desc.set.author.lastname'">
book.desc.set.author.lastname
</small>
<small style="display: inline-block;" class="form-text text-info"
th:text="(${#messages.msgOrNull('book.desc.example.headertext')} ?: 'book.desc.example.headertext') + ': '">
book.desc.example.headertext
</small>
<small style="display: inline-block;" class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.example.author.lastname')} ?: 'book.desc.example.author.lastname'">
book.desc.example.author.lastname
</small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('author.lastName')}"
th:errors="*{author.lastName}">Invalid author last name value</div>
</div>
</div>
</div> </div>
<div class="form-group bookform-section"> <div class="form-group bookform-section">


+ 17
- 1
bookstore/src/main/resources/templates/booklist.html View File

@ -33,7 +33,23 @@
</tr> </tr>
<tr th:each="book : ${books}"> <tr th:each="book : ${books}">
<td th:text="${book.author}">(obj) book.author</td>
<!--/*
Check if book.author exists. If yes, then:
|-> Check if firstName exists. If yes, then:
| Set author first name
| else:
| Set empty string for first name
|----------
|-> Check if lastName exists, if yes, then:
| Set author last name
| else:
| Set empty string for last name
else:
Author is 'Unknown'
*/-->
<td th:text="${book.author != null} ? ( (${book.author.firstName != null} ? (${book.author.firstName} + ' ') : '') + (${book.author.lastName != null} ? ${book.author.lastName} : '') ) : 'Unknown'">(obj) book.author.firstName (obj) book.author.lastName</td>
<td th:text="${book.title}">(obj) book.title</td> <td th:text="${book.title}">(obj) book.title</td>
<td th:text="${book.isbn}">(obj) book.isbn</td> <td th:text="${book.isbn}">(obj) book.isbn</td>
<td th:text="${book.year}">(obj) book.year</td> <td th:text="${book.year}">(obj) book.year</td>


Loading…
Cancel
Save