Propozycja: historia zmian szablonów i layoutów z przywracaniem poprzedniej wersji

Closed
#298 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
php
Domain
backend

Research direction

Start by reading models/Template.php, models/Layout.php, traits/FollowsView.php:41-48, and October's Revisionable trait at vendor/october/rain/src/Database/Traits/Revisionable.php; the issue also points to #267 for the text-column limit. The proposed scope spans revision storage, history and restore actions in backend forms, permissions, and view-file synchronization. Done means the acceptance criteria are met, including bounded history and tests for recording, restoring, permissions, and synchronization.

Written by the indexing model from the issue text.

Description

code-review enhancement low-priority

Problem

Szablony i layouty edytują w panelu także osoby nietechniczne, a edytor to surowy HTML/Twig. Zapisanej zmiany nie da się cofnąć do poprzedniej wersji. Reset to Default przywraca tylko plik widoku z pluginu i działa wyłącznie dla rekordów z widoku. Szablony utworzone w panelu (is_custom) i layouty odłączone od widoku nie mają żadnej drogi powrotu.

Dowód

  • models/Template.php i models/Layout.php nie używają Revisionable ani niczego podobnego. Zapis nadpisuje content_html / content_css bez śladu.
  • traits/FollowsView.php:41-48: resetToView() cofa do pliku widoku, nie do poprzedniego zapisu.
  • October ma gotowy trait October\Rain\Database\Traits\Revisionable z tabelą system_revisions (vendor/october/rain/src/Database/Traits/Revisionable.php).

Skutek

Jedna błędna zmiana, np. usunięty fragment faktury albo zepsuty Twig zapisany razem z poprawną treścią, oznacza ręczne odtwarzanie z pamięci lub z backupu bazy. Nie wiadomo też, kto i kiedy zmienił dokument prawny.

Proponowane rozwiązanie

  • Revisionable na Template (title, description, content_html, layout_id, size, orientation, sample_data) i Layout (name, content_html, content_css), z rozsądnym $revisionableLimit i getRevisionableUser() zwracającym administratora backendu.
  • Zakładka History w formularzu: lista zmian (data, administrator, pole) z podglądem starej treści.
  • Akcja Restore za uprawnieniem Update, która przywraca wartości i oznacza szablon jako Customized.
  • Uwaga: system_revisions.old_value/new_value to TEXT, więc ma ten sam limit 64 KB co obecne kolumny treści (zob. #267).

Kryteria akceptacji

  • Każdy zapis zmienionej treści tworzy rewizję z autorem i datą.
  • Z formularza można obejrzeć i przywrócić wybraną wersję; przywrócenie wymaga Update.
  • Synchronizacja z plikami widoków nie zapełnia historii zmianami z pluginu albo oznacza je osobno.
  • Liczba rewizji na rekord jest ograniczona.
Dominant language
PHP
Stars
30
Forks
22
Avg merge
5m
Merged PRs (30d)
47

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.