From 8ced83ad2b6509341058a11a2c9621f3dac8e72d Mon Sep 17 00:00:00 2001 From: T-Midnight Date: Thu, 25 Apr 2019 13:23:36 +0400 Subject: [PATCH 1/5] #116 delete annotation --- src/main/java/ru/ulstu/grant/model/Grant.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/ru/ulstu/grant/model/Grant.java b/src/main/java/ru/ulstu/grant/model/Grant.java index c8bdd8a..abd61ac 100644 --- a/src/main/java/ru/ulstu/grant/model/Grant.java +++ b/src/main/java/ru/ulstu/grant/model/Grant.java @@ -64,8 +64,6 @@ public class Grant extends BaseEntity implements UserContainer { @OrderBy("date") private List deadlines = new ArrayList<>(); - //Описание гранта - @NotNull private String comment; //Заявка на грант From 7c5a0826c5aaac19a356922d47e8d2e21ed84e7a Mon Sep 17 00:00:00 2001 From: T-Midnight Date: Thu, 25 Apr 2019 13:24:36 +0400 Subject: [PATCH 2/5] #116 add new variable --- src/main/java/ru/ulstu/grant/model/GrantDto.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/ru/ulstu/grant/model/GrantDto.java b/src/main/java/ru/ulstu/grant/model/GrantDto.java index d979e23..3fb77c5 100644 --- a/src/main/java/ru/ulstu/grant/model/GrantDto.java +++ b/src/main/java/ru/ulstu/grant/model/GrantDto.java @@ -35,6 +35,7 @@ public class GrantDto { private boolean hasDegree; private List paperIds = new ArrayList<>(); private List papers = new ArrayList<>(); + private List removedDeadlineIds = new ArrayList<>(); public GrantDto() { deadlines.add(new Deadline()); @@ -215,4 +216,12 @@ public class GrantDto { public void setPapers(List papers) { this.papers = papers; } + + public List getRemovedDeadlineIds() { + return removedDeadlineIds; + } + + public void setRemovedDeadlineIds(List removedDeadlineIds) { + this.removedDeadlineIds = removedDeadlineIds; + } } From 4fa0c14ae62904f2e4509c5784c44752d6f8fb6a Mon Sep 17 00:00:00 2001 From: T-Midnight Date: Thu, 25 Apr 2019 13:25:32 +0400 Subject: [PATCH 3/5] #116 add removeDeadline method --- .../java/ru/ulstu/grant/controller/GrantController.java | 8 ++++++++ src/main/java/ru/ulstu/grant/service/GrantService.java | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/ru/ulstu/grant/controller/GrantController.java b/src/main/java/ru/ulstu/grant/controller/GrantController.java index 92ce826..85a0cd9 100644 --- a/src/main/java/ru/ulstu/grant/controller/GrantController.java +++ b/src/main/java/ru/ulstu/grant/controller/GrantController.java @@ -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()) { diff --git a/src/main/java/ru/ulstu/grant/service/GrantService.java b/src/main/java/ru/ulstu/grant/service/GrantService.java index 1f0b6ce..cabed80 100644 --- a/src/main/java/ru/ulstu/grant/service/GrantService.java +++ b/src/main/java/ru/ulstu/grant/service/GrantService.java @@ -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); + } + } From 2bb5189fff7e80b2921857e996346d0d02410903 Mon Sep 17 00:00:00 2001 From: T-Midnight Date: Thu, 25 Apr 2019 13:25:56 +0400 Subject: [PATCH 4/5] #116 update view --- src/main/resources/templates/grants/grant.html | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/resources/templates/grants/grant.html b/src/main/resources/templates/grants/grant.html index f66c74c..8ac81ab 100644 --- a/src/main/resources/templates/grants/grant.html +++ b/src/main/resources/templates/grants/grant.html @@ -48,6 +48,7 @@
+
@@ -59,12 +60,14 @@ th:field="*{deadlines[__${rowStat.index}__].description}"/>
- - +

Date: Thu, 25 Apr 2019 13:26:40 +0400 Subject: [PATCH 5/5] #116 add style for delete icon --- src/main/resources/public/css/grant.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/public/css/grant.css b/src/main/resources/public/css/grant.css index 2176acf..3c0cfc8 100644 --- a/src/main/resources/public/css/grant.css +++ b/src/main/resources/public/css/grant.css @@ -24,4 +24,8 @@ height: 22px; width: 22px; margin: 3px; +} + +.btn-delete-deadline { + color: black; } \ No newline at end of file