Commit a40798fe authored by Abdelmoujib Megzari's avatar Abdelmoujib Megzari
Browse files

associating old paragraphe working but onlu when calling new paragraph

parent 7bdee226
......@@ -107,8 +107,13 @@ public class AssociateParagraphChoice extends HttpServlet {
}
System.out.println("choice_id: " + request.getParameter("choice_id"));
int choiceID = Integer.parseInt(request.getParameter("choice_id"));
System.out.println(request.getAttribute("paragraphFollower") instanceof Integer);
int paragraphFollowerID = (Integer) (request.getAttribute("paragraphFollower"));
int paragraphFollowerID;
if(request.getParameterMap().containsKey("paragraphFollower")){
paragraphFollowerID = Integer.parseInt(request.getParameter("paragraphFollower"));
}else {
System.out.println(request.getAttribute("paragraphFollower") instanceof Integer);
paragraphFollowerID = (Integer) (request.getAttribute("paragraphFollower"));
}
System.out.println(paragraphFollowerID);
paragraphDAO.associateParagraphChoice(choiceID, paragraphFollowerID);
......
......@@ -76,10 +76,10 @@ function editParagraphe(paragraph_id,isConclusion,notvalid) {
console.log(data);
additionalforms="";
if (notvalid){
additionalforms=`<button onclick="unlock(${paragraph_id})" type="button">abandonner et dévrouiller</button>`+
`<input type="text" id="link${paragraph_id}">`+
additionalforms=`<button onclick="deleteParagraphe(${paragraph_id})" type="button">abandonner et dévrouiller</button>`+
`<br><input type="text" id="link${paragraph_id}">`+
`<button onclick="associate(${paragraph_id})" type="button">associer à ce paragraph existant</button>`+
`<input type="text" id="link${paragraph_id}">`+
`<br><input type="text" id="require${paragraph_id}">`+
`<button onclick="associate(${paragraph_id})" type="button">paragraphe requis</button>`
}
element.innerHTML = `<form method='post' action='index.jsp' id='modif${paragraph_id}'> ` +
......@@ -172,8 +172,9 @@ function switchMode(){
}
}
function newParagraphe(paragraphToContinueID, choice_id){
last_lock=choice_id;
last_lock_first = paragraphToContinueID;
let paragraphFollowerID = createParagraph(choice_id);
console.log(paragraphFollowerID);
if (paragraphFollowerID !== -1) {
......@@ -229,3 +230,20 @@ function deleteParagraphe(id){
});
}
function associate(id){
let follower = parseInt(document.getElementById(`link${id}`).value);
console.log(follower)
console.log(last_lock)
$.post("AssociateParagraphChoice", {choice_id:last_lock , paragraphFollower: follower}).done(function (data) {
console.log("done")
console.log(data)
choose(last_lock_first,follower,0)//TODO change story id
}).fail(function (jqXHR, textStatus, errorThrown) {
return console.error(errorThrown);
});
}
//TODO i dont know where but when i lock a choice and click the choice a second time it tels me that it has been already locked
......@@ -6,6 +6,7 @@
<div class="delete edit" id="deleteParagraph${paragraph.id}" onclick="deleteParagraphe(${paragraph.id},${paragraph.isConclusion?'true':'false'})"><button>suprimer</button></div>
</c:if>
</c:if>
<div class="edit">${paragraph.id}</div>
<p id="paragrapheText${paragraph.id}" class="paragraph_text">
${empty paragraph? "no paragraphe found": paragraph.texte}
</p>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment