feat: object words in left sidebar + suggestions in pair form
- Backend: GET /api/directus/db-objects/<id>/words via db_objects_db_words - GenerateIt: load objectWords on object select, show as chips in left sidebar - PairForm: show object words as clickable suggestion chips above word input (click to add, greyed out if already added) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
27
app.py
27
app.py
@@ -1877,6 +1877,33 @@ def directus_db_object_pairs(obj_id):
|
||||
return jsonify({"ok": True, "pair_id": pair_id, "statement_id": stmt_id, "question_id": q_id})
|
||||
|
||||
|
||||
@app.route("/api/directus/db-objects/<obj_id>/words", methods=["GET"])
|
||||
def directus_db_object_words(obj_id):
|
||||
"""Gibt alle db_words zurück, die via db_objects_db_words mit dem Objekt verknüpft sind."""
|
||||
token = request.headers.get("Authorization", "")
|
||||
data, s = _directus(
|
||||
"GET",
|
||||
f"/items/db_objects_db_words?filter[db_objects_id][_eq]={obj_id}"
|
||||
f"&fields=id,db_words_id.id,db_words_id.titel_de,db_words_id.level,db_words_id.status&limit=500",
|
||||
token,
|
||||
)
|
||||
if s != 200:
|
||||
return jsonify({"data": []})
|
||||
items = []
|
||||
for entry in (data.get("data") or []):
|
||||
word = entry.get("db_words_id") or {}
|
||||
if not isinstance(word, dict) or not word.get("id"):
|
||||
continue
|
||||
if word.get("status") == "archived":
|
||||
continue
|
||||
items.append({
|
||||
"word_id": word["id"],
|
||||
"titel_de": word.get("titel_de", ""),
|
||||
"level": word.get("level") or 50,
|
||||
})
|
||||
return jsonify({"data": items})
|
||||
|
||||
|
||||
@app.route("/api/directus/db-pairs/<pair_id>", methods=["PATCH", "DELETE"])
|
||||
def directus_db_pair(pair_id):
|
||||
"""PATCH: level + question/statement inline aktualisieren.
|
||||
|
||||
Reference in New Issue
Block a user