From 48e447bebacba45a75170688789ef575e5268726 Mon Sep 17 00:00:00 2001 From: Ro Date: Sun, 8 Jan 2023 14:49:54 -0800 Subject: [PATCH] Switch render method There were still some reference to the base Controller page renderer that needed to switched to the new Render class. Oops. Also for got mention tabler icons (https://tabler-icons.io/) were added in the last commit. They are so nice. --- src/Controller/Routes/Back/Locations.php | 63 +++++++++++------------- src/Service/HandleLocations.php | 2 + templates/back/locations.twig | 4 +- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/Controller/Routes/Back/Locations.php b/src/Controller/Routes/Back/Locations.php index 45f903e..837f7da 100644 --- a/src/Controller/Routes/Back/Locations.php +++ b/src/Controller/Routes/Back/Locations.php @@ -113,11 +113,11 @@ class Locations extends AbstractController $request->request->get("loc_tags") == "" ) { $notice = "All fields are required, champ."; - return $this->render("back/locations.twig", [ - "title" => "Bad Space | Locations | Add", - "notice" => $notice, - "mode" => "add" - ]); + return $render->page( + ["mode" => "add", "notice" => $notice], + "Bad Space | Locations | Add", + "back/locations.twig" + ); } //once everything clears, upload images and process request @@ -132,29 +132,26 @@ class Locations extends AbstractController } $response = $locations->modifyLocation($request, $result["id"], $mode, $request->request->get("uuid")); if ($response["status"]) { - $options = []; if ($mode == 'add') { - $options = [ - "title" => "Bad Space | Locations | Add", - "notice" => $response["message"], - "mode" => $mode - ]; + return $render->page( + ["mode" => $mode, "notice" => $response["message"]], + "Bad Space | Locations | Add", + "back/locations.twig" + ); } else { $location = $locations->getLocationbyUUID($request->request->get("uuid")); - $options = [ - "title" => "Bad Space | Locations | Edit", - "mode" => $mode, - "notice" => $response["message"], - "location" => $location[0] - ]; + return $render->page( + ["mode" => $mode, "notice" => $response["message"], "location" => $location[0]], + "Bad Space | Locations | Edit", + "back/locations.twig" + ); } - return $this->render("back/locations.twig", $options); } else { - return $this->render("back/locations.twig", [ - "title" => "Bad Space | Locations | Error", - "notice" => $response["message"], - "mode" => $mode - ]); + return $render->page( + ["mode" => $mode, "notice" => $response["message"]], + "Bad Space | Locations | Error", + "back/locations.twig" + ); } } } else { @@ -227,17 +224,17 @@ class Locations extends AbstractController $response = $locations->addMultipleLocations($file, $result["id"]); if ($response["status"]) { $notice = "New locations added! Take a break."; - return $this->render("back/locations.twig", [ - "title" => "Bad Space | Locations | Add", - "notice" => $response["message"], - "mode" => "bulk-add" - ]); + return $render->page( + ["mode" => "bulk-add", "notice" => $response["message"], ], + "Bad Space | Locations | Bulk Add", + "back/locations.twig" + ); } else { - return $this->render("back/locations.twig", [ - "title" => "Bad Space | Locations | Add", - "notice" => $response["message"], - "mode" => "bulk-add" - ]); + return $render->page( + ["mode" => "bulk-add", "notice" => $response["message"], ], + "Bad Space | Locations | Bulk Add", + "back/locations.twig" + ); } } } else { diff --git a/src/Service/HandleLocations.php b/src/Service/HandleLocations.php index e693791..22d67d5 100644 --- a/src/Service/HandleLocations.php +++ b/src/Service/HandleLocations.php @@ -173,6 +173,8 @@ class HandleLocations // Save image //extract data row by row + + //TODO: set name to lowercase for comparison foreach ($records as $offset => $row) { $name = $row["Name"]; $url = $row["Url"]; diff --git a/templates/back/locations.twig b/templates/back/locations.twig index 49b4cdc..fbd4d72 100644 --- a/templates/back/locations.twig +++ b/templates/back/locations.twig @@ -8,9 +8,9 @@

Location Listing

- {% if notice is defined %} + {% if options.notice is defined %}
- {{ notice }} + {{ options.notice }}
{% endif %}