From de14863e2f7b7e99bdda4c5cd1232771b65d92f8 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 4 Jun 2018 04:16:40 +0800 Subject: [PATCH 1/3] Add flag_mobile fields in vehicle and vehicle manufacturer #134 --- src/Controller/RAPIController.php | 3 ++- src/Entity/Vehicle.php | 19 +++++++++++++++++++ src/Entity/VehicleManufacturer.php | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/Controller/RAPIController.php b/src/Controller/RAPIController.php index 4973d5b2..a0c18b8b 100644 --- a/src/Controller/RAPIController.php +++ b/src/Controller/RAPIController.php @@ -24,6 +24,7 @@ use App\Ramcar\TradeInType; use App\Ramcar\InvoiceStatus; use App\Service\InvoiceCreator; +use App\Service\MQTTClient; use App\Entity\RiderSession; use App\Entity\Customer; @@ -457,7 +458,7 @@ class RAPIController extends Controller $jo->setStatus(JOStatus::IN_TRANSIT); $em->flush(); - // TODO: send mqtt event + // TODO: send mqtt event (?) // TODO: add event diff --git a/src/Entity/Vehicle.php b/src/Entity/Vehicle.php index f751b473..e7a9a22a 100644 --- a/src/Entity/Vehicle.php +++ b/src/Entity/Vehicle.php @@ -59,10 +59,18 @@ class Vehicle */ protected $batteries; + // display in mobile app + /** + * @ORM\Column(type="boolean") + */ + protected $flag_mobile; + + public function __construct() { $this->customers = new ArrayCollection(); $this->batteries = new ArrayCollection(); + $this->flag_mobile = true; } public function getID() @@ -151,4 +159,15 @@ class Vehicle { return $this->batteries; } + + public function setDisplayMobile($bool = true) + { + $this->flag_mobile = $bool; + return $this; + } + + public function shouldDisplayMobile() + { + return $this->flag_mobile; + } } diff --git a/src/Entity/VehicleManufacturer.php b/src/Entity/VehicleManufacturer.php index 00026b05..86c1be4b 100644 --- a/src/Entity/VehicleManufacturer.php +++ b/src/Entity/VehicleManufacturer.php @@ -34,9 +34,16 @@ class VehicleManufacturer */ protected $vehicles; + // display in mobile app + /** + * @ORM\Column(type="boolean") + */ + protected $flag_mobile; + public function __construct() { $this->vehicles = new ArrayCollection(); + $this->flag_mobile = true; } public function getID() @@ -71,4 +78,15 @@ class VehicleManufacturer { return $this->vehicles; } + + public function setDisplayMobile($bool = true) + { + $this->flag_mobile = $bool; + return $this; + } + + public function shouldDisplayMobile() + { + return $this->flag_mobile; + } } From 220a78d275eb9cf3897bbb30c23323ab043ab2ed Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 4 Jun 2018 05:21:33 +0800 Subject: [PATCH 2/3] Add flag_mobile UI and controller functionality for vehicle and vehicle manufacturer #134 --- src/Controller/VehicleController.php | 11 +++++++++ .../VehicleManufacturerController.php | 10 ++++++++ templates/vehicle-manufacturer/form.html.twig | 24 +++++++++++++------ templates/vehicle/form.html.twig | 14 +++++++++++ 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/src/Controller/VehicleController.php b/src/Controller/VehicleController.php index dada947b..2065f1f9 100644 --- a/src/Controller/VehicleController.php +++ b/src/Controller/VehicleController.php @@ -152,6 +152,11 @@ class VehicleController extends BaseController $row->setMake($req->request->get('make')) ->setModelYearFrom($req->request->get('model_year_from')) ->setModelYearTo($req->request->get('model_year_to')); + $flag_mobile = $req->request->get('flag_mobile'); + if ($flag_mobile) + $row->setDisplayMobile(true); + else + $row->setDisplayMobile(false); // initialize error list $error_array = []; @@ -233,6 +238,12 @@ class VehicleController extends BaseController $row->setMake($req->request->get('make')) ->setModelYearFrom($req->request->get('model_year_from')) ->setModelYearTo($req->request->get('model_year_to')); + $flag_mobile = $req->request->get('flag_mobile'); + if ($flag_mobile) + $row->setDisplayMobile(true); + else + $row->setDisplayMobile(false); + // validate $errors = $validator->validate($row); diff --git a/src/Controller/VehicleManufacturerController.php b/src/Controller/VehicleManufacturerController.php index 045779af..86e15ee3 100644 --- a/src/Controller/VehicleManufacturerController.php +++ b/src/Controller/VehicleManufacturerController.php @@ -141,6 +141,11 @@ class VehicleManufacturerController extends BaseController // set and save values $row->setName($req->request->get('name')); + $flag_mobile = $req->request->get('flag_mobile'); + if ($flag_mobile) + $row->setDisplayMobile(true); + else + $row->setDisplayMobile(false); // validate $errors = $validator->validate($row); @@ -208,6 +213,11 @@ class VehicleManufacturerController extends BaseController // set and save values $row->setName($req->request->get('name')); + $flag_mobile = $req->request->get('flag_mobile'); + if ($flag_mobile) + $row->setDisplayMobile(true); + else + $row->setDisplayMobile(false); // validate $errors = $validator->validate($row); diff --git a/templates/vehicle-manufacturer/form.html.twig b/templates/vehicle-manufacturer/form.html.twig index 682e9367..ed5f8ee6 100644 --- a/templates/vehicle-manufacturer/form.html.twig +++ b/templates/vehicle-manufacturer/form.html.twig @@ -34,17 +34,27 @@
-
- -
- +
+
+ + Display name for this manufacturer
-
+
+
+
+ + + + +
+
diff --git a/templates/vehicle/form.html.twig b/templates/vehicle/form.html.twig index 05e4f55b..c182512e 100644 --- a/templates/vehicle/form.html.twig +++ b/templates/vehicle/form.html.twig @@ -80,6 +80,20 @@
+ +
+ +
+ + + +
+
From 6c77e77e2a51eeaeff005914ff0b41795f02f1be Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 4 Jun 2018 05:49:26 +0800 Subject: [PATCH 3/3] Add filter for flag_mobile in app API #134 --- src/Controller/APIController.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 03216a17..09410a7e 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -383,7 +383,7 @@ class APIController extends Controller return $res->getReturnResponse(); // get manufacturer list - $mfgs = $em->getRepository(VehicleManufacturer::class)->findBy([], ['name' => 'asc']); + $mfgs = $em->getRepository(VehicleManufacturer::class)->findBy(['flag_mobile' => true], ['name' => 'asc']); $mfg_list = []; foreach ($mfgs as $mfg) { @@ -420,7 +420,14 @@ class APIController extends Controller } // get makes - $vehicles = $mfg->getVehicles(); + $vehicles = $em->getRepository(Vehicle::class)->findBy( + [ + 'flag_mobile' => true, + 'manufacturer' => $mfg_id, + ], + ['make' => 'asc'] + ); + // $vehicles = $mfg->getVehicles(); $vlist = []; foreach ($vehicles as $v) {