#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) @Fetch(FetchMode.SUBSELECT)
private List<FileData> files = new ArrayList<>(); private List<FileData> files = new ArrayList<>();
private int indicatorValue; private int indicatorValue;
private String comment;
public Indicator getIndicator() { public Indicator getIndicator() {
return indicator; return indicator;
@ -48,4 +49,12 @@ public class ReportValue extends BaseEntity {
public void setFiles(List<FileData> files) { public void setFiles(List<FileData> files) {
this.files = 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 Indicator indicator;
private int indicatorValue; private int indicatorValue;
private List<FileDataDto> files = new ArrayList<>(); private List<FileDataDto> files = new ArrayList<>();
private String comment;
public ReportValueDto() { public ReportValueDto() {
} }
@ -33,6 +34,7 @@ public class ReportValueDto {
this.indicator = reportValue.getIndicator(); this.indicator = reportValue.getIndicator();
this.files = reportValue.getFiles().stream().map(FileDataDto::new).collect(Collectors.toList()); this.files = reportValue.getFiles().stream().map(FileDataDto::new).collect(Collectors.toList());
this.indicatorValue = reportValue.getIndicatorValue(); this.indicatorValue = reportValue.getIndicatorValue();
this.comment = reportValue.getComment();
} }
public Indicator getIndicator() { public Indicator getIndicator() {
@ -74,4 +76,12 @@ public class ReportValueDto {
public void setReportId(Integer reportId) { public void setReportId(Integer reportId) {
this.reportId = 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()); .toList());
reportValue.getFiles().removeAll(files); reportValue.getFiles().removeAll(files);
reportValue.setFiles(files); reportValue.setFiles(files);
reportValue.setComment(reportValueDto.getComment());
reportValue = reportValueRepository.save(reportValue); reportValue = reportValueRepository.save(reportValue);
reportService.addReportValue(reportValueDto.getReportId(), reportValue); reportService.addReportValue(reportValueDto.getReportId(), reportValue);

View File

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