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.DecimalMax;
import javax.validation.constraints.DecimalMin; import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits; import javax.validation.constraints.Digits;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min; import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
@ -233,14 +232,15 @@ public class Book {
) )
private Category category; private Category category;
/*
* TODO should this be a separate Entity with one-to-one relationship?
*/
@Column( @Column(
nullable = false, nullable = false,
columnDefinition = "BIT" columnDefinition = "BIT"
) )
@Min(0)
@Max(1)
@JsonIgnore @JsonIgnore
private int publish;
private boolean publish;
//////////////////// ////////////////////
// Attribute setters // Attribute setters
@ -284,7 +284,7 @@ public class Book {
this.category = category; this.category = category;
} }
public void setPublish(int publish) {
public void setPublish(boolean publish) {
this.publish = publish; this.publish = publish;
} }
@ -326,7 +326,7 @@ public class Book {
return category; return category;
} }
public int getPublish() {
public boolean getPublish() {
return publish; return publish;
} }
@ -335,7 +335,7 @@ public class Book {
public 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(); // super();
this.title = title; this.title = title;
this.author = author; 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 <tr
th:each="book : ${books}" th:each="book : ${books}"
th:object="${book}" 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> <td>
<p sec:authorize="hasAuthority('MARKETING')" <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] page.text.list.[yes|no]
</p> </p>


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

@ -216,7 +216,8 @@
</div> </div>
<div class="checkbox-box"> <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>
</div> </div>


Loading…
Cancel
Save