diff --git a/src/Controller/ScrumController.php b/src/Controller/ScrumController.php index 2e7619b..66e0cf0 100755 --- a/src/Controller/ScrumController.php +++ b/src/Controller/ScrumController.php @@ -599,23 +599,57 @@ class ScrumController extends AbstractController public function stat($id,Request $request) { - // Initialisation de l'enregistrement $em = $this->getDoctrine()->getManager(); - $data=$em->getRepository($this->entity)->find($id); - if(!$data) return $this->redirectToRoute($this->route); - $firstcolumn=$em->getRepository('App:Scrumcolumn')->findOneBy(["scrum"=>$data], ['rowid' => 'ASC']); - if(!$firstcolumn) return $this->redirectToRoute($this->route); - - $em->getRepository("App:Scrum")->getGitea($data,$giteaassignees,$giteacolumns,$giteamilestones,$giteateams,$giteaprioritys,$giteatypes,$gitealabels); + $scrum=$em->getRepository($this->entity)->find($id); + if(!$scrum) return $this->redirectToRoute($this->route); + $em->getRepository("App:Scrum")->getGitea($scrum,$giteaassignees,$giteacolumns,$giteamilestones,$giteateams,$giteaprioritys,$giteatypes,$gitealabels); // Préférences utilisateur $filtermilestones = $em->getRepository("App:User")->getUserpreference($this->getUser(),"filtermilestones",$id); $filtersprints = $em->getRepository("App:User")->getUserpreference($this->getUser(),"filtersprints",$id); $filterbynumber = $em->getRepository("App:User")->getUserpreference($this->getUser(),"filterbynumber",$id); $showfilters = $em->getRepository("App:User")->getUserpreference($this->getUser(),"showfilters",$id); + + $tbestim=$this->getEstim($scrum); + + return $this->render($this->render.'stat.html.twig', [ + 'useheader' => true, + 'usesidebar' => false, + 'usetitle' => $scrum->getName(), + 'giteamilestones' => $giteamilestones, + 'sprints' => $scrum->getScrumsprints(), + 'filtermilestones' => $filtermilestones, + 'filtersprints' => $filtersprints, + 'filterbynumber' => $filterbynumber, + 'showfilters' => $showfilters, + $this->data => $scrum, + 'tbestim' => $tbestim, + ]); + } + + public function info($id,Request $request) + { + $em = $this->getDoctrine()->getManager(); + $scrum=$em->getRepository($this->entity)->find($id); + if(!$scrum) return $this->redirectToRoute($this->route); + $em->getRepository("App:Scrum")->getGitea($scrum,$giteaassignees,$giteacolumns,$giteamilestones,$giteateams,$giteaprioritys,$giteatypes,$gitealabels); + + $tbestim=$this->getEstim($scrum); + + $output=[]; + $output["tbestim"]=$tbestim; + return new JsonResponse($output); + } + + private function getEstim($scrum) { + // Initialisation de l'enregistrement + $em = $this->getDoctrine()->getManager(); + $firstcolumn=$em->getRepository('App:Scrumcolumn')->findOneBy(["scrum"=>$scrum], ['rowid' => 'ASC']); + if(!$firstcolumn) return $this->redirectToRoute($this->route); + // Création du tableau des issues - $issues=$data->getScrumissues(); + $issues=$scrum->getScrumissues(); $tbissues=[]; $tbcols=[]; $tbjals=[]; @@ -642,10 +676,15 @@ class ScrumController extends AbstractController $nmjal=($issue->getGiteaMilestonename()?$issue->getGiteaMilestonename():"Aucun"); $nmspr=($issue->getScrumsprint()?$issue->getScrumsprint()->getName():"Aucun"); + // Idgiteas + $gicol=($issue->getScrumcolumn()?$issue->getScrumcolumn()->getGiteaid():$firstcolumn->getGiteaid()); + $gijal=($issue->getGiteaMilestone()?$issue->getGiteaMilestone():-100); + if(!array_key_exists($idjal,$tbestim)) { $tbestim[$idjal] = [ "rowjal" => $rowjal, "idjal" => $idjal, + "gijal" => $gijal, "nmjal" => $nmjal, "nbjrs" => 0, "nbiss" => 0, @@ -669,6 +708,7 @@ class ScrumController extends AbstractController $tbestim[$idjal]["columns"][$idcol] = [ "rowcol" => $rowcol, "idcol" => $idcol, + "gicol" => $gicol, "nmcol" => $nmcol, "color" => ($issue->getScrumcolumn()?$issue->getScrumcolumn()->getGiteajson()["color"]:$firstcolumn->getGiteajson()["color"]), "nbjrs" => 0, @@ -680,6 +720,7 @@ class ScrumController extends AbstractController $tbestim[$idjal]["sprints"][$idspr]["columns"][$idcol] = [ "rowcol" => $rowcol, "idcol" => $idcol, + "gicol" => $gicol, "nmcol" => $nmcol, "color" => ($issue->getScrumcolumn()?$issue->getScrumcolumn()->getGiteajson()["color"]:$firstcolumn->getGiteajson()["color"]), "nbjrs" => 0, @@ -698,69 +739,20 @@ class ScrumController extends AbstractController $tbestim[$idjal]["sprints"][$idspr]["nbiss"]++; $tbestim[$idjal]["sprints"][$idspr]["columns"][$idcol]["nbiss"]++; + $this->formatDec($tbestim[$idjal]["nbjrs"]); + $this->formatDec($tbestim[$idjal]["columns"][$idcol]["nbjrs"]); + $this->formatDec($tbestim[$idjal]["sprints"][$idspr]["nbjrs"]); + $this->formatDec($tbestim[$idjal]["sprints"][$idspr]["columns"][$idcol]["nbjrs"]); + + } - return $this->render($this->render.'stat.html.twig', [ - 'useheader' => true, - 'usesidebar' => false, - 'usetitle' => $data->getName(), - 'giteamilestones' => $giteamilestones, - 'sprints' => $data->getScrumsprints(), - 'filtermilestones' => $filtermilestones, - 'filtersprints' => $filtersprints, - 'filterbynumber' => $filterbynumber, - 'showfilters' => $showfilters, - $this->data => $data, - 'tbestim' => $tbestim, - ]); - } + return $tbestim; + } - public function info($id,Request $request) - { - $em = $this->getDoctrine()->getManager(); - $viewclosed = $request->getSession()->get("viewclosed"); - - // Rechercher du scrum en cours - $scrum=$em->getRepository("App:Scrum")->find($id); - if(!$scrum) return new JsonResponse(['message' => 'No Issue'], 403); - - $giteaissues=$this->giteaservice->getIssues($scrum->getGiteajson()["owner"]["login"],$scrum->getGiteajson()["name"],"?state=".($viewclosed=="true"?"all":"open")); - - $weights=[]; - foreach($giteaissues as $giteaissue) { - $scrumissue=$em->getRepository("App:Scrumissue")->findOneBy(["scrum"=>$scrum,"giteaid"=>$giteaissue->id]); - if($scrumissue) { - if($giteaissue->milestone) $milestoneid=$giteaissue->milestone->id; - else $milestoneid=-100; - - if($scrumissue->getScrumsprint()) $sprintid=$milestoneid."-".$scrumissue->getScrumsprint()->getId(); - else $sprintid=$milestoneid."-".-100; - - - if(!array_key_exists($milestoneid,$weights)) { - $weights[$milestoneid]=[ - "id" => $milestoneid, - "weight"=>0, - "sprints"=>[], - ]; - } - - if(!array_key_exists($sprintid,$weights[$milestoneid]["sprints"])) { - $weights[$milestoneid]["sprints"][$sprintid]=[ - "id" => $sprintid, - "weight"=>0 - ]; - } - - $weights[$milestoneid]["weight"]+=$scrumissue->getWeight(); - $weights[$milestoneid]["sprints"][$sprintid]["weight"]+=$scrumissue->getWeight(); - //dump($weights[$milestoneid]["sprints"][$sprintid]["weight"]); - } - } - - $output=[]; - $output["weights"]=$weights; - return new JsonResponse($output); + private function formatDec(&$number) { + if(strpos(strval($number), '.') !== false) $number=number_format($number,1); + else $number=intval($number); } protected function getErrorForm($id,$form,$request,$data,$mode) { diff --git a/src/Controller/ScrumissueController.php b/src/Controller/ScrumissueController.php index 25da7db..b4077ca 100755 --- a/src/Controller/ScrumissueController.php +++ b/src/Controller/ScrumissueController.php @@ -158,6 +158,9 @@ class ScrumissueController extends AbstractController $giteaissue->comments=$this->giteaservice->getIssueComments($repoowner,$reponame,$giteaissue->number); $giteaissue->statuslife=$issue->getScrumcolumn()->getName(); + $giteaissue->weight=$issue->getWeight(); + $giteaissue->nineid=$issue->getId(); + $giteaissue->sprint=($issue->getScrumsprint()?$issue->getScrumsprint()->getName():null); foreach($giteaissue->comments as $keycomment => $comment) { $giteaissue->comments[$keycomment]->body=$this->giteaservice->markdown("/".$scrum->getGiteajson()["full_name"],"comment",$giteaissue->comments[$keycomment]->body); diff --git a/templates/Scrum/issue.html.twig b/templates/Scrum/issue.html.twig index 8677f47..1694eb9 100644 --- a/templates/Scrum/issue.html.twig +++ b/templates/Scrum/issue.html.twig @@ -37,6 +37,7 @@
+
{{issue.user.login}}
@@ -65,6 +66,14 @@
Modifier dans Gitea + +
+
+
+
{{ issue.weight }}
+
+
+
Statut
@@ -192,5 +201,64 @@
+ +{% endblock %} + +{% block localjavascript %} + $(document).on('click','.modissu',function(){ + $.ajax({ + method: "POST", + url: "{{path("app_scrumissue_info")}}", + data: { + id:{{issue.nineid}}, + }, + success: function(data) { + $("#modal-issueweight").val(data.weight); + $("#mymodalissue").modal('show'); + $("#modal-issueweight").focus(); + }, + }); + }); + + $("#issu_update").click(function(){ + $.ajax({ + method: "POST", + url: "{{path("app_scrumissue_update")}}", + data: { + id:{{issue.nineid}}, + weight:$("#modal-issueweight").val(), + }, + success: function(data) { + parent.$(".issue{{issue.nineid}}-weight").html($("#modal-issueweight").val()); + window.parent.refreshinfo(); + location.reload(); + }, + error: function (request, status, error) { + $("#mymodalissue").modal('hide'); + } + }); + }); {% endblock %} diff --git a/templates/Scrum/stat.html.twig b/templates/Scrum/stat.html.twig index b16ab1b..ea7affc 100644 --- a/templates/Scrum/stat.html.twig +++ b/templates/Scrum/stat.html.twig @@ -68,7 +68,7 @@

{{ scrum.name }}

-
+
{% for jalon in tbestim %} {% if jalon.nbjrs>0 %} diff --git a/templates/Scrum/view.html.twig b/templates/Scrum/view.html.twig index 169471d..2fdf2ba 100644 --- a/templates/Scrum/view.html.twig +++ b/templates/Scrum/view.html.twig @@ -139,23 +139,7 @@
-
- {% for jalon in tbestim %} - - - - - - {% for sprint in jalon.sprints %} - {% if not loop.first or sprint.idspr!=-100 %} - - - - - {% endif %} - {% endfor %} -
{{jalon.nmjal}}{{jalon.nbjrs}}
{{sprint.nmspr}}{{sprint.nbjrs}}
- {% endfor %} +
@@ -180,12 +164,18 @@ {% for jalon in column.jalons %} {% for sprint in jalon.sprints %}
-
- JALON = {{jalon.nmjal}} - {% if sprint.idspr!=-100 %} -
- SPRINT = {{sprint.nmspr}} - {% endif %} +
+
+ JALON = {{jalon.nmjal}} + {% if sprint.idspr!=-100 %} +
+ SPRINT = {{sprint.nmspr}} + {% endif %} +
+ +
+ +
@@ -562,25 +552,6 @@ $("#textfilters").html(textfilters); } - function refreshinfo() { - $.ajax({ - method: "POST", - url: "{{path("app_scrum_info",{id:scrum.id})}}", - success: function(data) { - $(".totalweight").html("0"); - - Object.entries(data.weights).forEach(entry => { - const [keyj, jalon] = entry; - $("#totaljal"+jalon.id).html(jalon.weight.toFixed(1).replace(/\.0$/, '')); - Object.entries(jalon.sprints).forEach(entry => { - const [keys, sprint] = entry; - $("#totalspr"+sprint.id).html(sprint.weight.toFixed(1).replace(/\.0$/, '')); - }); - }); - } - }); - } - $(document).on('click','.modissu',function(){ $(".modal-title").html("#"+$(this).data("giteaid")+" - "+$(this).data("giteatitle")); $("#modal-issueid").val($(this).data("issue")); @@ -897,8 +868,7 @@ start: function( event, ui ) { $(".submenu").hide(); }, - update: function( event, ui ) { - + stop: function( event, ui ) { id=$(ui.item).data("issue"); oldcolumn=$(ui.item).data("column"); oldmilestone=$(ui.item).data("milestone"); @@ -974,6 +944,49 @@ }); + function refreshinfo() { + $.ajax({ + method: "POST", + url: "{{path("app_scrum_info",{id:scrum.id})}}", + success: function(data) { + html=""; + $("[data-weight]").html(""); + + Object.entries(data.tbestim).forEach(entry => { + const [keyj, jalon] = entry; + + html+=''; + html+=''; + html+=''; + html+=''; + html+=''; + + nofirst=false; + Object.entries(jalon.sprints).forEach(entry => { + const [keys, sprint] = entry; + if(nofirst || sprint.idspr!=-100) { + html+=''; + html+=''; + html+=''; + html+=''; + } + + Object.entries(sprint.columns).forEach(entry => { + const [keys, column] = entry; + $("[data-weight="+column.gicol+"-"+jalon.gijal+"-"+sprint.idspr+"]").html(column.nbjrs); + + }); + nofirst=true; + }); + + html+='
'+jalon.nmjal+''+jalon.nbjrs+'
'+sprint.nmspr+''+sprint.nbjrs+'
'; + }); + + $("#tbestim").html(html); + } + }); + } + function issuhover(btn,idissu) { $(".submenu").hide(); $("#submenu"+idissu).css("display","flex");