Merge branch '35-' into 'master'

Resolve "Создать контроллер грантов"

Closes #35

See merge request romanov73/ng-tracker!24
This commit is contained in:
Anton Romanov 2018-12-28 10:04:42 +00:00
commit 7a490ef7a5
19 changed files with 641 additions and 298 deletions

View File

@ -0,0 +1,101 @@
package ru.ulstu.grant.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.DeadlineDto;
import ru.ulstu.grant.model.Grant;
import ru.ulstu.grant.model.GrantDto;
import ru.ulstu.grant.service.GrantService;
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 = "/grants")
public class GrantController {
private final GrantService grantService;
public GrantController(GrantService grantService) {
this.grantService = grantService;
}
@GetMapping("/grants")
public void getGrants(ModelMap modelMap) {
modelMap.put("grants", grantService.findAllDto());
}
@GetMapping("/dashboard")
public void getDashboard(ModelMap modelMap) {
modelMap.put("grants", grantService.findAllDto());
}
@GetMapping("/grant")
public void getGrant(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
if (id != null && id > 0) {
modelMap.put("grantDto", grantService.findOneDto(id));
} else {
modelMap.put("grantDto", new GrantDto());
}
}
@PostMapping(value = "/grant", params = "save")
public String save(@Valid GrantDto grantDto, Errors errors) throws IOException {
filterEmptyDeadlines(grantDto);
if (grantDto.getDeadlines().isEmpty()) {
errors.rejectValue("deadlines", "errorCode", "Не может быть пустым");
}
if (errors.hasErrors()) {
return "/grants/grant";
}
grantService.save(grantDto);
return "redirect:/grants/grants";
}
@PostMapping(value = "/grant", params = "addDeadline")
public String addDeadline(@Valid GrantDto grantDto, Errors errors) {
filterEmptyDeadlines(grantDto);
if (errors.hasErrors()) {
return "/grants/grant";
}
grantDto.getDeadlines().add(new DeadlineDto());
return "/grants/grant";
}
@PostMapping(value = "/grant", params = "createProject")
public String createProject(@Valid GrantDto grantDto, Errors errors) {
if (errors.hasErrors()) {
return "/grants/grant";
}
grantService.createProject(grantDto);
return "/grants/grant";
}
@GetMapping("/delete/{grant-id}")
public String delete(@PathVariable("grant-id") Integer grantId) throws IOException {
grantService.delete(grantId);
return "redirect:/grants/grants";
}
@ModelAttribute("allStatuses")
public List<Grant.GrantStatus> getGrantStatuses() {
return grantService.getGrantStatuses();
}
private void filterEmptyDeadlines(GrantDto grantDto) {
grantDto.setDeadlines(grantDto.getDeadlines().stream()
.filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription()))
.collect(Collectors.toList()));
}
}

View File

@ -2,22 +2,28 @@ package ru.ulstu.grant.model;
import org.hibernate.validator.constraints.NotBlank;
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.project.model.Project;
import ru.ulstu.user.model.User;
import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Optional;
@Entity
public class Grant extends BaseEntity {
@Table(name = "grants")
public class Grant extends BaseEntity {
public enum GrantStatus {
APPLICATION("Заявка"),
ON_COMPETITION("Отправлен на конкурс"),
@ -26,14 +32,14 @@ public class Grant extends BaseEntity {
COMPLETED("Завершен"),
FAILED("Провалены сроки");
private String name;
private String statusName;
GrantStatus(String name) {
this.name = name;
GrantStatus(String statusName) {
this.statusName = statusName;
}
public String getName() {
return name;
public String getStatusName() {
return statusName;
}
}
@ -88,13 +94,17 @@ public class Grant extends BaseEntity {
return application;
}
public void setApplication(FileData application) { this.application = application; }
public void setApplication(FileData application) {
this.application = application;
}
public String getTitle() {
return title;
}
public void setTitle(String title) { this.title = title; }
public void setTitle(String title) {
this.title = title;
}
public Project getProject() {
return project;
@ -103,4 +113,13 @@ public class Grant extends BaseEntity {
public void setProject(Project project) {
this.project = project;
}
public Optional<Deadline> getNextDeadline() {
return deadlines
.stream()
.filter(deadline -> deadline.getDate() != null)
.sorted(Comparator.comparing(Deadline::getDate))
.filter(d -> d.getDate().after(new Date()))
.findFirst();
}
}

View File

@ -4,21 +4,27 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.hibernate.validator.constraints.NotEmpty;
import ru.ulstu.deadline.model.DeadlineDto;
import ru.ulstu.grant.model.Grant;
import ru.ulstu.project.model.ProjectDto;
import java.util.ArrayList;
import java.util.List;
import static ru.ulstu.core.util.StreamApiUtils.convert;
public class GrantDto {
private final Integer id;
private Integer id;
@NotEmpty
private final String title;
private final Grant.GrantStatus status;
private final List<DeadlineDto> deadlines;
private final String comment;
private final String applicationFileName;
private final ProjectDto project;
private String title;
private Grant.GrantStatus status;
private List<DeadlineDto> deadlines = new ArrayList<>();
private String comment;
private String applicationFileName;
private ProjectDto project;
public GrantDto() {
deadlines.add(new DeadlineDto());
}
@JsonCreator
public GrantDto(@JsonProperty("id") Integer id,
@ -50,27 +56,46 @@ public class GrantDto {
return id;
}
public void setId(Integer id) {this.id = id;}
public String getTitle() {
return title;
}
public void setTitle(String title) {this.title = title;}
public Grant.GrantStatus getStatus() {
return status;
}
public void setStatus(Grant.GrantStatus status) {
this.status = status;
}
public List<DeadlineDto> getDeadlines() {
return deadlines;
}
public void setDeadlines(List<DeadlineDto> deadlines) {
this.deadlines = deadlines;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {this.comment = comment;}
public ProjectDto getProject() {
return project;
}
public void setProject(ProjectDto project) {this.project = project;}
public String getApplicationFileName() {
return applicationFileName;
}
public void setApplicationFileName(String applicationFileName) {
this.applicationFileName = applicationFileName;}
}

View File

@ -6,7 +6,7 @@ public class GrantStatusDto {
public GrantStatusDto(Grant.GrantStatus status) {
this.id = status.name();
this.name = status.getName();
this.name = status.getStatusName();
}
public String getId() {

View File

@ -0,0 +1,8 @@
package ru.ulstu.grant.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import ru.ulstu.grant.model.Grant;
public interface GrantRepository extends JpaRepository<Grant, Integer> {
}

View File

@ -0,0 +1,128 @@
package ru.ulstu.grant.service;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.deadline.service.DeadlineService;
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.project.model.Project;
import ru.ulstu.project.model.ProjectDto;
import ru.ulstu.project.service.ProjectService;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import static org.springframework.util.ObjectUtils.isEmpty;
import static ru.ulstu.core.util.StreamApiUtils.convert;
import static ru.ulstu.grant.model.Grant.GrantStatus.APPLICATION;
@Service
public class GrantService {
private final static int MAX_DISPLAY_SIZE = 40;
private final GrantRepository grantRepository;
private final ProjectService projectService;
private final DeadlineService deadlineService;
private final FileService fileService;
public GrantService(GrantRepository grantRepository,
FileService fileService,
DeadlineService deadlineService,
ProjectService projectService) {
this.grantRepository = grantRepository;
this.projectService = projectService;
this.fileService = fileService;
this.deadlineService = deadlineService;
}
public List<Grant> findAll() {
return grantRepository.findAll();
}
public List<GrantDto> findAllDto() {
List<GrantDto> grants = convert(findAll(), GrantDto::new);
grants.forEach(grantDto -> grantDto.setTitle(StringUtils.abbreviate(grantDto.getTitle(), MAX_DISPLAY_SIZE)));
return grants;
}
public GrantDto findOneDto(Integer id) {
return new GrantDto(grantRepository.findOne(id));
}
@Transactional
public Integer create(GrantDto grantDto) throws IOException {
Grant newGrant = copyFromDto(new Grant(), grantDto);
newGrant = grantRepository.save(newGrant);
return newGrant.getId();
}
private Grant copyFromDto(Grant grant, GrantDto grantDto) throws IOException {
grant.setComment(grantDto.getComment());
grant.setStatus(grantDto.getStatus() == null ? APPLICATION : grantDto.getStatus());
grant.setTitle(grantDto.getTitle());
if (grantDto.getProject() != null && grantDto.getProject().getId() != null) {
grant.setProject(projectService.findById(grantDto.getProject().getId()));
}
grant.setDeadlines(deadlineService.saveOrCreate(grantDto.getDeadlines()));
if (grantDto.getApplicationFileName() != null) {
grant.setApplication(fileService.createFileFromTmp(grantDto.getApplicationFileName()));
}
return grant;
}
public void createProject(GrantDto grantDto) {
grantDto.setProject(
new ProjectDto(projectService.save(new ProjectDto(grantDto.getTitle()))));
}
@Transactional
public Integer update(GrantDto grantDto) throws IOException {
Grant grant = grantRepository.findOne(grantDto.getId());
Grant.GrantStatus oldStatus = grant.getStatus();
if (grantDto.getApplicationFileName() != null && grant.getApplication() != null) {
fileService.deleteFile(grant.getApplication());
}
grantRepository.save(copyFromDto(grant, grantDto));
return grant.getId();
}
@Transactional
public void delete(Integer grantId) throws IOException {
Grant grant = grantRepository.findOne(grantId);
if (grant.getApplication() != null) {
fileService.deleteFile(grant.getApplication());
}
//возможно при удалении гранта будет удаляться и проект, к нему привязанный
grantRepository.delete(grant);
}
public List<Grant.GrantStatus> getGrantStatuses() {
return Arrays.asList(Grant.GrantStatus.values());
}
@Transactional
public Grant create(String title, Project project_id, Date deadlineDate) {
Grant grant = new Grant();
grant.setTitle(title);
grant.setComment("Комментарий к гранту 1");
grant.setProject(project_id);
grant.setStatus(APPLICATION);
grant.getDeadlines().add(new Deadline(deadlineDate, "первый дедлайн"));
grant = grantRepository.save(grant);
return grant;
}
public void save(GrantDto grantDto) throws IOException {
if (isEmpty(grantDto.getId())) {
create(grantDto);
} else {
update(grantDto);
}
}
}

View File

@ -4,18 +4,26 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.hibernate.validator.constraints.NotEmpty;
import ru.ulstu.deadline.model.DeadlineDto;
import ru.ulstu.project.model.Project;
import java.util.ArrayList;
import java.util.List;
import static ru.ulstu.core.util.StreamApiUtils.convert;
public class ProjectDto {
private final Integer id;
private Integer id;
@NotEmpty
private final String title;
private String title;
private final List<DeadlineDto> deadlines;
private List<DeadlineDto> deadlines = new ArrayList<>();
public ProjectDto() {}
public ProjectDto(String title) {
this.title = title;
}
@JsonCreator
public ProjectDto(@JsonProperty("id") Integer id,
@ -26,6 +34,7 @@ public class ProjectDto {
this.deadlines = deadlines;
}
public ProjectDto(Project project) {
this.id = project.getId();
this.title = project.getTitle();
@ -39,4 +48,19 @@ public class ProjectDto {
public String getTitle() {
return title;
}
public void setId(Integer id) {
this.id = id;
}
public void setTitle(String title) {
this.title = title;
}
public void setDeadlines(List<DeadlineDto> deadlines) {
this.deadlines = deadlines;
}
public List<DeadlineDto> getDeadlines() {
return deadlines;
}
}

View File

@ -0,0 +1,8 @@
package ru.ulstu.project.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import ru.ulstu.project.model.Project;
public interface ProjectRepository extends JpaRepository<Project, Integer> {
}

View File

@ -0,0 +1,59 @@
package ru.ulstu.project.service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ru.ulstu.deadline.service.DeadlineService;
import ru.ulstu.project.model.Project;
import ru.ulstu.project.model.ProjectDto;
import ru.ulstu.project.repository.ProjectRepository;
import java.util.List;
import static org.springframework.util.ObjectUtils.isEmpty;
@Service
public class ProjectService {
private final ProjectRepository projectRepository;
private final DeadlineService deadlineService;
public ProjectService(ProjectRepository projectRepository,
DeadlineService deadlineService) {
this.projectRepository = projectRepository;
this.deadlineService = deadlineService;
}
public List<Project> findAll() {
return projectRepository.findAll();
}
@Transactional
public Project create(ProjectDto projectDto) {
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()));
return project;
}
public Project save(ProjectDto projectDto) {
if (isEmpty(projectDto.getId())) {
return create(projectDto);
} else {
return update(projectDto);
}
}
private Project update(ProjectDto projectDto) {
throw new RuntimeException("not implemented yet");
}
public Project findById(Integer id) {
return projectRepository.findOne(id);
}
}

View File

@ -0,0 +1,9 @@
<?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="20181224_000000-1">
<renameTable oldTableName="grant"
newTableName="grants"/>
</changeSet>
</databaseChangeLog>

View File

@ -17,4 +17,5 @@
<include file="db/changelog-20181108_000000-data.xml"/>
<include file="db/changelog-20181111_000000-schema.xml"/>
<include file="db/changelog-20181208_000000-schema.xml"/>
<include file="db/changelog-20181224_000000-schema.xml"/>
</databaseChangeLog>

View File

@ -0,0 +1,42 @@
/*<![CDATA[*/
$(document).ready(function () {
$(".grant-row").mouseenter(function (event) {
var grantRow = $(event.target).closest(".grant-row");
$(grantRow).css("background-color", "#f8f9fa");
$(grantRow).find(".remove-paper").removeClass("d-none");
});
$(".grant-row").mouseleave(function (event) {
var grantRow = $(event.target).closest(".grant-row");
$(grantRow).css("background-color", "white");
$(grantRow).closest(".grant-row").find(".remove-grant").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

@ -1,177 +1,24 @@
<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="default">
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div class="container" layout:fragment="content">
<!-- Services -->
<section id="services">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2 class="section-heading text-uppercase">Dashboard</h2>
<div class="row justify-content-center">
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./grants" class="btn btn-light toolbar-button"><i class="fa fa-list-alt"></i>
Список</a>
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./dashboard" class="btn btn-light toolbar-button"><i class="fa fa-newspaper-o"
aria-hidden="true"></i> Панель управления</a>
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./grant" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle" aria-hidden="true"></i>
Добавить грант</a>
</div>
</div>
</div>
<div class="col-lg-12 text-center">
<h2 class="section-heading text-uppercase">Гранты</h2>
<div th:replace="grants/fragments/grantNavigationFragment"/>
</div>
<div class="row justify-content-center">
<div 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 class="fa-stack fa-1x">
<i class="fa fa-circle fa-stack-2x text-primary"></i>
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
</span>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading"><a href="./grant">Название гранта</a></h7>
<p class="text-muted">Краткое описание</p>
<p class="text-muted">Статус: статус</p>
</div>
</div>
</div>
<div 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 class="fa-stack fa-1x">
<i class="fa fa-circle fa-stack-2x text-primary"></i>
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
</span>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading">Название гранта</h7>
<p class="text-muted">Краткое описание</p>
<p class="text-muted">Статус: статус</p>
</div>
</div>
</div>
<div 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 class="fa-stack fa-1x">
<i class="fa fa-circle fa-stack-2x text-primary"></i>
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
</span>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading">Название гранта</h7>
<p class="text-muted">Краткое описание</p>
<p class="text-muted">Статус: статус</p>
</div>
</div>
</div>
<div 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 class="fa-stack fa-1x">
<i class="fa fa-circle fa-stack-2x text-primary"></i>
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
</span>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading">Название гранта</h7>
<p class="text-muted">Краткое описание</p>
<p class="text-muted">Статус: статус</p>
</div>
</div>
</div>
<div 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 class="fa-stack fa-1x">
<i class="fa fa-circle fa-stack-2x text-primary"></i>
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
</span>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading">Название гранта</h7>
<p class="text-muted">Краткое описание</p>
<p class="text-muted">Статус: статус</p>
</div>
</div>
</div>
<div 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 class="fa-stack fa-1x">
<i class="fa fa-circle fa-stack-2x text-primary"></i>
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
</span>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading">Название гранта</h7>
<p class="text-muted">Краткое описание</p>
<p class="text-muted">Статус: статус</p>
</div>
</div>
</div>
<div 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 class="fa-stack fa-1x">
<i class="fa fa-circle fa-stack-2x text-primary"></i>
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
</span>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading">Название гранта</h7>
<p class="text-muted">Краткое описание</p>
<p class="text-muted">Статус: статус</p>
</div>
</div>
</div>
<div 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 class="fa-stack fa-1x">
<i class="fa fa-circle fa-stack-2x text-primary"></i>
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
</span>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading">Название гранта</h7>
<p class="text-muted">Краткое описание</p>
<p class="text-muted">Статус: статус</p>
</div>
</div>
</div>
<div 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 class="fa-stack fa-1x">
<i class="fa fa-circle fa-stack-2x text-primary"></i>
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
</span>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading">Название гранта</h7>
<p class="text-muted">Краткое описание</p>
<p class="text-muted">Статус: статус</p>
</div>
</div>
</div>
<div class="row justify-content-center" id="dashboard">
<th:block th:each="grant : ${grants}">
<div th:replace="grants/fragments/grantDashboardFragment :: grantDashboard(grant=${grant})"/>
</th:block>
</div>
</div>
</section>
</div>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="headerfiles">
<meta charset="UTF-8"/>
</head>
<body>
<div th:fragment="grantDashboard (grant)" 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="grants/fragments/grantStatusFragment :: grantStatus(grantStatus=${grant.status})"/>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading" th:text="${grant.title}"> title</h7>
<p class="text-muted" th:text="${grant.status.statusName}"> status</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,22 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="headerfiles">
<meta charset="UTF-8"/>
</head>
<body>
<div th:fragment="grantLine (grant)" class="row text-left grant-row" style="background-color: white;">
<div class="col">
<span th:replace="grants/fragments/grantStatusFragment :: grantStatus(grantStatus=${grant.status})"/>
<a th:href="@{'grant?id='+${grant.id}}">
<span class="h6" th:text="${grant.title}"/>
<span class="text-muted" th:text="${grant.comment}"/>
</a>
<input class="id-class" type="hidden" th:value="${grant.id}"/>
<a class="remove-paper pull-right d-none" th:href="@{'/grants/delete/'+${grant.id}}"
data-confirm="Удалить грант?">
<i class="fa fa-trash" aria-hidden="true"></i>
</a>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="headerfiles">
<meta charset="UTF-8"/>
</head>
<body>
<div class="row justify-content-center">
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./grants" class="btn btn-light toolbar-button"><i class="fa fa-list-alt"></i>
Список</a>
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./dashboard" class="btn btn-light toolbar-button"><i class="fa fa-newspaper-o"
aria-hidden="true"></i> Панель
управления</a>
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./grant?id=0" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle"
aria-hidden="true"></i>
Добавить грант</a>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="headerfiles">
<meta charset="UTF-8"/>
</head>
<body>
<span th:fragment="paperStatus (paperStatus)" class="fa-stack fa-1x">
<th:block th:switch="${grantStatus.name()}">
<div th:case="'APPLICATION'">
<i class="fa fa-circle fa-stack-2x text-draft"></i>
</div>
<div th:case="'ON_COMPETITION'">
<i class="fa fa-circle fa-stack-2x text-review"></i>
</div>
<div th:case="'SUCCESSFUL_PASSAGE'">
<i class="fa fa-circle fa-stack-2x text-accepted"></i>
</div>
<div th:case="'IN_WORK'">
<i class="fa fa-circle fa-stack-2x text-primary"></i>
</div>
<div th:case="'COMPLETED'">
<i class="fa fa-circle fa-stack-2x text-success"></i>
</div>
<div th:case="'FAILED'">
<i class="fa fa-circle fa-stack-2x text-failed"></i>
</div>
</th:block>
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
</span>
</body>
</html>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="default">
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
<head>
</head>
@ -14,49 +14,68 @@
<div class="row">
<div class="col-lg-12 text-center">
<h2 class="section-heading text-uppercase">Редактирование гранта</h2>
<div class="row justify-content-center">
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./grants" class="btn btn-light toolbar-button"><i class="fa fa-list-alt"></i>
Список</a>
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./dashboard" class="btn btn-light toolbar-button"><i class="fa fa-newspaper-o"
aria-hidden="true"></i> Панель управления</a>
</div>
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
<a href="./grant" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle" aria-hidden="true"></i>
Добавить грант</a>
</div>
</div>
<div th:replace="grants/fragments/grantNavigationFragment"/>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<form id="contactForm" name="sentMessage" novalidate="">
<form id="grant-form" method="post" th:action="@{'/grants/grant?id='+ *{id == null ? '' : id} + ''}"
th:object="${grantDto}">
<div class="row">
<div class="col-md-6 col-sm-12">
<input type="hidden" name="id" th:field="*{id}"/>
<div class="form-group">
<label for="name">Название:</label>
<input class="form-control" id="name" type="text" placeholder="Название гранта"
required="" data-validation-required-message="Введите название гранта"/>
<label for="title">Название:</label>
<input class="form-control" id="title" type="text"
placeholder="Название гранта"
th:field="*{title}"/>
<p th:if="${#fields.hasErrors('title')}" th:errors="*{title}"
class="alert alert-danger">Incorrect title</p>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<label for="status">Статус:</label>
<select class="form-control" id="status">
<select class="form-control" th:field="*{status}" id="status">
<option th:each="status : ${allStatuses}" th:value="${status}"
th:text="${status.name}">Status
</option>
</select>
</div>
<div class="form-group">
<label for="comment">Комментарий:</label>
<textarea class="form-control" rows="3" id="comment"></textarea>
<textarea class="form-control" rows="3" id="comment"
th:field="*{comment}"></textarea>
</div>
<div class="form-group">
<label>Дедлайн:</label>
<input type="date" class="form-control" name="deadline"/>
<label>Дедлайны показателей:</label>
<div class="row" th:each="deadline, rowStat : *{deadlines}">
<input type="hidden" th:field="*{deadlines[__${rowStat.index}__].id}"/>
<div class="col-6">
<input type="date" class="form-control" name="deadline"
th:field="*{deadlines[__${rowStat.index}__].date}"/>
</div>
<div class="col-4">
<input class="form-control" type="text" placeholder="Описание"
th:field="*{deadlines[__${rowStat.index}__].description}"/>
</div>
<div class="col-2">
<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>
</a>
</div>
</div>
<p th:if="${#fields.hasErrors('deadlines')}" th:errors="*{deadlines}"
class="alert alert-danger">Incorrect title</p>
</div>
<div class="form-group">
<input type="submit" id="addDeadline" name="addDeadline" class="btn btn-primary" value="Добавить
дедлайн"/>
</div>
<div class="form-group">
<label for="loader">Загрузить заявку:</label>
<div id="loader">
@ -70,100 +89,22 @@
</div>
<div class="form-group">
<label>К этому гранту привязан проект:</label>
<p><a href="./#" class="btn btn-primary" ><i class="fa fa-plus-circle" aria-hidden="true">
</i> Добавить проект</a></p>
</div>
<div class="form-group">
<label>Научные показатели:</label>
<p><a href="./#" class="btn btn-primary" ><i class="fa fa-plus-circle" aria-hidden="true">
</i> Добавить показатель</a></p>
</div>
<div class="form-group">
<label>Публикационные показатели:</label>
<p><a href="./#" class="btn btn-primary" ><i class="fa fa-plus-circle" aria-hidden="true">
</i> Добавить показатель</a></p>
</div>
<div class="form-group">
<label>Последнее изменение:</label>
<input type="date" class="form-control" name="date-update"/>
</div>
<p><a href="#myModal1" class="btn btn-primary" data-toggle="modal">Редактировать
участников гранта</a></p>
<div id="myModal1" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×
</button>
<h4 class="modal-title">Авторы статьи</h4>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th>Фамилия</th>
<th>Имя</th>
<th>Отчество</th>
</tr>
</thead>
<tbody>
<tr>
<td>Иванов</td>
<td>Иван</td>
<td>Иванович</td>
<td>
<span class="table-remove"><button type="button"
class="btn btn-danger btn-rounded btn-sm my-0">Remove</button></span>
</td>
</tr>
<tr>
<td>text</td>
<td>text</td>
<td>text</td>
<td>
<span class="table-remove"><button type="button"
class="btn btn-danger btn-rounded btn-sm my-0">Remove</button></span>
</td>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle"
type="button" data-toggle="dropdown">Выберите автора
<span class="caret"></span></button>
<ul class="dropdown-menu">
<input class="form-control" id="myInput" type="text"
placeholder="Search.."/>
<li><a href="#">Иванов</a></li>
<li><a href="#">Смирнов</a></li>
<li><a href="#">Кузнецов</a></li>
</ul>
</div>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">Сохранить изменения
</button>
<button type="button" class="btn btn-default" data-dismiss="modal">
Отмена
</button>
</div>
</div>
<div th:if="*{project} == null">
<input type="submit" name="createProject" class="btn btn-primary"
value="Добавить проект"/>
</div>
<input type = "hidden" th:field="*{project.id}"/>
</div>
</div>
<div class="clearfix"></div>
<div class="col-lg-12">
<div class="form-group">
<button id="sendMessageButton" class="btn btn-success text-uppercase"
<button id="sendMessageButton" name="save" class="btn btn-success text-uppercase"
type="submit">
Сохранить
</button>
<button id="cancelButton" class="btn btn-default text-uppercase" type="button">
<button id="cancelButton" class="btn btn-default text-uppercase" href="/grants/grants">
Отмена
</button>
</div>
@ -188,10 +129,7 @@
console.debug(response);
}
});
getFromRest(urlPaperStatuses, function (response) {
fillSelect($("#status"), response);
});
$('.selectpicker').selectpicker();
});
/*]]>*/
</script>

View File

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="default" xmlns:th="">
<head>
</head>
<body>
<div class="container" layout:fragment="content">
<form id="grants-form" method="post" th:action="@{'/grants/grants'}">
<input th:type="hidden" name="grantDeleteId" id="grantDeleteId"/>
<section id="grants">
<div class="container">
<div class="row" id="grant-list">
<div class="col-lg-12 text-center">
<h2 class="section-heading text-uppercase">Гранты</h2>
<div th:replace="grants/fragments/grantNavigationFragment"/>
</div>
</div>
<div class="row">
<div class="col-md-9 col-sm-12">
<th:block th:each="grant : ${grants}">
<div th:replace="grants/fragments/grantLineFragment :: grantLine(grant=${grant})"/>
</th:block>
</div>
<div class="col-md-3 col-sm-12">
</div>
</div>
</div>
</section>
<div id="modalDelete"/>
</form>
<script src="/js/grants.js"></script>
</div>
</body>
</html>