From 909c657c890a2bc4994141d60d6692120dc51d2d Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Mon, 15 Apr 2019 15:48:17 +0400 Subject: [PATCH] #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 @@
- +