From 7d40a52f19f26b59203138528021c0212c19daba Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Thu, 3 Apr 2025 16:09:34 +0400 Subject: [PATCH] #21 -- Fix report indicator description --- .../ru/ulstu/report/controller/ReportController.java | 11 +++++++---- src/main/resources/templates/report/editReport.html | 10 ++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/ru/ulstu/report/controller/ReportController.java b/src/main/java/ru/ulstu/report/controller/ReportController.java index f7837b7..78eee25 100644 --- a/src/main/java/ru/ulstu/report/controller/ReportController.java +++ b/src/main/java/ru/ulstu/report/controller/ReportController.java @@ -13,6 +13,7 @@ import ru.ulstu.indicator.model.Indicator; import ru.ulstu.model.OffsetablePageRequest; import ru.ulstu.report.model.Report; import ru.ulstu.report.model.ReportListForm; +import ru.ulstu.report.model.ReportPeriod; import ru.ulstu.report.service.ReportPeriodService; import ru.ulstu.report.service.ReportService; @@ -42,17 +43,19 @@ public class ReportController { @GetMapping("reportList") public String getReportPeriods(Model model) { model.addAttribute("reportListForm", new ReportListForm()); - model.addAttribute("reportPeriods", reportPeriodService.getReportPeriods()); - model.addAttribute("canCreate", false); + List periods = reportPeriodService.getReportPeriods(); + model.addAttribute("reportPeriods", periods); + model.addAttribute("canCreate", !periods.isEmpty() && reportService.canCreateReport(periods.getFirst())); return "report/reportList"; } @PostMapping("reportList") public String getReportPeriods(ReportListForm reportListForm, Model model) { model.addAttribute("reportListForm", reportListForm); - model.addAttribute("reportPeriods", reportPeriodService.getReportPeriods()); model.addAttribute("reports", reportService.getReports(reportListForm.getReportPeriod())); - model.addAttribute("canCreate", reportService.canCreateReport(reportListForm.getReportPeriod())); + List periods = reportPeriodService.getReportPeriods(); + model.addAttribute("reportPeriods", periods); + model.addAttribute("canCreate", !periods.isEmpty() && reportService.canCreateReport(periods.getFirst())); return "report/reportList"; } diff --git a/src/main/resources/templates/report/editReport.html b/src/main/resources/templates/report/editReport.html index 84eb4cf..ba87a9a 100644 --- a/src/main/resources/templates/report/editReport.html +++ b/src/main/resources/templates/report/editReport.html @@ -2,14 +2,16 @@ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml" layout:decorate="~{default}">
-

+

- +

+

+