From 60d85643dee3ff51b9238f2094e581ba7c50b9cf Mon Sep 17 00:00:00 2001 From: Fagner Lima Date: Sat, 12 Dec 2020 15:47:19 -0300 Subject: [PATCH 01/11] =?UTF-8?q?Atualiza=20=C3=ADcones=20dos=20bot=C3=B5e?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + Data/tasks.db | Bin 45056 -> 45056 bytes templates/lista-projetos.html.twig | 4 ++-- templates/novo-projeto.html.twig | 3 ++- templates/usuarios-listar.html.twig | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index a3dafb9..843f729 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ /vendor/ ###< symfony/framework-bundle ### /.idea/ +/nbproject/ diff --git a/Data/tasks.db b/Data/tasks.db index 57ed5d508a869aa3f1139848b5216c37d1fc6e3d..69bd5d49b74b1add5e26e29b9966b365fa5d06fe 100644 GIT binary patch delta 96 zcmZp8z|`=7X@WH4iHS1KtS1=sWHxL}nXAvwTgkx2ZO6!O&bNZknA>i%fPo%2Z=;0* z7ek{kqcNj#qwwSpw$77J+KNoxV9GT)%7zQX-~7|MfsuuQfnnFg#%-I8?ameg0C|xf Apa1{> delta 266 zcmZp8z|`=7X@WH4@rg3dtj8I2KknF=GFP9Ufq{XI`zIs6Io}FCW8TWm0tR~A_4%pA z3Mr`yW%)TJiA4&jxeCdNDTxXtsX2*kMg~R(x`sx&h6V}-23BCi1Q#=hizVmhU_ r*3ih=21c$%a|JGjMqx%{&dDCuQImJu3s2r=?Y!C8?rb3d3`k2| diff --git a/templates/lista-projetos.html.twig b/templates/lista-projetos.html.twig index 65ee7b4..25d78c4 100644 --- a/templates/lista-projetos.html.twig +++ b/templates/lista-projetos.html.twig @@ -34,8 +34,8 @@ {{ projeto.gerente }} {{ projeto.dtCadastro| date("m/d/Y") }} - - + + diff --git a/templates/novo-projeto.html.twig b/templates/novo-projeto.html.twig index 717e35e..f15ecb1 100644 --- a/templates/novo-projeto.html.twig +++ b/templates/novo-projeto.html.twig @@ -23,7 +23,8 @@ {{ form_row(form.gerente) }} - + Voltar + {% include 'footer.html.twig' %} diff --git a/templates/usuarios-listar.html.twig b/templates/usuarios-listar.html.twig index 5ebf1e7..ae08e38 100644 --- a/templates/usuarios-listar.html.twig +++ b/templates/usuarios-listar.html.twig @@ -33,8 +33,8 @@ {{ usuario.rolesString }} *********** - - + + From 459ae5ebe1bc6869ef9e80aeb2ee59dc50e99ae4 Mon Sep 17 00:00:00 2001 From: Fagner Lima Date: Thu, 7 Jan 2021 22:05:19 -0300 Subject: [PATCH 02/11] =?UTF-8?q?Adiciona=20servi=C3=A7o=20e=20reposit?= =?UTF-8?q?=C3=B3rio=20de=20Task?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjetoRepositoryInterface.php | 6 +- .../Repository/TaskRepositoryInterface.php | 16 +++++ src/Domain/Services/ProjetoService.php | 2 +- src/Domain/Services/TaskService.php | 44 ++++++++++++ .../Controller/TaskController.php | 23 +++++-- .../Repository/ProjetoRepository.php | 2 +- .../Repository/TaskRepository.php | 39 +++++++++++ templates/header.html.twig | 19 +++++- templates/lista-tasks.html.twig | 68 +++++++++++++++++++ templates/novo-task.html.twig | 18 ++--- 10 files changed, 216 insertions(+), 21 deletions(-) rename src/Domain/{Model => Repository}/ProjetoRepositoryInterface.php (64%) create mode 100644 src/Domain/Repository/TaskRepositoryInterface.php create mode 100644 src/Domain/Services/TaskService.php create mode 100644 src/Infrastructure/Repository/TaskRepository.php create mode 100644 templates/lista-tasks.html.twig diff --git a/src/Domain/Model/ProjetoRepositoryInterface.php b/src/Domain/Repository/ProjetoRepositoryInterface.php similarity index 64% rename from src/Domain/Model/ProjetoRepositoryInterface.php rename to src/Domain/Repository/ProjetoRepositoryInterface.php index ee55a03..2e19f24 100644 --- a/src/Domain/Model/ProjetoRepositoryInterface.php +++ b/src/Domain/Repository/ProjetoRepositoryInterface.php @@ -1,10 +1,12 @@ taskRepository = $taskRepository; + } + + /** + * @param Task $task + */ + public function salvar(Task $task) + { + $this->taskRepository->salvar($task); + } + + /** + * @return array + */ + public function listar(): array + { + return $this->taskRepository->listar(); + } +} diff --git a/src/Infrastructure/Controller/TaskController.php b/src/Infrastructure/Controller/TaskController.php index d5db585..eb17a55 100644 --- a/src/Infrastructure/Controller/TaskController.php +++ b/src/Infrastructure/Controller/TaskController.php @@ -7,6 +7,7 @@ use App\Domain\Model\Status; use App\Domain\Model\Task; use App\Domain\Model\UsuarioAtribuicao; +use \App\Domain\Services\TaskService; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -14,18 +15,27 @@ use Symfony\Component\Routing\Annotation\Route; /** - * @Route("/task") + * @Route("/tasks") */ class TaskController extends AbstractController { + private TaskService $taskService; + + public function __construct(TaskService $taskService) + { + $this->taskService = $taskService; + } /** - * @Route("/usuario/{id}") + * @Route("/listar", name="task_listar") */ - public function listTasks() + public function listarTasks() { + $tasks = $this->taskService->listar(); - + return $this->render('lista-tasks.html.twig', [ + 'tasks' => $tasks + ]); } /** @@ -100,11 +110,12 @@ public function editar(Task $task, Request $request) $this->addFlash('success','Task Cadastrada com sucesso'); - return $this->redirect('/usuario/tasks'); + return $this->redirect('/tasks/listar'); } return $this->render('novo-task.html.twig', [ - 'form' => $form->createView(), 'projeto' => $task->getProjeto() + 'form' => $form->createView(), + 'projeto' => $task->getProjeto() ]); } diff --git a/src/Infrastructure/Repository/ProjetoRepository.php b/src/Infrastructure/Repository/ProjetoRepository.php index 4393401..c83b75f 100644 --- a/src/Infrastructure/Repository/ProjetoRepository.php +++ b/src/Infrastructure/Repository/ProjetoRepository.php @@ -3,7 +3,7 @@ namespace App\Infrastructure\Repository; use App\Domain\Model\Projeto; -use App\Domain\Model\ProjetoRepositoryInterface; +use App\Domain\Repository\ProjetoRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; diff --git a/src/Infrastructure/Repository/TaskRepository.php b/src/Infrastructure/Repository/TaskRepository.php new file mode 100644 index 0000000..94ae5e1 --- /dev/null +++ b/src/Infrastructure/Repository/TaskRepository.php @@ -0,0 +1,39 @@ +getEntityManager()->persist($task); + $this->getEntityManager()->flush(); + } + + /** + * @return array + */ + public function listar(): array + { + return $this->findAll(); + } +} diff --git a/templates/header.html.twig b/templates/header.html.twig index c2b89c6..8995abd 100644 --- a/templates/header.html.twig +++ b/templates/header.html.twig @@ -84,17 +84,32 @@ + + - + {# + #} diff --git a/templates/lista-tasks.html.twig b/templates/lista-tasks.html.twig new file mode 100644 index 0000000..f947b9b --- /dev/null +++ b/templates/lista-tasks.html.twig @@ -0,0 +1,68 @@ +{% include 'header.html.twig' %} + +
+
+
+
Lista de Tasks
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + {% for task in tasks %} + {% if task.status.id == 2 %} + + {% elseif task.status.id == 3 %} + + {% else %} + + {% endif %} + + + + + + + + + {% endfor %} + +
NomeDescricaoProjetoStatusData CadastroData Conclusão
NomeDescricaoProjetoStatusData CadastroData Conclusão
{{ task.nome }}{{ task.descricao }}{{ task.projeto.nome }}{{ task.status.descricao }}{{ task.dtCadastro| date("m/d/Y") }}{{ task.dtConclusao| date("m/d/Y") }} + + + + {# + + #} +
+
+
+
+ +
+ + + +{% include 'footer.html.twig' %} diff --git a/templates/novo-task.html.twig b/templates/novo-task.html.twig index aa3e3ba..17c7bc5 100644 --- a/templates/novo-task.html.twig +++ b/templates/novo-task.html.twig @@ -28,18 +28,18 @@ {{ form_row(form.status) }} - - - - - + + Voltar + From dde78656c0b0955ba1d40a30b01a8ed4bea7d4fa Mon Sep 17 00:00:00 2001 From: Fagner Lima Date: Thu, 7 Jan 2021 22:13:40 -0300 Subject: [PATCH 03/11] Ajusta cores dos status das tasks --- templates/lista-tasks.html.twig | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/templates/lista-tasks.html.twig b/templates/lista-tasks.html.twig index f947b9b..9dc8d62 100644 --- a/templates/lista-tasks.html.twig +++ b/templates/lista-tasks.html.twig @@ -32,12 +32,16 @@ {% for task in tasks %} - {% if task.status.id == 2 %} - + {% if task.status.id == 1 %} + + {% elseif task.status.id == 2 %} + {% elseif task.status.id == 3 %} - + + {% elseif task.status.id == 4 %} + {% else %} - + {% endif %} {{ task.nome }} {{ task.descricao }} From 4e64ad4da379236db2b6357ec07f57eb8a490ddf Mon Sep 17 00:00:00 2001 From: Fagner Lima Date: Thu, 7 Jan 2021 22:13:48 -0300 Subject: [PATCH 04/11] Atualiza o banco de dados --- Data/tasks.db | Bin 45056 -> 45056 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Data/tasks.db b/Data/tasks.db index 69bd5d49b74b1add5e26e29b9966b365fa5d06fe..031dd4c1ccbc28f8c5b6b31e58bed518cbfe21bb 100644 GIT binary patch delta 118 zcmV-+0Ez#A-~xc)0+1U4%#j>J0nD*rp)U~(!2kvdbO8!<4yX<@3qB2dvl1|33JQTo z9SHz|RRJ>rlR-avldv@kldL-mlg>XflRi6S3j{JSGBGVMH!UzRv#mQ60R#^>0J@QZ Ywv)j;xU(}p1OWs9007C6fyJUgaA#E{mH+?% delta 236 zcmZp8z|`=7X@WH4iHS1Kj3+iGEYug|tz=;1wqxWs=Uc&N%x%YWaI=s>64xX%K4U>6 z10w@nLnB>7Lj@xPD!6Jmv*T}%f z!4S)6%xD~&oS&1QoLHogU#yUnUozRwI%V<(Q?AKTHe8#xS#vW^uD0F5!oa|=YhvTJ k&Bk^tj9iUwvYZT!p^V0ylk2RiCa2g)PHwZ(S>#Xv05^$0k^lez From 3493516b47bdc07565ab53dadce773ba64f7aaba Mon Sep 17 00:00:00 2001 From: Fagner Lima Date: Thu, 7 Jan 2021 22:36:15 -0300 Subject: [PATCH 05/11] Adiciona listagem de Tasks por Projeto --- .../Repository/TaskRepositoryInterface.php | 3 +++ src/Domain/Services/TaskService.php | 6 ++++++ src/Infrastructure/Controller/TaskController.php | 16 +++++++++++++++- src/Infrastructure/Repository/TaskRepository.php | 11 +++++++++++ templates/header.html.twig | 15 --------------- templates/lista-projetos.html.twig | 5 ++++- templates/lista-tasks.html.twig | 2 +- templates/novo-task.html.twig | 4 ++-- 8 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/Domain/Repository/TaskRepositoryInterface.php b/src/Domain/Repository/TaskRepositoryInterface.php index 4f4231b..a0840f2 100644 --- a/src/Domain/Repository/TaskRepositoryInterface.php +++ b/src/Domain/Repository/TaskRepositoryInterface.php @@ -2,6 +2,7 @@ namespace App\Domain\Repository; +use \App\Domain\Model\Projeto; use \App\Domain\Model\Task; /** @@ -13,4 +14,6 @@ interface TaskRepositoryInterface public function salvar(Task $task): void; public function listar(): array; + + public function listarPorProjeto(Projeto $projeto); } diff --git a/src/Domain/Services/TaskService.php b/src/Domain/Services/TaskService.php index db974a8..7055265 100644 --- a/src/Domain/Services/TaskService.php +++ b/src/Domain/Services/TaskService.php @@ -2,6 +2,7 @@ namespace App\Domain\Services; +use App\Domain\Model\Projeto; use App\Domain\Model\Task; use App\Domain\Repository\TaskRepositoryInterface; @@ -41,4 +42,9 @@ public function listar(): array { return $this->taskRepository->listar(); } + + public function listarPorProjeto(Projeto $projeto): array + { + return $this->taskRepository->listarPorProjeto($projeto); + } } diff --git a/src/Infrastructure/Controller/TaskController.php b/src/Infrastructure/Controller/TaskController.php index eb17a55..d68ce56 100644 --- a/src/Infrastructure/Controller/TaskController.php +++ b/src/Infrastructure/Controller/TaskController.php @@ -38,6 +38,20 @@ public function listarTasks() ]); } + /** + * @Route("/projeto/{projeto}", name="task_projeto_listar") + * @ParamConverter("projeto", class="App\Domain\Model\Projeto") + * @param Projeto $projeto + */ + public function listarTasksPorProjeto(Projeto $projeto) + { + $tasks = $this->taskService->listarPorProjeto($projeto); + + return $this->render('lista-tasks.html.twig', [ + 'tasks' => $tasks + ]); + } + /** * @Route("/atribuir/{task}" , name="atribuir_task") * @ParamConverter("task", class="App\Domain\Model\Task") @@ -93,7 +107,7 @@ public function cadastrar(Projeto $projeto, Request $request) } /** - * @Route("/editar/{task}", name="editar_task", methods={"GET", "POST"}) + * @Route("/editar/{task}", name="task_editar", methods={"GET", "POST"}) * @ParamConverter("task", class="App\Domain\Model\Task") */ public function editar(Task $task, Request $request) diff --git a/src/Infrastructure/Repository/TaskRepository.php b/src/Infrastructure/Repository/TaskRepository.php index 94ae5e1..3f8381d 100644 --- a/src/Infrastructure/Repository/TaskRepository.php +++ b/src/Infrastructure/Repository/TaskRepository.php @@ -2,6 +2,7 @@ namespace App\Infrastructure\Repository; +use App\Domain\Model\Projeto; use App\Domain\Model\Task; use App\Domain\Repository\TaskRepositoryInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; @@ -36,4 +37,14 @@ public function listar(): array { return $this->findAll(); } + + public function listarPorProjeto(Projeto $projeto) + { + return $this->createQueryBuilder('t') + ->andWhere('t.projeto = :projeto') + ->setParameter('projeto', $projeto->getId()) + ->orderBy('t.id', 'ASC') + ->getQuery() + ->getResult(); + } } diff --git a/templates/header.html.twig b/templates/header.html.twig index 8995abd..82ce558 100644 --- a/templates/header.html.twig +++ b/templates/header.html.twig @@ -84,21 +84,6 @@ - - diff --git a/templates/lista-projetos.html.twig b/templates/lista-projetos.html.twig index 25d78c4..d1005f2 100644 --- a/templates/lista-projetos.html.twig +++ b/templates/lista-projetos.html.twig @@ -33,7 +33,10 @@ {{ projeto.descricao }} {{ projeto.gerente }} {{ projeto.dtCadastro| date("m/d/Y") }} - + + + + diff --git a/templates/lista-tasks.html.twig b/templates/lista-tasks.html.twig index 9dc8d62..ce9c4ee 100644 --- a/templates/lista-tasks.html.twig +++ b/templates/lista-tasks.html.twig @@ -50,7 +50,7 @@ {{ task.dtCadastro| date("m/d/Y") }} {{ task.dtConclusao| date("m/d/Y") }} - + {# diff --git a/templates/novo-task.html.twig b/templates/novo-task.html.twig index 17c7bc5..bcb9767 100644 --- a/templates/novo-task.html.twig +++ b/templates/novo-task.html.twig @@ -28,7 +28,7 @@ {{ form_row(form.status) }} - + @@ -38,7 +38,7 @@ - Cadastrar + Salvar From e12f6c127b6ec9d5c657a8461cfee80b9adbf71e Mon Sep 17 00:00:00 2001 From: Fagner Lima Date: Fri, 8 Jan 2021 09:32:25 -0300 Subject: [PATCH 06/11] Atualiza .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 843f729..edd7a45 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ ###< symfony/framework-bundle ### /.idea/ /nbproject/ +.project From eded99db4adae7ce56aca8e3c5bd4998118ee0bd Mon Sep 17 00:00:00 2001 From: Fagner Lima Date: Fri, 8 Jan 2021 09:34:48 -0300 Subject: [PATCH 07/11] Adiciona nome do projeto na lista de tasks --- src/Infrastructure/Controller/TaskController.php | 3 ++- templates/lista-tasks.html.twig | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/Controller/TaskController.php b/src/Infrastructure/Controller/TaskController.php index d68ce56..c59417b 100644 --- a/src/Infrastructure/Controller/TaskController.php +++ b/src/Infrastructure/Controller/TaskController.php @@ -48,7 +48,8 @@ public function listarTasksPorProjeto(Projeto $projeto) $tasks = $this->taskService->listarPorProjeto($projeto); return $this->render('lista-tasks.html.twig', [ - 'tasks' => $tasks + 'tasks' => $tasks, + 'projeto' => $projeto ]); } diff --git a/templates/lista-tasks.html.twig b/templates/lista-tasks.html.twig index ce9c4ee..3c37b0c 100644 --- a/templates/lista-tasks.html.twig +++ b/templates/lista-tasks.html.twig @@ -4,6 +4,7 @@
Lista de Tasks
+

Projeto: {{ projeto.nome }}

From 6ea47418a22ef2120995baf1b0799b8873f1a225 Mon Sep 17 00:00:00 2001 From: Fagner Lima Date: Fri, 8 Jan 2021 09:59:40 -0300 Subject: [PATCH 08/11] =?UTF-8?q?Adiciona=20exclus=C3=A3o=20de=20Task?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Data/tasks.db | Bin 45056 -> 45056 bytes src/Domain/Form/Type/TaskType.php | 2 +- .../Repository/TaskRepositoryInterface.php | 2 + src/Domain/Services/TaskService.php | 5 + .../Controller/TaskController.php | 27 ++-- .../Repository/TaskRepository.php | 6 + templates/lista-tasks.html.twig | 142 +++++++++--------- templates/novo-task.html.twig | 1 + 8 files changed, 102 insertions(+), 83 deletions(-) diff --git a/Data/tasks.db b/Data/tasks.db index 031dd4c1ccbc28f8c5b6b31e58bed518cbfe21bb..0128c977108193a361c934b11e0118ea6a4a56e6 100644 GIT binary patch delta 346 zcmZp8z|`=7X@WH4m5DOWj8`@$%-5GzNn&w!u|i6!LLyK;B_F6NS0P^ksGy{@Si#7^$WYe+h%6Kg46MM2 z1&bJ}4M0=bAjWR4w%yOj7&WmmtUgzTgCP*)9B0Rr%;e1cJfMS;@=Fdc&Q~Z%EJ{=; zO3lqLOD$3e0Xm0hYvCrPRwUfbha*0f!Iy01}94 Ad;kCd delta 83 zcmZp8z|`=7X@WH4nTayajAu3`%-5Gz;^jHWz{XX=$W_9(g3p-Sj<=foC;Ladd('nome', TextType::class, ['label' => false, 'attr' => ['placeholder' => 'Nome do Projeto ']]) + ->add('nome', TextType::class, ['label' => false, 'attr' => ['placeholder' => 'Nome da Task ']]) ->add('descricao', TextareaType::class) ->add('dtCadastro', DateType::class, [ 'label' => 'Data de Cadastro', diff --git a/src/Domain/Repository/TaskRepositoryInterface.php b/src/Domain/Repository/TaskRepositoryInterface.php index a0840f2..f0cf492 100644 --- a/src/Domain/Repository/TaskRepositoryInterface.php +++ b/src/Domain/Repository/TaskRepositoryInterface.php @@ -16,4 +16,6 @@ public function salvar(Task $task): void; public function listar(): array; public function listarPorProjeto(Projeto $projeto); + + public function deletar(Task $task): void; } diff --git a/src/Domain/Services/TaskService.php b/src/Domain/Services/TaskService.php index 7055265..3d70eb6 100644 --- a/src/Domain/Services/TaskService.php +++ b/src/Domain/Services/TaskService.php @@ -47,4 +47,9 @@ public function listarPorProjeto(Projeto $projeto): array { return $this->taskRepository->listarPorProjeto($projeto); } + + public function deletar(Task $task): void + { + $this->taskRepository->deletar($task); + } } diff --git a/src/Infrastructure/Controller/TaskController.php b/src/Infrastructure/Controller/TaskController.php index c59417b..fce3a33 100644 --- a/src/Infrastructure/Controller/TaskController.php +++ b/src/Infrastructure/Controller/TaskController.php @@ -82,7 +82,9 @@ public function atribuir(Task $task) } /** - * @Route("/cadastrar/{projeto}", name="cadastrar_task", methods={"GET", "POST"}) + * @Route("/cadastrar/{projeto}", name="task_cadastrar", methods={"GET", "POST"}) + * @ParamConverter("projeto", class="App\Domain\Model\Projeto") + * @param Projeto $projeto */ public function cadastrar(Projeto $projeto, Request $request) { @@ -99,11 +101,12 @@ public function cadastrar(Projeto $projeto, Request $request) $this->addFlash('success','Task Cadastrada com sucesso'); - return $this->redirect('/projetos/visualizar/'.$projeto->getId()); + return $this->redirect('/tasks/projeto/'.$projeto->getId()); } return $this->render('novo-task.html.twig', [ - 'form' => $form->createView(), 'projeto' => $projeto + 'form' => $form->createView(), + 'projeto' => $projeto ]); } @@ -125,7 +128,7 @@ public function editar(Task $task, Request $request) $this->addFlash('success','Task Cadastrada com sucesso'); - return $this->redirect('/tasks/listar'); + return $this->redirect('/tasks/projeto/' . $task->getProjeto()->getId()); } return $this->render('novo-task.html.twig', [ @@ -135,21 +138,17 @@ public function editar(Task $task, Request $request) } /** - * @Route("/deletar/{atribuicao}", name="deletar_task", methods={"GET", "POST"}) - * @ParamConverter("atribuicao", class="App\Domain\Model\UsuarioAtribuicao") + * @Route("/deletar/{task}", name="task_deletar", methods={"GET", "POST"}) + * @ParamConverter("task", class="App\Domain\Model\Task") */ - public function deletar(UsuarioAtribuicao $atribuicao) + public function deletar(Task $task) { - $doctrine = $this->getDoctrine()->getManager(); - $task = $atribuicao->getTask(); - - $doctrine->remove($atribuicao); - $doctrine->remove($task); - $doctrine->flush(); + $idProjeto = $task->getProjeto()->getId(); + $this->taskService->deletar($task); $this->addFlash('success','Task Deletada com sucesso'); - return $this->redirect('/usuario/tasks'); + return $this->redirect('/tasks/projeto/' . $idProjeto); } } diff --git a/src/Infrastructure/Repository/TaskRepository.php b/src/Infrastructure/Repository/TaskRepository.php index 3f8381d..dd7c27b 100644 --- a/src/Infrastructure/Repository/TaskRepository.php +++ b/src/Infrastructure/Repository/TaskRepository.php @@ -47,4 +47,10 @@ public function listarPorProjeto(Projeto $projeto) ->getQuery() ->getResult(); } + + public function deletar(Task $task): void + { + $this->getEntityManager()->remove($task); + $this->getEntityManager()->flush(); + } } diff --git a/templates/lista-tasks.html.twig b/templates/lista-tasks.html.twig index 3c37b0c..4a2f12a 100644 --- a/templates/lista-tasks.html.twig +++ b/templates/lista-tasks.html.twig @@ -1,73 +1,79 @@ {% include 'header.html.twig' %} -
-
-
-
Lista de Tasks
-

Projeto: {{ projeto.nome }}

-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - {% for task in tasks %} - {% if task.status.id == 1 %} - - {% elseif task.status.id == 2 %} - - {% elseif task.status.id == 3 %} - - {% elseif task.status.id == 4 %} - - {% else %} - - {% endif %} - - - - - - - - - {% endfor %} - -
NomeDescricaoProjetoStatusData CadastroData Conclusão
NomeDescricaoProjetoStatusData CadastroData Conclusão
{{ task.nome }}{{ task.descricao }}{{ task.projeto.nome }}{{ task.status.descricao }}{{ task.dtCadastro| date("m/d/Y") }}{{ task.dtConclusao| date("m/d/Y") }} - - - - {# - - #} -
-
-
-
- -
- +
+
+
+
Lista de Tasks
+

Projeto: {{ projeto.nome }}

+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + {% for task in tasks %} + {% if task.status.id == 1 %} + + {% elseif task.status.id == 2 %} + + {% elseif task.status.id == 3 %} + + {% elseif task.status.id == 4 %} + + {% else %} + + {% endif %} + + + + + + + + + {% endfor %} + +
NomeDescricaoProjetoStatusData CadastroData Conclusão
NomeDescricaoProjetoStatusData CadastroData Conclusão
{{ task.nome }}{{ task.descricao }}{{ task.projeto.nome }}{{ task.status.descricao }}{{ task.dtCadastro| date("m/d/Y") }}{{ task.dtConclusao| date("m/d/Y") }} + + + + + + +
+
+
+
+ +
{% include 'footer.html.twig' %} diff --git a/templates/novo-task.html.twig b/templates/novo-task.html.twig index bcb9767..06718a6 100644 --- a/templates/novo-task.html.twig +++ b/templates/novo-task.html.twig @@ -2,6 +2,7 @@

Cadastrar Nova Task

+

Projeto: {{ projeto.nome }}

{{ form_start(form) }}
From 75b1511bcf2f00937fecc2210e1453b7e394dfda Mon Sep 17 00:00:00 2001 From: Fagner Lima Date: Fri, 8 Jan 2021 10:26:28 -0300 Subject: [PATCH 09/11] Adiciona CRUD de Status --- Data/tasks.db | Bin 45056 -> 45056 bytes src/Domain/Form/Type/StatusType.php | 35 ++++++++ .../Repository/StatusRepositoryInterface.php | 16 ++++ src/Domain/Services/StatusService.php | 44 ++++++++++ .../Controller/StatusController.php | 82 ++++++++++++++++++ .../Controller/TaskController.php | 13 +-- .../Repository/StatusRepository.php | 39 +++++++++ templates/header.html.twig | 14 +++ templates/lista-status.html.twig | 50 +++++++++++ templates/novo-status.html.twig | 26 ++++++ 10 files changed, 309 insertions(+), 10 deletions(-) create mode 100644 src/Domain/Form/Type/StatusType.php create mode 100644 src/Domain/Repository/StatusRepositoryInterface.php create mode 100644 src/Domain/Services/StatusService.php create mode 100644 src/Infrastructure/Controller/StatusController.php create mode 100644 src/Infrastructure/Repository/StatusRepository.php create mode 100644 templates/lista-status.html.twig create mode 100644 templates/novo-status.html.twig diff --git a/Data/tasks.db b/Data/tasks.db index 0128c977108193a361c934b11e0118ea6a4a56e6..b94bafa6bd6b3551f55bba128040b4aa713f640f 100644 GIT binary patch delta 201 zcmV;)05<=C-~xc)0+1U4*^wMW0ok!&h%W&Klj$!W1po?k4+66cFtrQ>4yXV%k%2L@ z_B^ry1ONa4T9JWP34shA2mogRGXayaK0}kRH42kjJPMNsKQFV9KXVWe1`m+|58)5W z54sPL51VG0EU02@YSV`yPyVE_vT z0{|UGZ6H)-b97~sx?f5V1`pl<5Bv}I5AYA_59ANtvms!^50Ov@1_c8F0R{%M4>tfck%2L@ z_B^ry34se92mogRGYOLmKSPsbJQadd('descricao', TextType::class, ['label' => false, 'attr' => ['placeholder' => 'Descrição da Task ']]) + ->add('salvar', SubmitType::class); + } + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Status::class + ]); + } +} diff --git a/src/Domain/Repository/StatusRepositoryInterface.php b/src/Domain/Repository/StatusRepositoryInterface.php new file mode 100644 index 0000000..d45bba5 --- /dev/null +++ b/src/Domain/Repository/StatusRepositoryInterface.php @@ -0,0 +1,16 @@ +statusRepository = $statusRepository; + } + + /** + * @param Status $status + */ + public function salvar(Status $status) + { + $this->statusRepository->salvar($status); + } + + /** + * @return array + */ + public function listar(): array + { + return $this->statusRepository->listar(); + } +} diff --git a/src/Infrastructure/Controller/StatusController.php b/src/Infrastructure/Controller/StatusController.php new file mode 100644 index 0000000..0a06dd0 --- /dev/null +++ b/src/Infrastructure/Controller/StatusController.php @@ -0,0 +1,82 @@ +statusService = $statusService; + } + + /** + * @Route("/listar", name="status_listar") + */ + public function listarStatus() + { + $statusList = $this->statusService->listar(); + + return $this->render('lista-status.html.twig', [ + 'statusList' => $statusList + ]); + } + + /** + * @Route("/cadastrar", name="status_cadastrar", methods={"GET", "POST"}) + */ + public function cadastrar(Request $request) + { + $form = $this->createForm(StatusType::class); + $form->handleRequest($request); + + if ($form->isSubmitted()) { + $status = $form->getData(); + $this->statusService->salvar($status); + + $this->addFlash('success','Status Cadastrada com sucesso'); + + return $this->redirect('/status/listar'); + } + + return $this->render('novo-status.html.twig', [ + 'form' => $form->createView() + ]); + } + + /** + * @Route("/editar/{status}", name="status_editar", methods={"GET", "POST"}) + * @ParamConverter("status", class="App\Domain\Model\Status") + */ + public function editar(Status $status, Request $request) + { + $form = $this->createForm(StatusType::class, $status); + $form->handleRequest($request); + + if ($form->isSubmitted()) { + $status = $form->getData(); + $this->statusService->salvar($status); + + $this->addFlash('success','Status alterado com sucesso'); + + return $this->redirect('/status/listar'); + } + + return $this->render('novo-status.html.twig', [ + 'form' => $form->createView() + ]); + } + +} diff --git a/src/Infrastructure/Controller/TaskController.php b/src/Infrastructure/Controller/TaskController.php index fce3a33..413b986 100644 --- a/src/Infrastructure/Controller/TaskController.php +++ b/src/Infrastructure/Controller/TaskController.php @@ -11,7 +11,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; /** @@ -94,10 +93,7 @@ public function cadastrar(Projeto $projeto, Request $request) if ($form->isSubmitted()) { $task = $form->getData(); $task->setProjeto($projeto); - $doctrine = $this->getDoctrine()->getManager(); - - $doctrine->persist($task); - $doctrine->flush(); + $this->taskService->salvar($task); $this->addFlash('success','Task Cadastrada com sucesso'); @@ -121,12 +117,9 @@ public function editar(Task $task, Request $request) if ($form->isSubmitted()) { $task = $form->getData(); - $doctrine = $this->getDoctrine()->getManager(); - - $doctrine->persist($task); - $doctrine->flush(); + $this->taskService->salvar($task); - $this->addFlash('success','Task Cadastrada com sucesso'); + $this->addFlash('success','Task alterada com sucesso'); return $this->redirect('/tasks/projeto/' . $task->getProjeto()->getId()); } diff --git a/src/Infrastructure/Repository/StatusRepository.php b/src/Infrastructure/Repository/StatusRepository.php new file mode 100644 index 0000000..cdbcd71 --- /dev/null +++ b/src/Infrastructure/Repository/StatusRepository.php @@ -0,0 +1,39 @@ +getEntityManager()->persist($status); + $this->getEntityManager()->flush(); + } + + /** + * @return array + */ + public function listar(): array + { + return $this->findAll(); + } +} diff --git a/templates/header.html.twig b/templates/header.html.twig index 82ce558..4da112c 100644 --- a/templates/header.html.twig +++ b/templates/header.html.twig @@ -85,6 +85,20 @@
+ + diff --git a/templates/lista-status.html.twig b/templates/lista-status.html.twig new file mode 100644 index 0000000..f5b71e2 --- /dev/null +++ b/templates/lista-status.html.twig @@ -0,0 +1,50 @@ +{% include 'header.html.twig' %} + +
+
+
+
Lista de Status
+
+
+ +
+ + + + + + + + + + + + + + + {% for status in statusList %} + + + + + {% endfor %} + +
Descricao
Descricao
{{ status.descricao }} + + + +
+
+
+
+ +
+ +{% include 'footer.html.twig' %} diff --git a/templates/novo-status.html.twig b/templates/novo-status.html.twig new file mode 100644 index 0000000..37b9991 --- /dev/null +++ b/templates/novo-status.html.twig @@ -0,0 +1,26 @@ +{% include 'header.html.twig' %} + +
+

Cadastrar Novo Status

+ {{ form_start(form) }} +
+
+ {{ form_row(form.descricao) }} +
+
+ + + + + Voltar + + +
+
+ +{% include 'footer.html.twig' %} From bd7e6a1f28f22f9502a5cf8f0030b5601f801cdc Mon Sep 17 00:00:00 2001 From: Fagner Lima Date: Fri, 8 Jan 2021 10:27:49 -0300 Subject: [PATCH 10/11] Atualiza o banco de dados --- Data/tasks.db | Bin 45056 -> 45056 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Data/tasks.db b/Data/tasks.db index b94bafa6bd6b3551f55bba128040b4aa713f640f..4bb48646b012b0e34b80e64ba0e711b572f7ec0a 100644 GIT binary patch delta 28 kcmZp8z|`=7X@WH4t%)+ujJGx>ytAA9!%Av%hW(5J0JCfilmGw# delta 32 ocmZp8z|`=7X@WH4&51J3j5jwXytA9U!IW!qlnvMBB>Q;<0O6wzXaE2J From dcec786b38f953c47ebc3153cd9e1d0a72662950 Mon Sep 17 00:00:00 2001 From: Fagner Lima Date: Fri, 8 Jan 2021 10:31:11 -0300 Subject: [PATCH 11/11] =?UTF-8?q?Desabilita=20funcionalidades=20n=C3=A3o?= =?UTF-8?q?=20implementadas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/header.html.twig | 10 +++++----- templates/usuarios-listar.html.twig | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/templates/header.html.twig b/templates/header.html.twig index 4da112c..b8f08b7 100644 --- a/templates/header.html.twig +++ b/templates/header.html.twig @@ -34,7 +34,7 @@
diff --git a/templates/usuarios-listar.html.twig b/templates/usuarios-listar.html.twig index ae08e38..7bbee61 100644 --- a/templates/usuarios-listar.html.twig +++ b/templates/usuarios-listar.html.twig @@ -12,7 +12,7 @@ Email roles Password - Visualizar +{# Visualizar#} @@ -22,7 +22,7 @@ Email roles Password - Visualizar +{# Visualizar#} @@ -32,11 +32,11 @@ {{ usuario.email }} {{ usuario.rolesString }} *********** - + {# - + #} {% endfor %}