From 009289b2825b2518fac59aedb4820e67022a0e2a Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Thu, 11 Jan 2018 15:34:53 +0800 Subject: [PATCH 1/5] Add ACL security checks for role views and controllers --- src/Controller/RoleController.php | 57 +++++++++++++++++++++++-------- templates/role/form.html.twig | 2 +- templates/role/list.html.twig | 16 ++++----- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/Controller/RoleController.php b/src/Controller/RoleController.php index f527e1f9..465ca2bb 100644 --- a/src/Controller/RoleController.php +++ b/src/Controller/RoleController.php @@ -25,22 +25,18 @@ class RoleController extends BaseController public function index() { + $this->denyAccessUnlessGranted('role.list', null, 'No access.'); + $params = $this->initParameters('role_list'); - $qb = $this->getDoctrine() - ->getRepository(Role::class) - ->createQueryBuilder('q') - ->getQuery(); - - // get all rows - $rows = $qb->getResult(Query::HYDRATE_ARRAY); - // response return $this->render('role/list.html.twig', $params); } public function rows(Request $req) { + $this->denyAccessUnlessGranted('role.list', null, 'No access.'); + // build query $qb = $this->getDoctrine() ->getRepository(Role::class) @@ -89,15 +85,38 @@ class RoleController extends BaseController } // get rows for this page - $rows = $query->setFirstResult($offset) + $obj_rows = $query->setFirstResult($offset) ->setMaxResults($perpage) ->getQuery() - ->getResult(Query::HYDRATE_ARRAY); + ->getResult(); - // add crud urls - foreach ($rows as $index => $row) { - $rows[$index]['update_url'] = $this->generateUrl('role_update', ['id' => $row['id']]); - $rows[$index]['delete_url'] = $this->generateUrl('role_delete', ['id' => $row['id']]); + // process rows + $rows = []; + foreach ($obj_rows as $orow) { + // add row data + $row['id'] = $orow->getID(); + $row['name'] = $orow->getName(); + + // add row metadata + $row['meta'] = [ + 'update_url' => '', + 'delete_url' => '' + ]; + + // check if they have access to super admin users + if (!$this->isGranted('user.role.sadmin') && $orow->isSuperAdmin()) + { + $rows[] = $row; + continue; + } + + // add crud urls + if ($this->isGranted('user.update')) + $row['meta']['update_url'] = $this->generateUrl('role_update', ['id' => $row['id']]); + if ($this->isGranted('user.delete')) + $row['meta']['delete_url'] = $this->generateUrl('role_delete', ['id' => $row['id']]); + + $rows[] = $row; } // response @@ -116,6 +135,8 @@ class RoleController extends BaseController public function create() { + $this->denyAccessUnlessGranted('role.add', null, 'No access.'); + $params = $this->initParameters('role_list'); $this->padACLHierarchy($params); @@ -126,6 +147,8 @@ class RoleController extends BaseController public function createSubmit(Request $req, ValidatorInterface $validator) { + $this->denyAccessUnlessGranted('role.add', null, 'No access.'); + // create new row $em = $this->getDoctrine()->getManager(); $row = new Role(); @@ -173,6 +196,8 @@ class RoleController extends BaseController public function update($id) { + $this->denyAccessUnlessGranted('role.update', null, 'No access.'); + $params = $this->initParameters('role_list'); $this->padACLHierarchy($params); @@ -193,6 +218,8 @@ class RoleController extends BaseController public function updateSubmit(Request $req, ValidatorInterface $validator, $id) { + $this->denyAccessUnlessGranted('role.update', null, 'No access.'); + // get row data $em = $this->getDoctrine()->getManager(); $row = $em->getRepository(Role::class)->find($id); @@ -250,6 +277,8 @@ class RoleController extends BaseController public function destroy($id) { + $this->denyAccessUnlessGranted('role.delete', null, 'No access.'); + $params = $this->initParameters('role_list'); // get row data diff --git a/templates/role/form.html.twig b/templates/role/form.html.twig index f7c3fd1f..39686605 100644 --- a/templates/role/form.html.twig +++ b/templates/role/form.html.twig @@ -56,7 +56,7 @@
diff --git a/templates/role/list.html.twig b/templates/role/list.html.twig index 89d4d833..4332f3eb 100644 --- a/templates/role/list.html.twig +++ b/templates/role/list.html.twig @@ -18,12 +18,6 @@
- {% for message in app.flashes('success') %} - - {% endfor %}
@@ -96,10 +90,14 @@ sortable: false, overflow: 'visible', template: function (row, index, datatable) { - var actions = ''; + var actions = ''; + + if (row.meta.update_url != '') { + actions += ''; + } - if (row.id != 'ROLE_SUPER_ADMIN') { - actions += ''; + if (row.meta.delete_url != '') { + actions += ''; } return actions; From e780c56aa2514521832cb839fd1a2462b1880fe9 Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Thu, 11 Jan 2018 23:53:56 +0800 Subject: [PATCH 2/5] Add crud, asserts, getters and setters for auxilliary battery entities --- .../BatteryManufacturerController.php | 259 ++++++++++++++++++ src/Controller/BatteryModelController.php | 259 ++++++++++++++++++ src/Controller/BatterySizeController.php | 259 ++++++++++++++++++ src/Entity/BatteryManufacturer.php | 40 +++ src/Entity/BatteryModel.php | 43 ++- src/Entity/BatterySize.php | 42 ++- templates/battery-manufacturer/form.html.twig | 132 +++++++++ templates/battery-manufacturer/list.html.twig | 152 ++++++++++ templates/battery-model/form.html.twig | 132 +++++++++ templates/battery-model/list.html.twig | 152 ++++++++++ templates/battery-size/form.html.twig | 132 +++++++++ templates/battery-size/list.html.twig | 152 ++++++++++ 12 files changed, 1752 insertions(+), 2 deletions(-) create mode 100644 src/Controller/BatteryManufacturerController.php create mode 100644 src/Controller/BatteryModelController.php create mode 100644 src/Controller/BatterySizeController.php create mode 100644 templates/battery-manufacturer/form.html.twig create mode 100644 templates/battery-manufacturer/list.html.twig create mode 100644 templates/battery-model/form.html.twig create mode 100644 templates/battery-model/list.html.twig create mode 100644 templates/battery-size/form.html.twig create mode 100644 templates/battery-size/list.html.twig diff --git a/src/Controller/BatteryManufacturerController.php b/src/Controller/BatteryManufacturerController.php new file mode 100644 index 00000000..18b67c09 --- /dev/null +++ b/src/Controller/BatteryManufacturerController.php @@ -0,0 +1,259 @@ +acl_gen = $acl_gen; + parent::__construct($menu_gen); + } + + public function index() + { + $this->denyAccessUnlessGranted('bmfg.list', null, 'No access.'); + + $params = $this->initParameters('bmfg_list'); + + // response + return $this->render('battery-manufacturer/list.html.twig', $params); + } + + public function rows(Request $req) + { + $this->denyAccessUnlessGranted('bmfg.list', null, 'No access.'); + + // build query + $qb = $this->getDoctrine() + ->getRepository(BatteryManufacturer::class) + ->createQueryBuilder('q'); + + // count total records + $total = $qb->select('COUNT(q)') + ->getQuery() + ->getSingleScalarResult(); + + // get datatable params + $datatable = $req->request->get('datatable'); + + // get current page number + $page = $datatable['pagination']['page'] ?? 1; + + $perpage = $datatable['pagination']['perpage']; + $offset = ($page - 1) * $perpage; + + // add metadata + $meta = [ + 'page' => $page, + 'perpage' => $perpage, + 'pages' => ceil($total / $perpage), + 'total' => $total, + 'sort' => 'asc', + 'field' => 'id' + ]; + + // build query + $query = $qb->select('q'); + + // check if filter is present + if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) { + $query->where('q.name LIKE :filter') + ->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%'); + } + + // check if sorting is present, otherwise use default + if (isset($datatable['sort']['field']) && !empty($datatable['sort']['field'])) { + $order = $datatable['sort']['sort'] ?? 'asc'; + $query->orderBy('q.' . $datatable['sort']['field'], $order); + } else { + $query->orderBy('q.name', 'asc'); + } + + // get rows for this page + $obj_rows = $query->setFirstResult($offset) + ->setMaxResults($perpage) + ->getQuery() + ->getResult(); + + // process rows + $rows = []; + foreach ($obj_rows as $orow) { + // add row data + $row['id'] = $orow->getID(); + $row['name'] = $orow->getName(); + + // add row metadata + $row['meta'] = [ + 'update_url' => '', + 'delete_url' => '' + ]; + + // add crud urls + if ($this->isGranted('user.update')) + $row['meta']['update_url'] = $this->generateUrl('bmfg_update', ['id' => $row['id']]); + if ($this->isGranted('user.delete')) + $row['meta']['delete_url'] = $this->generateUrl('bmfg_delete', ['id' => $row['id']]); + + $rows[] = $row; + } + + // response + return $this->json([ + 'meta' => $meta, + 'data' => $rows + ]); + } + + public function create() + { + $this->denyAccessUnlessGranted('bmfg.add', null, 'No access.'); + + $params = $this->initParameters('bmfg_list'); + + // response + return $this->render('battery-manufacturer/form.html.twig', $params); + } + + public function createSubmit(Request $req, ValidatorInterface $validator) + { + $this->denyAccessUnlessGranted('bmfg.add', null, 'No access.'); + + // create new row + $em = $this->getDoctrine()->getManager(); + $row = new BatteryManufacturer(); + + // set and save values + $row->setName($req->request->get('name')); + + // validate + $errors = $validator->validate($row); + + // initialize error list + $error_array = []; + + // add errors to list + foreach ($errors as $error) { + $error_array[$error->getPropertyPath()] = $error->getMessage(); + } + + // check if any errors were found + if (!empty($error_array)) { + // return validation failure response + return $this->json([ + 'success' => false, + 'errors' => $error_array + ], 422); + } else { + // validated! save the entity + $em->persist($row); + $em->flush(); + + // return successful response + return $this->json([ + 'success' => 'Changes have been saved!' + ]); + } + } + + public function update($id) + { + $this->denyAccessUnlessGranted('bmfg.update', null, 'No access.'); + + $params = $this->initParameters('bmfg_list'); + + // get row data + $em = $this->getDoctrine()->getManager(); + $row = $em->getRepository(BatteryManufacturer::class)->find($id); + + // make sure this row exists + if (empty($row)) + throw $this->createNotFoundException('The item does not exist'); + + $params['row'] = $row; + $params['values'] = []; + + // response + return $this->render('battery-manufacturer/form.html.twig', $params); + } + + public function updateSubmit(Request $req, ValidatorInterface $validator, $id) + { + $this->denyAccessUnlessGranted('bmfg.update', null, 'No access.'); + + // get row data + $em = $this->getDoctrine()->getManager(); + $row = $em->getRepository(BatteryManufacturer::class)->find($id); + + // make sure this row exists + if (empty($row)) + throw $this->createNotFoundException('The item does not exist'); + + // set and save values + $row->setName($req->request->get('name')); + + // validate + $errors = $validator->validate($row); + + // initialize error list + $error_array = []; + + // add errors to list + foreach ($errors as $error) { + $error_array[$error->getPropertyPath()] = $error->getMessage(); + } + + // check if any errors were found + if (!empty($error_array)) { + // return validation failure response + return $this->json([ + 'success' => false, + 'errors' => $error_array + ], 422); + } else { + // validated! save the entity + $em->flush(); + + // return successful response + return $this->json([ + 'success' => 'Changes have been saved!' + ]); + } + } + + public function destroy($id) + { + $this->denyAccessUnlessGranted('bmfg.delete', null, 'No access.'); + + $params = $this->initParameters('bmfg_list'); + + // get row data + $em = $this->getDoctrine()->getManager(); + $row = $em->getRepository(BatteryManufacturer::class)->find($id); + + if (empty($row)) + throw $this->createNotFoundException('The item does not exist'); + + // delete this row + $em->remove($row); + $em->flush(); + + // response + $response = new Response(); + $response->setStatusCode(Response::HTTP_OK); + $response->send(); + } +} diff --git a/src/Controller/BatteryModelController.php b/src/Controller/BatteryModelController.php new file mode 100644 index 00000000..2d9772cc --- /dev/null +++ b/src/Controller/BatteryModelController.php @@ -0,0 +1,259 @@ +acl_gen = $acl_gen; + parent::__construct($menu_gen); + } + + public function index() + { + $this->denyAccessUnlessGranted('bmodel.list', null, 'No access.'); + + $params = $this->initParameters('bmodel_list'); + + // response + return $this->render('battery-model/list.html.twig', $params); + } + + public function rows(Request $req) + { + $this->denyAccessUnlessGranted('bmodel.list', null, 'No access.'); + + // build query + $qb = $this->getDoctrine() + ->getRepository(BatteryModel::class) + ->createQueryBuilder('q'); + + // count total records + $total = $qb->select('COUNT(q)') + ->getQuery() + ->getSingleScalarResult(); + + // get datatable params + $datatable = $req->request->get('datatable'); + + // get current page number + $page = $datatable['pagination']['page'] ?? 1; + + $perpage = $datatable['pagination']['perpage']; + $offset = ($page - 1) * $perpage; + + // add metadata + $meta = [ + 'page' => $page, + 'perpage' => $perpage, + 'pages' => ceil($total / $perpage), + 'total' => $total, + 'sort' => 'asc', + 'field' => 'id' + ]; + + // build query + $query = $qb->select('q'); + + // check if filter is present + if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) { + $query->where('q.name LIKE :filter') + ->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%'); + } + + // check if sorting is present, otherwise use default + if (isset($datatable['sort']['field']) && !empty($datatable['sort']['field'])) { + $order = $datatable['sort']['sort'] ?? 'asc'; + $query->orderBy('q.' . $datatable['sort']['field'], $order); + } else { + $query->orderBy('q.name', 'asc'); + } + + // get rows for this page + $obj_rows = $query->setFirstResult($offset) + ->setMaxResults($perpage) + ->getQuery() + ->getResult(); + + // process rows + $rows = []; + foreach ($obj_rows as $orow) { + // add row data + $row['id'] = $orow->getID(); + $row['name'] = $orow->getName(); + + // add row metadata + $row['meta'] = [ + 'update_url' => '', + 'delete_url' => '' + ]; + + // add crud urls + if ($this->isGranted('user.update')) + $row['meta']['update_url'] = $this->generateUrl('bmodel_update', ['id' => $row['id']]); + if ($this->isGranted('user.delete')) + $row['meta']['delete_url'] = $this->generateUrl('bmodel_delete', ['id' => $row['id']]); + + $rows[] = $row; + } + + // response + return $this->json([ + 'meta' => $meta, + 'data' => $rows + ]); + } + + public function create() + { + $this->denyAccessUnlessGranted('bmodel.add', null, 'No access.'); + + $params = $this->initParameters('bmodel_list'); + + // response + return $this->render('battery-model/form.html.twig', $params); + } + + public function createSubmit(Request $req, ValidatorInterface $validator) + { + $this->denyAccessUnlessGranted('bmodel.add', null, 'No access.'); + + // create new row + $em = $this->getDoctrine()->getManager(); + $row = new BatteryModel(); + + // set and save values + $row->setName($req->request->get('name')); + + // validate + $errors = $validator->validate($row); + + // initialize error list + $error_array = []; + + // add errors to list + foreach ($errors as $error) { + $error_array[$error->getPropertyPath()] = $error->getMessage(); + } + + // check if any errors were found + if (!empty($error_array)) { + // return validation failure response + return $this->json([ + 'success' => false, + 'errors' => $error_array + ], 422); + } else { + // validated! save the entity + $em->persist($row); + $em->flush(); + + // return successful response + return $this->json([ + 'success' => 'Changes have been saved!' + ]); + } + } + + public function update($id) + { + $this->denyAccessUnlessGranted('bmodel.update', null, 'No access.'); + + $params = $this->initParameters('bmodel_list'); + + // get row data + $em = $this->getDoctrine()->getManager(); + $row = $em->getRepository(BatteryModel::class)->find($id); + + // make sure this row exists + if (empty($row)) + throw $this->createNotFoundException('The item does not exist'); + + $params['row'] = $row; + $params['values'] = []; + + // response + return $this->render('battery-model/form.html.twig', $params); + } + + public function updateSubmit(Request $req, ValidatorInterface $validator, $id) + { + $this->denyAccessUnlessGranted('bmodel.update', null, 'No access.'); + + // get row data + $em = $this->getDoctrine()->getManager(); + $row = $em->getRepository(BatteryModel::class)->find($id); + + // make sure this row exists + if (empty($row)) + throw $this->createNotFoundException('The item does not exist'); + + // set and save values + $row->setName($req->request->get('name')); + + // validate + $errors = $validator->validate($row); + + // initialize error list + $error_array = []; + + // add errors to list + foreach ($errors as $error) { + $error_array[$error->getPropertyPath()] = $error->getMessage(); + } + + // check if any errors were found + if (!empty($error_array)) { + // return validation failure response + return $this->json([ + 'success' => false, + 'errors' => $error_array + ], 422); + } else { + // validated! save the entity + $em->flush(); + + // return successful response + return $this->json([ + 'success' => 'Changes have been saved!' + ]); + } + } + + public function destroy($id) + { + $this->denyAccessUnlessGranted('bmodel.delete', null, 'No access.'); + + $params = $this->initParameters('bmodel_list'); + + // get row data + $em = $this->getDoctrine()->getManager(); + $row = $em->getRepository(BatteryModel::class)->find($id); + + if (empty($row)) + throw $this->createNotFoundException('The item does not exist'); + + // delete this row + $em->remove($row); + $em->flush(); + + // response + $response = new Response(); + $response->setStatusCode(Response::HTTP_OK); + $response->send(); + } +} diff --git a/src/Controller/BatterySizeController.php b/src/Controller/BatterySizeController.php new file mode 100644 index 00000000..ad886272 --- /dev/null +++ b/src/Controller/BatterySizeController.php @@ -0,0 +1,259 @@ +acl_gen = $acl_gen; + parent::__construct($menu_gen); + } + + public function index() + { + $this->denyAccessUnlessGranted('bsize.list', null, 'No access.'); + + $params = $this->initParameters('bsize_list'); + + // response + return $this->render('battery-size/list.html.twig', $params); + } + + public function rows(Request $req) + { + $this->denyAccessUnlessGranted('bsize.list', null, 'No access.'); + + // build query + $qb = $this->getDoctrine() + ->getRepository(BatterySize::class) + ->createQueryBuilder('q'); + + // count total records + $total = $qb->select('COUNT(q)') + ->getQuery() + ->getSingleScalarResult(); + + // get datatable params + $datatable = $req->request->get('datatable'); + + // get current page number + $page = $datatable['pagination']['page'] ?? 1; + + $perpage = $datatable['pagination']['perpage']; + $offset = ($page - 1) * $perpage; + + // add metadata + $meta = [ + 'page' => $page, + 'perpage' => $perpage, + 'pages' => ceil($total / $perpage), + 'total' => $total, + 'sort' => 'asc', + 'field' => 'id' + ]; + + // build query + $query = $qb->select('q'); + + // check if filter is present + if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) { + $query->where('q.name LIKE :filter') + ->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%'); + } + + // check if sorting is present, otherwise use default + if (isset($datatable['sort']['field']) && !empty($datatable['sort']['field'])) { + $order = $datatable['sort']['sort'] ?? 'asc'; + $query->orderBy('q.' . $datatable['sort']['field'], $order); + } else { + $query->orderBy('q.name', 'asc'); + } + + // get rows for this page + $obj_rows = $query->setFirstResult($offset) + ->setMaxResults($perpage) + ->getQuery() + ->getResult(); + + // process rows + $rows = []; + foreach ($obj_rows as $orow) { + // add row data + $row['id'] = $orow->getID(); + $row['name'] = $orow->getName(); + + // add row metadata + $row['meta'] = [ + 'update_url' => '', + 'delete_url' => '' + ]; + + // add crud urls + if ($this->isGranted('user.update')) + $row['meta']['update_url'] = $this->generateUrl('bsize_update', ['id' => $row['id']]); + if ($this->isGranted('user.delete')) + $row['meta']['delete_url'] = $this->generateUrl('bsize_delete', ['id' => $row['id']]); + + $rows[] = $row; + } + + // response + return $this->json([ + 'meta' => $meta, + 'data' => $rows + ]); + } + + public function create() + { + $this->denyAccessUnlessGranted('bsize.add', null, 'No access.'); + + $params = $this->initParameters('bsize_list'); + + // response + return $this->render('battery-size/form.html.twig', $params); + } + + public function createSubmit(Request $req, ValidatorInterface $validator) + { + $this->denyAccessUnlessGranted('bsize.add', null, 'No access.'); + + // create new row + $em = $this->getDoctrine()->getManager(); + $row = new BatterySize(); + + // set and save values + $row->setName($req->request->get('name')); + + // validate + $errors = $validator->validate($row); + + // initialize error list + $error_array = []; + + // add errors to list + foreach ($errors as $error) { + $error_array[$error->getPropertyPath()] = $error->getMessage(); + } + + // check if any errors were found + if (!empty($error_array)) { + // return validation failure response + return $this->json([ + 'success' => false, + 'errors' => $error_array + ], 422); + } else { + // validated! save the entity + $em->persist($row); + $em->flush(); + + // return successful response + return $this->json([ + 'success' => 'Changes have been saved!' + ]); + } + } + + public function update($id) + { + $this->denyAccessUnlessGranted('bsize.update', null, 'No access.'); + + $params = $this->initParameters('bsize_list'); + + // get row data + $em = $this->getDoctrine()->getManager(); + $row = $em->getRepository(BatterySize::class)->find($id); + + // make sure this row exists + if (empty($row)) + throw $this->createNotFoundException('The item does not exist'); + + $params['row'] = $row; + $params['values'] = []; + + // response + return $this->render('battery-size/form.html.twig', $params); + } + + public function updateSubmit(Request $req, ValidatorInterface $validator, $id) + { + $this->denyAccessUnlessGranted('bsize.update', null, 'No access.'); + + // get row data + $em = $this->getDoctrine()->getManager(); + $row = $em->getRepository(BatterySize::class)->find($id); + + // make sure this row exists + if (empty($row)) + throw $this->createNotFoundException('The item does not exist'); + + // set and save values + $row->setName($req->request->get('name')); + + // validate + $errors = $validator->validate($row); + + // initialize error list + $error_array = []; + + // add errors to list + foreach ($errors as $error) { + $error_array[$error->getPropertyPath()] = $error->getMessage(); + } + + // check if any errors were found + if (!empty($error_array)) { + // return validation failure response + return $this->json([ + 'success' => false, + 'errors' => $error_array + ], 422); + } else { + // validated! save the entity + $em->flush(); + + // return successful response + return $this->json([ + 'success' => 'Changes have been saved!' + ]); + } + } + + public function destroy($id) + { + $this->denyAccessUnlessGranted('bsize.delete', null, 'No access.'); + + $params = $this->initParameters('bsize_list'); + + // get row data + $em = $this->getDoctrine()->getManager(); + $row = $em->getRepository(BatterySize::class)->find($id); + + if (empty($row)) + throw $this->createNotFoundException('The item does not exist'); + + // delete this row + $em->remove($row); + $em->flush(); + + // response + $response = new Response(); + $response->setStatusCode(Response::HTTP_OK); + $response->send(); + } +} diff --git a/src/Entity/BatteryManufacturer.php b/src/Entity/BatteryManufacturer.php index dc434e32..9cd44bf6 100644 --- a/src/Entity/BatteryManufacturer.php +++ b/src/Entity/BatteryManufacturer.php @@ -4,6 +4,7 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; +use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity @@ -22,6 +23,7 @@ class BatteryManufacturer // name /** * @ORM\Column(type="string", length=80) + * @Assert\NotBlank() */ protected $name; @@ -35,4 +37,42 @@ class BatteryManufacturer { $this->batteries = new ArrayCollection(); } + + public function getID() + { + return $this->id; + } + + public function setName($name) + { + $this->name = $name; + return $this; + } + + public function getName() + { + return $this->name; + } + + public function addBattery(Battery $battery) + { + $this->batteries->add($battery); + return $this; + } + + public function clearBatteries() + { + $this->batteries->clear(); + return $this; + } + + public function getBatteries() + { + // has to return set of strings because symfony is trying to move away from role objects + $str_batteries = []; + foreach ($this->batteries as $battery) + $str_batteries[] = $this->getName() . " " . $battery->getModel()->getName() . " " . $battery->getSize()->getName(); + + return $str_batteries; + } } diff --git a/src/Entity/BatteryModel.php b/src/Entity/BatteryModel.php index 17a22f14..678c2592 100644 --- a/src/Entity/BatteryModel.php +++ b/src/Entity/BatteryModel.php @@ -3,6 +3,8 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; +use Doctrine\Common\Collections\ArrayCollection; +use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity @@ -21,12 +23,13 @@ class BatteryModel // name /** * @ORM\Column(type="string", length=80) + * @Assert\NotBlank() */ protected $name; // battery /** - * @ORM\OneToMany(targetEntity="Battery", mappedBy="manufacturer") + * @ORM\OneToMany(targetEntity="Battery", mappedBy="model") */ protected $batteries; @@ -34,4 +37,42 @@ class BatteryModel { $this->batteries = new ArrayCollection(); } + + public function getID() + { + return $this->id; + } + + public function setName($name) + { + $this->name = $name; + return $this; + } + + public function getName() + { + return $this->name; + } + + public function addBattery(Battery $battery) + { + $this->batteries->add($battery); + return $this; + } + + public function clearBatteries() + { + $this->batteries->clear(); + return $this; + } + + public function getBatteries() + { + // has to return set of strings because symfony is trying to move away from role objects + $str_batteries = []; + foreach ($this->batteries as $battery) + $str_batteries[] = $battery->getManufacturer()->getName() . " " . $battery->getModel()->getName() . " " . $this->getName(); + + return $str_batteries; + } } diff --git a/src/Entity/BatterySize.php b/src/Entity/BatterySize.php index 6851e166..79045124 100644 --- a/src/Entity/BatterySize.php +++ b/src/Entity/BatterySize.php @@ -4,6 +4,7 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; +use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity @@ -22,12 +23,13 @@ class BatterySize // name /** * @ORM\Column(type="string", length=80) + * @Assert\NotBlank() */ protected $name; // battery /** - * @ORM\OneToMany(targetEntity="Battery", mappedBy="manufacturer") + * @ORM\OneToMany(targetEntity="Battery", mappedBy="size") */ protected $batteries; @@ -35,4 +37,42 @@ class BatterySize { $this->batteries = new ArrayCollection(); } + + public function getID() + { + return $this->id; + } + + public function setName($name) + { + $this->name = $name; + return $this; + } + + public function getName() + { + return $this->name; + } + + public function addBattery(Battery $battery) + { + $this->batteries->add($battery); + return $this; + } + + public function clearBatteries() + { + $this->batteries->clear(); + return $this; + } + + public function getBatteries() + { + // has to return set of strings because symfony is trying to move away from role objects + $str_batteries = []; + foreach ($this->batteries as $battery) + $str_batteries[] = $battery->getManufacturer()->getName() . " " . $battery->getModel()->getName() . " " . $this->getName(); + + return $str_batteries; + } } diff --git a/templates/battery-manufacturer/form.html.twig b/templates/battery-manufacturer/form.html.twig new file mode 100644 index 00000000..2b0f9505 --- /dev/null +++ b/templates/battery-manufacturer/form.html.twig @@ -0,0 +1,132 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

Battery Manufacturers

+
+
+
+ +
+ +
+
+
+
+
+
+ + + +

+ {% if row is defined %} + Edit Manufacturer + {{ row.getName() }} + {% else %} + New Manufacturer + {% endif %} +

+
+
+
+
+
+
+ +
+ + + Display name for this manufacturer +
+
+
+
+
+
+
+ + Cancel +
+
+
+
+
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/templates/battery-manufacturer/list.html.twig b/templates/battery-manufacturer/list.html.twig new file mode 100644 index 00000000..8c13c188 --- /dev/null +++ b/templates/battery-manufacturer/list.html.twig @@ -0,0 +1,152 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Battery Manufacturers +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} \ No newline at end of file diff --git a/templates/battery-model/form.html.twig b/templates/battery-model/form.html.twig new file mode 100644 index 00000000..fa19d61f --- /dev/null +++ b/templates/battery-model/form.html.twig @@ -0,0 +1,132 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

Battery Models

+
+
+
+ +
+ +
+
+
+
+
+
+ + + +

+ {% if row is defined %} + Edit Model + {{ row.getName() }} + {% else %} + New Model + {% endif %} +

+
+
+
+
+
+
+ +
+ + + Display name for this model +
+
+
+
+
+
+
+ + Cancel +
+
+
+
+
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/templates/battery-model/list.html.twig b/templates/battery-model/list.html.twig new file mode 100644 index 00000000..bec1aa6d --- /dev/null +++ b/templates/battery-model/list.html.twig @@ -0,0 +1,152 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Battery Models +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} \ No newline at end of file diff --git a/templates/battery-size/form.html.twig b/templates/battery-size/form.html.twig new file mode 100644 index 00000000..fb2eab3e --- /dev/null +++ b/templates/battery-size/form.html.twig @@ -0,0 +1,132 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

Battery Sizes

+
+
+
+ +
+ +
+
+
+
+
+
+ + + +

+ {% if row is defined %} + Edit Size + {{ row.getName() }} + {% else %} + New Size + {% endif %} +

+
+
+
+
+
+
+ +
+ + + Display name for this size +
+
+
+
+
+
+
+ + Cancel +
+
+
+
+
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/templates/battery-size/list.html.twig b/templates/battery-size/list.html.twig new file mode 100644 index 00000000..7afe2389 --- /dev/null +++ b/templates/battery-size/list.html.twig @@ -0,0 +1,152 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Battery Sizes +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} \ No newline at end of file From fcec1599f660857859491f44857da5eae6dd6934 Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Thu, 11 Jan 2018 23:56:06 +0800 Subject: [PATCH 3/5] Make user list button icon same as the one used in form --- templates/user/list.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/user/list.html.twig b/templates/user/list.html.twig index 5b228166..ad650b76 100644 --- a/templates/user/list.html.twig +++ b/templates/user/list.html.twig @@ -35,7 +35,7 @@
- + New User From 34dd1aaa9c1ac113981ea8e3c1e73c7389eec24d Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Thu, 11 Jan 2018 23:58:24 +0800 Subject: [PATCH 4/5] Add acl/menu/route lists for battery modules --- config/acl.yaml | 57 ++++++++++++++++++++++++ config/menu.yaml | 21 +++++++++ config/routes.yaml | 108 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+) diff --git a/config/acl.yaml b/config/acl.yaml index 5d5d6e45..2e0eaa8a 100644 --- a/config/acl.yaml +++ b/config/acl.yaml @@ -32,3 +32,60 @@ access_keys: label: Update - id: role.delete label: Delete + - id: database + label: Database Access + acls: + - id: database.menu + label: Menu + - id: battery + label: Battery Access + acls: + - id: battery.menu + label: Menu + - id: battery.list + label: List + - id: battery.add + label: Add + - id: battery.update + label: Update + - id: battery.delete + label: Delete + - id: bmfg + label: Battery Manufacturer Access + acls: + - id: bmfg.menu + label: Menu + - id: bmfg.list + label: List + - id: bmfg.add + label: Add + - id: bmfg.update + label: Update + - id: bmfg.delete + label: Delete + - id: bmodel + label: Battery Model Access + acls: + - id: bmodel.menu + label: Menu + - id: bmodel.list + label: List + - id: bmodel.add + label: Add + - id: bmodel.update + label: Update + - id: bmodel.delete + label: Delete + - id: bsize + label: Battery Size Access + acls: + - id: bsize.menu + label: Menu + - id: bsize.list + label: List + - id: bsize.add + label: Add + - id: bsize.update + label: Update + - id: bsize.delete + label: Delete \ No newline at end of file diff --git a/config/menu.yaml b/config/menu.yaml index 3894ef03..bd3f6672 100644 --- a/config/menu.yaml +++ b/config/menu.yaml @@ -15,3 +15,24 @@ main_menu: acl: role.list label: Roles parent: user + + - id: database + acl: database.menu + label: Database + icon: flaticon-tabs + - id: battery_list + acl: battery.list + label: Batteries + parent: database + - id: bmfg_list + acl: bmfg.list + label: Battery Manufacturers + parent: database + - id: bmodel_list + acl: bmodel.list + label: Battery Models + parent: database + - id: bsize_list + acl: bsize.list + label: Battery Sizes + parent: database \ No newline at end of file diff --git a/config/routes.yaml b/config/routes.yaml index 4f74a5b1..c32eea80 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -88,6 +88,114 @@ role_delete: controller: App\Controller\RoleController::destroy methods: [DELETE] +# battery manufacturers + +bmfg_list: + path: /battery-manufacturers + controller: App\Controller\BatteryManufacturerController::index + +bmfg_rows: + path: /battery-manufacturers/rows + controller: App\Controller\BatteryManufacturerController::rows + methods: [POST] + +bmfg_create: + path: /battery-manufacturers/create + controller: App\Controller\BatteryManufacturerController::create + methods: [GET] + +bmfg_create_submit: + path: /battery-manufacturers/create + controller: App\Controller\BatteryManufacturerController::createSubmit + methods: [POST] + +bmfg_update: + path: /battery-manufacturers/{id} + controller: App\Controller\BatteryManufacturerController::update + methods: [GET] + +bmfg_update_submit: + path: /battery-manufacturers/{id} + controller: App\Controller\BatteryManufacturerController::updateSubmit + methods: [POST] + +bmfg_delete: + path: /battery-manufacturers/{id} + controller: App\Controller\BatteryManufacturerController::destroy + methods: [DELETE] + +# battery models + +bmodel_list: + path: /battery-models + controller: App\Controller\BatteryModelController::index + +bmodel_rows: + path: /battery-models/rows + controller: App\Controller\BatteryModelController::rows + methods: [POST] + +bmodel_create: + path: /battery-models/create + controller: App\Controller\BatteryModelController::create + methods: [GET] + +bmodel_create_submit: + path: /battery-models/create + controller: App\Controller\BatteryModelController::createSubmit + methods: [POST] + +bmodel_update: + path: /battery-models/{id} + controller: App\Controller\BatteryModelController::update + methods: [GET] + +bmodel_update_submit: + path: /battery-models/{id} + controller: App\Controller\BatteryModelController::updateSubmit + methods: [POST] + +bmodel_delete: + path: /battery-models/{id} + controller: App\Controller\BatteryModelController::destroy + methods: [DELETE] + +# battery sizes + +bsize_list: + path: /battery-sizes + controller: App\Controller\BatterySizeController::index + +bsize_rows: + path: /battery-sizes/rows + controller: App\Controller\BatterySizeController::rows + methods: [POST] + +bsize_create: + path: /battery-sizes/create + controller: App\Controller\BatterySizeController::create + methods: [GET] + +bsize_create_submit: + path: /battery-sizes/create + controller: App\Controller\BatterySizeController::createSubmit + methods: [POST] + +bsize_update: + path: /battery-sizes/{id} + controller: App\Controller\BatterySizeController::update + methods: [GET] + +bsize_update_submit: + path: /battery-sizes/{id} + controller: App\Controller\BatterySizeController::updateSubmit + methods: [POST] + +bsize_delete: + path: /battery-sizes/{id} + controller: App\Controller\BatterySizeController::destroy + methods: [DELETE] + # test test_acl: From b4300d48de38578be12ecf44924459b83253020b Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Fri, 12 Jan 2018 02:40:39 +0800 Subject: [PATCH 5/5] Add acl/menu/route lists for vehicle modules --- config/acl.yaml | 39 ++-- config/menu.yaml | 12 +- config/routes.yaml | 72 ++++++++ public/assets/css/style.css | 10 ++ src/Entity/Vehicle.php | 80 ++++++++- src/Entity/VehicleManufacturer.php | 40 +++++ templates/vehicle-manufacturer/form.html.twig | 132 ++++++++++++++ templates/vehicle-manufacturer/list.html.twig | 152 ++++++++++++++++ templates/vehicle/form.html.twig | 168 ++++++++++++++++++ templates/vehicle/list.html.twig | 160 +++++++++++++++++ 10 files changed, 846 insertions(+), 19 deletions(-) create mode 100644 templates/vehicle-manufacturer/form.html.twig create mode 100644 templates/vehicle-manufacturer/list.html.twig create mode 100644 templates/vehicle/form.html.twig create mode 100644 templates/vehicle/list.html.twig diff --git a/config/acl.yaml b/config/acl.yaml index 2e0eaa8a..a22d351a 100644 --- a/config/acl.yaml +++ b/config/acl.yaml @@ -37,19 +37,6 @@ access_keys: acls: - id: database.menu label: Menu - - id: battery - label: Battery Access - acls: - - id: battery.menu - label: Menu - - id: battery.list - label: List - - id: battery.add - label: Add - - id: battery.update - label: Update - - id: battery.delete - label: Delete - id: bmfg label: Battery Manufacturer Access acls: @@ -88,4 +75,30 @@ access_keys: - id: bsize.update label: Update - id: bsize.delete + label: Delete + - id: vehicle + label: Vehicle Access + acls: + - id: vehicle.menu + label: Menu + - id: vehicle.list + label: List + - id: vehicle.add + label: Add + - id: vehicle.update + label: Update + - id: vehicle.delete + label: Delete + - id: vmfg + label: Vehicle Manufacturer Access + acls: + - id: vmfg.menu + label: Menu + - id: vmfg.list + label: List + - id: vmfg.add + label: Add + - id: vmfg.update + label: Update + - id: vmfg.delete label: Delete \ No newline at end of file diff --git a/config/menu.yaml b/config/menu.yaml index bd3f6672..7f9c7043 100644 --- a/config/menu.yaml +++ b/config/menu.yaml @@ -20,10 +20,6 @@ main_menu: acl: database.menu label: Database icon: flaticon-tabs - - id: battery_list - acl: battery.list - label: Batteries - parent: database - id: bmfg_list acl: bmfg.list label: Battery Manufacturers @@ -35,4 +31,12 @@ main_menu: - id: bsize_list acl: bsize.list label: Battery Sizes + parent: database + - id: vehicle_list + acl: vehicle.list + label: Vehicles + parent: database + - id: vmfg_list + acl: vmfg.list + label: Vehicle Manufacturers parent: database \ No newline at end of file diff --git a/config/routes.yaml b/config/routes.yaml index c32eea80..840698f0 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -196,6 +196,78 @@ bsize_delete: controller: App\Controller\BatterySizeController::destroy methods: [DELETE] +# vehicles + +vehicle_list: + path: /vehicle + controller: App\Controller\VehicleController::index + +vehicle_rows: + path: /vehicle/rows + controller: App\Controller\VehicleController::rows + methods: [POST] + +vehicle_create: + path: /vehicle/create + controller: App\Controller\VehicleController::create + methods: [GET] + +vehicle_create_submit: + path: /vehicle/create + controller: App\Controller\VehicleController::createSubmit + methods: [POST] + +vehicle_update: + path: /vehicle/{id} + controller: App\Controller\VehicleController::update + methods: [GET] + +vehicle_update_submit: + path: /vehicle/{id} + controller: App\Controller\VehicleController::updateSubmit + methods: [POST] + +vehicle_delete: + path: /vehicle/{id} + controller: App\Controller\VehicleController::destroy + methods: [DELETE] + +# vehicle manufacturers + +vmfg_list: + path: /vehicle-manufacturers + controller: App\Controller\VehicleManufacturerController::index + +vmfg_rows: + path: /vehicle-manufacturers/rows + controller: App\Controller\VehicleManufacturerController::rows + methods: [POST] + +vmfg_create: + path: /vehicle-manufacturers/create + controller: App\Controller\VehicleManufacturerController::create + methods: [GET] + +vmfg_create_submit: + path: /vehicle-manufacturers/create + controller: App\Controller\VehicleManufacturerController::createSubmit + methods: [POST] + +vmfg_update: + path: /vehicle-manufacturers/{id} + controller: App\Controller\VehicleManufacturerController::update + methods: [GET] + +vmfg_update_submit: + path: /vehicle-manufacturers/{id} + controller: App\Controller\VehicleManufacturerController::updateSubmit + methods: [POST] + +vmfg_delete: + path: /vehicle-manufacturers/{id} + controller: App\Controller\VehicleManufacturerController::destroy + methods: [DELETE] + # test test_acl: diff --git a/public/assets/css/style.css b/public/assets/css/style.css index 0293fcea..4e766ec9 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -16,4 +16,14 @@ label.has-danger, .no-border { border: 0 !important; +} + +.flex-row { + display: flex; + flex-flow: row; + justify-content: center; +} + +.flex-row > * + * { + margin-left: 10px; } \ No newline at end of file diff --git a/src/Entity/Vehicle.php b/src/Entity/Vehicle.php index 29978961..4a53a9dd 100644 --- a/src/Entity/Vehicle.php +++ b/src/Entity/Vehicle.php @@ -4,6 +4,7 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; +use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity @@ -21,7 +22,7 @@ class Vehicle // customer vehicles /** - * @ORM\OneToMany(targetEntity="CustomerVehicle", mappedBy="customer") + * @ORM\OneToMany(targetEntity="CustomerVehicle", mappedBy="vehicle") */ protected $customers; @@ -29,30 +30,34 @@ class Vehicle /** * @ORM\ManyToOne(targetEntity="VehicleManufacturer", inversedBy="vehicles") * @ORM\JoinColumn(name="manufacturer_id", referencedColumnName="id") + * @Assert\NotBlank() */ protected $manufacturer; // make /** * @ORM\Column(type="string", length=80) + * @Assert\NotBlank() */ protected $make; // model year from /** * @ORM\Column(type="smallint") + * @Assert\NotBlank() */ protected $model_year_from; // model year to /** * @ORM\Column(type="smallint") + * @Assert\NotBlank() */ protected $model_year_to; // link to batteries compatible with this vehicle /** - * @ORM\OneToMany(targetEntity="Battery", mappedBy="vehicle") + * @ORM\ManyToMany(targetEntity="Battery", mappedBy="vehicles", fetch="EXTRA_LAZY") */ protected $batteries; @@ -61,4 +66,75 @@ class Vehicle $this->customers = new ArrayCollection(); $this->batteries = new ArrayCollection(); } + + public function getID() + { + return $this->id; + } + + public function setManufacturer($manufacturer) + { + $this->manufacturer = $manufacturer; + return $this; + } + + public function getManufacturer() + { + return $this->manufacturer; + } + + public function setMake($make) + { + $this->make = $make; + return $this; + } + + public function getMake() + { + return $this->make; + } + + public function setModelYearFrom($model_year_from) + { + $this->model_year_from = $model_year_from; + return $this; + } + + public function getModelYearFrom() + { + return $this->model_year_from; + } + + public function setModelYearTo($model_year_to) + { + $this->model_year_to = $model_year_to; + return $this; + } + + public function getModelYearTo() + { + return $this->model_year_to; + } + + public function addBattery(Battery $battery) + { + $this->batteries->add($battery); + return $this; + } + + public function clearBatteries() + { + $this->batteries->clear(); + return $this; + } + + public function getBatteries() + { + // has to return set of strings because symfony is trying to move away from role objects + $str_batteries = []; + foreach ($this->batteries as $battery) + $str_batteries[] = $battery->getManufacturer()->getName() . " " . $battery->getModel()->getName() . " " . $battery->getSize()->getName(); + + return $str_batteries; + } } diff --git a/src/Entity/VehicleManufacturer.php b/src/Entity/VehicleManufacturer.php index 4c38d6be..437b75d1 100644 --- a/src/Entity/VehicleManufacturer.php +++ b/src/Entity/VehicleManufacturer.php @@ -4,6 +4,7 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; +use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity @@ -22,6 +23,7 @@ class VehicleManufacturer // name /** * @ORM\Column(type="string", length=80) + * @Assert\NotBlank() */ protected $name; @@ -35,4 +37,42 @@ class VehicleManufacturer { $this->vehicles = new ArrayCollection(); } + + public function getID() + { + return $this->id; + } + + public function setName($name) + { + $this->name = $name; + return $this; + } + + public function getName() + { + return $this->name; + } + + public function addVehicle(Vehicle $vehicle) + { + $this->vehicles->add($vehicle); + return $this; + } + + public function clearVehicles() + { + $this->vehicles->clear(); + return $this; + } + + public function getVehicles() + { + // has to return set of strings because symfony is trying to move away from role objects + $str_vehicles = []; + foreach ($this->vehicles as $vehicle) + $str_vehicles[] = $this->getName() . " " . $vehicle->getMake() . " " . $vehicle->getYearFrom() . "-" . $vehicle->getYearTo(); + + return $str_vehicles; + } } diff --git a/templates/vehicle-manufacturer/form.html.twig b/templates/vehicle-manufacturer/form.html.twig new file mode 100644 index 00000000..13e630a2 --- /dev/null +++ b/templates/vehicle-manufacturer/form.html.twig @@ -0,0 +1,132 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

Vehicle Manufacturers

+
+
+
+ +
+ +
+
+
+
+
+
+ + + +

+ {% if row is defined %} + Edit Manufacturer + {{ row.getName() }} + {% else %} + New Manufacturer + {% endif %} +

+
+
+
+
+
+
+ +
+ + + Display name for this manufacturer +
+
+
+
+
+
+
+ + Cancel +
+
+
+
+
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/templates/vehicle-manufacturer/list.html.twig b/templates/vehicle-manufacturer/list.html.twig new file mode 100644 index 00000000..5a7cae59 --- /dev/null +++ b/templates/vehicle-manufacturer/list.html.twig @@ -0,0 +1,152 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Vehicle Manufacturers +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} \ No newline at end of file diff --git a/templates/vehicle/form.html.twig b/templates/vehicle/form.html.twig new file mode 100644 index 00000000..e4ce3be3 --- /dev/null +++ b/templates/vehicle/form.html.twig @@ -0,0 +1,168 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

Vehicles

+
+
+
+ +
+ +
+
+
+
+
+
+ + + +

+ {% if row is defined %} + Edit Vehicle + {{ row.getManufacturer().getName() ~ ' ' ~ row.getMake() ~ row.getModelYearFrom() ~ '-' ~ row.getModelYearTo() }} + {% else %} + New Vehicle + {% endif %} +

+
+
+
+
+ +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + + +
+
+
+
+
+
+
+ + Cancel +
+
+
+
+
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/templates/vehicle/list.html.twig b/templates/vehicle/list.html.twig new file mode 100644 index 00000000..84ee78cf --- /dev/null +++ b/templates/vehicle/list.html.twig @@ -0,0 +1,160 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Vehicles +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %}