From 63ec2cc289ba02e9d96dee0a7a222f1cc461b0b6 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 18 Feb 2025 12:03:15 +0400 Subject: [PATCH] #13 -- Add link to rule edit page --- .../java/ru/ulstu/fc/rule/controller/RuleController.java | 7 +++++-- .../ulstu/fc/rule/{controller => service}/RuleService.java | 2 +- src/main/resources/templates/project/edit.html | 1 + src/main/resources/templates/rule/edit.html | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) rename src/main/java/ru/ulstu/fc/rule/{controller => service}/RuleService.java (97%) diff --git a/src/main/java/ru/ulstu/fc/rule/controller/RuleController.java b/src/main/java/ru/ulstu/fc/rule/controller/RuleController.java index 5788d53..6107baa 100644 --- a/src/main/java/ru/ulstu/fc/rule/controller/RuleController.java +++ b/src/main/java/ru/ulstu/fc/rule/controller/RuleController.java @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import ru.ulstu.fc.rule.model.Rule; import ru.ulstu.fc.rule.model.RuleForm; +import ru.ulstu.fc.rule.service.RuleService; @Controller @RequestMapping("rule") @@ -19,8 +20,10 @@ public class RuleController { this.ruleService = ruleService; } - @GetMapping("/edit/{ruleId}") - public String edit(@PathVariable(value = "ruleId") Integer id, Model model) { + @GetMapping("/edit/{projectId}/{ruleId}") + public String edit(@PathVariable(value = "projectId") Integer projectId, + @PathVariable(value = "ruleId") Integer id, Model model) { + model.addAttribute("projectId", projectId); model.addAttribute("rule", new RuleForm((id != null && id != 0) ? ruleService.getById(id) diff --git a/src/main/java/ru/ulstu/fc/rule/controller/RuleService.java b/src/main/java/ru/ulstu/fc/rule/service/RuleService.java similarity index 97% rename from src/main/java/ru/ulstu/fc/rule/controller/RuleService.java rename to src/main/java/ru/ulstu/fc/rule/service/RuleService.java index 8e7d89a..929892a 100644 --- a/src/main/java/ru/ulstu/fc/rule/controller/RuleService.java +++ b/src/main/java/ru/ulstu/fc/rule/service/RuleService.java @@ -1,4 +1,4 @@ -package ru.ulstu.fc.rule.controller; +package ru.ulstu.fc.rule.service; import org.springframework.stereotype.Service; diff --git a/src/main/resources/templates/project/edit.html b/src/main/resources/templates/project/edit.html index aa796e0..ed29db0 100644 --- a/src/main/resources/templates/project/edit.html +++ b/src/main/resources/templates/project/edit.html @@ -68,5 +68,6 @@ И / ИЛИ + Добавить правило diff --git a/src/main/resources/templates/rule/edit.html b/src/main/resources/templates/rule/edit.html index c9551a2..81b03d1 100644 --- a/src/main/resources/templates/rule/edit.html +++ b/src/main/resources/templates/rule/edit.html @@ -9,6 +9,7 @@

Редактирование правила:

+
@@ -22,7 +23,7 @@ onclick="return confirm('Удалить запись?')"> Удалить - Отмена + Отмена