update
This commit is contained in:
122
.paul/phases/58-automation-form-preserve/58-01-PLAN.md
Normal file
122
.paul/phases/58-automation-form-preserve/58-01-PLAN.md
Normal file
@@ -0,0 +1,122 @@
|
||||
---
|
||||
phase: 58-automation-form-preserve
|
||||
plan: 01
|
||||
type: execute
|
||||
wave: 1
|
||||
depends_on: ["57-01"]
|
||||
files_modified:
|
||||
- src/Modules/Automation/AutomationController.php
|
||||
- DOCS/TECH_CHANGELOG.md
|
||||
autonomous: true
|
||||
---
|
||||
|
||||
<objective>
|
||||
## Goal
|
||||
Zachowanie danych formularza automatyzacji po bledzie walidacji. Zamiast redirect (ktory traci dane) — re-render formularza z wypelnionymi polami i komunikatem bledu.
|
||||
|
||||
## Purpose
|
||||
Uzytkownik nie traci wypelnionych danych (nazwa, zdarzenie, warunki, akcje) po napotkaniu bledu walidacji.
|
||||
|
||||
## Output
|
||||
- Zmiana store() i update() w AutomationController — renderForm() z danymi z request zamiast redirect
|
||||
</objective>
|
||||
|
||||
<context>
|
||||
## Source Files
|
||||
@src/Modules/Automation/AutomationController.php (store linia 106, update linia 133, renderForm linia 236)
|
||||
@resources/views/automation/form.php (formularz korzysta z $rule do wypelnienia pol)
|
||||
</context>
|
||||
|
||||
<acceptance_criteria>
|
||||
|
||||
## AC-1: Store — dane zachowane po bledzie walidacji
|
||||
```gherkin
|
||||
Given wypelniam formularz nowej reguly automatyzacji
|
||||
When walidacja zwraca blad (np. brak warunkow)
|
||||
Then formularz wyswietla sie ponownie z wypelnionymi danymi
|
||||
And komunikat bledu jest widoczny
|
||||
And nie nastepuje redirect
|
||||
```
|
||||
|
||||
## AC-2: Update — dane zachowane po bledzie walidacji
|
||||
```gherkin
|
||||
Given edytuje istniejaca regule i zmieniam dane
|
||||
When walidacja zwraca blad
|
||||
Then formularz wyswietla sie ponownie z danymi z formularza (nie z DB)
|
||||
And komunikat bledu jest widoczny
|
||||
```
|
||||
|
||||
## AC-3: Zapis sukces — bez zmian w zachowaniu
|
||||
```gherkin
|
||||
Given wypelniam poprawnie formularz
|
||||
When zapisuje
|
||||
Then regula jest zapisana i nastepuje redirect do listy
|
||||
```
|
||||
|
||||
</acceptance_criteria>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 1: Re-render formularza zamiast redirect przy bledzie walidacji</name>
|
||||
<files>src/Modules/Automation/AutomationController.php</files>
|
||||
<action>
|
||||
1. Dodaj prywatna metode buildRuleFromRequest(Request $request, ?int $id = null): array
|
||||
- Zbuduj tablice $rule z POST data w formacie oczekiwanym przez form.php:
|
||||
- 'id' => $id
|
||||
- 'name' => $request->input('name')
|
||||
- 'event_type' => $request->input('event_type')
|
||||
- 'is_active' => $request->input('is_active') !== null ? 1 : 0
|
||||
- 'conditions' => zmapuj z extractConditions — format: [{condition_type, condition_value}]
|
||||
- 'actions' => zmapuj z extractActions — format: [{action_type, action_config}]
|
||||
- Warunki i akcje powinny byc w takim formacie, jaki form.php oczekuje od $rule
|
||||
|
||||
2. Zmien renderForm(?array $rule, string $errorMessage = ''): Response
|
||||
- Dodaj parametr $errorMessage
|
||||
- Uzyj $errorMessage jesli niepusty, inaczej Flash::get
|
||||
|
||||
3. W store():
|
||||
- Zamiast: Flash::set('error') + redirect('/create')
|
||||
- Zrob: return $this->renderForm($this->buildRuleFromRequest($request), $validationError)
|
||||
|
||||
4. W update():
|
||||
- Zamiast: Flash::set('error') + redirect('/edit?id=')
|
||||
- Zrob: return $this->renderForm($this->buildRuleFromRequest($request, $id), $validationError)
|
||||
|
||||
5. Upewnij sie ze try/catch bledy (blad zapisu DB) tez uzywaja renderForm z danymi request — nie redirect.
|
||||
</action>
|
||||
<verify>PHP lint. Sprawdz ze formularz z bledna walidacja renderuje sie z danymi.</verify>
|
||||
<done>AC-1, AC-2, AC-3 satisfied</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<boundaries>
|
||||
|
||||
## DO NOT CHANGE
|
||||
- resources/views/automation/form.php (widok juz obsluguje $rule — nie wymaga zmian)
|
||||
- public/assets/js/modules/automation-form.js
|
||||
- src/Modules/Automation/AutomationRepository.php
|
||||
- src/Modules/Automation/AutomationService.php
|
||||
|
||||
## SCOPE LIMITS
|
||||
- Tylko formularz automatyzacji — nie naprawiamy innych formularzy w tej fazie
|
||||
- Nie zmieniamy struktury Flash class
|
||||
|
||||
</boundaries>
|
||||
|
||||
<verification>
|
||||
- [ ] PHP lint bez bledow
|
||||
- [ ] store() z bledna walidacja — formularz zachowuje dane
|
||||
- [ ] update() z bledna walidacja — formularz zachowuje dane
|
||||
- [ ] store() z poprawnymi danymi — zapis + redirect (bez regresji)
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- Dane formularza zachowane po bledzie walidacji
|
||||
- Brak regresji w happy path (poprawny zapis)
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
After completion, create `.paul/phases/58-automation-form-preserve/58-01-SUMMARY.md`
|
||||
</output>
|
||||
Reference in New Issue
Block a user