Resolve "Ping конференции в списке конференций" #196

Merged
VladimirZarayskiy merged 44 commits from 68-ping-conf into dev 2019-04-25 14:00:36 +04:00
54 changed files with 796 additions and 149 deletions

View File

@ -6,7 +6,6 @@ import org.springframework.ui.ModelMap;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute; 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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; 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") @PostMapping(value = "/conference", params = "save")
public String save(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException { public String save(@Valid ConferenceDto conferenceDto, Errors errors) throws IOException {
filterEmptyDeadlines(conferenceDto); filterEmptyDeadlines(conferenceDto);
@ -78,17 +83,10 @@ public class ConferenceController {
} }
conferenceService.save(conferenceDto); conferenceService.save(conferenceDto);
return String.format(REDIRECT_TO, CONFERENCES_PAGE); 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") @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); filterEmptyDeadlines(conferenceDto);
if (errors.hasErrors()) { if (errors.hasErrors()) {
return CONFERENCE_PAGE; return CONFERENCE_PAGE;
@ -107,6 +105,16 @@ public class ConferenceController {
return CONFERENCE_PAGE; 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") @PostMapping(value = "/conference", params = "removePaper")
public String removePaper(@Valid ConferenceDto conferenceDto, Errors errors, public String removePaper(@Valid ConferenceDto conferenceDto, Errors errors,
@RequestParam(value = "removePaper") Integer paperIndex) throws IOException { @RequestParam(value = "removePaper") Integer paperIndex) throws IOException {

View File

@ -53,7 +53,7 @@ public class Conference extends BaseEntity {
@OrderBy("date") @OrderBy("date")
private List<Deadline> deadlines = new ArrayList<>(); private List<Deadline> deadlines = new ArrayList<>();
@ManyToMany(fetch = FetchType.EAGER) @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
@JoinTable(name = "paper_conference", @JoinTable(name = "paper_conference",
joinColumns = {@JoinColumn(name = "conference_id")}, joinColumns = {@JoinColumn(name = "conference_id")},
inverseJoinColumns = {@JoinColumn(name = "paper_id")}) inverseJoinColumns = {@JoinColumn(name = "paper_id")})

View File

@ -11,14 +11,14 @@ public class ConferenceFilterDto {
public ConferenceFilterDto() { public ConferenceFilterDto() {
} }
public ConferenceFilterDto(List<ConferenceDto> conferenceDtos, Integer filterUserId, Integer year) { public ConferenceFilterDto(List<ConferenceDto> conferences, Integer filterUserId, Integer year) {
this.conferences = conferenceDtos; this.conferences = conferences;
this.filterUserId = filterUserId; this.filterUserId = filterUserId;
this.year = year; this.year = year;
} }
public ConferenceFilterDto(List<ConferenceDto> conferenceDtos) { public ConferenceFilterDto(List<ConferenceDto> conferences) {
this(conferenceDtos, null, null); this(conferences, null, null);
} }
public List<ConferenceDto> getConferences() { public List<ConferenceDto> getConferences() {

View File

@ -18,6 +18,9 @@ public interface ConferenceRepository extends JpaRepository<Conference, Integer>
@Query("SELECT c FROM Conference c WHERE c.beginDate > :date") @Query("SELECT c FROM Conference c WHERE c.beginDate > :date")
List<Conference> findAllActive(@Param("date") Date date); List<Conference> 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 @Modifying
@Query("UPDATE Conference c SET c.ping = (c.ping + 1) WHERE c.id = :id") @Query("UPDATE Conference c SET c.ping = (c.ping + 1) WHERE c.id = :id")
int updatePingConference(@Param("id") Integer id); int updatePingConference(@Param("id") Integer id);

View File

@ -116,10 +116,20 @@ public class ConferenceService {
conferenceDto.getDeadlines().remove((int) deadlineIndex); 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 { public void removePaper(ConferenceDto conferenceDto, Integer paperIndex) throws IOException {
Paper removedPaper = conferenceDto.getPapers().remove((int) paperIndex); Paper removedPaper = conferenceDto.getPapers().remove((int) paperIndex);
if (removedPaper.getId() != null) {
conferenceDto.getNotSelectedPapers().add(removedPaper); conferenceDto.getNotSelectedPapers().add(removedPaper);
} }
}
public void takePart(ConferenceDto conferenceDto) throws IOException { public void takePart(ConferenceDto conferenceDto) throws IOException {
conferenceDto.getUsers().add(new ConferenceUser(userService.getCurrentUser())); conferenceDto.getUsers().add(new ConferenceUser(userService.getCurrentUser()));
@ -146,15 +156,15 @@ public class ConferenceService {
conference.setTitle(conferenceDto.getTitle()); conference.setTitle(conferenceDto.getTitle());
conference.setDescription(conferenceDto.getDescription()); conference.setDescription(conferenceDto.getDescription());
conference.setUrl(conferenceDto.getUrl()); conference.setUrl(conferenceDto.getUrl());
conference.setPing(conference.getPing());
conference.setBeginDate(conferenceDto.getBeginDate()); conference.setBeginDate(conferenceDto.getBeginDate());
conference.setEndDate(conferenceDto.getEndDate()); 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.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines()));
conference.setUsers(conferenceUserService.saveOrCreate(conferenceDto.getUsers())); conference.setUsers(conferenceUserService.saveOrCreate(conferenceDto.getUsers()));
if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) { if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) {
conferenceDto.getPaperIds().forEach(paperId -> conferenceDto.getPaperIds().forEach(paperId ->
conference.getPapers().add(paperService.findEntityById(paperId))); conference.getPapers().add(paperService.findPaperById(paperId)));
} }
return conference; return conference;
} }
@ -179,6 +189,10 @@ public class ConferenceService {
return conferenceRepository.findAllActive(new Date()); return conferenceRepository.findAllActive(new Date());
} }
public boolean isAttachedToConference(Integer paperId) {
return conferenceRepository.isPaperAttached(paperId);
}
@Transactional @Transactional
public void ping(ConferenceDto conferenceDto) throws IOException { public void ping(ConferenceDto conferenceDto) throws IOException {
pingService.addPing(findOne(conferenceDto.getId())); pingService.addPing(findOne(conferenceDto.getId()));

View File

@ -39,6 +39,11 @@ public class AdviceController {
return userService.getCurrentUser().getUserAbbreviate(); return userService.getCurrentUser().getUserAbbreviate();
} }
@ModelAttribute("flashMessage")
public String getFlashMessage() {
return null;
}
private Response<Void> handleException(ErrorConstants error) { private Response<Void> handleException(ErrorConstants error) {
log.warn(error.toString()); log.warn(error.toString());
return new Response<>(error); return new Response<>(error);

View File

@ -13,6 +13,7 @@ import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.grant.model.Grant; import ru.ulstu.grant.model.Grant;
import ru.ulstu.grant.model.GrantDto; import ru.ulstu.grant.model.GrantDto;
import ru.ulstu.grant.service.GrantService; import ru.ulstu.grant.service.GrantService;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
@ -50,7 +51,9 @@ public class GrantController {
@GetMapping("/grant") @GetMapping("/grant")
public void getGrant(ModelMap modelMap, @RequestParam(value = "id") Integer id) { public void getGrant(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
if (id != null && id > 0) { if (id != null && id > 0) {
modelMap.put("grantDto", grantService.findOneDto(id)); GrantDto grantDto = grantService.findOneDto(id);
attachPaper(grantDto);
modelMap.put("grantDto", grantDto);
} else { } else {
modelMap.put("grantDto", new GrantDto()); modelMap.put("grantDto", new GrantDto());
} }
@ -78,6 +81,12 @@ public class GrantController {
return GRANT_PAGE; return GRANT_PAGE;
} }
@PostMapping(value = "/grant", params = "attachPaper")
public String attachPaper(GrantDto grantDto) {
grantService.attachPaper(grantDto);
return GRANT_PAGE;
}
@PostMapping(value = "/grant", params = "addDeadline") @PostMapping(value = "/grant", params = "addDeadline")
public String addDeadline(@Valid GrantDto grantDto, Errors errors) { public String addDeadline(@Valid GrantDto grantDto, Errors errors) {
filterEmptyDeadlines(grantDto); filterEmptyDeadlines(grantDto);
@ -89,7 +98,7 @@ public class GrantController {
} }
@PostMapping(value = "/grant", params = "createProject") @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()) { if (errors.hasErrors()) {
return GRANT_PAGE; return GRANT_PAGE;
} }
@ -113,6 +122,11 @@ public class GrantController {
return grantService.getGrantAuthors(grantDto); return grantService.getGrantAuthors(grantDto);
} }
@ModelAttribute("allPapers")
public List<Paper> getAllPapers() {
return grantService.getAllPapers();
}
private void filterEmptyDeadlines(GrantDto grantDto) { private void filterEmptyDeadlines(GrantDto grantDto) {
grantDto.setDeadlines(grantDto.getDeadlines().stream() grantDto.setDeadlines(grantDto.getDeadlines().stream()
.filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription())) .filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription()))

View File

@ -5,6 +5,7 @@ import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.core.model.UserContainer; import ru.ulstu.core.model.UserContainer;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.file.model.FileData; import ru.ulstu.file.model.FileData;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.project.model.Project; import ru.ulstu.project.model.Project;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
@ -14,6 +15,7 @@ import javax.persistence.EnumType;
import javax.persistence.Enumerated; import javax.persistence.Enumerated;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
@ -83,6 +85,12 @@ public class Grant extends BaseEntity implements UserContainer {
@JoinColumn(name = "leader_id") @JoinColumn(name = "leader_id")
private User leader; private User leader;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "grants_papers",
joinColumns = {@JoinColumn(name = "grant_id")},
inverseJoinColumns = {@JoinColumn(name = "paper_id")})
private List<Paper> papers = new ArrayList<>();
public GrantStatus getStatus() { public GrantStatus getStatus() {
return status; return status;
} }
@ -152,6 +160,14 @@ public class Grant extends BaseEntity implements UserContainer {
this.leader = leader; this.leader = leader;
} }
public List<Paper> getPapers() {
return papers;
}
public void setPapers(List<Paper> papers) {
this.papers = papers;
}
public Optional<Deadline> getNextDeadline() { public Optional<Deadline> getNextDeadline() {
return deadlines return deadlines
.stream() .stream()

View File

@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.model.ProjectDto;
import ru.ulstu.user.model.UserDto; import ru.ulstu.user.model.UserDto;
@ -32,6 +33,8 @@ public class GrantDto {
private boolean wasLeader; private boolean wasLeader;
private boolean hasAge; private boolean hasAge;
private boolean hasDegree; private boolean hasDegree;
private List<Integer> paperIds = new ArrayList<>();
private List<Paper> papers = new ArrayList<>();
public GrantDto() { public GrantDto() {
deadlines.add(new Deadline()); deadlines.add(new Deadline());
@ -49,7 +52,9 @@ public class GrantDto {
@JsonProperty("leader") Integer leaderId, @JsonProperty("leader") Integer leaderId,
@JsonProperty("wasLeader") boolean wasLeader, @JsonProperty("wasLeader") boolean wasLeader,
@JsonProperty("hasAge") boolean hasAge, @JsonProperty("hasAge") boolean hasAge,
@JsonProperty("hasDegree") boolean hasDegree) { @JsonProperty("hasDegree") boolean hasDegree,
@JsonProperty("paperIds") List<Integer> paperIds,
@JsonProperty("papers") List<Paper> papers) {
this.id = id; this.id = id;
this.title = title; this.title = title;
this.status = status; this.status = status;
@ -62,6 +67,8 @@ public class GrantDto {
this.wasLeader = wasLeader; this.wasLeader = wasLeader;
this.hasAge = hasAge; this.hasAge = hasAge;
this.hasDegree = hasDegree; this.hasDegree = hasDegree;
this.paperIds = paperIds;
this.papers = papers;
} }
public GrantDto(Grant grant) { public GrantDto(Grant grant) {
@ -78,6 +85,8 @@ public class GrantDto {
this.wasLeader = false; this.wasLeader = false;
this.hasAge = false; this.hasAge = false;
this.hasDegree = false; this.hasDegree = false;
this.paperIds = convert(grant.getPapers(), paper -> paper.getId());
this.papers = grant.getPapers();
} }
public Integer getId() { public Integer getId() {
@ -190,4 +199,20 @@ public class GrantDto {
public void setHasDegree(boolean hasDegree) { public void setHasDegree(boolean hasDegree) {
this.hasDegree = hasDegree; this.hasDegree = hasDegree;
} }
public List<Integer> getPaperIds() {
return paperIds;
}
public void setPaperIds(List<Integer> paperIds) {
this.paperIds = paperIds;
}
public List<Paper> getPapers() {
return papers;
}
public void setPapers(List<Paper> papers) {
this.papers = papers;
}
} }

View File

@ -9,6 +9,8 @@ import ru.ulstu.file.service.FileService;
import ru.ulstu.grant.model.Grant; import ru.ulstu.grant.model.Grant;
import ru.ulstu.grant.model.GrantDto; import ru.ulstu.grant.model.GrantDto;
import ru.ulstu.grant.repository.GrantRepository; 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.Project;
import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.model.ProjectDto;
import ru.ulstu.project.service.ProjectService; import ru.ulstu.project.service.ProjectService;
@ -34,17 +36,20 @@ public class GrantService {
private final DeadlineService deadlineService; private final DeadlineService deadlineService;
private final FileService fileService; private final FileService fileService;
private final UserService userService; private final UserService userService;
private final PaperService paperService;
public GrantService(GrantRepository grantRepository, public GrantService(GrantRepository grantRepository,
FileService fileService, FileService fileService,
DeadlineService deadlineService, DeadlineService deadlineService,
ProjectService projectService, ProjectService projectService,
UserService userService) { UserService userService,
PaperService paperService) {
this.grantRepository = grantRepository; this.grantRepository = grantRepository;
this.fileService = fileService; this.fileService = fileService;
this.deadlineService = deadlineService; this.deadlineService = deadlineService;
this.projectService = projectService; this.projectService = projectService;
this.userService = userService; this.userService = userService;
this.paperService = paperService;
} }
public List<Grant> findAll() { public List<Grant> findAll() {
@ -86,10 +91,14 @@ public class GrantService {
if (grantDto.getLeaderId() != null) { if (grantDto.getLeaderId() != null) {
grant.setLeader(userService.findById(grantDto.getLeaderId())); 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; return grant;
} }
public void createProject(GrantDto grantDto) { public void createProject(GrantDto grantDto) throws IOException {
grantDto.setProject( grantDto.setProject(
new ProjectDto(projectService.save(new ProjectDto(grantDto.getTitle())))); new ProjectDto(projectService.save(new ProjectDto(grantDto.getTitle()))));
} }
@ -118,7 +127,7 @@ public class GrantService {
} }
@Transactional @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 grant = new Grant();
grant.setTitle(title); grant.setTitle(title);
grant.setComment("Комментарий к гранту 1"); grant.setComment("Комментарий к гранту 1");
@ -127,6 +136,7 @@ public class GrantService {
grant.getDeadlines().add(new Deadline(deadlineDate, "первый дедлайн")); grant.getDeadlines().add(new Deadline(deadlineDate, "первый дедлайн"));
grant.getAuthors().add(user); grant.getAuthors().add(user);
grant.setLeader(user); grant.setLeader(user);
grant.getPapers().add(paper);
grant = grantRepository.save(grant); grant = grantRepository.save(grant);
return grant; return grant;
} }
@ -156,4 +166,22 @@ public class GrantService {
.map(Grant::getLeader) .map(Grant::getLeader)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public List<Paper> getGrantPapers(List<Integer> paperIds) {
return paperService.findAllSelect(paperIds);
}
public List<Paper> 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();
}
}
} }

View File

@ -8,14 +8,14 @@ import org.springframework.ui.ModelMap;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute; 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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import ru.ulstu.conference.service.ConferenceService;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.paper.model.Paper; import ru.ulstu.paper.model.Paper;
import ru.ulstu.paper.model.PaperDto; 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.LatexService;
import ru.ulstu.paper.service.PaperService; import ru.ulstu.paper.service.PaperService;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
@ -38,23 +38,34 @@ import static org.springframework.util.StringUtils.isEmpty;
@ApiIgnore @ApiIgnore
public class PaperController { public class PaperController {
private final PaperService paperService; private final PaperService paperService;
private final ConferenceService conferenceService;
private final LatexService latexService; private final LatexService latexService;
public PaperController(PaperService paperService, LatexService latexService) { public PaperController(PaperService paperService,
ConferenceService conferenceService,
LatexService latexService) {
this.paperService = paperService; this.paperService = paperService;
this.conferenceService = conferenceService;
this.latexService = latexService; this.latexService = latexService;
} }
@GetMapping("/papers") @GetMapping("/papers")
public void getPapers(ModelMap modelMap) { 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") @PostMapping("/papers")
public void filterPapers(@Valid PaperFilterDto paperFilterDto, ModelMap modelMap) { public void listPapers(@Valid PaperListDto paperListDto, ModelMap modelMap) {
modelMap.put("filteredPapers", new PaperFilterDto(paperService.filter(paperFilterDto), if (paperListDto.getPaperDeleteId() != null) {
paperFilterDto.getFilterAuthorId(), if (conferenceService.isAttachedToConference(paperListDto.getPaperDeleteId())) {
paperFilterDto.getYear())); modelMap.put("flashMessage", "Статью нельзя удалить, она прикреплена к конференции");
} else {
paperService.delete(paperListDto.getPaperDeleteId());
}
}
modelMap.put("filteredPapers", new PaperListDto(paperService.filter(paperListDto),
paperListDto.getFilterAuthorId(),
paperListDto.getYear()));
} }
@GetMapping("/dashboard") @GetMapping("/dashboard")
@ -94,12 +105,6 @@ public class PaperController {
return "/papers/paper"; 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") @ModelAttribute("allStatuses")
public List<Paper.PaperStatus> getPaperStatuses() { public List<Paper.PaperStatus> getPaperStatuses() {
return paperService.getPaperStatuses(); return paperService.getPaperStatuses();

View File

@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
import ru.ulstu.configuration.Constants; import ru.ulstu.configuration.Constants;
import ru.ulstu.core.model.response.Response; import ru.ulstu.core.model.response.Response;
import ru.ulstu.paper.model.PaperDto; 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 ru.ulstu.paper.service.PaperService;
import javax.validation.Valid; import javax.validation.Valid;
@ -58,8 +58,8 @@ public class PaperRestController {
} }
@PostMapping("/filter") @PostMapping("/filter")
public Response<List<PaperDto>> filter(@RequestBody @Valid PaperFilterDto paperFilterDto) throws IOException { public Response<List<PaperDto>> filter(@RequestBody @Valid PaperListDto paperListDto) throws IOException {
return new Response<>(paperService.filter(paperFilterDto)); return new Response<>(paperService.filter(paperListDto));
} }
@GetMapping("formatted-list") @GetMapping("formatted-list")

View File

@ -0,0 +1,7 @@
package ru.ulstu.paper.error;
public class PaperConferenceRelationExistException extends RuntimeException {
public PaperConferenceRelationExistException(String message) {
super(message);
}
}

View File

@ -2,15 +2,16 @@ package ru.ulstu.paper.model;
import java.util.List; import java.util.List;
public class PaperFilterDto { public class PaperListDto {
private List<PaperDto> papers; private List<PaperDto> papers;
private Integer filterAuthorId; private Integer filterAuthorId;
private Integer paperDeleteId;
private Integer year; private Integer year;
public PaperFilterDto() { public PaperListDto() {
} }
public PaperFilterDto(List<PaperDto> paperDtos, Integer filterAuthorId, Integer year) { public PaperListDto(List<PaperDto> paperDtos, Integer filterAuthorId, Integer year) {
this.papers = paperDtos; this.papers = paperDtos;
this.filterAuthorId = filterAuthorId; this.filterAuthorId = filterAuthorId;
this.year = year; this.year = year;
@ -39,4 +40,12 @@ public class PaperFilterDto {
public void setYear(Integer year) { public void setYear(Integer year) {
this.year = year; this.year = year;
} }
public Integer getPaperDeleteId() {
return paperDeleteId;
}
public void setPaperDeleteId(Integer paperDeleteId) {
this.paperDeleteId = paperDeleteId;
}
} }

View File

@ -14,4 +14,6 @@ public interface PaperRepository extends JpaRepository<Paper, Integer> {
List<Paper> filter(@Param("author") User author, @Param("year") Integer year); List<Paper> filter(@Param("author") User author, @Param("year") Integer year);
List<Paper> findByIdNotIn(List<Integer> paperIds); List<Paper> findByIdNotIn(List<Integer> paperIds);
List<Paper> findAllByIdIn(List<Integer> paperIds);
} }

View File

@ -9,7 +9,7 @@ import ru.ulstu.file.model.FileDataDto;
import ru.ulstu.file.service.FileService; import ru.ulstu.file.service.FileService;
import ru.ulstu.paper.model.Paper; import ru.ulstu.paper.model.Paper;
import ru.ulstu.paper.model.PaperDto; 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.paper.repository.PaperRepository;
import ru.ulstu.timeline.service.EventService; import ru.ulstu.timeline.service.EventService;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
@ -93,6 +93,14 @@ public class PaperService {
return newPaper.getId(); 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 { private Paper copyFromDto(Paper paper, PaperDto paperDto) throws IOException {
paper.setComment(paperDto.getComment()); paper.setComment(paperDto.getComment());
paper.setUrl(paperDto.getUrl()); paper.setUrl(paperDto.getUrl());
@ -173,7 +181,7 @@ public class PaperService {
return paper; return paper;
} }
public List<PaperDto> filter(PaperFilterDto filterDto) { public List<PaperDto> filter(PaperListDto filterDto) {
return convert(sortPapers(paperRepository.filter( return convert(sortPapers(paperRepository.filter(
filterDto.getFilterAuthorId() == null ? null : userService.findById(filterDto.getFilterAuthorId()), filterDto.getFilterAuthorId() == null ? null : userService.findById(filterDto.getFilterAuthorId()),
filterDto.getYear())), PaperDto::new); filterDto.getYear())), PaperDto::new);
@ -223,7 +231,7 @@ public class PaperService {
return new PaperDto(paperRepository.findOne(paperId)); return new PaperDto(paperRepository.findOne(paperId));
} }
public Paper findEntityById(Integer paperId) { public Paper findPaperById(Integer paperId) {
return paperRepository.findOne(paperId); return paperRepository.findOne(paperId);
} }
@ -236,6 +244,10 @@ public class PaperService {
} }
public List<Paper> findAllSelect(List<Integer> paperIds) {
return sortPapers(paperRepository.findAllByIdIn(paperIds));
}
public List<User> getPaperAuthors() { public List<User> getPaperAuthors() {
return userService.findAll(); return userService.findAll();
} }

View File

@ -2,16 +2,25 @@ package ru.ulstu.project.controller;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.project.model.Project; import ru.ulstu.project.model.Project;
import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.model.ProjectDto;
import ru.ulstu.project.service.ProjectService; import ru.ulstu.project.service.ProjectService;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import static org.springframework.util.StringUtils.isEmpty;
@Controller() @Controller()
@RequestMapping(value = "/projects") @RequestMapping(value = "/projects")
@ -46,4 +55,39 @@ public class ProjectController {
public List<Project.ProjectStatus> getProjectStatuses() { public List<Project.ProjectStatus> getProjectStatuses() {
return projectService.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()));
}
} }

View File

@ -3,6 +3,7 @@ package ru.ulstu.project.model;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import ru.ulstu.core.model.BaseEntity; import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.file.model.FileData;
import ru.ulstu.grant.model.Grant; import ru.ulstu.grant.model.Grant;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
@ -57,6 +58,10 @@ public class Project extends BaseEntity {
@NotNull @NotNull
private String repository; private String repository;
@ManyToOne
@JoinColumn(name = "file_id")
private FileData application;
public String getTitle() { public String getTitle() {
return title; return title;
} }
@ -104,4 +109,12 @@ public class Project extends BaseEntity {
public void setDeadlines(List<Deadline> deadlines) { public void setDeadlines(List<Deadline> deadlines) {
this.deadlines = deadlines; this.deadlines = deadlines;
} }
public FileData getApplication() {
return application;
}
public void setApplication(FileData application) {
this.application = application;
}
} }

View File

@ -19,6 +19,7 @@ public class ProjectDto {
private List<Deadline> deadlines = new ArrayList<>(); private List<Deadline> deadlines = new ArrayList<>();
private GrantDto grant; private GrantDto grant;
private String repository; private String repository;
private String applicationFileName;
public ProjectDto() { public ProjectDto() {
} }
@ -42,6 +43,7 @@ public class ProjectDto {
this.grant = grant; this.grant = grant;
this.repository = repository; this.repository = repository;
this.deadlines = deadlines; this.deadlines = deadlines;
this.applicationFileName = null;
} }
@ -50,6 +52,7 @@ public class ProjectDto {
this.title = project.getTitle(); this.title = project.getTitle();
this.status = project.getStatus(); this.status = project.getStatus();
this.description = project.getDescription(); this.description = project.getDescription();
this.applicationFileName = project.getApplication() == null ? null : project.getApplication().getName();
this.grant = project.getGrant() == null ? null : new GrantDto(project.getGrant()); this.grant = project.getGrant() == null ? null : new GrantDto(project.getGrant());
this.repository = project.getRepository(); this.repository = project.getRepository();
this.deadlines = project.getDeadlines(); this.deadlines = project.getDeadlines();
@ -110,4 +113,12 @@ public class ProjectDto {
public void setDeadlines(List<Deadline> deadlines) { public void setDeadlines(List<Deadline> deadlines) {
this.deadlines = deadlines; this.deadlines = deadlines;
} }
public String getApplicationFileName() {
return applicationFileName;
}
public void setApplicationFileName(String applicationFileName) {
this.applicationFileName = applicationFileName;
}
} }

View File

@ -4,15 +4,19 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.thymeleaf.util.StringUtils; import org.thymeleaf.util.StringUtils;
import ru.ulstu.deadline.service.DeadlineService; 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.Project;
import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.model.ProjectDto;
import ru.ulstu.project.repository.ProjectRepository; import ru.ulstu.project.repository.ProjectRepository;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import static org.springframework.util.ObjectUtils.isEmpty; import static org.springframework.util.ObjectUtils.isEmpty;
import static ru.ulstu.core.util.StreamApiUtils.convert; import static ru.ulstu.core.util.StreamApiUtils.convert;
import static ru.ulstu.project.model.Project.ProjectStatus.APPLICATION;
@Service @Service
public class ProjectService { public class ProjectService {
@ -20,11 +24,17 @@ public class ProjectService {
private final ProjectRepository projectRepository; private final ProjectRepository projectRepository;
private final DeadlineService deadlineService; private final DeadlineService deadlineService;
private final GrantRepository grantRepository;
private final FileService fileService;
public ProjectService(ProjectRepository projectRepository, public ProjectService(ProjectRepository projectRepository,
DeadlineService deadlineService) { DeadlineService deadlineService,
GrantRepository grantRepository,
FileService fileService) {
this.projectRepository = projectRepository; this.projectRepository = projectRepository;
this.deadlineService = deadlineService; this.deadlineService = deadlineService;
this.grantRepository = grantRepository;
this.fileService = fileService;
} }
public List<Project> findAll() { public List<Project> findAll() {
@ -46,19 +56,47 @@ public class ProjectService {
} }
@Transactional @Transactional
public Project create(ProjectDto projectDto) { public Project create(ProjectDto projectDto) throws IOException {
Project newProject = copyFromDto(new Project(), projectDto); Project newProject = copyFromDto(new Project(), projectDto);
newProject = projectRepository.save(newProject); newProject = projectRepository.save(newProject);
return newProject; return newProject;
} }
private Project copyFromDto(Project project, ProjectDto projectDto) { @Transactional
project.setTitle(projectDto.getTitle()); public Project update(ProjectDto projectDto) throws IOException {
project.setDeadlines(deadlineService.saveOrCreate(projectDto.getDeadlines())); Project project = projectRepository.findOne(projectDto.getId());
if (projectDto.getApplicationFileName() != null && project.getApplication() != null) {
fileService.deleteFile(project.getApplication());
}
projectRepository.save(copyFromDto(project, projectDto));
return project; 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())) { if (isEmpty(projectDto.getId())) {
return create(projectDto); return create(projectDto);
} else { } else {
@ -66,10 +104,6 @@ public class ProjectService {
} }
} }
private Project update(ProjectDto projectDto) {
throw new RuntimeException("not implemented yet");
}
public Project findById(Integer id) { public Project findById(Integer id) {
return projectRepository.findOne(id); return projectRepository.findOne(id);
} }

View File

@ -5,13 +5,16 @@ import org.springframework.ui.ModelMap;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute; 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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.students.model.Task; import ru.ulstu.students.model.Task;
import ru.ulstu.students.model.TaskDto; import ru.ulstu.students.model.TaskDto;
import ru.ulstu.students.model.TaskFilterDto;
import ru.ulstu.students.service.TaskService; import ru.ulstu.students.service.TaskService;
import ru.ulstu.tags.model.Tag;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid; import javax.validation.Valid;
@ -35,16 +38,16 @@ public class TaskController {
this.taskService = taskService; this.taskService = taskService;
} }
@GetMapping("/tasks")
public void getTasks(ModelMap modelMap) {
modelMap.put("tasks", taskService.findAllDto());
}
@GetMapping("/dashboard") @GetMapping("/dashboard")
public void getDashboard(ModelMap modelMap) { public void getDashboard(ModelMap modelMap) {
modelMap.put("tasks", taskService.findAllDto()); modelMap.put("tasks", taskService.findAllDto());
} }
@GetMapping("/tasks")
public void getTask(ModelMap modelMap) {
modelMap.put("filteredTasks", new TaskFilterDto(taskService.findAllDto(), null, null, null));
}
@GetMapping("/task") @GetMapping("/task")
public void getTask(ModelMap modelMap, @RequestParam(value = "id") Integer id) { public void getTask(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
if (id != null && id > 0) { 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") @PostMapping(value = "/task", params = "save")
public String save(@Valid TaskDto taskDto, Errors errors) throws IOException { public String save(@Valid TaskDto taskDto, Errors errors) throws IOException {
filterEmptyDeadlines(taskDto); filterEmptyDeadlines(taskDto);
@ -77,11 +88,23 @@ public class TaskController {
return TASK_PAGE; 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") @ModelAttribute("allStatuses")
public List<Task.TaskStatus> getTaskStatuses() { public List<Task.TaskStatus> getTaskStatuses() {
return taskService.getTaskStatuses(); return taskService.getTaskStatuses();
} }
@ModelAttribute("allTags")
public List<Tag> getTags() {
return taskService.getTags();
}
private void filterEmptyDeadlines(TaskDto taskDto) { private void filterEmptyDeadlines(TaskDto taskDto) {
taskDto.setDeadlines(taskDto.getDeadlines().stream() taskDto.setDeadlines(taskDto.getDeadlines().stream()
.filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription())) .filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription()))

View File

@ -50,7 +50,7 @@ public class Task extends BaseEntity {
private String description; private String description;
@Enumerated(value = EnumType.STRING) @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) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "task_id", unique = true) @JoinColumn(name = "task_id", unique = true)

View File

@ -26,7 +26,7 @@ public class TaskDto {
private Date createDate; private Date createDate;
private Date updateDate; private Date updateDate;
private Set<Integer> tagIds; private Set<Integer> tagIds;
private List<Tag> tags; private List<Tag> tags = new ArrayList<>();
public TaskDto() { public TaskDto() {
deadlines.add(new Deadline()); deadlines.add(new Deadline());

View File

@ -0,0 +1,54 @@
package ru.ulstu.students.model;
import java.util.List;
public class TaskFilterDto {
private List<TaskDto> tasks;
private Task.TaskStatus status;
private Integer tagId;
private String order;
public TaskFilterDto(List<TaskDto> tasks, Task.TaskStatus status, Integer tagId, String order) {
this.tasks = tasks;
this.status = status;
this.tagId = tagId;
this.order = order;
}
public TaskFilterDto() {
}
public List<TaskDto> getTasks() {
return tasks;
}
public void setTasks(List<TaskDto> 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;
}
}

View File

@ -1,7 +1,18 @@
package ru.ulstu.students.repository; package ru.ulstu.students.repository;
import org.springframework.data.jpa.repository.JpaRepository; 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.students.model.Task;
import ru.ulstu.tags.model.Tag;
import java.util.List;
public interface TaskRepository extends JpaRepository<Task, Integer> { public interface TaskRepository extends JpaRepository<Task, Integer> {
@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<Task> 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<Task> filterOld(@Param("status") Task.TaskStatus status, @Param("tag") Tag tag);
} }

View File

@ -1,12 +1,15 @@
package ru.ulstu.students.service; package ru.ulstu.students.service;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import ru.ulstu.deadline.service.DeadlineService; import ru.ulstu.deadline.service.DeadlineService;
import ru.ulstu.students.model.Task; import ru.ulstu.students.model.Task;
import ru.ulstu.students.model.TaskDto; import ru.ulstu.students.model.TaskDto;
import ru.ulstu.students.model.TaskFilterDto;
import ru.ulstu.students.repository.TaskRepository; import ru.ulstu.students.repository.TaskRepository;
import ru.ulstu.tags.model.Tag;
import ru.ulstu.tags.service.TagService; import ru.ulstu.tags.service.TagService;
import java.io.IOException; import java.io.IOException;
@ -27,15 +30,15 @@ public class TaskService {
private final DeadlineService deadlineService; private final DeadlineService deadlineService;
private final TagService tagService; private final TagService tagService;
public TaskService(TaskRepository grantRepository, public TaskService(TaskRepository taskRepository,
DeadlineService deadlineService, TagService tagService) { DeadlineService deadlineService, TagService tagService) {
this.taskRepository = grantRepository; this.taskRepository = taskRepository;
this.deadlineService = deadlineService; this.deadlineService = deadlineService;
this.tagService = tagService; this.tagService = tagService;
} }
public List<Task> findAll() { public List<Task> findAll() {
return taskRepository.findAll(); return taskRepository.findAll(new Sort(Sort.Direction.DESC, "createDate"));
} }
public List<TaskDto> findAllDto() { public List<TaskDto> findAllDto() {
@ -48,6 +51,18 @@ public class TaskService {
return new TaskDto(taskRepository.findOne(id)); return new TaskDto(taskRepository.findOne(id));
} }
public List<TaskDto> 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 @Transactional
public Integer create(TaskDto taskDto) throws IOException { public Integer create(TaskDto taskDto) throws IOException {
Task newTask = copyFromDto(new Task(), taskDto); Task newTask = copyFromDto(new Task(), taskDto);
@ -76,8 +91,10 @@ public class TaskService {
@Transactional @Transactional
public void delete(Integer taskId) throws IOException { public void delete(Integer taskId) throws IOException {
Task task = taskRepository.findOne(taskId); if (taskRepository.exists(taskId)) {
taskRepository.delete(task); taskRepository.delete(taskId);
}
} }
public void save(TaskDto taskDto) throws IOException { public void save(TaskDto taskDto) throws IOException {
@ -92,4 +109,8 @@ public class TaskService {
return Arrays.asList(Task.TaskStatus.values()); return Arrays.asList(Task.TaskStatus.values());
} }
public List<Tag> getTags() {
return tagService.getTags();
}
} }

View File

@ -50,4 +50,12 @@ public class TagService {
return newTag; return newTag;
} }
public List<Tag> getTags() {
return tagRepository.findAll();
}
public Tag findById(Integer tagId) {
return tagRepository.findOne(tagId);
}
} }

View File

@ -0,0 +1,17 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet author="tanya" id="20190419_000000-1">
<createTable tableName="grants_papers">
<column name="grant_id" type="integer"/>
<column name="paper_id" type="integer"/>
</createTable>
<addForeignKeyConstraint baseTableName="grants_papers" baseColumnNames="grant_id"
constraintName="fk_grants_grants_papers" referencedTableName="grants"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="grants_papers" baseColumnNames="paper_id"
constraintName="fk_paper_grants_papers" referencedTableName="paper"
referencedColumnNames="id"/>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,16 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet author="anton" id="20190418_000000-1">
<addColumn tableName="project">
<column name="file_id" type="integer"/>
</addColumn>
<addForeignKeyConstraint baseTableName="project" baseColumnNames="file_id"
constraintName="fk_project_file_id" referencedTableName="file"
referencedColumnNames="id"/>
<addColumn tableName="project">
<column name="applicationFileName" type="varchar(255)"/>
</addColumn>
</changeSet>
</databaseChangeLog>

View File

@ -30,6 +30,8 @@
<include file="db/common/changelog-20190312_130000-schema.xml"/> <include file="db/common/changelog-20190312_130000-schema.xml"/>
<include file="db/changelog-20190402_000000-schema.xml"/> <include file="db/changelog-20190402_000000-schema.xml"/>
<include file="db/changelog-20190404_000000-schema.xml"/> <include file="db/changelog-20190404_000000-schema.xml"/>
<include file="db/changelog-20190419_000000-schema.xml"/>
<include file="db/changelog-20190421_000000-schema.xml"/> <include file="db/changelog-20190421_000000-schema.xml"/>
<include file="db/changelog-20190422_000000-schema.xml"/>
<include file="db/changelog-20190424_000000-schema.xml"/> <include file="db/changelog-20190424_000000-schema.xml"/>
</databaseChangeLog> </databaseChangeLog>

View File

@ -2,8 +2,8 @@ body {
min-width: 400px; min-width: 400px;
} }
.conference-row .col:hover { .conference-row .d-flex:hover {
background-color: #f3f3f3; background-color: #f1f1f1;
border-radius: .25rem; border-radius: .25rem;
} }
@ -15,10 +15,20 @@ body {
margin-bottom: 10px; margin-bottom: 10px;
} }
.conference-row .col .text-decoration { .conference-row .d-flex .text-decoration {
text-decoration: none; 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 { .form-group textarea {
min-height: 206px; min-height: 206px;
@ -61,13 +71,17 @@ body {
padding: 0.5rem 1.75em 0.5rem 0.5em; padding: 0.5rem 1.75em 0.5rem 0.5em;
display: inline-block; display: inline-block;
background: transparent url("https://cdn3.iconfinder.com/data/icons/faticons/32/arrow-down-01-16.png") no-repeat right 7px center; 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) { .member select:nth-child(4) {
border-right: 1px solid #ced4da; border-right: 1px solid #ced4da;
} }
.member select:hover {
background-color: #f1f1f1;
}
.member-name { .member-name {
padding: .75rem 1.25rem; padding: .75rem 1.25rem;
@ -114,11 +128,22 @@ body {
flex: 1; flex: 1;
} }
.paper-name:hover {
background-color: #f1f1f1;
}
.paper-name span { .paper-name span {
margin: 6px 15px; margin: 7px 10px;
display: inline-block; display: inline-block;
} }
.paper-name span:nth-child(1) {
margin: 3px 0px 3px 10px;
float: left;
}
.icon { .icon {
width: 38px; width: 38px;
height: 38px; height: 38px;
@ -127,14 +152,14 @@ body {
} }
.icon-delete { .icon-delete {
background-color: #f44; background-color: #ff7272;
background-image: url(/img/conference/delete.png); background-image: url(/img/conference/delete.png);
background-repeat: round; background-repeat: round;
color: transparent !important; color: transparent !important;
} }
.icon-delete:hover { .icon-delete:hover {
background-color: #ff2929; background-color: #ff0000;
transition: background-color .15s ease-in-out; transition: background-color .15s ease-in-out;
} }

View File

@ -10,3 +10,18 @@
padding-left: 5px; padding-left: 5px;
padding-right: 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;
}

View File

@ -13,6 +13,21 @@
cursor: text; 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 { .input-tag-name {
border: none; border: none;
box-shadow: none; box-shadow: none;

View File

@ -1,7 +1,6 @@
$(document).ready(function () { $(document).ready(function () {
$('input[data-confirm]').click(function(ev) {
$('a[data-confirm]').click(function(ev) { var value = $(this).attr('value');
var href = $(this).attr('href');
if (!$('#dataConfirmModal').length) { if (!$('#dataConfirmModal').length) {
$('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' + $('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' +
' >\n' + ' >\n' +
@ -14,7 +13,7 @@ $(document).ready(function () {
' </div>\n' + ' </div>\n' +
' <div class="modal-footer">\n' + ' <div class="modal-footer">\n' +
' <a class="btn btn-primary" id="dataConfirmOK">Да</a>'+ ' <button type="submit" name="deleteConference" class="btn btn-primary" id="deleteConference">Да</button>'+
' <button class="btn primary" data-dismiss="modal" aria-hidden="true">Нет</button>'+ ' <button class="btn primary" data-dismiss="modal" aria-hidden="true">Нет</button>'+
' </div>\n' + ' </div>\n' +
' </div>\n' + ' </div>\n' +
@ -22,7 +21,7 @@ $(document).ready(function () {
' </div>'); ' </div>');
} }
$('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm')); $('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm'));
$('#dataConfirmOK').attr('href', href); $('#deleteConference').attr('value', value);
$('#dataConfirmModal').modal({show:true}); $('#dataConfirmModal').modal({show:true});
return false; return false;
}); });

View File

@ -13,7 +13,8 @@ $(document).ready(function () {
}); });
$('a[data-confirm]').click(function(ev) { $('a[data-confirm]').click(function(ev) {
var href = $(this).attr('href'); var id = $(this).parent().parent().find('.id-class').val();
if (!$('#dataConfirmModal').length) { if (!$('#dataConfirmModal').length) {
$('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' + $('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' +
' >\n' + ' >\n' +
@ -34,7 +35,10 @@ $(document).ready(function () {
' </div>'); ' </div>');
} }
$('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm')); $('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm'));
$('#dataConfirmOK').attr('href', href); $('#dataConfirmOK').click(function () {
$("#paperDeleteId").val(id);
$('form').submit();
});
$('#dataConfirmModal').modal({show:true}); $('#dataConfirmModal').modal({show:true});
return false; return false;
}); });

View File

@ -0,0 +1,42 @@
/*<![CDATA[*/
$(document).ready(function () {
$(".project-row").mouseenter(function (event) {
var projectRow = $(event.target).closest(".project-row");
$(projectRow).css("background-color", "#f8f9fa");
$(projectRow).find(".remove-paper").removeClass("d-none");
});
$(".project-row").mouseleave(function (event) {
var projectRow = $(event.target).closest(".project-row");
$(projectRow).css("background-color", "white");
$(projectRow).find(".remove-paper").addClass("d-none");
});
$('a[data-confirm]').click(function(ev) {
var href = $(this).attr('href');
if (!$('#dataConfirmModal').length) {
$('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' +
' >\n' +
' <div class="modal-dialog modal-sm">\n' +
' <div class="modal-content">\n' +
' <div class="modal-header">\n' +
' <h8 class="modal-title" id="myModalLabel">Удалить проект?</h8>\n' +
' <button type="button" class="close" data-dismiss="modal" aria-label="Закрыть"><span\n' +
' aria-hidden="true">&times;</span></button>\n' +
' </div>\n' +
' <div class="modal-footer">\n' +
' <a class="btn btn-primary" id="dataConfirmOK">Да</a>'+
' <button class="btn primary" data-dismiss="modal" aria-hidden="true">Нет</button>'+
' </div>\n' +
' </div>\n' +
' </div>\n' +
' </div>');
}
$('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm'));
$('#dataConfirmOK').attr('href', href);
$('#dataConfirmModal').modal({show:true});
return false;
});
});
/*]]>*/

View File

@ -90,7 +90,7 @@ $(document).ready(function () {
' <div class="modal-dialog modal-sm">\n' + ' <div class="modal-dialog modal-sm">\n' +
' <div class="modal-content">\n' + ' <div class="modal-content">\n' +
' <div class="modal-header">\n' + ' <div class="modal-header">\n' +
' <h8 class="modal-title" id="myModalLabel">Удалить статью?</h8>\n' + ' <h8 class="modal-title" id="myModalLabel">Удалить задачу?</h8>\n' +
' <button type="button" class="close" data-dismiss="modal" aria-label="Закрыть"><span\n' + ' <button type="button" class="close" data-dismiss="modal" aria-label="Закрыть"><span\n' +
' aria-hidden="true">&times;</span></button>\n' + ' aria-hidden="true">&times;</span></button>\n' +
' </div>\n' + ' </div>\n' +

View File

@ -135,11 +135,24 @@
<div class="form-group"> <div class="form-group">
<label for="papers">Статьи:</label> <label for="papers">Статьи:</label>
<div class="paper-list form-control list-group" id="papers"> <div class="paper-list form-control list-group" id="papers">
<input th:type="hidden" th:field="*{papers}"/> <!--<input th:type="hidden" th:field="*{papers}"/>-->
<div class="paper d-flex list-group-item p-0" <div class="paper d-flex list-group-item p-0"
th:each="paper, rowStat : *{papers}"> th:each="paper, rowStat : *{papers}">
<input type="hidden" th:field="*{papers[__${rowStat.index}__].id}"/>
<input type="hidden" th:field="*{papers[__${rowStat.index}__].title}"/>
<input type="hidden" th:field="*{papers[__${rowStat.index}__].status}"/>
<a class="paper-name" <a class="paper-name"
th:href="@{'/papers/paper?id=' + *{papers[__${rowStat.index}__].id} + ''}"> th:href="@{'/papers/paper?id=' + *{papers[__${rowStat.index}__].id} + ''}"
th:if="*{papers[__${rowStat.index}__].id !=null}">
<span th:replace="papers/fragments/paperStatusFragment :: paperStatus(paperStatus=*{papers[__${rowStat.index}__].status})"/>
<span th:text="*{papers[__${rowStat.index}__].title}">
Имя статьи
</span>
<!--<img class="icon-paper" src="/img/conference/paper.png"/>-->
</a>
<a class="paper-name"
th:unless="*{papers[__${rowStat.index}__].id !=null}">
<span th:text="*{papers[__${rowStat.index}__].title}"> <span th:text="*{papers[__${rowStat.index}__].title}">
Имя статьи Имя статьи
</span> </span>
@ -160,7 +173,7 @@
</option> </option>
</select> </select>
<button id="add-paper" class="btn btn-primary" <button id="add-paper" class="btn btn-primary"
type="button"> type="submit" name="addPaper">
Добавить статью Добавить статью
</button> </button>
</div> </div>

View File

@ -8,7 +8,9 @@
<body> <body>
<div layout:fragment="content"> <div layout:fragment="content">
<form id="conferences-form" method="post" th:action="@{'/conferences/conferences'}"> <form id="conferences-form" method="post" th:action="@{'/conferences/conferences'}"
th:object="${filteredConferences}">
<section id="conferences"> <section id="conferences">
<div class="container"> <div class="container">
<div class="row" id="conference-list"> <div class="row" id="conference-list">
@ -18,9 +20,12 @@
</div> </div>
</div> </div>
<hr/> <hr/>
<div class="alert alert-danger" th:if="${#fields.hasErrors('*')}">
<p th:each="err : ${#fields.errors('*')}" th:text="${err}"></p>
</div>
<div class="row"> <div class="row">
<div class="col-md-9 col-sm-12"> <div class="col-md-9 col-sm-12">
<th:block th:each="conference : ${filteredConferences.conferences}"> <th:block th:each="conference : *{conferences}">
<div th:replace="conferences/fragments/confLineFragment :: confLine(conference=${conference})"/> <div th:replace="conferences/fragments/confLineFragment :: confLine(conference=${conference})"/>
</th:block> </th:block>
</div> </div>

View File

@ -5,16 +5,19 @@
</head> </head>
<body> <body>
<div th:fragment="confLine (conference)" class="row text-left conference-row h3" style="background-color: white;"> <div th:fragment="confLine (conference)" class="row text-left conference-row h3" style="background-color: white;">
<div class="col d-flex justify-content-between"> <div class="d-flex justify-content-between w-100">
<a th:href="@{'conference?id='+${conference.id}}" class="w-100 text-decoration"> <a th:href="@{'conference?id='+${conference.id}}" class="w-100 text-decoration">
<span class="h5" th:text="${conference.title}"/> <span class="h5" th:text="${conference.title}"/>
<span class="text-muted h6 float-right m-2" th:text="${conference.datesString}"/> <span class="text-muted h6 float-right m-2" th:text="${conference.datesString}"/>
</a> </a>
<input class="id-class" type="hidden" th:value="${conference.id}"/> <input class="id-class" type="hidden" th:value="${conference.id}"/>
<a class="remove-paper pull-right m-auto" th:href="@{'/conferences/delete/'+${conference.id}}" <input type="submit" class="icon icon-delete grey-border"
data-confirm="Удалить конференцию?"> alt="Удалить" th:value="${conference.id}"
<i class="fa fa-trash" aria-hidden="true"></i> data-confirm="Удалить конференцию?"/>
</a> <!--<a class="remove-paper pull-right m-auto" th:href="@{'/conferences/delete/'+${conference.id}}"-->
<!--data-confirm="Удалить конференцию?">-->
<!--<i class="fa fa-trash" aria-hidden="true"></i>-->
<!--</a>-->
</div> </div>
</div> </div>

View File

@ -55,7 +55,8 @@
<a class="nav-link js-scroll-trigger" target="_blank" href="http://is.ulstu.ru">Сайт кафедры</a> <a class="nav-link js-scroll-trigger" target="_blank" href="http://is.ulstu.ru">Сайт кафедры</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link js-scroll-trigger" target="_blank" th:href="@{'http://timetable.athene.tech?filter='+${currentUser}}">Расписание</a> <a class="nav-link js-scroll-trigger" target="_blank"
th:href="@{'http://timetable.athene.tech?filter='+${currentUser}}">Расписание</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link js-scroll-trigger" target="_blank" href="https://kias.rfbr.ru/">КИАС РФФИ</a> <a class="nav-link js-scroll-trigger" target="_blank" href="https://kias.rfbr.ru/">КИАС РФФИ</a>
@ -97,36 +98,54 @@
<script src="/js/core.js"></script> <script src="/js/core.js"></script>
<script src="/js/config.js"></script> <script src="/js/config.js"></script>
<script src="/js/odin.js"></script> <script src="/js/odin.js"></script>
<script th:inline="javascript">
/*<![CDATA[*/
var message = /*[[${flashMessage}]]*/ "";
if (message && message.length > 0) {
showFeedbackMessage(message, MessageTypesEnum.DANGER);
}
/*]]>*/
</script>
<th:block layout:fragment="scripts"> <th:block layout:fragment="scripts">
</th:block> </th:block>
<!-- Yandex.Metrika counter --> <!-- Yandex.Metrika counter -->
<script type="text/javascript" > <script type="text/javascript">
(function (d, w, c) { (function (d, w, c) {
(w[c] = w[c] || []).push(function() { (w[c] = w[c] || []).push(function () {
try { try {
w.yaCounter49387279 = new Ya.Metrika2({ w.yaCounter49387279 = new Ya.Metrika2({
id:49387279, id: 49387279,
clickmap:true, clickmap: true,
trackLinks:true, trackLinks: true,
accurateTrackBounce:true, accurateTrackBounce: true,
webvisor:true webvisor: true
}); });
} catch(e) { } } catch (e) {
}
}); });
var n = d.getElementsByTagName("script")[0], var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"), s = d.createElement("script"),
f = function () { n.parentNode.insertBefore(s, n); }; f = function () {
n.parentNode.insertBefore(s, n);
};
s.type = "text/javascript"; s.type = "text/javascript";
s.async = true; s.async = true;
s.src = "https://mc.yandex.ru/metrika/tag.js"; s.src = "https://mc.yandex.ru/metrika/tag.js";
if (w.opera == "[object Opera]") { if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f, false); d.addEventListener("DOMContentLoaded", f, false);
} else { f(); } } else {
f();
}
})(document, window, "yandex_metrika_callbacks2"); })(document, window, "yandex_metrika_callbacks2");
</script> </script>
<noscript><div><img src="https://mc.yandex.ru/watch/49387279" style="position:absolute; left:-9999px;" alt="" /></div></noscript> <noscript>
<div><img src="https://mc.yandex.ru/watch/49387279" style="position:absolute; left:-9999px;" alt=""/></div>
</noscript>
<!-- /Yandex.Metrika counter --> <!-- /Yandex.Metrika counter -->
</body> </body>
</html> </html>

View File

@ -144,9 +144,9 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Участники гранта:</label> <label>Участники гранта:</label>
<select class="selectpicker form-control" multiple="true" <select class="selectpicker form-control" multiple="true" data-live-search="true"
title="-- Выберите участников --" id="authors" title="-- Выберите участников --" id="authors"
th:field="*{authorIds}"> th:field="*{authorIds}" data-size="5">
<option th:each="author : ${allAuthors}" th:value="${author.id}" <option th:each="author : ${allAuthors}" th:value="${author.id}"
th:text="${author.lastName}"> Участник th:text="${author.lastName}"> Участник
</option> </option>
@ -154,9 +154,48 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Список статей:</label> <label>Список статей:</label>
<p><a href="./#" class="btn btn-primary"><i class="fa fa-plus-circle" <div class="row">
aria-hidden="true"> <div class="col-8">
</i> Добавить статью</a></p> <select class="selectpicker form-control" multiple="true"
data-live-search="true"
title="Прикрепить статью" id="allPapers"
th:field="*{paperIds}" data-size="5">
<option th:each="paper : ${allPapers}" th:value="${paper.id}"
th:text="${paper.title}">Статья для прикрепления
</option>
</select>
</div>
<div class="col-4 div-view-paper">
<a th:onclick="|$('#attachPaper').click();|">
<span aria-hidden="true">
<label>Отобразить</label>
</span>
</a>
</div>
<input type="submit" hidden="hidden" id="attachPaper" name="attachPaper"
value="Отобразить прикрепленную статью"/>
</div>
<div class="row">
<input th:type="hidden" th:field="*{papers}"/>
<div class="form-control list-group div-selected-papers" id="selected-papers">
<div th:each="paper, rowStat : *{papers}">
<div class="col">
<a th:href="@{'/papers/paper?id=' + *{papers[__${rowStat.index}__].id} + ''}">
<img class="icon-paper" src="/img/conference/paper.png"/>
<span th:text="*{papers[__${rowStat.index}__].title}">
Название статьи
</span>
</a>
</div>
<div class="col">
<label>Статус: </label>
<span th:text="*{papers[__${rowStat.index}__].status.statusName}">
Статус статьи
</span>
</div>
</div>
</div>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div th:if="*{project} == null"> <div th:if="*{project} == null">
@ -203,6 +242,8 @@
/*]]>*/ /*]]>*/
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
function updateAuthors() { function updateAuthors() {
@ -212,6 +253,23 @@
var lid = $("#leaderId option:selected").val(); var lid = $("#leaderId option:selected").val();
$("#authors [value='" + lid + "']").attr("disabled", "disabled"); $("#authors [value='" + lid + "']").attr("disabled", "disabled");
} }
</script>
<script>
function viewdiv(id) {
var el = document.getElementById(id);
var link = document.getElementById('toggleLink');
if (el.style.display == "block") {
el.style.display = "none";
link.innerText = link.getAttribute('data-text-hide');
} else {
el.style.display = "block";
link.innerText = link.getAttribute('data-text-show');
}
}
</script> </script>
</div> </div>
</body> </body>

View File

@ -8,7 +8,8 @@
<div th:fragment="filesList (isLatexAttach)" th:remove="tag"> <div th:fragment="filesList (isLatexAttach)" th:remove="tag">
<th:block th:each="file, rowStat : *{files}"> <th:block th:each="file, rowStat : *{files}">
<span th:if="${(!isLatexAttach and file.isLatexAttach == null) or file.isLatexAttach == isLatexAttach}" th:remove="tag"> <span th:if="${(!isLatexAttach and file.isLatexAttach == null) or file.isLatexAttach == isLatexAttach}"
th:remove="tag">
<div class="row" th:id="|files${rowStat.index}|" <div class="row" th:id="|files${rowStat.index}|"
th:style="${file.deleted} ? 'display: none;' :''"> th:style="${file.deleted} ? 'display: none;' :''">

View File

@ -12,8 +12,7 @@
<span class="text-muted" th:text="${paper.authorsString}"/> <span class="text-muted" th:text="${paper.authorsString}"/>
</a> </a>
<input class="id-class" type="hidden" th:value="${paper.id}"/> <input class="id-class" type="hidden" th:value="${paper.id}"/>
<a class="remove-paper pull-right d-none" th:href="@{'/papers/delete/'+${paper.id}}" <a class="remove-paper pull-right d-none" href="#" data-confirm="Удалить статью?">
data-confirm="Удалить статью?">
<i class="fa fa-trash" aria-hidden="true"></i> <i class="fa fa-trash" aria-hidden="true"></i>
</a> </a>
</div> </div>

View File

@ -7,7 +7,8 @@
<body> <body>
<div class="container" layout:fragment="content"> <div class="container" layout:fragment="content">
<form id="papers-form" method="post" th:action="@{'/papers/papers'}"> <form id="papers-form" method="post" th:action="@{'/papers/papers'}"
th:object="${filteredPapers}">
<input th:type="hidden" name="paperDeleteId" id="paperDeleteId"/> <input th:type="hidden" name="paperDeleteId" id="paperDeleteId"/>
<section id="papers"> <section id="papers">
<div class="container"> <div class="container">
@ -17,7 +18,11 @@
<div th:replace="papers/fragments/paperNavigationFragment"/> <div th:replace="papers/fragments/paperNavigationFragment"/>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="alert alert-danger" th:if="${#fields.hasErrors('*')}">
<p th:each="err : ${#fields.errors('*')}" th:text="${err}"></p>
</div>
<div class="col-md-9 col-sm-12"> <div class="col-md-9 col-sm-12">
<th:block th:each="paper : ${filteredPapers.papers}"> <th:block th:each="paper : ${filteredPapers.papers}">
<div th:replace="papers/fragments/paperLineFragment :: paperLine(paper=${paper})"/> <div th:replace="papers/fragments/paperLineFragment :: paperLine(paper=${paper})"/>
@ -43,7 +48,7 @@
</div> </div>
</div> </div>
</div> </div>
<div th:replace="fragments/noRecordsFragment :: noRecords(entities=${filteredPapers.papers}, noRecordsMessage=' одной статьи', url='paper')"/> <!--<div th:replace="fragments/noRecordsFragment :: noRecords(entities=${filteredPapers.papers}, noRecordsMessage=' одной статьи', url='paper')"/>-->
</div> </div>
</section> </section>

View File

@ -13,8 +13,8 @@
<div th:replace="projects/fragments/projectNavigationFragment"/> <div th:replace="projects/fragments/projectNavigationFragment"/>
</div> </div>
<div class="row justify-content-center" id="dashboard"> <div class="row justify-content-center" id="dashboard">
<th:block> <th:block th:each="project : ${projects}">
<div/> <div th:replace="projects/fragments/projectDashboardFragment :: projectDashboard(project=${project})"/>
</th:block> </th:block>
</div> </div>
</div> </div>

View File

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="headerfiles">
<meta charset="UTF-8"/>
</head>
<body>
<div th:fragment="projectDashboard (project)" class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3 dashboard-card">
<div class="row">
<div class="col-2">
<span th:replace="projects/fragments/projectStatusFragment :: projectStatus(projectStatus=${project.status})"/>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading" th:text="${project.title}"> title</h7>
</div>
</div>
</div>
</body>
</html>

View File

@ -12,6 +12,10 @@
<span class="text-muted" th:text="${project.description}"/> <span class="text-muted" th:text="${project.description}"/>
</a> </a>
<input class="id-class" type="hidden" th:value="${project.id}"/> <input class="id-class" type="hidden" th:value="${project.id}"/>
<a class="remove-paper pull-right d-none" th:href="@{'/projects/delete/'+${project.id}}"
data-confirm="Удалить проект?">
<i class="fa fa-trash" aria-hidden="true"></i>
</a>
</div> </div>
</div> </div>
</body> </body>

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8"/> <meta charset="UTF-8"/>
</head> </head>
<body> <body>
<span th:fragment="paperStatus (paperStatus)" class="fa-stack fa-1x"> <span th:fragment="projectStatus (projectStatus)" class="fa-stack fa-1x">
<th:block th:switch="${projectStatus.name()}"> <th:block th:switch="${projectStatus.name()}">
<div th:case="'APPLICATION'"> <div th:case="'APPLICATION'">
<i class="fa fa-circle fa-stack-2x text-draft"></i> <i class="fa fa-circle fa-stack-2x text-draft"></i>

View File

@ -71,16 +71,21 @@
<div class="form-group"> <div class="form-group">
<label>Дедлайны показателей:</label> <label>Дедлайны показателей:</label>
<div class="row"> <div class="row" th:each="deadline, rowStat : *{deadlines}">
<input type="hidden"/> <input type="hidden" th:field="*{deadlines[__${rowStat.index}__].id}"/>
<div class="col-6"> <div class="col-6 div-deadline-date">
<input type="date" class="form-control" name="deadline"/> <input type="date" class="form-control form-deadline-date" name="deadline"
th:field="*{deadlines[__${rowStat.index}__].date}"/>
</div> </div>
<div class="col-4"> <div class="col-4 div-deadline-description">
<input class="form-control" type="text" placeholder="Описание"/> <input class="form-control" type="text" placeholder="Описание"
th:field="*{deadlines[__${rowStat.index}__].description}"/>
</div> </div>
<div class="col-2"> <div class="col-2">
<a class="btn btn-danger float-right"><span <a class="btn btn-danger float-right"
th:onclick="|$('#deadlines${rowStat.index}\\.description').val('');
$('#deadlines${rowStat.index}\\.date').val('');
$('#addDeadline').click();|"><span
aria-hidden="true"><i class="fa fa-times"/></span> aria-hidden="true"><i class="fa fa-times"/></span>
</a> </a>
</div> </div>
@ -90,8 +95,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="submit" id="addDeadline" name="addDeadline" class="btn btn-primary" <input type="submit" id="addDeadline" name="addDeadline" class="btn btn-primary"
value="Добавить value="Добавить дедлайн"/>
дедлайн"/>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -110,7 +114,8 @@
Сохранить Сохранить
</button> </button>
<button id="cancelButton" class="btn btn-default text-uppercase" <button id="cancelButton" class="btn btn-default text-uppercase"
href="/projects/projects"> onclick="location.href='/projects/projects'" href="/projects/projects"
type="button">
Отмена Отмена
</button> </button>
</div> </div>

View File

@ -27,7 +27,9 @@
</div> </div>
</div> </div>
</section> </section>
<div id="modalDelete"/>
</form> </form>
<script src="/js/projects.js"></script>
</div> </div>
</body> </body>
</html> </html>

View File

@ -14,10 +14,10 @@
</div> </div>
<hr/> <hr/>
<div class="row justify-content-center" id="dashboard"> <div class="row justify-content-center" id="dashboard">
<div th:replace="students/fragments/taskDashboardFragment"/> <th:block th:each="task : ${tasks}">
<!--<th:block th:each="task : ${tasks}">--> <div th:replace="students/fragments/taskDashboardFragment :: taskDashboard(task=${task})"/>
<!--<div th:replace="students/fragments/taskDashboardFragment :: taskDashboard(task=${task})"/>--> </th:block>
<!--</th:block>-->
</div> </div>
</div> </div>
</section> </section>

View File

@ -6,9 +6,6 @@
<body> <body>
<span th:fragment="taskStatus (taskStatus)" class="fa-stack fa-1x"> <span th:fragment="taskStatus (taskStatus)" class="fa-stack fa-1x">
<th:block th:switch="${taskStatus.name()}"> <th:block th:switch="${taskStatus.name()}">
<!--<div th:case="'ATTENTION'">-->
<!--<i class="fa fa-circle fa-stack-2x text-warning"></i>-->
<!--</div>-->
<div th:case="'IN_WORK'"> <div th:case="'IN_WORK'">
<i class="fa fa-circle fa-stack-2x text-primary"></i> <i class="fa fa-circle fa-stack-2x text-primary"></i>
</div> </div>

View File

@ -7,7 +7,7 @@
<body> <body>
<div class="container" layout:fragment="content"> <div class="container" layout:fragment="content">
<form id="tasks-form" method="post" th:action="@{'/tasks/tasks'}"> <form id="tasks-form" method="post" th:action="@{'/students/tasks'}">
<input th:type="hidden" name="taskDeleteId" id="taskDeleteId"/> <input th:type="hidden" name="taskDeleteId" id="taskDeleteId"/>
<section id="tasks"> <section id="tasks">
<div class="container"> <div class="container">
@ -20,26 +20,42 @@
<hr/> <hr/>
<div class="row"> <div class="row">
<div class="col-md-9 col-sm-12"> <div class="col-md-9 col-sm-12">
<th:block th:each="task : ${tasks}"> <th:block th:each="task : ${filteredTasks.tasks}">
<div th:replace="students/fragments/taskLineFragment :: taskLine(task=${task})"/> <div th:replace="students/fragments/taskLineFragment :: taskLine(task=${task})"/>
</th:block> </th:block>
</div> </div>
<div class="col-md-3 col-sm-12"> <div class="col-md-3 col-sm-12">
<div class="sorting">
<h5>Сортировать:</h5>
<select class="form-control selectpicker" size="auto" th:field="${filteredTasks.order}"
id="order"
onchange="this.form.submit();">
<option th:value="new">
Сначала новые
</option>
<option th:value="old">
Сначала старые
</option>
</select>
</div>
<div class="filter"> <div class="filter">
<h5>Фильтр:</h5> <h5>Фильтр:</h5>
<select class="form-control" id="status" <select class="form-control selectpicker" size="auto" th:field="${filteredTasks.status}"
id="status"
onchange="this.form.submit();"> onchange="this.form.submit();">
<option value="">Все статусы</option> <option value="">Все статусы</option>
<!--<option th:each="author: ${allAuthors}" th:value="${author.id}"--> <option th:each="status: ${allStatuses}" th:value="${status}"
<!--th:text="${author.lastName}">lastName--> th:text="${status.statusName}">
<!--</option>--> status
</option>
</select> </select>
<select class="form-control" id="tags" <select class="form-control selectpicker" size="auto" data-live-search="true"
th:field="${filteredTasks.tag}" id="tags"
onchange="this.form.submit();"> onchange="this.form.submit();">
<option value="">Все типы</option> <option value="">Все теги</option>
<!--<option th:each="year: ${allYears}" th:value="${year}"--> <option th:each="tag: ${allTags}" th:value="${tag.id}"
<!--th:text="${year}">year--> th:text="${tag.tagName}">tag
<!--</option>--> </option>
</select> </select>
</div> </div>
</div> </div>