Compare commits

...

3 Commits

Author SHA1 Message Date
f838943827
point pages to user injected navbar controller 2023-10-11 20:42:58 +00:00
17d8e1413b
doc change 2023-10-10 19:46:10 +00:00
Audrey Jensen
818a9d1edd
add navbar item config file 2023-10-10 19:43:48 +00:00
10 changed files with 53 additions and 24 deletions

15
config/navbar.yaml Normal file
View File

@ -0,0 +1,15 @@
# To add a new button: copy the template below.
# Label: This is the text displayed on the navbar item
# Type: Intern (Internal Link), Extern (External link, default), File (locally hosted files)
# URI: Resource locator. For Internal links, this is the route's friendly name. If you don't know this, then set an External link to the page.
# Disabled: Defaults to false. If true, button becomes unclickable.
# TEMPLATE
# - { Label: Example, Type: Extern, URI: "example.com", Disabled: False}
Buttons:
- { Label: Cram-A-Lot, Type: Extern, URI: "https://www.cram-a-lot.com/", Disabled: False}
- { Label: Office 365, Type: Extern, URI: "https://myapps.microsoft.com/", Disabled: False}
- { Label: Directory, Type: Extern, URI: "http://site:81/directory/home.php", Disabled: False}
- { Label: Software Basics, Type: File, URI: "documents/JV Software Basics.docx", Disabled: False}
- { Label: Safety Training, Type: Intern, URI: "safetyHome", Disabled: False}
- { Label: Anonymous Comment, Type: Intern, URI: "complaint", Disabled: False}

View File

@ -19,7 +19,7 @@ use Symfony\Component\Mime\Address;
class ComplaintController extends AbstractController class ComplaintController extends AbstractController
{ {
#[Route('/complaint/anon', name: 'complaint')] #[Route('/complaint/anon', name: 'complaint')]
public function Index(Request $request, TransportTransportInterface $mailer,LoggerInterface $log) : Response public function Index(Request $request, TransportTransportInterface $mailer,LoggerInterface $log, NavbarController $_navbar) : Response
{ {
$form = $this->createForm(AnonymousComplaintType::class); $form = $this->createForm(AnonymousComplaintType::class);
$form->handleRequest($request); $form->handleRequest($request);
@ -33,7 +33,7 @@ class ComplaintController extends AbstractController
{ {
$sendMail = null; $sendMail = null;
} }
return $this->render('complaint.html.twig',['form' => $form, 'isSubmitted' => $sendMail, 'complaintReceiverName' => $_SERVER['COMPLAINT_RECIPIENT_NAME']]); return new Response($_navbar->navbar() . $this->renderView('complaint.html.twig',['form' => $form, 'isSubmitted' => $sendMail, 'complaintReceiverName' => $_SERVER['COMPLAINT_RECIPIENT_NAME']]));
} }
public function sendEmail(TransportTransportInterface $mailer, string $message, LoggerInterface $log) : bool public function sendEmail(TransportTransportInterface $mailer, string $message, LoggerInterface $log) : bool
{ {

View File

@ -0,0 +1,21 @@
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Twig\Environment;
#[AsController]
class NavbarController
{
public function __construct(private Environment $twig){}
public function navbar() : string
{
$contentFile = Yaml::parseFile('../config/navbar.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP);
$content = $this->twig->render('_navbar.html.twig', $contentFile);
return $content;
}
}

View File

@ -8,10 +8,12 @@ use jv\intranet\Types\NavbarItem;
class PortalController extends AbstractController class PortalController extends AbstractController
{ {
#[Route('/')] #[Route('/')]
public function page() : Response public function page(NavbarController $navbar) : Response
{ {
$navbar = $navbar->navbar();
$contentFile = Yaml::parseFile('../config/portalLinks.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP); $contentFile = Yaml::parseFile('../config/portalLinks.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP);
return $this->render('portal.html.twig',$contentFile); $page = $this->render('portal.html.twig',$contentFile);
return new Response($navbar . $page->getContent());
} }
} }

View File

@ -14,14 +14,17 @@ use function PHPUnit\Framework\containsIdentical;
class SafetyController extends AbstractController class SafetyController extends AbstractController
{ {
#[Route('/training/safety', name: 'safetyHome')] #[Route('/training/safety', name: 'safetyHome')]
public function Index() : Response public function Index(NavbarController $_navbar) : Response
{ {
$contentFile = Yaml::parseFile('../config/safetyLinks.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP); $contentFile = Yaml::parseFile('../config/safetyLinks.yaml', 2, 2, Yaml::PARSE_OBJECT_FOR_MAP);
return $this->render('Training/Safety/safetyHome.html.twig',['content' => $contentFile]); $navbar = $_navbar->navbar();
return new Response($navbar . $this->renderView('Training/Safety/safetyHome.html.twig',['content' => $contentFile]));
} }
#[Route('/training/safety/quiz')] #[Route('/training/safety/quiz')]
public function Quiz(Request $request, LoggerInterface $log) public function Quiz(Request $request, LoggerInterface $log, NavbarController $_navbar)
{ {
$form = $this->createForm(SafetyQuizType::class); $form = $this->createForm(SafetyQuizType::class);
$form->handleRequest($request); $form->handleRequest($request);
@ -43,10 +46,10 @@ class SafetyController extends AbstractController
return $this->render('Training/Safety/quizResults.html.twig', ['testerName'=>$testerName, return $this->render('Training/Safety/quizResults.html.twig', ['testerName'=>$testerName,
'correctAnswers'=>$correctAnswers, 'totalAnswers'=>count($data)]); 'correctAnswers'=>$correctAnswers, 'totalAnswers'=>count($data)]);
} }
return $this->render('Training/Safety/SafetyQuiz.html.twig',['quiz'=>$form]); return new Response($navbar = $_navbar->navbar() . $this->renderView('Training/Safety/SafetyQuiz.html.twig',['quiz'=>$form]));
} }
#[Route('/Training/Safety/Topics/{topic?}')] #[Route('/Training/Safety/Topics/{topic?}')]
public function Topics(?string $topic, LoggerInterface $log) : Response public function Topics(?string $topic, LoggerInterface $log, NavbarController $navbar) : Response
{ {
//We want to show the safety homepage if this is blank //We want to show the safety homepage if this is blank
if($topic == null) if($topic == null)
@ -96,7 +99,7 @@ class SafetyController extends AbstractController
$topic = strtolower($topic); $topic = strtolower($topic);
//Render the page header //Render the page header
$header = $this->renderView('_header.html.twig') . $this->renderView ('_navbar.html.twig'); $header = $navbar->navbar();
//prepare navButton data //prepare navButton data
$navButtonData = ['previous'=> $previousTopic, 'next' => $nextTopic]; $navButtonData = ['previous'=> $previousTopic, 'next' => $nextTopic];
$contents = $this->renderView('Training/Safety/Topics/'.$topic.".html.twig"); //render main page contents $contents = $this->renderView('Training/Safety/Topics/'.$topic.".html.twig"); //render main page contents

View File

@ -1,10 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
{{ include('_header.html.twig') }}
<body> <body>
{{ include('_navbar.html.twig')}}
<div class="container"> <div class="container">
<h4>Complete the Safety Quiz below</h4> <h4>Complete the Safety Quiz below</h4>
<p>When you're finished, click 'Submit' at the bottom and print your results. <p>When you're finished, click 'Submit' at the bottom and print your results.

View File

@ -1,10 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
{{ include('_header.html.twig') }}
<body> <body>
{{ include('_navbar.html.twig')}}
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">

View File

@ -1,3 +1,4 @@
{{ include('_header.html.twig') }}
<!-- Navigation --> <!-- Navigation -->
<div class="siteNavbar"> <div class="siteNavbar">
<ul class="list-group list-group-horizontal-md"> <ul class="list-group list-group-horizontal-md">

View File

@ -1,10 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
{{ include('_header.html.twig') }}
<body> <body>
{{ include('_navbar.html.twig')}}
<div class="container"> <div class="container">
<h2>Anonymous Complaint Page <h2>Anonymous Complaint Page
<h4 class="text-bold">Instructions</h4> <h4 class="text-bold">Instructions</h4>

View File

@ -1,9 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
{{ include('_header.html.twig') }}
<body> <body>
{{ include('_navbar.html.twig')}}
<div class="container"> <div class="container">
<div class="row g-1 my-2"> <div class="row g-1 my-2">
<!--Emergency Card --> <!--Emergency Card -->