From 0cc8de2d323fd026fdf4983292d5e23079878dbd Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Mon, 15 Apr 2019 10:36:55 +0400 Subject: [PATCH 1/2] #58 added delete method of conference --- .../ulstu/conference/controller/ConferenceController.java | 7 +++++++ .../ru/ulstu/conference/service/ConferenceService.java | 6 ++++++ .../templates/conferences/fragments/confLineFragment.html | 8 ++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 7a229ca..1011c51 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -5,6 +5,7 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.GetMapping; +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; @@ -60,6 +61,12 @@ public class ConferenceController { } + @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") public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) { filterEmptyDeadlines(conferenceDto); diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index 9c40295..b01bd42 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -64,6 +64,12 @@ public class ConferenceService { return conference.getId(); } + @Transactional + public void delete(Integer conferenceId) { + // Conference conference = conferenceRepository.findOne(conferenceId); + conferenceRepository.delete(conferenceId); + } + public void removeDeadline(ConferenceDto conferenceDto, Integer deadlineIndex) throws IOException { if (conferenceDto.getDeadlines().get(deadlineIndex).getId() != null) { conferenceDto.getRemovedDeadlineIds().add(conferenceDto.getDeadlines().get(deadlineIndex).getId()); diff --git a/src/main/resources/templates/conferences/fragments/confLineFragment.html b/src/main/resources/templates/conferences/fragments/confLineFragment.html index 317da03..d104952 100644 --- a/src/main/resources/templates/conferences/fragments/confLineFragment.html +++ b/src/main/resources/templates/conferences/fragments/confLineFragment.html @@ -4,13 +4,13 @@ -
+
- + - - + From 909c657c890a2bc4994141d60d6692120dc51d2d Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Mon, 15 Apr 2019 15:48:17 +0400 Subject: [PATCH 2/2] #58 added delete confirm --- .../conference/service/ConferenceService.java | 5 +- src/main/resources/public/css/conference.css | 5 ++ src/main/resources/public/js/conference.js | 54 ++++++++++++------- .../templates/conferences/conferences.html | 3 +- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index b01bd42..84ae923 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -66,8 +66,9 @@ public class ConferenceService { @Transactional public void delete(Integer conferenceId) { - // Conference conference = conferenceRepository.findOne(conferenceId); - conferenceRepository.delete(conferenceId); + if (conferenceRepository.exists(conferenceId)) { + conferenceRepository.delete(conferenceId); + } } public void removeDeadline(ConferenceDto conferenceDto, Integer deadlineIndex) throws IOException { diff --git a/src/main/resources/public/css/conference.css b/src/main/resources/public/css/conference.css index 004fe8c..bc63bfe 100644 --- a/src/main/resources/public/css/conference.css +++ b/src/main/resources/public/css/conference.css @@ -2,6 +2,11 @@ body { min-width: 400px; } +.conference-row .col:hover { + background-color: #eaeaea; + border-radius: .25rem; +} + diff --git a/src/main/resources/public/js/conference.js b/src/main/resources/public/js/conference.js index 304daae..dd843ca 100644 --- a/src/main/resources/public/js/conference.js +++ b/src/main/resources/public/js/conference.js @@ -1,27 +1,41 @@ $(document).ready(function () { - $('.data-href-js').click( function() { - window.location = $(this).attr('data-href'); + $(".conference-row").mouseenter(function (event) { + var conferenceRow = $(event.target).closest(".conference-row"); + $(conferenceRow).css("background-color", "#f8f9fa"); + $(conferenceRow).find(".remove-conference").removeClass("d-none"); + + }); + $(".conference-row").mouseleave(function (event) { + var conferenceRow = $(event.target).closest(".conference-row"); + $(conferenceRow).css("background-color", "white"); + $(conferenceRow).closest(".conference-row").find(".remove-conference").addClass("d-none"); }); - $('.circle').parent().click( function() { - $(this).children('.circle').toggleClass('circle-active'); - }); + $('a[data-confirm]').click(function(ev) { + var href = $(this).attr('href'); + if (!$('#dataConfirmModal').length) { + $('#modalDelete').append(''); + } + $('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm')); + $('#dataConfirmOK').attr('href', href); + $('#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 fa88aaf..46b2e73 100644 --- a/src/main/resources/templates/conferences/conferences.html +++ b/src/main/resources/templates/conferences/conferences.html @@ -3,6 +3,7 @@ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorator="default" xmlns:th=""> + @@ -46,7 +47,7 @@
- +