#98 project tasks deadline edited

This commit is contained in:
Васин Антон 2019-05-06 17:43:20 +03:00
parent 2dff183662
commit ee55e08fee
10 changed files with 78 additions and 9 deletions

View File

@ -267,7 +267,8 @@ public class ConferenceService {
} }
public Deadline copyDeadline(Deadline oldDeadline) { public Deadline copyDeadline(Deadline oldDeadline) {
Deadline newDeadline = new Deadline(oldDeadline.getDate(), oldDeadline.getDescription()); Deadline newDeadline = new Deadline(oldDeadline.getDate(), oldDeadline.getDescription(),
oldDeadline.getExecutor(), oldDeadline.getDone());
newDeadline.setId(oldDeadline.getId()); newDeadline.setId(oldDeadline.getId());
return newDeadline; return newDeadline;
} }

View File

@ -20,21 +20,30 @@ public class Deadline extends BaseEntity {
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date date; private Date date;
private String executor;
private Boolean done;
public Deadline() { public Deadline() {
} }
public Deadline(Date deadlineDate, String description) { public Deadline(Date deadlineDate, String description, String executor, Boolean done) {
this.date = deadlineDate; this.date = deadlineDate;
this.description = description; this.description = description;
this.executor = executor;
this.done = done;
} }
@JsonCreator @JsonCreator
public Deadline(@JsonProperty("id") Integer id, public Deadline(@JsonProperty("id") Integer id,
@JsonProperty("description") String description, @JsonProperty("description") String description,
@JsonProperty("date") Date date) { @JsonProperty("date") Date date,
@JsonProperty("executor") String executor,
@JsonProperty("done") Boolean done) {
this.setId(id); this.setId(id);
this.description = description; this.description = description;
this.date = date; this.date = date;
this.executor = executor;
this.done = done;
} }
public String getDescription() { public String getDescription() {
@ -53,6 +62,22 @@ public class Deadline extends BaseEntity {
this.date = date; this.date = date;
} }
public String getExecutor() {
return executor;
}
public void setExecutor(String executor) {
this.executor = executor;
}
public Boolean getDone() {
return done;
}
public void setDone(Boolean done) {
this.done = done;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {
@ -67,11 +92,13 @@ public class Deadline extends BaseEntity {
Deadline deadline = (Deadline) o; Deadline deadline = (Deadline) o;
return getId().equals(deadline.getId()) && return getId().equals(deadline.getId()) &&
description.equals(deadline.description) && description.equals(deadline.description) &&
date.equals(deadline.date); date.equals(deadline.date) &&
executor.equals(deadline.executor) &&
done.equals(deadline.done);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(super.hashCode(), description, date); return Objects.hash(super.hashCode(), description, date, executor, done);
} }
} }

View File

@ -141,7 +141,7 @@ public class GrantService {
grant.setComment("Комментарий к гранту 1"); grant.setComment("Комментарий к гранту 1");
grant.setProject(projectId); grant.setProject(projectId);
grant.setStatus(APPLICATION); grant.setStatus(APPLICATION);
grant.getDeadlines().add(new Deadline(deadlineDate, "первый дедлайн")); grant.getDeadlines().add(new Deadline(deadlineDate, "первый дедлайн", "", false));
grant.getAuthors().add(user); grant.getAuthors().add(user);
grant.setLeader(user); grant.setLeader(user);
grant.getPapers().add(paper); grant.getPapers().add(paper);

View File

@ -173,7 +173,7 @@ public class PaperService {
Paper paper = new Paper(); Paper paper = new Paper();
paper.setTitle(title); paper.setTitle(title);
paper.getAuthors().add(user); paper.getAuthors().add(user);
paper.getDeadlines().add(new Deadline(deadlineDate, "первый дедлайн")); paper.getDeadlines().add(new Deadline(deadlineDate, "первый дедлайн", "", false));
paper.setCreateDate(new Date()); paper.setCreateDate(new Date());
paper.setUpdateDate(new Date()); paper.setUpdateDate(new Date());
paper.setStatus(DRAFT); paper.setStatus(DRAFT);

View File

@ -79,6 +79,13 @@ public class ProjectController {
return "/projects/project"; return "/projects/project";
} }
@PostMapping(value = "/project", params = "removeDeadline")
public String removeDeadline(ProjectDto projectDto,
@RequestParam(value = "removeDeadline") Integer deadlineId) {
projectService.removeDeadline(projectDto, deadlineId);
return "/projects/project";
}
@GetMapping("/delete/{project-id}") @GetMapping("/delete/{project-id}")
public String delete(@PathVariable("project-id") Integer projectId) throws IOException { public String delete(@PathVariable("project-id") Integer projectId) throws IOException {
projectService.delete(projectId); projectService.delete(projectId);

View File

@ -20,6 +20,7 @@ public class ProjectDto {
private GrantDto grant; private GrantDto grant;
private String repository; private String repository;
private String applicationFileName; private String applicationFileName;
private List<Integer> removedDeadlineIds = new ArrayList<>();
public ProjectDto() { public ProjectDto() {
} }
@ -121,4 +122,12 @@ public class ProjectDto {
public void setApplicationFileName(String applicationFileName) { public void setApplicationFileName(String applicationFileName) {
this.applicationFileName = applicationFileName; this.applicationFileName = applicationFileName;
} }
public List<Integer> getRemovedDeadlineIds() {
return removedDeadlineIds;
}
public void setRemovedDeadlineIds(List<Integer> removedDeadlineIds) {
this.removedDeadlineIds = removedDeadlineIds;
}
} }

View File

@ -104,6 +104,13 @@ public class ProjectService {
} }
} }
public void removeDeadline(ProjectDto projectDto, Integer deadlineId) {
if (projectDto.getDeadlines().get(deadlineId).getId() != null) {
projectDto.getRemovedDeadlineIds().add(projectDto.getDeadlines().get(deadlineId).getId());
}
projectDto.getDeadlines().remove((int) deadlineId);
}
public Project findById(Integer id) { public Project findById(Integer id) {
return projectRepository.findOne(id); return projectRepository.findOne(id);
} }

View File

@ -0,0 +1,13 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet author="anton" id="20190506_000000-1">
<addColumn tableName="deadline">
<column name="executor" type="varchar(255)"/>
</addColumn>
<addColumn tableName="deadline">
<column name="done" type="boolean"/>
</addColumn>
</changeSet>
</databaseChangeLog>

View File

@ -38,4 +38,5 @@
<include file="db/changelog-20190428_000000-schema.xml"/> <include file="db/changelog-20190428_000000-schema.xml"/>
<include file="db/changelog-20190430_000000-schema.xml"/> <include file="db/changelog-20190430_000000-schema.xml"/>
<include file="db/changelog-20190505_000000-schema.xml"/> <include file="db/changelog-20190505_000000-schema.xml"/>
<include file="db/changelog-20190506_000000-schema.xml"/>
</databaseChangeLog> </databaseChangeLog>

View File

@ -73,14 +73,18 @@
<label>Дедлайны показателей:</label> <label>Дедлайны показателей:</label>
<div class="row" th:each="deadline, rowStat : *{deadlines}"> <div class="row" th:each="deadline, rowStat : *{deadlines}">
<input type="hidden" th:field="*{deadlines[__${rowStat.index}__].id}"/> <input type="hidden" th:field="*{deadlines[__${rowStat.index}__].id}"/>
<div class="col-6 div-deadline-date"> <div class="col-3 div-deadline-date">
<input type="date" class="form-control form-deadline-date" name="deadline" <input type="date" class="form-control form-deadline-date" name="deadline"
th:field="*{deadlines[__${rowStat.index}__].date}"/> th:field="*{deadlines[__${rowStat.index}__].date}"/>
</div> </div>
<div class="col-4 div-deadline-description"> <div class="col-3 div-deadline-description">
<input class="form-control" type="text" placeholder="Описание" <input class="form-control" type="text" placeholder="Описание"
th:field="*{deadlines[__${rowStat.index}__].description}"/> th:field="*{deadlines[__${rowStat.index}__].description}"/>
</div> </div>
<div class="col-4 div-deadline-executor">
<input class="form-control" type="text" placeholder="Исполнитель"
th:field="*{deadlines[__${rowStat.index}__].executor}"/>
</div>
<div class="col-2"> <div class="col-2">
<a class="btn btn-danger float-right" <a class="btn btn-danger float-right"
th:onclick="|$('#deadlines${rowStat.index}\\.description').val(''); th:onclick="|$('#deadlines${rowStat.index}\\.description').val('');