diff --git a/client/projectPage/projectPageA.html b/client/projectPage/projectPageA.html index 6c6653363f07967ea0e999ec338d5b0d83e59f7e..a672f645da566473feb38ff5a6c6a090ce498cf8 100644 --- a/client/projectPage/projectPageA.html +++ b/client/projectPage/projectPageA.html @@ -104,10 +104,6 @@ <h1>Sista steget</h1> <p>Agera-steget är det sista steget i modellen. Du kan nu avsluta projektet eller låta förbättringsarbetet gå ienom en till iteration avd PGDA.</p> </article> - - <button id="toCurrentProjects" data-project-id="${this.id}" class="btn btn-secondary" role="button">Avsluta förbättringsarbete</button> - <button id="toCurrentProjects" data-project-id="${this.id}" class="btn btn-secondary" role="button">En till iteration</button> - </div> <div style="width: 25%;"> <div class="sideTitle">Dokument</div> diff --git a/client/projectPage/projectPageA.ts b/client/projectPage/projectPageA.ts index d2865a6b3f48d53bcd5c6e05ffccb39f1ad500cb..7dd13a0483dd3bf4003d70d1e80fd5e67e453057 100644 --- a/client/projectPage/projectPageA.ts +++ b/client/projectPage/projectPageA.ts @@ -47,9 +47,7 @@ export async function loadPage (projectId : string) { const target = event.target as HTMLElement; // Type assertion const pdfInput = document.getElementById('pdfInput') as HTMLInputElement; const pdfLinkContainer = document.getElementById('pdfLink'); - if (target.id === 'toCurrentProjects') { - checkInputFields(projectId, "formPageA"); - } else if(target.id === 'nolansToP'){ + if(target.id === 'nolansToP'){ loadProjectPageP(projectId); } else if(target.id === 'nolansToG'){ loadProjectPageG(projectId); @@ -139,6 +137,7 @@ async function loadImprovementWorkDataPageA(projectId:string) { } } loadProjectHeader(improvementWork); + loadInitiateAndFinalizeBtn(projectId, improvementWork.completed); } @@ -187,4 +186,35 @@ async function checkInputFields(projectId: string, formId: string) { } } +function loadInitiateAndFinalizeBtn(projectId : string, completed : boolean) { + alert("hej"); + if(!completed) { + alert("not completed"); + const nolanModelElement = document.getElementById("projectPageNolandsModel") as HTMLElement; + + //Creates buttons with classname, id, attribute and text + const finalizeButton = document.createElement("button"); + const iterationButton = document.createElement("button"); + if (nolanModelElement) { + alert("finds element"); + finalizeButton.id = "toCurrentProjects"; + iterationButton.id = "toCurrentProjects"; + finalizeButton.classList.add("btn", "btn-primary"); + iterationButton.classList.add("btn", "btn-primary"); + iterationButton.setAttribute('role', 'button'); + finalizeButton.setAttribute('role', 'button'); + finalizeButton.textContent = 'Avsluta Förbättringsarbete'; + iterationButton.textContent = 'En till iteration'; + } + //Append buttons to html + nolanModelElement.append(iterationButton); + nolanModelElement.append(finalizeButton); + + //Eventlistener for button + finalizeButton.addEventListener('click', function() { + checkInputFields(projectId, "formPageA");; + }); + } +} +