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 %}