Compare commits
No commits in common. "3e278c27fa5a9810548f9b56ab68dba0be0dd219" and "d0e2e102226b9515470168eb9b98e5bda8bfe8ee" have entirely different histories.
3e278c27fa
...
d0e2e10222
@ -5,7 +5,6 @@ var tabs = [];
|
||||
let saved = false;
|
||||
let textDirty = false;
|
||||
let saveTimeout = 10000;
|
||||
var to = null;
|
||||
|
||||
document.addEventListener('keyup', function (event) {
|
||||
if (event.key == "F3") {
|
||||
@ -61,9 +60,7 @@ function setHeight() {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!to) {
|
||||
to = setTimeout(saveNote, saveTimeout);
|
||||
}
|
||||
setTimeout(saveNote, saveTimeout);
|
||||
}
|
||||
|
||||
function search() {
|
||||
@ -136,8 +133,7 @@ function saveNote(event) {
|
||||
}
|
||||
|
||||
if (!textDirty || !validateNote()) {
|
||||
clearTimeout(to);
|
||||
to = setTimeout(saveNote, saveTimeout);
|
||||
setTimeout(saveNote, saveTimeout);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -165,14 +161,10 @@ function saveNote(event) {
|
||||
saved = true;
|
||||
textDirty = false;
|
||||
document.querySelector('#note-header-left h2').classList.remove('dirty');
|
||||
|
||||
if (data.new) {
|
||||
document.querySelector('#noteId').value = data.id;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
.finally(() => function () { clearTimeout(to); to = setTimeout(saveNote, saveTimeout); });
|
||||
.finally(() => setTimeout(saveNote, saveTimeout));
|
||||
}
|
||||
|
||||
function validateNote() {
|
||||
@ -181,8 +173,10 @@ function validateNote() {
|
||||
const speaker = document.querySelector('#speaker');
|
||||
const series = document.querySelector('#series');
|
||||
const title = document.querySelector('#noteTitle');
|
||||
const id = document.querySelector('#noteId');
|
||||
const psg = document.querySelector('#passage');
|
||||
|
||||
if (!isUuidValid(id.value)) { return false; }
|
||||
if (!title.value.length) { return false; }
|
||||
if (!date.value) { return false; }
|
||||
if (!parseInt(speaker.value)) { return false; }
|
||||
@ -386,7 +380,6 @@ function queryRef(type = null, book = null, input = null) {
|
||||
document.querySelector('#referenceType').value = '';
|
||||
document.querySelector('#referenceBook').value = '';
|
||||
document.querySelector('#referenceBook').style.display = 'none';
|
||||
document.querySelector('#refQuery #search').value = '';
|
||||
closeRef();
|
||||
|
||||
saved = false;
|
||||
|
@ -98,8 +98,8 @@ class AjaxController extends AbstractController
|
||||
$user = $this->getUser();
|
||||
|
||||
$speaker = new Speaker();
|
||||
$speaker->setName($data->speakerName)
|
||||
->setUser($user);
|
||||
$speaker->setName($data->speakerName);
|
||||
$speaker->setUser($user);
|
||||
|
||||
$emi->persist($speaker);
|
||||
$emi->flush();
|
||||
@ -139,8 +139,8 @@ class AjaxController extends AbstractController
|
||||
$user = $this->getUser();
|
||||
|
||||
$series = new Series();
|
||||
$series->setName($data->seriesName)
|
||||
->setUser($user);
|
||||
$series->setName($data->seriesName);
|
||||
$series->setUser($user);
|
||||
|
||||
$emi->persist($series);
|
||||
$emi->flush();
|
||||
@ -267,28 +267,22 @@ class AjaxController extends AbstractController
|
||||
public function saveNote(Request $req, EntityManagerInterface $emi): Response
|
||||
{
|
||||
$data = json_decode($req->getContent());
|
||||
$newNote = false;
|
||||
if (isset($data->id) && $data->id) {
|
||||
/** @var Note|array $note */
|
||||
$note = $emi->getRepository(Note::class)->findBy(['id' => $data->id, 'user' => $this->getUser()]);
|
||||
$note = $emi->getRepository(Note::class)->find($data->id);
|
||||
|
||||
if (is_array($note) && count($note) > 0) {
|
||||
/** @var Note $note */
|
||||
$note = $note[0];
|
||||
}
|
||||
} else {
|
||||
if (!$note) {
|
||||
$note = new Note();
|
||||
$newNote = true;
|
||||
$note->setUser($this->getUser());
|
||||
$uuid = Uuid::fromString($data->id);
|
||||
$note->setId($uuid);
|
||||
}
|
||||
|
||||
$refs = json_decode(json_encode($data->refs), true);
|
||||
|
||||
$series = $emi->getRepository(Series::class)->find($data->series);
|
||||
$speaker = $emi->getRepository(Speaker::class)->find($data->speaker);
|
||||
$user = $this->getUser();
|
||||
|
||||
/** @var Note $note */
|
||||
$note->setTitle($data->title)
|
||||
$note->setUser($user)
|
||||
->setTitle($data->title)
|
||||
->setDate(new DateTime($data->date))
|
||||
->setSeries($series)
|
||||
->setSpeaker($speaker)
|
||||
@ -302,8 +296,7 @@ class AjaxController extends AbstractController
|
||||
$res = new Response();
|
||||
$res->setContent(json_encode([
|
||||
'msg' => 'saved',
|
||||
'id' => $note->getId(),
|
||||
'new' => $newNote,
|
||||
'id' => $note->getId()
|
||||
]));
|
||||
|
||||
return $res;
|
||||
|
@ -26,9 +26,11 @@ class DefaultController extends AbstractController
|
||||
{
|
||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
||||
$last4Notes = $emi->getRepository(Note::class)->getLast4Notes($user);
|
||||
$uuid = Uuid::v4();
|
||||
|
||||
return $this->render('default/home.html.twig', [
|
||||
'last4Notes' => $last4Notes,
|
||||
'id' => $uuid,
|
||||
'isAdmin' => $this->isGranted('ROLE_ADMIN'),
|
||||
]);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@
|
||||
</div>
|
||||
|
||||
<div id='fields-container'>
|
||||
<input type="hidden" id="noteId" value="" />
|
||||
<input type="hidden" id="noteId" value="{{ id }}" />
|
||||
<input type="text" id="noteTitle" placeholder="Title..." />
|
||||
<input type='text' id='noteDate' onchange='textDirty=true;saved=false;' />
|
||||
<input type='text' id='newSpeaker' placeholder='Name...' onkeyup='saveSpeaker(event)' style='display:none;' />
|
||||
|
Loading…
Reference in New Issue
Block a user