Browse Source

Add web form data fields related to book publication

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.3-alpha
Pekka Helenius 4 years ago
parent
commit
44fef19cf2
3 changed files with 61 additions and 1 deletions
  1. +6
    -0
      bookstore/src/main/resources/messages.properties
  2. +25
    -1
      bookstore/src/main/resources/templates/booklist.html
  3. +30
    -0
      bookstore/src/main/resources/templates/fragments/bookfields.html

+ 6
- 0
bookstore/src/main/resources/messages.properties View File

@ -16,6 +16,8 @@ book.price = Price
book.category = Category book.category = Category
book.json = JSON Data book.json = JSON Data
book.fields.publish = Publish the book?
book.desc.set.author.firstname = Set book author first name book.desc.set.author.firstname = Set book author first name
book.desc.set.author.lastname = Set book author last name book.desc.set.author.lastname = Set book author last name
book.desc.set.title = Set book primary title book.desc.set.title = Set book primary title
@ -23,6 +25,7 @@ book.desc.set.isbn = Set book ISBN code
book.desc.set.year = Set book publication year book.desc.set.year = Set book publication year
book.desc.set.price = Set book price book.desc.set.price = Set book price
book.desc.set.category = Select appropriate category book.desc.set.category = Select appropriate category
book.desc.set.publish = Should the book be published on the store page?
book.desc.example.headertext = Valid inputs (examples) book.desc.example.headertext = Valid inputs (examples)
book.desc.example.author.firstname = Andrzej book.desc.example.author.firstname = Andrzej
@ -55,6 +58,9 @@ page.title.webform.edit = Update existing book
page.title.webform.error = Error page.title.webform.error = Error
page.title.webform.apiref = API Reference help page page.title.webform.apiref = API Reference help page
page.text.list.yes = Yes
page.text.list.no = No
page.text.list.published = Visible\?
page.text.list.actions = Actions page.text.list.actions = Actions
page.text.list.delete = Delete page.text.list.delete = Delete
page.text.list.edit = Edit page.text.list.edit = Edit


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

@ -77,6 +77,16 @@ Idea of the following syntax used in this and other HTML document:
<th th:text="${#messages.msgOrNull('book.category')} ?: 'book.category'">book.category</th> <th th:text="${#messages.msgOrNull('book.category')} ?: 'book.category'">book.category</th>
<th th:text="${#messages.msgOrNull('book.price')} ?: 'book.price'">book.price</th> <th th:text="${#messages.msgOrNull('book.price')} ?: 'book.price'">book.price</th>
<th
th:text="${#messages.msgOrNull('page.text.list.published')} ?: 'page.text.list.published'"
th:if="${#authorization.expression('hasAuthority(''MARKETING'')')}"
>
page.text.list.published
</th>
<th th:unless="${#authorization.expression('hasAuthority(''MARKETING'')')}">
</th>
<th <th
th:text="${#messages.msgOrNull('page.text.list.actions')} ?: 'page.text.list.actions'" th:text="${#messages.msgOrNull('page.text.list.actions')} ?: 'page.text.list.actions'"
th:if="${#authorization.expression('hasAuthority(''MARKETING'') or hasAuthority(''HELPDESK'')')}" th:if="${#authorization.expression('hasAuthority(''MARKETING'') or hasAuthority(''HELPDESK'')')}"
@ -91,7 +101,11 @@ Idea of the following syntax used in this and other HTML document:
<th th:text="${#messages.msgOrNull('book.json')} ?: 'book.json'">book.json</th> <th th:text="${#messages.msgOrNull('book.json')} ?: 'book.json'">book.json</th>
</tr> </tr>
<tr th:each="book : ${books}">
<tr
th:each="book : ${books}"
th:object="${book}"
th:if="${book.publish == 1 or #authorization.expression('hasAuthority(''MARKETING'')')}"
>
<!--/* <!--/*
Check if book.author exists. If yes, then: Check if book.author exists. If yes, then:
@ -146,6 +160,14 @@ Idea of the following syntax used in this and other HTML document:
0.00 page.symbols.currency 0.00 page.symbols.currency
</td> </td>
<td>
<p sec:authorize="hasAuthority('MARKETING')"
th:text="${book.publish == 1} ? (${#messages.msgOrNull('page.text.list.yes')} ?: 'page.text.list.yes') : (${#messages.msgOrNull('page.text.list.no')} ?: 'page.text.list.no')"
>
page.text.list.[yes|no]
</p>
</td>
<td sec:authorize="hasAuthority('ADMIN')"> <td sec:authorize="hasAuthority('ADMIN')">
<a class="btn btn-danger" <a class="btn btn-danger"
th:attr="onclick='javascript:return confirm(\'' + 'Delete book: ' + ${book.title} + '?' + '\');'" th:attr="onclick='javascript:return confirm(\'' + 'Delete book: ' + ${book.title} + '?' + '\');'"
@ -190,6 +212,7 @@ Idea of the following syntax used in this and other HTML document:
<td></td> <td></td>
<td></td> <td></td>
<td></td> <td></td>
<td></td>
<td> <td>
<a class="btn btn-dark" th:href="@{__${restpage}__} + '/' + @{__${listpage}__}" <a class="btn btn-dark" th:href="@{__${restpage}__} + '/' + @{__${listpage}__}"
th:text="${#messages.msgOrNull('button.page.list.json')} ?: 'button.page.list.json'"> th:text="${#messages.msgOrNull('button.page.list.json')} ?: 'button.page.list.json'">
@ -213,6 +236,7 @@ Idea of the following syntax used in this and other HTML document:
<td></td> <td></td>
<td></td> <td></td>
<td></td> <td></td>
<td></td>
</tr> </tr>
</table> </table>


+ 30
- 0
bookstore/src/main/resources/templates/fragments/bookfields.html View File

@ -1,7 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" <html lang="en" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5"> xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
<link type="text/css" rel="stylesheet" href="../../static/css/bookstore.css" />
<link type="text/css" rel="stylesheet" href="../../static/css/bootstrap.min.css" />
</head>
<body> <body>
<div class="col-md-4 mb-3">
<th:block th:fragment="bookfields"> <th:block th:fragment="bookfields">
<div class="bookform-section"> <div class="bookform-section">
@ -198,7 +204,31 @@
book.desc.set.category book.desc.set.category
</small> </small>
</div> </div>
<div class="form-group bookform-section" th:if="${#authorization.expression('hasAuthority(''MARKETING'')')}">
<div class="checkbox-base">
<div>
<label for="BookPublish"
th:text="${#messages.msgOrNull('book.fields.publish')} ?: 'book.fields.publish'">
book.fields.publish
</label>
</div>
<div class="checkbox-box">
<input class="form-control" type="checkbox" th:checked="*{publish}"/>
</div>
</div>
<small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.publish')} ?: 'book.desc.set.publish'">
book.desc.set.publish
</small>
</div>
</th:block> </th:block>
</div>
</body> </body>
</html> </html>

Loading…
Cancel
Save