diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 8da0cce..4c5ea91 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; @@ -70,6 +69,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); @@ -78,17 +83,10 @@ 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") - public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) { + public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException { filterEmptyDeadlines(conferenceDto); if (errors.hasErrors()) { return CONFERENCE_PAGE; @@ -107,6 +105,16 @@ public class ConferenceController { return CONFERENCE_PAGE; } + @PostMapping(value = "/conference", params = "addPaper") + public String addPaper(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException { + if (errors.hasErrors()) { + return CONFERENCE_PAGE; + } + conferenceService.addPaper(conferenceDto); + + return CONFERENCE_PAGE; + } + @PostMapping(value = "/conference", params = "removePaper") public String removePaper(@Valid ConferenceDto conferenceDto, Errors errors, @RequestParam(value = "removePaper") Integer paperIndex) throws IOException { diff --git a/src/main/java/ru/ulstu/conference/model/Conference.java b/src/main/java/ru/ulstu/conference/model/Conference.java index 6221b64..3f77699 100644 --- a/src/main/java/ru/ulstu/conference/model/Conference.java +++ b/src/main/java/ru/ulstu/conference/model/Conference.java @@ -53,7 +53,7 @@ public class Conference extends BaseEntity { @OrderBy("date") private List deadlines = new ArrayList<>(); - @ManyToMany(fetch = FetchType.EAGER) + @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER) @JoinTable(name = "paper_conference", joinColumns = {@JoinColumn(name = "conference_id")}, inverseJoinColumns = {@JoinColumn(name = "paper_id")}) diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java index 8503b40..0649901 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceFilterDto.java @@ -11,14 +11,14 @@ public class ConferenceFilterDto { public ConferenceFilterDto() { } - public ConferenceFilterDto(List conferenceDtos, Integer filterUserId, Integer year) { - this.conferences = conferenceDtos; + public ConferenceFilterDto(List conferences, Integer filterUserId, Integer year) { + this.conferences = conferences; this.filterUserId = filterUserId; this.year = year; } - public ConferenceFilterDto(List conferenceDtos) { - this(conferenceDtos, null, null); + public ConferenceFilterDto(List conferences) { + this(conferences, null, null); } public List getConferences() { diff --git a/src/main/java/ru/ulstu/conference/repository/ConferenceRepository.java b/src/main/java/ru/ulstu/conference/repository/ConferenceRepository.java index 25a481c..3a8bbe1 100644 --- a/src/main/java/ru/ulstu/conference/repository/ConferenceRepository.java +++ b/src/main/java/ru/ulstu/conference/repository/ConferenceRepository.java @@ -18,6 +18,9 @@ public interface ConferenceRepository extends JpaRepository @Query("SELECT c FROM Conference c WHERE c.beginDate > :date") List findAllActive(@Param("date") Date date); + @Query("SELECT case when count(c) > 0 then true else false end FROM Conference c JOIN c.papers p WHERE p.id = :paperId") + boolean isPaperAttached(@Param("paperId") Integer paperId); + @Modifying @Query("UPDATE Conference c SET c.ping = (c.ping + 1) WHERE c.id = :id") int updatePingConference(@Param("id") Integer id); diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index 370d7d6..905c208 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -116,9 +116,19 @@ public class ConferenceService { conferenceDto.getDeadlines().remove((int) deadlineIndex); } + public void addPaper(ConferenceDto conferenceDto) { + Paper paper = new Paper(); + paper.setTitle(userService.getCurrentUser().getLastName() + "_" + conferenceDto.getTitle() + "_" + (new Date()).getTime()); + paper.setStatus(Paper.PaperStatus.DRAFT); + + conferenceDto.getPapers().add(paper); + } + public void removePaper(ConferenceDto conferenceDto, Integer paperIndex) throws IOException { Paper removedPaper = conferenceDto.getPapers().remove((int) paperIndex); - conferenceDto.getNotSelectedPapers().add(removedPaper); + if (removedPaper.getId() != null) { + conferenceDto.getNotSelectedPapers().add(removedPaper); + } } public void takePart(ConferenceDto conferenceDto) throws IOException { @@ -146,15 +156,15 @@ public class ConferenceService { conference.setTitle(conferenceDto.getTitle()); conference.setDescription(conferenceDto.getDescription()); conference.setUrl(conferenceDto.getUrl()); - conference.setPing(conference.getPing()); conference.setBeginDate(conferenceDto.getBeginDate()); conference.setEndDate(conferenceDto.getEndDate()); - conference.setPapers(conferenceDto.getPapers()); + conference.getPapers().clear(); + conferenceDto.getPapers().forEach(paper -> conference.getPapers().add(paper.getId() != null ? paperService.findPaperById(paper.getId()) : paperService.create(paper))); conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines())); conference.setUsers(conferenceUserService.saveOrCreate(conferenceDto.getUsers())); if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) { conferenceDto.getPaperIds().forEach(paperId -> - conference.getPapers().add(paperService.findEntityById(paperId))); + conference.getPapers().add(paperService.findPaperById(paperId))); } return conference; } @@ -179,6 +189,10 @@ public class ConferenceService { return conferenceRepository.findAllActive(new Date()); } + public boolean isAttachedToConference(Integer paperId) { + return conferenceRepository.isPaperAttached(paperId); + } + @Transactional public void ping(ConferenceDto conferenceDto) throws IOException { pingService.addPing(findOne(conferenceDto.getId())); diff --git a/src/main/java/ru/ulstu/core/controller/AdviceController.java b/src/main/java/ru/ulstu/core/controller/AdviceController.java index 8238797..27ba6c9 100644 --- a/src/main/java/ru/ulstu/core/controller/AdviceController.java +++ b/src/main/java/ru/ulstu/core/controller/AdviceController.java @@ -39,6 +39,11 @@ public class AdviceController { return userService.getCurrentUser().getUserAbbreviate(); } + @ModelAttribute("flashMessage") + public String getFlashMessage() { + return null; + } + private Response handleException(ErrorConstants error) { log.warn(error.toString()); return new Response<>(error); diff --git a/src/main/java/ru/ulstu/grant/controller/GrantController.java b/src/main/java/ru/ulstu/grant/controller/GrantController.java index 0731188..92ce826 100644 --- a/src/main/java/ru/ulstu/grant/controller/GrantController.java +++ b/src/main/java/ru/ulstu/grant/controller/GrantController.java @@ -13,6 +13,7 @@ import ru.ulstu.deadline.model.Deadline; import ru.ulstu.grant.model.Grant; import ru.ulstu.grant.model.GrantDto; import ru.ulstu.grant.service.GrantService; +import ru.ulstu.paper.model.Paper; import ru.ulstu.user.model.User; import springfox.documentation.annotations.ApiIgnore; @@ -50,7 +51,9 @@ public class GrantController { @GetMapping("/grant") public void getGrant(ModelMap modelMap, @RequestParam(value = "id") Integer id) { if (id != null && id > 0) { - modelMap.put("grantDto", grantService.findOneDto(id)); + GrantDto grantDto = grantService.findOneDto(id); + attachPaper(grantDto); + modelMap.put("grantDto", grantDto); } else { modelMap.put("grantDto", new GrantDto()); } @@ -78,6 +81,12 @@ public class GrantController { return GRANT_PAGE; } + @PostMapping(value = "/grant", params = "attachPaper") + public String attachPaper(GrantDto grantDto) { + grantService.attachPaper(grantDto); + return GRANT_PAGE; + } + @PostMapping(value = "/grant", params = "addDeadline") public String addDeadline(@Valid GrantDto grantDto, Errors errors) { filterEmptyDeadlines(grantDto); @@ -89,7 +98,7 @@ public class GrantController { } @PostMapping(value = "/grant", params = "createProject") - public String createProject(@Valid GrantDto grantDto, Errors errors) { + public String createProject(@Valid GrantDto grantDto, Errors errors) throws IOException { if (errors.hasErrors()) { return GRANT_PAGE; } @@ -113,6 +122,11 @@ public class GrantController { return grantService.getGrantAuthors(grantDto); } + @ModelAttribute("allPapers") + public List getAllPapers() { + return grantService.getAllPapers(); + } + private void filterEmptyDeadlines(GrantDto grantDto) { grantDto.setDeadlines(grantDto.getDeadlines().stream() .filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription())) diff --git a/src/main/java/ru/ulstu/grant/model/Grant.java b/src/main/java/ru/ulstu/grant/model/Grant.java index 9b1e8fe..c8bdd8a 100644 --- a/src/main/java/ru/ulstu/grant/model/Grant.java +++ b/src/main/java/ru/ulstu/grant/model/Grant.java @@ -5,6 +5,7 @@ import ru.ulstu.core.model.BaseEntity; import ru.ulstu.core.model.UserContainer; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.file.model.FileData; +import ru.ulstu.paper.model.Paper; import ru.ulstu.project.model.Project; import ru.ulstu.user.model.User; @@ -14,6 +15,7 @@ import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.FetchType; import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; @@ -83,6 +85,12 @@ public class Grant extends BaseEntity implements UserContainer { @JoinColumn(name = "leader_id") private User leader; + @ManyToMany(fetch = FetchType.EAGER) + @JoinTable(name = "grants_papers", + joinColumns = {@JoinColumn(name = "grant_id")}, + inverseJoinColumns = {@JoinColumn(name = "paper_id")}) + private List papers = new ArrayList<>(); + public GrantStatus getStatus() { return status; } @@ -152,6 +160,14 @@ public class Grant extends BaseEntity implements UserContainer { this.leader = leader; } + public List getPapers() { + return papers; + } + + public void setPapers(List papers) { + this.papers = papers; + } + public Optional getNextDeadline() { return deadlines .stream() diff --git a/src/main/java/ru/ulstu/grant/model/GrantDto.java b/src/main/java/ru/ulstu/grant/model/GrantDto.java index aa8634b..d979e23 100644 --- a/src/main/java/ru/ulstu/grant/model/GrantDto.java +++ b/src/main/java/ru/ulstu/grant/model/GrantDto.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils; import org.hibernate.validator.constraints.NotEmpty; import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.paper.model.Paper; import ru.ulstu.project.model.ProjectDto; import ru.ulstu.user.model.UserDto; @@ -32,6 +33,8 @@ public class GrantDto { private boolean wasLeader; private boolean hasAge; private boolean hasDegree; + private List paperIds = new ArrayList<>(); + private List papers = new ArrayList<>(); public GrantDto() { deadlines.add(new Deadline()); @@ -49,7 +52,9 @@ public class GrantDto { @JsonProperty("leader") Integer leaderId, @JsonProperty("wasLeader") boolean wasLeader, @JsonProperty("hasAge") boolean hasAge, - @JsonProperty("hasDegree") boolean hasDegree) { + @JsonProperty("hasDegree") boolean hasDegree, + @JsonProperty("paperIds") List paperIds, + @JsonProperty("papers") List papers) { this.id = id; this.title = title; this.status = status; @@ -62,6 +67,8 @@ public class GrantDto { this.wasLeader = wasLeader; this.hasAge = hasAge; this.hasDegree = hasDegree; + this.paperIds = paperIds; + this.papers = papers; } public GrantDto(Grant grant) { @@ -78,6 +85,8 @@ public class GrantDto { this.wasLeader = false; this.hasAge = false; this.hasDegree = false; + this.paperIds = convert(grant.getPapers(), paper -> paper.getId()); + this.papers = grant.getPapers(); } public Integer getId() { @@ -190,4 +199,20 @@ public class GrantDto { public void setHasDegree(boolean hasDegree) { this.hasDegree = hasDegree; } + + public List getPaperIds() { + return paperIds; + } + + public void setPaperIds(List paperIds) { + this.paperIds = paperIds; + } + + public List getPapers() { + return papers; + } + + public void setPapers(List papers) { + this.papers = papers; + } } diff --git a/src/main/java/ru/ulstu/grant/service/GrantService.java b/src/main/java/ru/ulstu/grant/service/GrantService.java index 8427da3..1f0b6ce 100644 --- a/src/main/java/ru/ulstu/grant/service/GrantService.java +++ b/src/main/java/ru/ulstu/grant/service/GrantService.java @@ -9,6 +9,8 @@ import ru.ulstu.file.service.FileService; import ru.ulstu.grant.model.Grant; import ru.ulstu.grant.model.GrantDto; import ru.ulstu.grant.repository.GrantRepository; +import ru.ulstu.paper.model.Paper; +import ru.ulstu.paper.service.PaperService; import ru.ulstu.project.model.Project; import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.service.ProjectService; @@ -34,17 +36,20 @@ public class GrantService { private final DeadlineService deadlineService; private final FileService fileService; private final UserService userService; + private final PaperService paperService; public GrantService(GrantRepository grantRepository, FileService fileService, DeadlineService deadlineService, ProjectService projectService, - UserService userService) { + UserService userService, + PaperService paperService) { this.grantRepository = grantRepository; this.fileService = fileService; this.deadlineService = deadlineService; this.projectService = projectService; this.userService = userService; + this.paperService = paperService; } public List findAll() { @@ -86,10 +91,14 @@ public class GrantService { if (grantDto.getLeaderId() != null) { grant.setLeader(userService.findById(grantDto.getLeaderId())); } + grant.getPapers().clear(); + if (grantDto.getPaperIds() != null && !grantDto.getPaperIds().isEmpty()) { + grantDto.getPaperIds().forEach(paperIds -> grant.getPapers().add(paperService.findPaperById(paperIds))); + } return grant; } - public void createProject(GrantDto grantDto) { + public void createProject(GrantDto grantDto) throws IOException { grantDto.setProject( new ProjectDto(projectService.save(new ProjectDto(grantDto.getTitle())))); } @@ -118,7 +127,7 @@ public class GrantService { } @Transactional - public Grant create(String title, Project projectId, Date deadlineDate, User user) { + public Grant create(String title, Project projectId, Date deadlineDate, User user, Paper paper) { Grant grant = new Grant(); grant.setTitle(title); grant.setComment("Комментарий к гранту 1"); @@ -127,6 +136,7 @@ public class GrantService { grant.getDeadlines().add(new Deadline(deadlineDate, "первый дедлайн")); grant.getAuthors().add(user); grant.setLeader(user); + grant.getPapers().add(paper); grant = grantRepository.save(grant); return grant; } @@ -156,4 +166,22 @@ public class GrantService { .map(Grant::getLeader) .collect(Collectors.toList()); } + + public List getGrantPapers(List paperIds) { + return paperService.findAllSelect(paperIds); + + } + + public List getAllPapers() { + return paperService.findAll(); + } + + public void attachPaper(GrantDto grantDto) { + if (!grantDto.getPaperIds().isEmpty()) { + grantDto.getPapers().clear(); + grantDto.setPapers(getGrantPapers(grantDto.getPaperIds())); + } else { + grantDto.getPapers().clear(); + } + } } diff --git a/src/main/java/ru/ulstu/paper/controller/PaperController.java b/src/main/java/ru/ulstu/paper/controller/PaperController.java index e11e4d9..41d5586 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperController.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperController.java @@ -8,14 +8,14 @@ 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; +import ru.ulstu.conference.service.ConferenceService; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.paper.model.Paper; import ru.ulstu.paper.model.PaperDto; -import ru.ulstu.paper.model.PaperFilterDto; +import ru.ulstu.paper.model.PaperListDto; import ru.ulstu.paper.service.LatexService; import ru.ulstu.paper.service.PaperService; import ru.ulstu.user.model.User; @@ -38,23 +38,34 @@ import static org.springframework.util.StringUtils.isEmpty; @ApiIgnore public class PaperController { private final PaperService paperService; + private final ConferenceService conferenceService; private final LatexService latexService; - public PaperController(PaperService paperService, LatexService latexService) { + public PaperController(PaperService paperService, + ConferenceService conferenceService, + LatexService latexService) { this.paperService = paperService; + this.conferenceService = conferenceService; this.latexService = latexService; } @GetMapping("/papers") public void getPapers(ModelMap modelMap) { - modelMap.put("filteredPapers", new PaperFilterDto(paperService.findAllDto(), null, null)); + modelMap.put("filteredPapers", new PaperListDto(paperService.findAllDto(), null, null)); } @PostMapping("/papers") - public void filterPapers(@Valid PaperFilterDto paperFilterDto, ModelMap modelMap) { - modelMap.put("filteredPapers", new PaperFilterDto(paperService.filter(paperFilterDto), - paperFilterDto.getFilterAuthorId(), - paperFilterDto.getYear())); + public void listPapers(@Valid PaperListDto paperListDto, ModelMap modelMap) { + if (paperListDto.getPaperDeleteId() != null) { + if (conferenceService.isAttachedToConference(paperListDto.getPaperDeleteId())) { + modelMap.put("flashMessage", "Статью нельзя удалить, она прикреплена к конференции"); + } else { + paperService.delete(paperListDto.getPaperDeleteId()); + } + } + modelMap.put("filteredPapers", new PaperListDto(paperService.filter(paperListDto), + paperListDto.getFilterAuthorId(), + paperListDto.getYear())); } @GetMapping("/dashboard") @@ -94,12 +105,6 @@ public class PaperController { return "/papers/paper"; } - @GetMapping("/delete/{paper-id}") - public String delete(@PathVariable("paper-id") Integer paperId) throws IOException { - paperService.delete(paperId); - return "redirect:/papers/papers"; - } - @ModelAttribute("allStatuses") public List getPaperStatuses() { return paperService.getPaperStatuses(); diff --git a/src/main/java/ru/ulstu/paper/controller/PaperRestController.java b/src/main/java/ru/ulstu/paper/controller/PaperRestController.java index 2bd8384..d98ba98 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperRestController.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperRestController.java @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController; import ru.ulstu.configuration.Constants; import ru.ulstu.core.model.response.Response; import ru.ulstu.paper.model.PaperDto; -import ru.ulstu.paper.model.PaperFilterDto; +import ru.ulstu.paper.model.PaperListDto; import ru.ulstu.paper.service.PaperService; import javax.validation.Valid; @@ -58,8 +58,8 @@ public class PaperRestController { } @PostMapping("/filter") - public Response> filter(@RequestBody @Valid PaperFilterDto paperFilterDto) throws IOException { - return new Response<>(paperService.filter(paperFilterDto)); + public Response> filter(@RequestBody @Valid PaperListDto paperListDto) throws IOException { + return new Response<>(paperService.filter(paperListDto)); } @GetMapping("formatted-list") 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/java/ru/ulstu/paper/model/PaperFilterDto.java b/src/main/java/ru/ulstu/paper/model/PaperListDto.java similarity index 67% rename from src/main/java/ru/ulstu/paper/model/PaperFilterDto.java rename to src/main/java/ru/ulstu/paper/model/PaperListDto.java index f7aef29..871047a 100644 --- a/src/main/java/ru/ulstu/paper/model/PaperFilterDto.java +++ b/src/main/java/ru/ulstu/paper/model/PaperListDto.java @@ -2,15 +2,16 @@ package ru.ulstu.paper.model; import java.util.List; -public class PaperFilterDto { +public class PaperListDto { private List papers; private Integer filterAuthorId; + private Integer paperDeleteId; private Integer year; - public PaperFilterDto() { + public PaperListDto() { } - public PaperFilterDto(List paperDtos, Integer filterAuthorId, Integer year) { + public PaperListDto(List paperDtos, Integer filterAuthorId, Integer year) { this.papers = paperDtos; this.filterAuthorId = filterAuthorId; this.year = year; @@ -39,4 +40,12 @@ public class PaperFilterDto { public void setYear(Integer year) { this.year = year; } + + public Integer getPaperDeleteId() { + return paperDeleteId; + } + + public void setPaperDeleteId(Integer paperDeleteId) { + this.paperDeleteId = paperDeleteId; + } } diff --git a/src/main/java/ru/ulstu/paper/repository/PaperRepository.java b/src/main/java/ru/ulstu/paper/repository/PaperRepository.java index 343e9e2..cab9b1a 100644 --- a/src/main/java/ru/ulstu/paper/repository/PaperRepository.java +++ b/src/main/java/ru/ulstu/paper/repository/PaperRepository.java @@ -14,4 +14,6 @@ public interface PaperRepository extends JpaRepository { List filter(@Param("author") User author, @Param("year") Integer year); List findByIdNotIn(List paperIds); + + List findAllByIdIn(List paperIds); } diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index 1633c07..325e377 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -9,7 +9,7 @@ import ru.ulstu.file.model.FileDataDto; import ru.ulstu.file.service.FileService; import ru.ulstu.paper.model.Paper; import ru.ulstu.paper.model.PaperDto; -import ru.ulstu.paper.model.PaperFilterDto; +import ru.ulstu.paper.model.PaperListDto; import ru.ulstu.paper.repository.PaperRepository; import ru.ulstu.timeline.service.EventService; import ru.ulstu.user.model.User; @@ -93,6 +93,14 @@ public class PaperService { return newPaper.getId(); } + @Transactional + public Paper create(Paper paper) { + Paper newPaper = paperRepository.save(paper); + paperNotificationService.sendCreateNotification(newPaper); + eventService.createFromPaper(newPaper); + return newPaper; + } + private Paper copyFromDto(Paper paper, PaperDto paperDto) throws IOException { paper.setComment(paperDto.getComment()); paper.setUrl(paperDto.getUrl()); @@ -173,7 +181,7 @@ public class PaperService { return paper; } - public List filter(PaperFilterDto filterDto) { + public List filter(PaperListDto filterDto) { return convert(sortPapers(paperRepository.filter( filterDto.getFilterAuthorId() == null ? null : userService.findById(filterDto.getFilterAuthorId()), filterDto.getYear())), PaperDto::new); @@ -223,7 +231,7 @@ public class PaperService { return new PaperDto(paperRepository.findOne(paperId)); } - public Paper findEntityById(Integer paperId) { + public Paper findPaperById(Integer paperId) { return paperRepository.findOne(paperId); } @@ -236,6 +244,10 @@ public class PaperService { } + public List findAllSelect(List paperIds) { + return sortPapers(paperRepository.findAllByIdIn(paperIds)); + } + public List getPaperAuthors() { return userService.findAll(); } diff --git a/src/main/java/ru/ulstu/project/controller/ProjectController.java b/src/main/java/ru/ulstu/project/controller/ProjectController.java index 3244ccb..ae09658 100644 --- a/src/main/java/ru/ulstu/project/controller/ProjectController.java +++ b/src/main/java/ru/ulstu/project/controller/ProjectController.java @@ -2,16 +2,25 @@ package ru.ulstu.project.controller; 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.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; +import ru.ulstu.deadline.model.Deadline; import ru.ulstu.project.model.Project; import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.service.ProjectService; import springfox.documentation.annotations.ApiIgnore; +import javax.validation.Valid; +import java.io.IOException; import java.util.List; +import java.util.stream.Collectors; + +import static org.springframework.util.StringUtils.isEmpty; @Controller() @RequestMapping(value = "/projects") @@ -46,4 +55,39 @@ public class ProjectController { public List getProjectStatuses() { return projectService.getProjectStatuses(); } + + @PostMapping(value = "/project", params = "save") + public String save(@Valid ProjectDto projectDto, Errors errors) throws IOException { + filterEmptyDeadlines(projectDto); + if (projectDto.getDeadlines().isEmpty()) { + errors.rejectValue("deadlines", "errorCode", "Не может быть пустым"); + } + if (errors.hasErrors()) { + return "/projects/project"; + } + projectService.save(projectDto); + return String.format("redirect:%s", "/projects/projects"); + } + + @PostMapping(value = "/project", params = "addDeadline") + public String addDeadline(@Valid ProjectDto projectDto, Errors errors) { + filterEmptyDeadlines(projectDto); + if (errors.hasErrors()) { + return "/projects/project"; + } + projectDto.getDeadlines().add(new Deadline()); + return "/projects/project"; + } + + @GetMapping("/delete/{project-id}") + public String delete(@PathVariable("project-id") Integer projectId) throws IOException { + projectService.delete(projectId); + return String.format("redirect:%s", "/projects/projects"); + } + + private void filterEmptyDeadlines(ProjectDto projectDto) { + projectDto.setDeadlines(projectDto.getDeadlines().stream() + .filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription())) + .collect(Collectors.toList())); + } } diff --git a/src/main/java/ru/ulstu/project/model/Project.java b/src/main/java/ru/ulstu/project/model/Project.java index 2e0e86c..c971c4b 100644 --- a/src/main/java/ru/ulstu/project/model/Project.java +++ b/src/main/java/ru/ulstu/project/model/Project.java @@ -3,6 +3,7 @@ package ru.ulstu.project.model; import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.deadline.model.Deadline; +import ru.ulstu.file.model.FileData; import ru.ulstu.grant.model.Grant; import javax.persistence.CascadeType; @@ -57,6 +58,10 @@ public class Project extends BaseEntity { @NotNull private String repository; + @ManyToOne + @JoinColumn(name = "file_id") + private FileData application; + public String getTitle() { return title; } @@ -104,4 +109,12 @@ public class Project extends BaseEntity { public void setDeadlines(List deadlines) { this.deadlines = deadlines; } + + public FileData getApplication() { + return application; + } + + public void setApplication(FileData application) { + this.application = application; + } } diff --git a/src/main/java/ru/ulstu/project/model/ProjectDto.java b/src/main/java/ru/ulstu/project/model/ProjectDto.java index 6c83d59..4e03365 100644 --- a/src/main/java/ru/ulstu/project/model/ProjectDto.java +++ b/src/main/java/ru/ulstu/project/model/ProjectDto.java @@ -19,6 +19,7 @@ public class ProjectDto { private List deadlines = new ArrayList<>(); private GrantDto grant; private String repository; + private String applicationFileName; public ProjectDto() { } @@ -42,6 +43,7 @@ public class ProjectDto { this.grant = grant; this.repository = repository; this.deadlines = deadlines; + this.applicationFileName = null; } @@ -50,6 +52,7 @@ public class ProjectDto { this.title = project.getTitle(); this.status = project.getStatus(); this.description = project.getDescription(); + this.applicationFileName = project.getApplication() == null ? null : project.getApplication().getName(); this.grant = project.getGrant() == null ? null : new GrantDto(project.getGrant()); this.repository = project.getRepository(); this.deadlines = project.getDeadlines(); @@ -110,4 +113,12 @@ public class ProjectDto { public void setDeadlines(List deadlines) { this.deadlines = deadlines; } + + public String getApplicationFileName() { + return applicationFileName; + } + + public void setApplicationFileName(String applicationFileName) { + this.applicationFileName = applicationFileName; + } } diff --git a/src/main/java/ru/ulstu/project/service/ProjectService.java b/src/main/java/ru/ulstu/project/service/ProjectService.java index 99d8919..247624d 100644 --- a/src/main/java/ru/ulstu/project/service/ProjectService.java +++ b/src/main/java/ru/ulstu/project/service/ProjectService.java @@ -4,15 +4,19 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.thymeleaf.util.StringUtils; import ru.ulstu.deadline.service.DeadlineService; +import ru.ulstu.file.service.FileService; +import ru.ulstu.grant.repository.GrantRepository; import ru.ulstu.project.model.Project; import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.repository.ProjectRepository; +import java.io.IOException; import java.util.Arrays; import java.util.List; import static org.springframework.util.ObjectUtils.isEmpty; import static ru.ulstu.core.util.StreamApiUtils.convert; +import static ru.ulstu.project.model.Project.ProjectStatus.APPLICATION; @Service public class ProjectService { @@ -20,11 +24,17 @@ public class ProjectService { private final ProjectRepository projectRepository; private final DeadlineService deadlineService; + private final GrantRepository grantRepository; + private final FileService fileService; public ProjectService(ProjectRepository projectRepository, - DeadlineService deadlineService) { + DeadlineService deadlineService, + GrantRepository grantRepository, + FileService fileService) { this.projectRepository = projectRepository; this.deadlineService = deadlineService; + this.grantRepository = grantRepository; + this.fileService = fileService; } public List findAll() { @@ -46,19 +56,47 @@ public class ProjectService { } @Transactional - public Project create(ProjectDto projectDto) { + public Project create(ProjectDto projectDto) throws IOException { Project newProject = copyFromDto(new Project(), projectDto); newProject = projectRepository.save(newProject); return newProject; } - private Project copyFromDto(Project project, ProjectDto projectDto) { - project.setTitle(projectDto.getTitle()); - project.setDeadlines(deadlineService.saveOrCreate(projectDto.getDeadlines())); + @Transactional + public Project update(ProjectDto projectDto) throws IOException { + Project project = projectRepository.findOne(projectDto.getId()); + if (projectDto.getApplicationFileName() != null && project.getApplication() != null) { + fileService.deleteFile(project.getApplication()); + } + projectRepository.save(copyFromDto(project, projectDto)); return project; } - public Project save(ProjectDto projectDto) { + @Transactional + public void delete(Integer projectId) throws IOException { + Project project = projectRepository.findOne(projectId); + if (project.getApplication() != null) { + fileService.deleteFile(project.getApplication()); + } + projectRepository.delete(project); + } + + private Project copyFromDto(Project project, ProjectDto projectDto) throws IOException { + project.setDescription(projectDto.getDescription()); + project.setStatus(projectDto.getStatus() == null ? APPLICATION : projectDto.getStatus()); + project.setTitle(projectDto.getTitle()); + if (projectDto.getGrant() != null && projectDto.getGrant().getId() != null) { + project.setGrant(grantRepository.findOne(projectDto.getGrant().getId())); + } + project.setRepository(projectDto.getRepository()); + project.setDeadlines(deadlineService.saveOrCreate(projectDto.getDeadlines())); + if (projectDto.getApplicationFileName() != null) { + project.setApplication(fileService.createFileFromTmp(projectDto.getApplicationFileName())); + } + return project; + } + + public Project save(ProjectDto projectDto) throws IOException { if (isEmpty(projectDto.getId())) { return create(projectDto); } else { @@ -66,10 +104,6 @@ public class ProjectService { } } - private Project update(ProjectDto projectDto) { - throw new RuntimeException("not implemented yet"); - } - public Project findById(Integer id) { return projectRepository.findOne(id); } diff --git a/src/main/java/ru/ulstu/students/controller/TaskController.java b/src/main/java/ru/ulstu/students/controller/TaskController.java index 50cb052..5d0f4e8 100644 --- a/src/main/java/ru/ulstu/students/controller/TaskController.java +++ b/src/main/java/ru/ulstu/students/controller/TaskController.java @@ -5,13 +5,16 @@ 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; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.students.model.Task; import ru.ulstu.students.model.TaskDto; +import ru.ulstu.students.model.TaskFilterDto; import ru.ulstu.students.service.TaskService; +import ru.ulstu.tags.model.Tag; import springfox.documentation.annotations.ApiIgnore; import javax.validation.Valid; @@ -35,16 +38,16 @@ public class TaskController { this.taskService = taskService; } - @GetMapping("/tasks") - public void getTasks(ModelMap modelMap) { - modelMap.put("tasks", taskService.findAllDto()); - } - @GetMapping("/dashboard") public void getDashboard(ModelMap modelMap) { modelMap.put("tasks", taskService.findAllDto()); } + @GetMapping("/tasks") + public void getTask(ModelMap modelMap) { + modelMap.put("filteredTasks", new TaskFilterDto(taskService.findAllDto(), null, null, null)); + } + @GetMapping("/task") public void getTask(ModelMap modelMap, @RequestParam(value = "id") Integer id) { if (id != null && id > 0) { @@ -54,6 +57,14 @@ public class TaskController { } } + @PostMapping("/tasks") + public void filterTasks(@Valid TaskFilterDto taskFilterDto, ModelMap modelMap) { + modelMap.put("filteredTasks", new TaskFilterDto(taskService.filter(taskFilterDto), + taskFilterDto.getStatus(), + taskFilterDto.getTag(), + taskFilterDto.getOrder())); + } + @PostMapping(value = "/task", params = "save") public String save(@Valid TaskDto taskDto, Errors errors) throws IOException { filterEmptyDeadlines(taskDto); @@ -77,11 +88,23 @@ public class TaskController { return TASK_PAGE; } + @GetMapping("/delete/{task-id}") + public String delete(@PathVariable("task-id") Integer taskId) throws IOException { + taskService.delete(taskId); + return String.format(REDIRECT_TO, TASKS_PAGE); + } + + @ModelAttribute("allStatuses") public List getTaskStatuses() { return taskService.getTaskStatuses(); } + @ModelAttribute("allTags") + public List getTags() { + return taskService.getTags(); + } + private void filterEmptyDeadlines(TaskDto taskDto) { taskDto.setDeadlines(taskDto.getDeadlines().stream() .filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription())) diff --git a/src/main/java/ru/ulstu/students/model/Task.java b/src/main/java/ru/ulstu/students/model/Task.java index c4d7409..8ec9081 100644 --- a/src/main/java/ru/ulstu/students/model/Task.java +++ b/src/main/java/ru/ulstu/students/model/Task.java @@ -50,7 +50,7 @@ public class Task extends BaseEntity { private String description; @Enumerated(value = EnumType.STRING) - private ru.ulstu.students.model.Task.TaskStatus status = TaskStatus.IN_WORK; + private TaskStatus status = TaskStatus.IN_WORK; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "task_id", unique = true) diff --git a/src/main/java/ru/ulstu/students/model/TaskDto.java b/src/main/java/ru/ulstu/students/model/TaskDto.java index 941a6df..8d52e01 100644 --- a/src/main/java/ru/ulstu/students/model/TaskDto.java +++ b/src/main/java/ru/ulstu/students/model/TaskDto.java @@ -26,7 +26,7 @@ public class TaskDto { private Date createDate; private Date updateDate; private Set tagIds; - private List tags; + private List tags = new ArrayList<>(); public TaskDto() { deadlines.add(new Deadline()); diff --git a/src/main/java/ru/ulstu/students/model/TaskFilterDto.java b/src/main/java/ru/ulstu/students/model/TaskFilterDto.java new file mode 100644 index 0000000..21bd5ac --- /dev/null +++ b/src/main/java/ru/ulstu/students/model/TaskFilterDto.java @@ -0,0 +1,54 @@ +package ru.ulstu.students.model; + +import java.util.List; + +public class TaskFilterDto { + + private List tasks; + private Task.TaskStatus status; + private Integer tagId; + private String order; + + public TaskFilterDto(List tasks, Task.TaskStatus status, Integer tagId, String order) { + this.tasks = tasks; + this.status = status; + this.tagId = tagId; + this.order = order; + } + + public TaskFilterDto() { + + } + + public List getTasks() { + return tasks; + } + + public void setTasks(List tasks) { + this.tasks = tasks; + } + + public Task.TaskStatus getStatus() { + return status; + } + + public void setStatus(Task.TaskStatus status) { + this.status = status; + } + + public Integer getTag() { + return tagId; + } + + public void setTag(Integer tagId) { + this.tagId = tagId; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } +} diff --git a/src/main/java/ru/ulstu/students/repository/TaskRepository.java b/src/main/java/ru/ulstu/students/repository/TaskRepository.java index 6f48d1f..ee49ab8 100644 --- a/src/main/java/ru/ulstu/students/repository/TaskRepository.java +++ b/src/main/java/ru/ulstu/students/repository/TaskRepository.java @@ -1,7 +1,18 @@ package ru.ulstu.students.repository; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import ru.ulstu.students.model.Task; +import ru.ulstu.tags.model.Tag; + +import java.util.List; public interface TaskRepository extends JpaRepository { + + @Query("SELECT t FROM Task t WHERE (t.status = :status OR :status IS NULL) AND (:tag IS NULL OR :tag MEMBER OF t.tags) ORDER BY create_date DESC") + List filterNew(@Param("status") Task.TaskStatus status, @Param("tag") Tag tag); + + @Query("SELECT t FROM Task t WHERE (t.status = :status OR :status IS NULL) AND (:tag IS NULL OR :tag MEMBER OF t.tags) ORDER BY create_date ASC") + List filterOld(@Param("status") Task.TaskStatus status, @Param("tag") Tag tag); } diff --git a/src/main/java/ru/ulstu/students/service/TaskService.java b/src/main/java/ru/ulstu/students/service/TaskService.java index 7b67a44..a8747c7 100644 --- a/src/main/java/ru/ulstu/students/service/TaskService.java +++ b/src/main/java/ru/ulstu/students/service/TaskService.java @@ -1,12 +1,15 @@ package ru.ulstu.students.service; import org.apache.commons.lang3.StringUtils; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import ru.ulstu.deadline.service.DeadlineService; import ru.ulstu.students.model.Task; import ru.ulstu.students.model.TaskDto; +import ru.ulstu.students.model.TaskFilterDto; import ru.ulstu.students.repository.TaskRepository; +import ru.ulstu.tags.model.Tag; import ru.ulstu.tags.service.TagService; import java.io.IOException; @@ -27,15 +30,15 @@ public class TaskService { private final DeadlineService deadlineService; private final TagService tagService; - public TaskService(TaskRepository grantRepository, + public TaskService(TaskRepository taskRepository, DeadlineService deadlineService, TagService tagService) { - this.taskRepository = grantRepository; + this.taskRepository = taskRepository; this.deadlineService = deadlineService; this.tagService = tagService; } public List findAll() { - return taskRepository.findAll(); + return taskRepository.findAll(new Sort(Sort.Direction.DESC, "createDate")); } public List findAllDto() { @@ -48,6 +51,18 @@ public class TaskService { return new TaskDto(taskRepository.findOne(id)); } + public List filter(TaskFilterDto filterDto) { + if (filterDto.getOrder().compareTo("new") == 0) { + return convert(taskRepository.filterNew( + filterDto.getStatus(), + filterDto.getTag() == null ? null : tagService.findById(filterDto.getTag())), TaskDto::new); + } else { + return convert(taskRepository.filterOld( + filterDto.getStatus(), + filterDto.getTag() == null ? null : tagService.findById(filterDto.getTag())), TaskDto::new); + } + } + @Transactional public Integer create(TaskDto taskDto) throws IOException { Task newTask = copyFromDto(new Task(), taskDto); @@ -76,8 +91,10 @@ public class TaskService { @Transactional public void delete(Integer taskId) throws IOException { - Task task = taskRepository.findOne(taskId); - taskRepository.delete(task); + if (taskRepository.exists(taskId)) { + taskRepository.delete(taskId); + } + } public void save(TaskDto taskDto) throws IOException { @@ -92,4 +109,8 @@ public class TaskService { return Arrays.asList(Task.TaskStatus.values()); } + public List getTags() { + return tagService.getTags(); + } + } diff --git a/src/main/java/ru/ulstu/tags/service/TagService.java b/src/main/java/ru/ulstu/tags/service/TagService.java index 4e88304..ba942f1 100644 --- a/src/main/java/ru/ulstu/tags/service/TagService.java +++ b/src/main/java/ru/ulstu/tags/service/TagService.java @@ -50,4 +50,12 @@ public class TagService { return newTag; } + public List getTags() { + return tagRepository.findAll(); + } + + public Tag findById(Integer tagId) { + return tagRepository.findOne(tagId); + } + } diff --git a/src/main/resources/db/changelog-20190419_000000-schema.xml b/src/main/resources/db/changelog-20190419_000000-schema.xml new file mode 100644 index 0000000..b56f322 --- /dev/null +++ b/src/main/resources/db/changelog-20190419_000000-schema.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/src/main/resources/db/changelog-20190422_000000-schema.xml b/src/main/resources/db/changelog-20190422_000000-schema.xml new file mode 100644 index 0000000..f110910 --- /dev/null +++ b/src/main/resources/db/changelog-20190422_000000-schema.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/src/main/resources/db/changelog-master.xml b/src/main/resources/db/changelog-master.xml index 7f40dc7..68b294a 100644 --- a/src/main/resources/db/changelog-master.xml +++ b/src/main/resources/db/changelog-master.xml @@ -30,6 +30,8 @@ + + \ No newline at end of file diff --git a/src/main/resources/public/css/conference.css b/src/main/resources/public/css/conference.css index 5a50b65..6018b9c 100644 --- a/src/main/resources/public/css/conference.css +++ b/src/main/resources/public/css/conference.css @@ -2,8 +2,8 @@ body { min-width: 400px; } -.conference-row .col:hover { - background-color: #f3f3f3; +.conference-row .d-flex:hover { + background-color: #f1f1f1; border-radius: .25rem; } @@ -15,10 +15,20 @@ body { margin-bottom: 10px; } -.conference-row .col .text-decoration { +.conference-row .d-flex .text-decoration { text-decoration: none; } +.conference-row .d-flex .text-decoration:nth-child(1) { + margin-left: 10px; +} + + + +.conference-row .d-flex { + margin: 0 15px; +} + .form-group textarea { min-height: 206px; @@ -61,13 +71,17 @@ body { padding: 0.5rem 1.75em 0.5rem 0.5em; display: inline-block; background: transparent url("https://cdn3.iconfinder.com/data/icons/faticons/32/arrow-down-01-16.png") no-repeat right 7px center; - + cursor: pointer; } .member select:nth-child(4) { border-right: 1px solid #ced4da; } +.member select:hover { + background-color: #f1f1f1; +} + .member-name { padding: .75rem 1.25rem; @@ -114,11 +128,22 @@ body { flex: 1; } +.paper-name:hover { + background-color: #f1f1f1; +} + .paper-name span { - margin: 6px 15px; + margin: 7px 10px; display: inline-block; } +.paper-name span:nth-child(1) { + margin: 3px 0px 3px 10px; + float: left; +} + + + .icon { width: 38px; height: 38px; @@ -127,14 +152,14 @@ body { } .icon-delete { - background-color: #f44; + background-color: #ff7272; background-image: url(/img/conference/delete.png); background-repeat: round; color: transparent !important; } .icon-delete:hover { - background-color: #ff2929; + background-color: #ff0000; transition: background-color .15s ease-in-out; } diff --git a/src/main/resources/public/css/grant.css b/src/main/resources/public/css/grant.css index 2c95628..2176acf 100644 --- a/src/main/resources/public/css/grant.css +++ b/src/main/resources/public/css/grant.css @@ -9,4 +9,19 @@ .div-deadline-description{ padding-left: 5px; padding-right: 5px; +} + +.div-view-paper { + margin-top: 6px; +} + +.div-selected-papers { + border: 0px; + padding-left: 12px; +} + +.icon-paper { + height: 22px; + width: 22px; + margin: 3px; } \ No newline at end of file diff --git a/src/main/resources/public/css/tasks.css b/src/main/resources/public/css/tasks.css index 6d18c99..7e350ed 100644 --- a/src/main/resources/public/css/tasks.css +++ b/src/main/resources/public/css/tasks.css @@ -13,6 +13,21 @@ cursor: text; } +.filter .bootstrap-select{ + margin-bottom: 10px; +} + +.filter-option-inner-inner{ + font-size: 12px; + text-transform: uppercase; + font-weight: normal; + line-height: 25px; +} + +.sorting .bootstrap-select{ + margin-bottom: 10px; +} + .input-tag-name { border: none; box-shadow: none; 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/public/js/papers.js b/src/main/resources/public/js/papers.js index 78d3120..7a937ba 100644 --- a/src/main/resources/public/js/papers.js +++ b/src/main/resources/public/js/papers.js @@ -13,7 +13,8 @@ $(document).ready(function () { }); $('a[data-confirm]').click(function(ev) { - var href = $(this).attr('href'); + var id = $(this).parent().parent().find('.id-class').val(); + if (!$('#dataConfirmModal').length) { $('#modalDelete').append(''); } $('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm')); - $('#dataConfirmOK').attr('href', href); + $('#dataConfirmOK').click(function () { + $("#paperDeleteId").val(id); + $('form').submit(); + }); $('#dataConfirmModal').modal({show:true}); return false; }); diff --git a/src/main/resources/public/js/projects.js b/src/main/resources/public/js/projects.js new file mode 100644 index 0000000..5867c50 --- /dev/null +++ b/src/main/resources/public/js/projects.js @@ -0,0 +1,42 @@ +/*\n' + + ' \n' + + ' '); + } + $('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm')); + $('#dataConfirmOK').attr('href', href); + $('#dataConfirmModal').modal({show:true}); + return false; + }); +}); +/*]]>*/ \ No newline at end of file diff --git a/src/main/resources/public/js/tasks.js b/src/main/resources/public/js/tasks.js index b333c31..f756199 100644 --- a/src/main/resources/public/js/tasks.js +++ b/src/main/resources/public/js/tasks.js @@ -90,7 +90,7 @@ $(document).ready(function () { '