#69 added button disabling take part, if cur user already taken part
This commit is contained in:
parent
8fd352aaa4
commit
96431701df
@ -51,6 +51,7 @@ public class ConferenceController {
|
|||||||
if (id != null && id > 0) {
|
if (id != null && id > 0) {
|
||||||
ConferenceDto conferenceDto = conferenceService.findOneDto(id);
|
ConferenceDto conferenceDto = conferenceService.findOneDto(id);
|
||||||
conferenceDto.setNotSelectedPapers(getNotSelectPapers(conferenceDto.getPaperIds()));
|
conferenceDto.setNotSelectedPapers(getNotSelectPapers(conferenceDto.getPaperIds()));
|
||||||
|
conferenceDto.setDisabledTakePart(isCurrentUserParticipant(conferenceDto.getUsers()));
|
||||||
modelMap.put("conferenceDto", conferenceDto);
|
modelMap.put("conferenceDto", conferenceDto);
|
||||||
} else {
|
} else {
|
||||||
ConferenceDto conferenceDto = new ConferenceDto();
|
ConferenceDto conferenceDto = new ConferenceDto();
|
||||||
@ -119,6 +120,10 @@ public class ConferenceController {
|
|||||||
return conferenceService.getConferencePapers(paperIds);
|
return conferenceService.getConferencePapers(paperIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCurrentUserParticipant(List<ConferenceUser> conferenceUsers) {
|
||||||
|
return conferenceService.isCurrentUserParticipant(conferenceUsers);
|
||||||
|
}
|
||||||
|
|
||||||
@ModelAttribute("allParticipation")
|
@ModelAttribute("allParticipation")
|
||||||
public List<ConferenceUser.Participation> getAllParticipation() {
|
public List<ConferenceUser.Participation> getAllParticipation() {
|
||||||
return conferenceService.getAllParticipations();
|
return conferenceService.getAllParticipations();
|
||||||
|
@ -40,7 +40,7 @@ public class ConferenceDto {
|
|||||||
private List<Paper> papers = new ArrayList<>();
|
private List<Paper> papers = new ArrayList<>();
|
||||||
private List<Paper> notSelectedPapers = new ArrayList<>();
|
private List<Paper> notSelectedPapers = new ArrayList<>();
|
||||||
private List<ConferenceUser> users = new ArrayList<>();
|
private List<ConferenceUser> users = new ArrayList<>();
|
||||||
private Integer filterUserId;
|
private boolean disabledTakePart = false;
|
||||||
|
|
||||||
public ConferenceDto() {
|
public ConferenceDto() {
|
||||||
}
|
}
|
||||||
@ -58,7 +58,8 @@ public class ConferenceDto {
|
|||||||
@JsonProperty("paperIds") List<Integer> paperIds,
|
@JsonProperty("paperIds") List<Integer> paperIds,
|
||||||
@JsonProperty("users") List<ConferenceUser> users,
|
@JsonProperty("users") List<ConferenceUser> users,
|
||||||
@JsonProperty("papers") List<Paper> papers,
|
@JsonProperty("papers") List<Paper> papers,
|
||||||
@JsonProperty("notSelectedPapers") List<Paper> notSelectedPapers) {
|
@JsonProperty("notSelectedPapers") List<Paper> notSelectedPapers,
|
||||||
|
@JsonProperty("notSelectedPapers") Boolean disabledTakePart) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@ -72,6 +73,7 @@ public class ConferenceDto {
|
|||||||
this.users = users;
|
this.users = users;
|
||||||
this.papers = papers;
|
this.papers = papers;
|
||||||
this.notSelectedPapers = notSelectedPapers;
|
this.notSelectedPapers = notSelectedPapers;
|
||||||
|
this.disabledTakePart = disabledTakePart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConferenceDto(Conference conference) {
|
public ConferenceDto(Conference conference) {
|
||||||
@ -87,7 +89,6 @@ public class ConferenceDto {
|
|||||||
this.paperIds = convert(conference.getPapers(), paper -> paper.getId());
|
this.paperIds = convert(conference.getPapers(), paper -> paper.getId());
|
||||||
this.users = conference.getUsers();
|
this.users = conference.getUsers();
|
||||||
this.papers = conference.getPapers();
|
this.papers = conference.getPapers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
@ -186,12 +187,12 @@ public class ConferenceDto {
|
|||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getFilterUserId() {
|
public boolean isDisabledTakePart() {
|
||||||
return filterUserId;
|
return disabledTakePart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilterUserId(Integer filterUserId) {
|
public void setDisabledTakePart(boolean disabledTakePart) {
|
||||||
this.filterUserId = filterUserId;
|
this.disabledTakePart = disabledTakePart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getRemovedDeadlineIds() {
|
public List<Integer> getRemovedDeadlineIds() {
|
||||||
|
@ -100,6 +100,7 @@ public class ConferenceService {
|
|||||||
|
|
||||||
public void takePart(ConferenceDto conferenceDto) throws IOException {
|
public void takePart(ConferenceDto conferenceDto) throws IOException {
|
||||||
conferenceDto.getUsers().add(new ConferenceUser(userService.getCurrentUser()));
|
conferenceDto.getUsers().add(new ConferenceUser(userService.getCurrentUser()));
|
||||||
|
conferenceDto.setDisabledTakePart(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Paper> getConferencePapers(List<Integer> paperIds) {
|
public List<Paper> getConferencePapers(List<Integer> paperIds) {
|
||||||
@ -132,4 +133,12 @@ public class ConferenceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isCurrentUserParticipant(List<ConferenceUser> conferenceUsers) {
|
||||||
|
for (ConferenceUser participant : conferenceUsers) {
|
||||||
|
if (participant.getUser().getId() == userService.getCurrentUser().getId()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,16 @@ body {
|
|||||||
border-right: 1px solid #ced4da;
|
border-right: 1px solid #ced4da;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#take-part[disabled=disabled] {
|
||||||
|
background-color: #ced4da;
|
||||||
|
border-color: #c2c5c7;
|
||||||
|
}
|
||||||
|
|
||||||
|
#take-part[disabled=disabled]:hover {
|
||||||
|
background-color: #737475 !important;
|
||||||
|
border-color: #5d5e5f !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.paper-list {
|
.paper-list {
|
||||||
height: 200px;
|
height: 200px;
|
||||||
|
@ -122,8 +122,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group d-flex justify-content-end">
|
<div class="form-group d-flex justify-content-end">
|
||||||
|
<input type="hidden" th:value="*{disabledTakePart}" th:name="disabledTakePart"/>
|
||||||
<input id="take-part" class="btn btn-primary"
|
<input id="take-part" class="btn btn-primary"
|
||||||
type="submit" name="takePart" value="Принять участие"/>
|
type="submit" name="takePart" value="Принять участие"
|
||||||
|
th:disabled="*{disabledTakePart}"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user