Browse Source

Change publish attribute data type to boolean

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.3-alpha
Pekka Helenius 4 years ago
parent
commit
db835dd753
3 changed files with 11 additions and 10 deletions
  1. +7
    -7
      bookstore/src/main/java/com/fjordtek/bookstore/model/book/Book.java
  2. +2
    -2
      bookstore/src/main/resources/templates/booklist.html
  3. +2
    -1
      bookstore/src/main/resources/templates/fragments/bookfields.html

+ 7
- 7
bookstore/src/main/java/com/fjordtek/bookstore/model/book/Book.java View File

@ -24,7 +24,6 @@ import javax.validation.Valid;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
@ -233,14 +232,15 @@ public class Book {
)
private Category category;
/*
* TODO should this be a separate Entity with one-to-one relationship?
*/
@Column(
nullable = false,
columnDefinition = "BIT"
)
@Min(0)
@Max(1)
@JsonIgnore
private int publish;
private boolean publish;
////////////////////
// Attribute setters
@ -284,7 +284,7 @@ public class Book {
this.category = category;
}
public void setPublish(int publish) {
public void setPublish(boolean publish) {
this.publish = publish;
}
@ -326,7 +326,7 @@ public class Book {
return category;
}
public int getPublish() {
public boolean getPublish() {
return publish;
}
@ -335,7 +335,7 @@ public class Book {
public Book() {}
public Book(String title, Author author, int year, String isbn, BigDecimal price, Category category, int publish) {
public Book(String title, Author author, int year, String isbn, BigDecimal price, Category category, boolean publish) {
// super();
this.title = title;
this.author = author;


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

@ -104,7 +104,7 @@ Idea of the following syntax used in this and other HTML document:
<tr
th:each="book : ${books}"
th:object="${book}"
th:if="${book.publish == 1 or #authorization.expression('hasAuthority(''MARKETING'')')}"
th:if="${book.publish == true or #authorization.expression('hasAuthority(''MARKETING'')')}"
>
<!--/*
@ -162,7 +162,7 @@ Idea of the following syntax used in this and other HTML document:
<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')"
th:text="${book.publish == true} ? (${#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>


+ 2
- 1
bookstore/src/main/resources/templates/fragments/bookfields.html View File

@ -216,7 +216,8 @@
</div>
<div class="checkbox-box">
<input class="form-control" type="checkbox" th:checked="*{publish}"/>
<input type="checkbox" th:field="*{publish}"/>
<!--/* th:text="${#messages.msgOrNull('book.fields.publish')} ?: 'book.fields.publish'" */-->
</div>
</div>


Loading…
Cancel
Save