Updated code

This commit is contained in:
Ryan Prather 2024-04-30 08:42:04 -04:00
parent 7e820f8138
commit bbaa084ae0
7 changed files with 44 additions and 45 deletions

View File

@ -38,6 +38,7 @@
"symfony/string": "6.4.*",
"symfony/translation": "6.4.*",
"symfony/twig-bundle": "6.4.*",
"symfony/uid": "6.4.*",
"symfony/ux-turbo": "^2.16",
"symfony/validator": "6.4.*",
"symfony/web-link": "6.4.*",

View File

@ -4,7 +4,6 @@ namespace App\Controller;
use App\Entity\Bible;
use DateTime;
use DateTimeZone;
use App\Entity\Series;
use App\Entity\Speaker;
@ -150,7 +149,7 @@ class AjaxController extends AbstractController
$ref = new Reference();
$ref->setType($data->type);
if((int) $data->book) {
if(is_numeric($data->book)) {
$ref->setNdx($data->book);
}
@ -167,7 +166,10 @@ class AjaxController extends AbstractController
'creed' => ReferenceController::retrieveCreed($data->book)
};
$res->setContent(json_encode(['text' => $ret->getContent(), 'title' => "{$ret->getLabel()}"]));
$res->setContent(json_encode([
'text' => $ret->getContent(),
'title' => "{$ret->getLabel()}",
]));
return $res;
}
@ -242,15 +244,18 @@ class AjaxController extends AbstractController
$note->setId($data->id);
}
$note->setTitle($data->title);
$note->setDate(new DateTime($data->date));
$refs = json_decode(json_encode($data->refs), true);
$series = $emi->getRepository(Series::class)->find($data->series);
$speaker = $emi->getRepository(Speaker::class)->find($data->speaker);
$note->setSeries($series);
$note->setSpeaker($speaker);
$note->setText($data->note);
$note->setPassage($data->passage);
$note->setTitle($data->title)
->setDate(new DateTime($data->date))
->setSeries($series)
->setSpeaker($speaker)
->setText($data->note)
->setPassage($data->passage)
->setRefs($refs);
$emi->persist($note);
$emi->flush();

View File

@ -11,6 +11,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Uid\Uuid;
class DefaultController extends AbstractController
{
@ -20,14 +21,14 @@ class DefaultController extends AbstractController
$speakers = $emi->getRepository(Speaker::class)->findAll();
$series = $emi->getRepository(Series::class)->findAll();
$templates = $emi->getRepository(Template::class)->findAll();
$note = $emi->getRepository(Notes::class)->findLastNote();
$uuid = Uuid::v4();
return $this->render('default/index.html.twig', [
'controller_name' => 'DefaultController',
'speakers' => $speakers,
'series' => $series,
'templates' => $templates,
'noteId' => ($note->getId() + 1)
'id' => $uuid,
]);
}

View File

@ -11,8 +11,8 @@ use Doctrine\ORM\Mapping as ORM;
class Notes implements JsonSerializable
{
#[ORM\Id()]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;
#[ORM\Column(type: Types::STRING, length: 64)]
private ?string $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
@ -33,12 +33,15 @@ class Notes implements JsonSerializable
#[ORM\Column(length: 255, nullable: true)]
private ?string $passage = null;
#[ORM\Column(type: Types::JSON, nullable: true)]
private ?array $refs = null;
/**
* Retrieves the ID of the object.
*
* @return int|null The ID of the object, or null if it is not set.
* @return string|null The ID of the object, or null if it is not set.
*/
public function getId(): ?int
public function getId(): ?string
{
return $this->id;
}
@ -46,10 +49,10 @@ class Notes implements JsonSerializable
/**
* Sets the ID of the object.
*
* @param int $id The ID to set.
* @param string $id The ID to set.
* @return static
*/
public function setId(int $id): static
public function setId(string $id): static
{
$this->id = $id;
@ -139,6 +142,18 @@ class Notes implements JsonSerializable
return $this;
}
public function getRefs(): ?array
{
return $this->refs;
}
public function setRefs(?array $refs): static
{
$this->refs = $refs;
return $this;
}
public function jsonSerialize(): array
{
return [
@ -148,6 +163,7 @@ class Notes implements JsonSerializable
'series' => $this->series,
'text' => $this->text,
'passage' => $this->passage,
'references' => $this->refs,
'date' => $this->date->format('Y-m-d'),
];
}

View File

@ -2,6 +2,7 @@
namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use JsonSerializable;
use App\Repository\ReferenceRepository;
@ -21,7 +22,7 @@ class Reference implements JsonSerializable
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 10)]
#[ORM\Column(length: 10, unique: true)]
private ?string $label = null;
#[ORM\Column(nullable: true)]

View File

@ -20,29 +20,4 @@ class ReferenceRepository extends ServiceEntityRepository
{
parent::__construct($registry, Reference::class);
}
// /**
// * @return Reference[] Returns an array of Reference objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('r.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Reference
// {
// return $this->createQueryBuilder('r')
// ->andWhere('r.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}

View File

@ -19,7 +19,7 @@
<section class="top-tab">
<i class="fa fa-bars hamburger" aria-hidden="true"></i>
<ul class="hamburger-list" style="display: none">
<li><a href="#">New Note</a></li>
<li><a href="#" onclick='newNote()'>New Note</a></li>
<li><a href="#" onclick='showSearchNote(event)'>Open Note</a></li>
<li><a href="#" onclick="saveNote();link.click();">Save Note</a></li>
<li><a href='#' onclick='discardNote()'>Discard Note</a></li>
@ -56,7 +56,7 @@
</div>
<div id='fields-container'>
<input type="hidden" id="noteId" value="{{ noteId }}" />
<input type="hidden" id="noteId" value="{{ id }}" />
<input type="text" id="noteTitle" placeholder="Title..." />
<input type='date' id='noteDate' />
<input type='text' id='newSpeaker' placeholder='Name...' onkeyup='saveSpeaker(event)' />