FriendsOfREDAXO / FriendsOfREDAXO/api

Slice-Priority beim Anlegen + `/move`-Endpunkt für Slices

Open
#62 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
20
Forks
0
Avg merge
49m
Merged PRs (30d)
17

Description

Übernommen aus #50 von @marcohanke. Der fachliche Zuschnitt stammt vollständig von ihm; der Branch ist gegen `main` konfliktbehaftet, weil `lib/RoutePackage/Structure.php` in #58/#59/#60 umgebaut wurde — deshalb hier als Issue festgehalten, statt den Branch nachzuziehen. Die Tests aus dem PR-Branch (`tests/StructureApiTest.php`, `tests/BackendApiTest.php`) lassen sich übernehmen.

**1. `priority` beim Anlegen eines Slices.** Optionales Body-Feld für `POST /api/structure/articles/{id}/slices`; ohne Angabe unverändertes Verhalten. `rex_content_service::addSlice()` versteht den Schlüssel bereits (`content_service.php:15-22`): ohne Angabe wird angehängt (`MAX(priority)+1`), `<= 0` auf `1` normalisiert, danach läuft `rex_sql_util::organizePriorities()`. Kein neues SQL, kein neuer EP.

**2. `POST /api/structure/articles/{id}/slices/{slice_id}/move`** mit Body `{"direction": "moveup"|"movedown"}` als Spiegel von `rex_api_content_move_slice::execute()`. `clang_id` und `module_id` kommen aus dem Slice-Datensatz, die Permission-Kaskade für Session-Aufrufe ist `moveSlice[]` → Kategorie-Perm → Modul-Perm. `rex_content_service::moveSlice()` erledigt den Rest (SLICE_MOVE, organizePriorities, `rex_article_cache::deleteContent()`, `art_content_updated`) und ist Bearer-tauglich: `getUser()` fällt auf `rex::getEnvironment()` zurück, kein `requireUser()`. Der Backend-Spiegel entsteht automatisch über `RoutePackage/Backend/Structure.php`.

Gegen den aktuellen `main` zusätzlich zu beachten:

- Slice-Bodys werden seit #58 strikt geprüft — `priority` muss in der Body-Definition stehen, und der move-Handler sollte ebenfalls mit `getQuerySet(..., true)` parsen.
- `checkLiveRevisionPerm()` fehlt im move-Handler: ein Move in Revision 0 ist ein Schreibzugriff auf die Live-Version und braucht bei Backend-Usern `version[live_version]`.
- Die Message aus `moveSlice()` kommt HTML-escaped aus `rex_i18n::msg()` — vor der JSON-Ausgabe `html_entity_decode()`.
- Statuscode an der Grenze (`moveup` auf dem obersten Slice): der PR nimmt 422, die Konvention im AddOn ist 409 für fachliche Verstöße (`Clangs::errorResponse`). Einmal festlegen.

Bewusst ausgelassen (so von Marco begründet): `priority` per `PATCH /slices/{id}`, absolute Positionen, `move-to-top`/`move-to-bottom`.

---
*Dieser Text wurde durch eine KI erstellt.*

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with lib/RoutePackage/Structure.php, rex_content_service::addSlice() and moveSlice(), and the existing tests in tests/StructureApiTest.php and tests/BackendApiTest.php. Compare the move behavior with rex_api_content_move_slice::execute() and inspect the current body validation and permission checks. Done means priority-aware slice creation and the move endpoint work for both API and backend routes, with tests covering validation, permissions, responses, and boundary behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.