Merge branch '33-paper-url' into 'dev'

Resolve "Добавить в конференцию/статью ссылку на сайт"

Closes #33

See merge request romanov73/ng-tracker!36
environments/staging/deployments/3
Anton Romanov 5 years ago
commit 1dbb9b9136

@ -29,7 +29,6 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
@Entity
public class Paper extends BaseEntity implements UserContainer {
public enum PaperStatus {
@ -75,6 +74,8 @@ public class Paper extends BaseEntity implements UserContainer {
private String comment;
private String url;
private Boolean locked = false;
@ -158,6 +159,14 @@ public class Paper extends BaseEntity implements UserContainer {
this.authors = authors;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public Set<User> getUsers() {
return getAuthors();

@ -30,6 +30,7 @@ public class PaperDto {
@NotEmpty
private List<Deadline> deadlines = new ArrayList<>();
private String comment;
private String url;
private Boolean locked;
private List<FileDataDto> files = new ArrayList<>();
private Set<Integer> authorIds;
@ -48,6 +49,7 @@ public class PaperDto {
@JsonProperty("updateDate") Date updateDate,
@JsonProperty("deadlines") List<Deadline> deadlines,
@JsonProperty("comment") String comment,
@JsonProperty("url") String url,
@JsonProperty("locked") Boolean locked,
@JsonProperty("files") List<FileDataDto> files,
@JsonProperty("authorIds") Set<Integer> authorIds,
@ -59,6 +61,7 @@ public class PaperDto {
this.updateDate = updateDate;
this.deadlines = deadlines;
this.comment = comment;
this.url = url;
this.locked = locked;
this.files = files;
this.authors = authors;
@ -72,6 +75,7 @@ public class PaperDto {
this.updateDate = paper.getUpdateDate();
this.deadlines = paper.getDeadlines();
this.comment = paper.getComment();
this.url = paper.getUrl();
this.locked = paper.getLocked();
this.files = convert(paper.getFiles(), FileDataDto::new);
this.authorIds = convert(paper.getAuthors(), user -> user.getId());
@ -166,6 +170,14 @@ public class PaperDto {
this.authorIds = authorIds;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getAuthorsString() {
return StringUtils.abbreviate(authors
.stream()

@ -83,6 +83,7 @@ public class PaperService {
private Paper copyFromDto(Paper paper, PaperDto paperDto) throws IOException {
paper.setComment(paperDto.getComment());
paper.setUrl(paperDto.getUrl());
paper.setCreateDate(paper.getCreateDate() == null ? new Date() : paper.getCreateDate());
paper.setLocked(paperDto.getLocked());
paper.setStatus(paperDto.getStatus() == null ? DRAFT : paperDto.getStatus());
@ -110,7 +111,6 @@ public class PaperService {
.collect(toList())) {
fileService.delete(file.getId());
}
paperRepository.save(copyFromDto(paper, paperDto));
paper.getAuthors().forEach(author -> {

@ -0,0 +1,10 @@
<?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="masha" id="20190319_000001-1">
<addColumn tableName="paper">
<column name="url" type="varchar(255)"></column>
</addColumn>
</changeSet>
</databaseChangeLog>

@ -19,5 +19,6 @@
<include file="db/changelog-20181208_000000-schema.xml"/>
<include file="db/changelog-20181224_000000-schema.xml"/>
<include file="db/changelog-20190318_000000-schema.xml"/>
<include file="db/changelog-20190318_000001-schema.xml"/>
<include file="db/common/changelog-20190312_130000-schema.xml"/>
</databaseChangeLog>

@ -10,7 +10,13 @@
<span th:replace="papers/fragments/paperStatusFragment :: paperStatus(paperStatus=${paper.status})"/>
</div>
<div class="col col-10 text-right">
<h7 class="service-heading" th:text="${paper.title}"> title</h7>
<p th:if="${paper.url!=null and paper.url!=''}"><a target="_blank" th:href="${paper.url}"><i
class="fa fa-external-link fa-2x"
aria-hidden="true"></i></a></p>
<p th:unless="${paper.url!=null and paper.url!=''}"><i class="fa fa-fw fa-2x" aria-hidden="true"></i></p>
<a th:href="'paper?id='+${paper.id}">
<h7 class="service-heading" th:text="${paper.title}"> title</h7>
</a>
<p class="text-muted" th:text="${paper.authorsString}">authors</p>
</div>
</div>

@ -50,6 +50,13 @@
th:field="*{comment}"></textarea>
</div>
<div class="form-group">
<label for="title">Ссылка на сайт конференции:</label>
<input class="form-control" id="url" type="text"
placeholder="Url"
th:field="*{url}"/>
</div>
<div class="form-group">
<label>Дедлайны:</label>
<div class="row" th:each="deadline, rowStat : *{deadlines}">

Loading…
Cancel
Save