Merge branch '116-delete-deadline' into 'dev'
Resolve "Удаление дедлайна" Closes #116 See merge request romanov73/ng-tracker!75
This commit is contained in:
commit
fc94ea1f26
@ -97,6 +97,14 @@ public class GrantController {
|
||||
return GRANT_PAGE;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/grant", params = "removeDeadline")
|
||||
public String removeDeadline(GrantDto grantDto,
|
||||
@RequestParam(value = "removeDeadline") Integer deadlineId) {
|
||||
grantService.removeDeadline(grantDto, deadlineId);
|
||||
return GRANT_PAGE;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/grant", params = "createProject")
|
||||
public String createProject(@Valid GrantDto grantDto, Errors errors) throws IOException {
|
||||
if (errors.hasErrors()) {
|
||||
|
@ -64,8 +64,6 @@ public class Grant extends BaseEntity implements UserContainer {
|
||||
@OrderBy("date")
|
||||
private List<Deadline> deadlines = new ArrayList<>();
|
||||
|
||||
//Описание гранта
|
||||
@NotNull
|
||||
private String comment;
|
||||
|
||||
//Заявка на грант
|
||||
|
@ -35,6 +35,7 @@ public class GrantDto {
|
||||
private boolean hasDegree;
|
||||
private List<Integer> paperIds = new ArrayList<>();
|
||||
private List<Paper> papers = new ArrayList<>();
|
||||
private List<Integer> removedDeadlineIds = new ArrayList<>();
|
||||
|
||||
public GrantDto() {
|
||||
deadlines.add(new Deadline());
|
||||
@ -215,4 +216,12 @@ public class GrantDto {
|
||||
public void setPapers(List<Paper> papers) {
|
||||
this.papers = papers;
|
||||
}
|
||||
|
||||
public List<Integer> getRemovedDeadlineIds() {
|
||||
return removedDeadlineIds;
|
||||
}
|
||||
|
||||
public void setRemovedDeadlineIds(List<Integer> removedDeadlineIds) {
|
||||
this.removedDeadlineIds = removedDeadlineIds;
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ public class GrantService {
|
||||
if (grantDto.getApplicationFileName() != null && grant.getApplication() != null) {
|
||||
fileService.deleteFile(grant.getApplication());
|
||||
}
|
||||
grantDto.getRemovedDeadlineIds().forEach(deadlineService::remove);
|
||||
grantRepository.save(copyFromDto(grant, grantDto));
|
||||
return grant.getId();
|
||||
}
|
||||
@ -184,4 +185,12 @@ public class GrantService {
|
||||
grantDto.getPapers().clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeDeadline(GrantDto grantDto, Integer deadlineId) {
|
||||
if (grantDto.getDeadlines().get(deadlineId).getId() != null) {
|
||||
grantDto.getRemovedDeadlineIds().add(grantDto.getDeadlines().get(deadlineId).getId());
|
||||
}
|
||||
grantDto.getDeadlines().remove((int) deadlineId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,3 +25,7 @@
|
||||
width: 22px;
|
||||
margin: 3px;
|
||||
}
|
||||
|
||||
.btn-delete-deadline {
|
||||
color: black;
|
||||
}
|
@ -48,6 +48,7 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Дедлайны показателей:</label>
|
||||
<input type="hidden" th:field="*{removedDeadlineIds}"/>
|
||||
<div class="row" th:each="deadline, rowStat : *{deadlines}">
|
||||
<input type="hidden" th:field="*{deadlines[__${rowStat.index}__].id}"/>
|
||||
<div class="col-6 div-deadline-date">
|
||||
@ -59,12 +60,14 @@
|
||||
th:field="*{deadlines[__${rowStat.index}__].description}"/>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<a class="btn btn-danger float-right"
|
||||
th:onclick="|$('#deadlines${rowStat.index}\\.description').val('');
|
||||
$('#deadlines${rowStat.index}\\.date').val('');
|
||||
$('#addDeadline').click();|"><span
|
||||
aria-hidden="true"><i class="fa fa-times"/></span>
|
||||
</a>
|
||||
<button type="submit"
|
||||
class="btn btn-danger float-right btn-delete-deadline "
|
||||
id="removeDeadline" name="removeDeadline"
|
||||
th:value="${rowStat.index}">
|
||||
<span aria-hidden="true">
|
||||
<i class="fa fa-times"/>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p th:if="${#fields.hasErrors('deadlines')}" th:errors="*{deadlines}"
|
||||
|
Loading…
Reference in New Issue
Block a user