#21 -- Add comments

This commit is contained in:
Anton Romanov 2025-04-15 22:22:07 +04:00
parent 93829f21ef
commit a22c180aa8
4 changed files with 37 additions and 10 deletions

View File

@ -24,6 +24,7 @@ public class ReportValue extends BaseEntity {
@Fetch(FetchMode.SUBSELECT)
private List<FileData> files = new ArrayList<>();
private int indicatorValue;
private String comment;
public Indicator getIndicator() {
return indicator;
@ -48,4 +49,12 @@ public class ReportValue extends BaseEntity {
public void setFiles(List<FileData> files) {
this.files = files;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
}

View File

@ -14,6 +14,7 @@ public class ReportValueDto {
private Indicator indicator;
private int indicatorValue;
private List<FileDataDto> files = new ArrayList<>();
private String comment;
public ReportValueDto() {
}
@ -33,6 +34,7 @@ public class ReportValueDto {
this.indicator = reportValue.getIndicator();
this.files = reportValue.getFiles().stream().map(FileDataDto::new).collect(Collectors.toList());
this.indicatorValue = reportValue.getIndicatorValue();
this.comment = reportValue.getComment();
}
public Indicator getIndicator() {
@ -74,4 +76,12 @@ public class ReportValueDto {
public void setReportId(Integer reportId) {
this.reportId = reportId;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
}

View File

@ -42,6 +42,7 @@ public class ReportValueService {
.toList());
reportValue.getFiles().removeAll(files);
reportValue.setFiles(files);
reportValue.setComment(reportValueDto.getComment());
reportValue = reportValueRepository.save(reportValue);
reportService.addReportValue(reportValueDto.getReportId(), reportValue);

View File

@ -11,8 +11,17 @@
<input type="hidden" th:field="*{reportId}">
<input type="hidden" th:field="*{indicator.id}">
<div class="row">
<div class="col col-md-6">
<div class="form-group">
<label class="form-label" for="loader">Загрузка подтверждающих документов</label>
<div id="loader">
</div>
</div>
</div>
</div>
<div class="form-group files-list" id="files-list">
<label class="form-label">Загрузка подтверждающих документов</label>
<div th:each="file, rowStat : ${reportValue.files}">
<div class="row" th:id="|files${rowStat.index}|"
@ -24,13 +33,13 @@
th:field="*{files[__${rowStat.index}__].name}"/>
<input type="hidden"
th:field="*{files[__${rowStat.index}__].tmpFileName}"/>
<div class="col col-md-2">
<div class="col col-md-1 m-1">
<a class="btn btn-danger float-right"
th:onclick="|$('#files${rowStat.index}\\.deleted').val('true'); $('#files${rowStat.index}').hide(); |">
<span><i class="fa fa-times"></i></span>
</a>
</div>
<div class="col col-md-8">
<div class="col col-md-8 m-2">
<a th:if="${file.id != null}"
th:onclick="downloadFile(null, [[${file.id}]], [[${file.name}]])"
href="javascript:void(0)"
@ -45,17 +54,15 @@
</div>
</div>
</div>
<div class="row">
<div class="col col-md-6">
<div class="form-group">
<label for="loader">Загрузить файл:</label>
<div id="loader">
<label for="comment" class="form-label">Комментарии</label>
<textarea class="form-control" id="comment" th:field="*{comment}" rows="5"></textarea>
</div>
</div>
</div>
</div>
<button name="save" type="submit" class="btn btn-outline-dark">Сохранить</button>
<a th:href="${'/report/edit-report/' + reportValue.reportId}" class="btn btn-outline-dark">Отмена</a>
@ -115,7 +122,7 @@
newFileRow.append(tmpFileNameInput);
var nextDiv = $("<div/>")
.addClass("col-2");
.addClass("col col-md-1 m-1");
var nextA = $("<a/>")
.addClass("btn btn-danger float-right")
@ -126,7 +133,7 @@
newFileRow.append(nextDiv);
var nameDiv = $("<div/>")
.addClass("col-10")
.addClass("col-10 m-2")
.append($("<a/>").text(fileDto.fileName)
.attr("href", 'javascript:void(0)')
.attr("onclick", "downloadFile('" + fileDto.tmpFileName + "',null,'" + fileDto.fileName + "')"));