diff --git a/truthinquiry/routes/routes_admin.py b/truthinquiry/routes/routes_admin.py index a4d23b7..2044499 100644 --- a/truthinquiry/routes/routes_admin.py +++ b/truthinquiry/routes/routes_admin.py @@ -35,11 +35,27 @@ def npc(npc_id): answer_list = [answer.TEXT for answer in answer_type.TEXT_LOCALE.TEXTS] npc_answers.append(answer_list) + reactions = [{ + "id": reaction.TRAIT.TRAIT_ID, + "name": reaction.TRAIT.NAME_LOCALE.get_text(DEFAULT_LANG).TEXT, + "url": "/api/v1/getReaction?uuid="+reaction.REACTION_UUID + } for reaction in npc_obj.REACTIONS] + + reactions_to_add = [] + for trait in db.session.query(Trait).all(): + if trait.TRAIT_ID not in [reaction.TRAIT.TRAIT_ID for reaction in npc_obj.REACTIONS]: + reactions_to_add.append({ + "id": trait.TRAIT_ID, + "name": trait.NAME_LOCALE.get_text(DEFAULT_LANG).TEXT + }) + npc_dict = { "id": npc_obj.NPC_ID, "name": npc_obj.NAME_LOCALE.get_text(DEFAULT_LANG).TEXT, "img": npc_obj.NPC_ID, "answers": npc_answers, + "reactions": reactions, + "reactions_to_add": reactions_to_add, } return flask.render_template("admin/npc.html", npc=npc_dict) diff --git a/truthinquiry/static/js/admin_npc.js b/truthinquiry/static/js/admin_npc.js index 0b345d0..bae9baf 100644 --- a/truthinquiry/static/js/admin_npc.js +++ b/truthinquiry/static/js/admin_npc.js @@ -31,3 +31,14 @@ async function deleteNpc() { alert("Opération effectuée avec succès"); document.location = "/admin"; } + +function changeReaction(inputNode){ + const parentNode = inputNode.parentNode; + const imgNode = parentNode.querySelector('img'); + + const reader = new FileReader(); + reader.onload = (e)=>{ + imgNode.src = e.target.result + } + reader.readAsDataURL(inputNode.files[0]); +} \ No newline at end of file diff --git a/truthinquiry/templates/admin/npc.html b/truthinquiry/templates/admin/npc.html index 1742f65..7b672d5 100644 --- a/truthinquiry/templates/admin/npc.html +++ b/truthinquiry/templates/admin/npc.html @@ -34,6 +34,28 @@

Image du personnage

{{'Image du personnage' + (' ' + npc.get('name') if npc.get('name') else '')}} + +
+

Réactions

+ + {%for reaction in npc.get("reactions")%} +
+

{{reaction.get('name')}}

+ + +
+ {%endfor%} + + + {%if npc.get("reaction_to_add")%} + + {%endif%} +
+

Réponses aux questions lors de l'interrogation