add dynamic deadlines
This commit is contained in:
parent
751195bf96
commit
708a1a6d32
@ -55,6 +55,13 @@ public class DeadlineService {
|
||||
return create(deadline);
|
||||
}
|
||||
|
||||
public Deadline create(String description, Date date) {
|
||||
Deadline deadline = new Deadline();
|
||||
deadline.setDate(date);
|
||||
deadline.setDescription(description);
|
||||
return create(deadline);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void remove(Integer deadlineId) {
|
||||
deadlineRepository.deleteById(deadlineId);
|
||||
|
@ -2,6 +2,8 @@ package ru.ulstu.paper.controller;
|
||||
|
||||
import ru.ulstu.core.navigation.Page;
|
||||
import ru.ulstu.core.util.FacesUtil;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.deadline.service.DeadlineService;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.paper.service.PaperService;
|
||||
import ru.ulstu.user.model.User;
|
||||
@ -22,6 +24,9 @@ public class PaperView implements Serializable {
|
||||
@Inject
|
||||
private PaperService paperService;
|
||||
|
||||
@Inject
|
||||
private DeadlineService deadlineService;
|
||||
|
||||
@Inject
|
||||
private UserService userService;
|
||||
|
||||
@ -34,6 +39,8 @@ public class PaperView implements Serializable {
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
paper = paperService.findPaperById(Integer.valueOf(FacesUtil.getRequestParams().get("id")));
|
||||
newDeadlineDescription = "";
|
||||
newDeadlineDate = new Date();
|
||||
FacesUtil.showInfoMessage("Статья открыта", "");
|
||||
}
|
||||
|
||||
@ -78,4 +85,14 @@ public class PaperView implements Serializable {
|
||||
public void setNewDeadlineDescription(String newDeadlineDescription) {
|
||||
this.newDeadlineDescription = newDeadlineDescription;
|
||||
}
|
||||
|
||||
public void deleteDeadline(Deadline deadline) {
|
||||
paper.getDeadlines().remove(deadline);
|
||||
}
|
||||
|
||||
public void addDeadline() {
|
||||
paper.getDeadlines().add(deadlineService.create(newDeadlineDescription, newDeadlineDate));
|
||||
newDeadlineDescription = "";
|
||||
newDeadlineDate = new Date();
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public class PaperService {
|
||||
Paper oldPaper = paperRepository.getOne(newPaper.getId());
|
||||
Paper.PaperStatus oldStatus = oldPaper.getStatus();
|
||||
Set<User> oldAuthors = new HashSet<>(oldPaper.getAuthors());
|
||||
|
||||
newPaper.setUpdateDate(new Date());
|
||||
newPaper = paperRepository.save(newPaper);
|
||||
for (User author : newPaper.getAuthors()) {
|
||||
if (!oldAuthors.contains(author)) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
<title><ui:insert name="header">NG-Tracker</ui:insert></title>
|
||||
<h:outputStylesheet name="css/style.css"/>
|
||||
<h:outputStylesheet name="css/google/kaushan.css"/>
|
||||
<h:outputStylesheet name="primeicons/primeicons.css" library="primefaces"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
|
||||
</h:head>
|
||||
|
||||
|
@ -107,6 +107,12 @@
|
||||
<div class="ui-md-5 ui-g-12">
|
||||
<p:inputText value="#{deadline.description}"/>
|
||||
</div>
|
||||
<div class="ui-md-1 ui-g-12">
|
||||
<p:commandButton icon="pi pi-times">
|
||||
<p:ajax update="mainForm" process="@this"
|
||||
listener="#{paperView.deleteDeadline(deadline)}"/>
|
||||
</p:commandButton>
|
||||
</div>
|
||||
</ui:repeat>
|
||||
<div class="ui-md-5 ui-g-12">
|
||||
<p:datePicker value="#{paperView.newDeadlineDate}" placeholder="Введите дату"
|
||||
@ -116,6 +122,12 @@
|
||||
<p:inputText value="#{paperView.newDeadlineDescription}"
|
||||
placeholder="Описание ключевой даты"/>
|
||||
</div>
|
||||
<div class="ui-md-1 ui-g-12">
|
||||
<p:commandButton icon="pi pi-check">
|
||||
<p:ajax update="mainForm" process="@this"
|
||||
listener="#{paperView.addDeadline()}"/>
|
||||
</p:commandButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -127,6 +139,20 @@
|
||||
<p:editor id="comment" widgetVar="editor2" value="#{paperView.paper.comment}" height="300"
|
||||
style="margin-bottom:10px" placeholder="Комментарий"/>
|
||||
</div>
|
||||
<div class="ui-md-2 ui-g-12">
|
||||
<p>
|
||||
Статья создана
|
||||
<h:outputText value="#{paperView.paper.createDate}">
|
||||
<f:convertDateTime pattern="dd.MM.yyyy HH:mm"/>
|
||||
</h:outputText>
|
||||
</p>
|
||||
<p>
|
||||
Статья обновлена
|
||||
<h:outputText value="#{paperView.paper.updateDate}">
|
||||
<f:convertDateTime pattern="dd.MM.yyyy HH:mm"/>
|
||||
</h:outputText>
|
||||
</p>
|
||||
</div>
|
||||
<div class="ui-md-5 ui-g-12">
|
||||
<p:commandButton action="#{paperView.save}" value="Сохранить" ajax="true" process="@form"
|
||||
update="messages @form"/>
|
||||
|
Loading…
Reference in New Issue
Block a user