#42 fix thymeleaf expressions

This commit is contained in:
Anton Romanov 2019-04-13 23:56:24 +04:00
parent 1756f29505
commit 8b2a559d37
4 changed files with 17 additions and 16 deletions

View File

@ -29,7 +29,7 @@ public class GrantDto {
private Set<Integer> authorIds;
private Set<UserDto> authors;
private Integer leaderId;
private boolean leader;
private boolean wasLeader;
private boolean birthDate;
private boolean degree;
@ -47,7 +47,7 @@ public class GrantDto {
@JsonProperty("authorIds") Set<Integer> authorIds,
@JsonProperty("authors") Set<UserDto> authors,
@JsonProperty("leader") Integer leaderId,
@JsonProperty("leader") boolean leader,
@JsonProperty("wasLeader") boolean wasLeader,
@JsonProperty("birthDate") boolean birthDate,
@JsonProperty("degree") boolean degree) {
this.id = id;
@ -59,7 +59,7 @@ public class GrantDto {
this.project = project;
this.authors = authors;
this.leaderId = leaderId;
this.leader = leader;
this.wasLeader = wasLeader;
this.birthDate = birthDate;
this.degree = degree;
}
@ -75,7 +75,7 @@ public class GrantDto {
this.authorIds = convert(grant.getAuthors(), user -> user.getId());
this.authors = convert(grant.getAuthors(), UserDto::new);
this.leaderId = grant.getLeader().getId();
this.leader = false;
this.wasLeader = false;
this.birthDate = false;
this.degree = false;
}
@ -167,12 +167,12 @@ public class GrantDto {
this.leaderId = leaderId;
}
public boolean isLeader() {
return leader;
public boolean isWasLeader() {
return wasLeader;
}
public void setLeader(boolean leader) {
this.leader = leader;
public void setWasLeader(boolean wasLeader) {
this.wasLeader = wasLeader;
}
public boolean isBirthDate() {

View File

@ -141,7 +141,7 @@ public class GrantService {
public List<User> getGrantAuthors(GrantDto grantDto) {
List<User> filteredUsers = userService.filterByAgeAndDegree(grantDto.isBirthDate(), grantDto.isDegree());
if (grantDto.isLeader()) {
if (grantDto.isWasLeader()) {
filteredUsers = filteredUsers
.stream()
.filter(getCompletedGrantLeaders()::contains)

View File

@ -29,7 +29,7 @@ public interface UserRepository extends JpaRepository<User, Integer> {
User findOneWithRolesByLogin(String login);
@Query("SELECT u FROM User u " +
"WHERE (YEAR(u.birthDate) - YEAR(CURRENT_DATE) < 35 OR :hasAge = FALSE) " +
"WHERE (YEAR(CURRENT_DATE) - YEAR(u.birthDate) < 35 OR :hasAge = FALSE) " +
"AND (u.degree = 'CANDIDATE' OR :hasDegree = FALSE)" +
"ORDER BY u.lastName")
List<User> filterByAgeAndDegree(@Param("hasAge") boolean hasAge,

View File

@ -85,16 +85,17 @@
</div>
</div>
</div>
<div class="col-md-6 col-sm-12">
<label data-toggle="collapse" href="#collapse-filter"
aria-expanded="false" aria-controls="collapse-filter">Фильтр рабочей
группы</label>
<div class="form-check collapse" id="collapse-filter">
<label data-toggle="collapse"
href="#collapse-filter"
aria-expanded="false"
aria-controls="collapse-filter">Фильтр рабочей группы
</label>
<div th:class="${grantDto.wasLeader || grantDto.birthDate || grantDto.degree} ? 'form-check' : 'form-check collapse'" id="collapse-filter">
<div class="row">
<div class="col">
<input class="form-check-input" type="checkbox" id="f1"
th:field="*{leader}" th:onclick="|$('#filter').click();|"/>
th:field="*{wasLeader}" th:onclick="|$('#filter').click();|"/>
<label class="form-check-label" for="f1">Был руководителем проекта</label>
</div>
<div class="col">