From 53cc777734bb1b04d2d9835dceafa2443c112b8c Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Mon, 22 Apr 2019 21:46:42 +0400 Subject: [PATCH] #64 delete conference refactor --- .../controller/ConferenceController.java | 14 ++++++-------- .../PaperConferenceRelationExistException.java | 7 +++++++ src/main/resources/public/css/conference.css | 8 ++++++-- src/main/resources/public/js/conference.js | 9 ++++----- .../templates/conferences/conferences.html | 3 ++- .../conferences/fragments/confLineFragment.html | 13 ++++++++----- 6 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 src/main/java/ru/ulstu/paper/error/PaperConferenceRelationExistException.java diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 3c5ee10..a143e3b 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -6,7 +6,6 @@ import org.springframework.ui.ModelMap; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -68,6 +67,12 @@ public class ConferenceController { } } + @PostMapping(value = "/conferences", params = "deleteConference") + public String delete(@RequestParam("deleteConference") Integer conferenceId) throws IOException { + conferenceService.delete(conferenceId); + return String.format(REDIRECT_TO, CONFERENCES_PAGE); + } + @PostMapping(value = "/conference", params = "save") public String save(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException { filterEmptyDeadlines(conferenceDto); @@ -76,13 +81,6 @@ public class ConferenceController { } conferenceService.save(conferenceDto); return String.format(REDIRECT_TO, CONFERENCES_PAGE); - - } - - @GetMapping("/delete/{conference-id}") - public String delete(@PathVariable("conference-id") Integer conferenceId) throws IOException { - conferenceService.delete(conferenceId); - return String.format(REDIRECT_TO, CONFERENCES_PAGE); } @PostMapping(value = "/conference", params = "addDeadline") diff --git a/src/main/java/ru/ulstu/paper/error/PaperConferenceRelationExistException.java b/src/main/java/ru/ulstu/paper/error/PaperConferenceRelationExistException.java new file mode 100644 index 0000000..ddb3b5e --- /dev/null +++ b/src/main/java/ru/ulstu/paper/error/PaperConferenceRelationExistException.java @@ -0,0 +1,7 @@ +package ru.ulstu.paper.error; + +public class PaperConferenceRelationExistException extends RuntimeException { + public PaperConferenceRelationExistException(String message) { + super(message); + } +} diff --git a/src/main/resources/public/css/conference.css b/src/main/resources/public/css/conference.css index ad06b3c..e4243b1 100644 --- a/src/main/resources/public/css/conference.css +++ b/src/main/resources/public/css/conference.css @@ -2,7 +2,7 @@ body { min-width: 400px; } -.conference-row .col:hover { +.conference-row .d-flex:hover { background-color: #f3f3f3; border-radius: .25rem; } @@ -15,10 +15,14 @@ body { margin-bottom: 10px; } -.conference-row .col .text-decoration { +.conference-row .d-flex .text-decoration { text-decoration: none; } +.conference-row .d-flex { + margin: 0 15px; +} + .form-group textarea { min-height: 206px; diff --git a/src/main/resources/public/js/conference.js b/src/main/resources/public/js/conference.js index d415ca2..18a8c67 100644 --- a/src/main/resources/public/js/conference.js +++ b/src/main/resources/public/js/conference.js @@ -1,7 +1,6 @@ $(document).ready(function () { - - $('a[data-confirm]').click(function(ev) { - var href = $(this).attr('href'); + $('input[data-confirm]').click(function(ev) { + var value = $(this).attr('value'); if (!$('#dataConfirmModal').length) { $('#modalDelete').append('\n' + ' \n' + ' \n' + @@ -22,7 +21,7 @@ $(document).ready(function () { ' '); } $('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm')); - $('#dataConfirmOK').attr('href', href); + $('#deleteConference').attr('value', value); $('#dataConfirmModal').modal({show:true}); return false; }); diff --git a/src/main/resources/templates/conferences/conferences.html b/src/main/resources/templates/conferences/conferences.html index 7b0ac8d..f471245 100644 --- a/src/main/resources/templates/conferences/conferences.html +++ b/src/main/resources/templates/conferences/conferences.html @@ -8,7 +8,7 @@
-
+
@@ -20,6 +20,7 @@
+
diff --git a/src/main/resources/templates/conferences/fragments/confLineFragment.html b/src/main/resources/templates/conferences/fragments/confLineFragment.html index 7d948d4..ecd166d 100644 --- a/src/main/resources/templates/conferences/fragments/confLineFragment.html +++ b/src/main/resources/templates/conferences/fragments/confLineFragment.html @@ -5,16 +5,19 @@
-
+
- - - + + + + +