Browse Source

Un-hardcode more messages; update web forms

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.3-alpha
Pekka Helenius 4 years ago
parent
commit
3cbe299f1c
3 changed files with 93 additions and 15 deletions
  1. +13
    -1
      bookstore/src/main/resources/messages.properties
  2. +39
    -12
      bookstore/src/main/resources/templates/fragments/bookfields.html
  3. +41
    -2
      bookstore/src/main/resources/templates/fragments/loginout.html

+ 13
- 1
bookstore/src/main/resources/messages.properties View File

@ -45,7 +45,14 @@ book.error.id.invalid = Wrong book
book.null.author = Unknown book.null.author = Unknown
book.null.category = None book.null.category = None
book.placeholder.title = Book title
book.placeholder.author.firstname = Book author first name
book.placeholder.author.lastname = Book author last name
book.placeholder.isbn = Book ISBN code
book.placeholder.year = Book publication year \(\YYYY\)
book.placeholder.price = 0.00
page.title.browser.list = Bookstore page page.title.browser.list = Bookstore page
page.title.browser.add = Add book page.title.browser.add = Add book
page.title.browser.edit = Update book page.title.browser.edit = Update book
@ -98,6 +105,11 @@ page.text.apiref.link = Link
page.text.error = Error while processing your request page.text.error = Error while processing your request
page.auth.failure = Authentication failure\!
auth.field.placeholder.username = User name
auth.field.placeholder.password = Password
button.book.add = Add book button.book.add = Add book
button.book.edit = Update book button.book.edit = Update book


+ 39
- 12
bookstore/src/main/resources/templates/fragments/bookfields.html View File

@ -22,7 +22,10 @@
th:text="${#messages.msgOrNull('book.author.firstName')} ?: 'book.author.firstName'"> th:text="${#messages.msgOrNull('book.author.firstName')} ?: 'book.author.firstName'">
book.author.firstName book.author.firstName
</label> </label>
<input class="form-control" type="text" th:field="*{author.firstName}" placeholder="Book author first name"/>
<input class="form-control" type="text" th:field="*{author.firstName}"
placeholder="Book author first name"
th:placeholder="#{book.placeholder.author.firstname}"
/>
<small class="form-text text-muted" <small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.author.firstname')} ?: 'book.desc.set.author.firstname'"> th:text="${#messages.msgOrNull('book.desc.set.author.firstname')} ?: 'book.desc.set.author.firstname'">
@ -40,7 +43,9 @@
</small> </small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('author.firstName')}" <div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('author.firstName')}"
th:errors="*{author.firstName}">Invalid author first name value</div>
th:errors="*{author.firstName}">
Invalid author first name value
</div>
</div> </div>
<div class="col"> <div class="col">
@ -48,7 +53,10 @@
th:text="${#messages.msgOrNull('book.author.lastName')} ?: 'book.author.lastName'"> th:text="${#messages.msgOrNull('book.author.lastName')} ?: 'book.author.lastName'">
book.author.lastName book.author.lastName
</label> </label>
<input class="form-control" type="text" th:field="*{author.lastName}" placeholder="Book author last name"/>
<input class="form-control" type="text" th:field="*{author.lastName}"
placeholder="Book author last name"
th:placeholder="#{book.placeholder.author.lastname}"
/>
<small class="form-text text-muted" <small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.author.lastname')} ?: 'book.desc.set.author.lastname'"> th:text="${#messages.msgOrNull('book.desc.set.author.lastname')} ?: 'book.desc.set.author.lastname'">
@ -66,7 +74,9 @@
</small> </small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('author.lastName')}" <div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('author.lastName')}"
th:errors="*{author.lastName}">Invalid author last name value</div>
th:errors="*{author.lastName}">
Invalid author last name value
</div>
</div> </div>
</div> </div>
</div> </div>
@ -76,7 +86,10 @@
th:text="${#messages.msgOrNull('book.title')} ?: 'book.title'"> th:text="${#messages.msgOrNull('book.title')} ?: 'book.title'">
book.title book.title
</label> </label>
<input class="form-control" type="text" th:field="*{title}" placeholder="Book title"/>
<input class="form-control" type="text" th:field="*{title}"
placeholder="Book title"
th:placeholder="#{book.placeholder.title}"
/>
<small class="form-text text-muted" <small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.title')} ?: 'book.desc.set.title'"> th:text="${#messages.msgOrNull('book.desc.set.title')} ?: 'book.desc.set.title'">
@ -94,7 +107,9 @@
</small> </small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('title')}" <div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('title')}"
th:errors="*{title}">Invalid title value</div>
th:errors="*{title}">
Invalid title value
</div>
</div> </div>
<div class="form-group bookform-section"> <div class="form-group bookform-section">
@ -102,7 +117,9 @@
th:text="${#messages.msgOrNull('book.isbn')} ?: 'book.isbn'"> th:text="${#messages.msgOrNull('book.isbn')} ?: 'book.isbn'">
book.isbn book.isbn
</label> </label>
<input class="form-control" type="text" th:field="*{isbn}" placeholder="Book ISBN code"/>
<input class="form-control" type="text" th:field="*{isbn}"
placeholder="Book ISBN code"
th:placeholder="#{book.placeholder.isbn}"/>
<small class="form-text text-muted" <small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.isbn')} ?: 'book.desc.set.isbn'"> th:text="${#messages.msgOrNull('book.desc.set.isbn')} ?: 'book.desc.set.isbn'">
@ -120,7 +137,9 @@
</small> </small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('isbn')}" <div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('isbn')}"
th:errors="*{isbn}">Invalid ISBN code</div>
th:errors="*{isbn}">
Invalid ISBN code
</div>
</div> </div>
<div class="form-group bookform-section"> <div class="form-group bookform-section">
@ -128,7 +147,9 @@
th:text="${#messages.msgOrNull('book.year')} ?: 'book.year'"> th:text="${#messages.msgOrNull('book.year')} ?: 'book.year'">
book.year book.year
</label> </label>
<input class="form-control" type="text" th:field="*{year}" placeholder="Book publication year (YYYY)"/>
<input class="form-control" type="text" th:field="*{year}"
placeholder="Book publication year (YYYY)"
th:placeholder="#{book.placeholder.year}"/>
<small class="form-text text-muted" <small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.year')} ?: 'book.desc.set.year'"> th:text="${#messages.msgOrNull('book.desc.set.year')} ?: 'book.desc.set.year'">
@ -146,7 +167,9 @@
</small> </small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('year')}" <div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('year')}"
th:errors="*{year}">Invalid year value</div>
th:errors="*{year}">
Invalid year value
</div>
</div> </div>
<div class="form-group bookform-section" th:if="${#authorization.expression('hasAuthority(''MARKETING'')')}"> <div class="form-group bookform-section" th:if="${#authorization.expression('hasAuthority(''MARKETING'')')}">
@ -162,7 +185,9 @@
page.symbols.currency page.symbols.currency
</div> </div>
</div> </div>
<input class="form-control" type="text" th:field="*{price}" placeholder="0.00"/>
<input class="form-control" type="text" th:field="*{price}"
placeholder="0.00"
th:placeholder="#{book.placeholder.price}"/>
</div> </div>
<small class="form-text text-muted" <small class="form-text text-muted"
th:text="${#messages.msgOrNull('book.desc.set.price')} ?: 'book.desc.set.price'"> th:text="${#messages.msgOrNull('book.desc.set.price')} ?: 'book.desc.set.price'">
@ -180,7 +205,9 @@
</small> </small>
<div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('price')}" <div class="alert alert-danger mt-2" th:if="${#fields.hasErrors('price')}"
th:errors="*{price}">Invalid price value</div>
th:errors="*{price}">
Invalid price value
</div>
</div> </div>
<div class="form-group bookform-section"> <div class="form-group bookform-section">


+ 41
- 2
bookstore/src/main/resources/templates/fragments/loginout.html View File

@ -8,6 +8,12 @@
<body> <body>
<th:block th:fragment="loginout"> <th:block th:fragment="loginout">
<div id="bookstore-loginout"> <div id="bookstore-loginout">
<!--/*
HTML element blocks when a user is authenticated
** START: logout elements **
*/-->
<div sec:authorize="isAuthenticated()"> <div sec:authorize="isAuthenticated()">
<div> <div>
<form th:action="@{__${logoutpage}__}" method="post"> <form th:action="@{__${logoutpage}__}" method="post">
@ -23,15 +29,44 @@
page.text.list.authenticated httpServletRequest.remoteUser page.text.list.authenticated httpServletRequest.remoteUser
</p> </p>
</div> </div>
<!--/*
** END: logout elements **
*/-->
<!--/*
HTML element blocks when a user is not authenticated
** START: login elements **
*/-->
<div sec:authorize="isAnonymous()"> <div sec:authorize="isAnonymous()">
<form th:action="@{__${loginpage}__}" method="post"> <form th:action="@{__${loginpage}__}" method="post">
<input type="text" id="b_username" name="b_username" placeholder="User name">
<!--/*
Keep normal id field as fallback (i.e. for defining plain HTML CSS styles)
*/-->
<input type="text"
id="b_username"
th:id="${@environment.getProperty('auth.field.username')}"
th:name="${@environment.getProperty('auth.field.username')}"
placeholder="User name"
th:placeholder="#{auth.field.placeholder.username}"
/>
<input type="password" id="b_password" name="b_password" placeholder="Password">
<!--/*
Keep normal id field as fallback (i.e. for defining plain HTML CSS styles)
*/-->
<input type="password"
id="b_password"
th:id="${@environment.getProperty('auth.field.password')}"
th:name="${@environment.getProperty('auth.field.password')}"
placeholder="Password"
th:placeholder="#{auth.field.placeholder.password}"
/>
<!--/*
This element is filled only when authentication fails
*/-->
<p th:text="${authfailure}"></p> <p th:text="${authfailure}"></p>
<div class="mt-2"> <div class="mt-2">
@ -44,6 +79,10 @@
</form> </form>
<th:block th:replace="fragments/devusers :: devusers"/> <th:block th:replace="fragments/devusers :: devusers"/>
</div> </div>
<!--/*
** END: login elements **
*/-->
</div> </div>
</th:block> </th:block>
</body> </body>

Loading…
Cancel
Save