Add reverse sort for open notes and a couple cleanups

This commit is contained in:
Ryan Prather 2024-05-22 19:42:50 -04:00
parent 6c6bbf8990
commit b307d616f6
5 changed files with 41 additions and 20 deletions

View File

@ -26,9 +26,11 @@ class DefaultController extends AbstractController
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
$last4Notes = $emi->getRepository(Note::class)->getLast4Notes($user);
$openNotes = $emi->getRepository(Note::class)->reverseNoteSort($user);
return $this->render('default/home.html.twig', [
'last4Notes' => $last4Notes,
'reverseNoteSort' => $openNotes,
'isAdmin' => $this->isGranted('ROLE_ADMIN'),
]);
}

View File

@ -17,6 +17,22 @@ class NoteRepository extends ServiceEntityRepository
parent::__construct($registry, Note::class);
}
public function reverseNoteSort(?User $user): array
{
if (!$user) {
return [];
}
$ret = $this->createQueryBuilder('n')
->where('n.user = :user')
->setParameter('user', $user->getId()->toBinary())
->orderBy('n.date', 'DESC')
->getQuery()
->getResult();
return $ret;
}
public function getLast4Notes(?User $user): array
{
if (!$user) {
@ -36,13 +52,13 @@ class NoteRepository extends ServiceEntityRepository
public function findNote(string $query, string $userId): array
{
$ret = $this->createQueryBuilder('n')
->orderBy('n.date', 'DESC')
->where('n.title LIKE :query')
->orWhere('n.passage LIKE :query')
->orWhere('n.text LIKE :query')
->andWhere('n.user = :user')
->setParameter('query', "%{$query}%")
->setParameter('user', $userId)
->orderBy('n.date', 'DESC')
->setMaxResults(3)
->getQuery()
->getResult();

View File

@ -10,13 +10,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>{% block title %}Welcome!{% endblock %}</title>
{% block stylesheets %}
{% endblock %}
{% block stylesheets %}{% endblock %}
</head>
<body class='is-preload' onload='setHeight()' onresize='setHeight()'>
{% block body %}{% endblock %}
{% block javascripts %}
{% block importmap %}{{ importmap('app') }}{% endblock %}
{% endblock %}
{% block javascripts %}{% endblock %}
</body>
</html>

View File

@ -10,7 +10,6 @@
{% endblock %}
{% block javascripts %}
<script src='/js/data.js'></script>
<script src='/js/script.js'></script>
<script src="/theme/assets/js/jquery.min.js"></script>
<script src='/theme/assets/js/jquery-ui.js'></script>
@ -24,19 +23,19 @@
{% block body %}
<div id='wrapper'>
<div id='main'>
<div class='inner' style='padding-left:0;'>
<div class='inner'>
<section class='ref-tab'>
<ul id='ref-list'>
</ul>
</section>
<section class='ref'>
<h2 style='display:inline-block'>Reference</h2>
<h2>Reference</h2>
<div style='display:inline-block'>
<button onclick='increaseFont()'><i class='fa fa-plus'></i></button>&nbsp;
<button onclick='decreaseFont()'><i class='fa fa-minus'></i></button>
</div>
<div id="ref"></div>
<div id="ref" style='font-size:12pt;'></div>
<div id='note-list'>
<table>
<thead>
@ -48,9 +47,9 @@
</tr>
</thead>
<tbody>
{% for n in app.user.notes|reverse %}
{{ n.toTableRow()|raw }}<br />
{% endfor %}
{% for n in reverseNoteSort %}
{{ n.toTableRow()|raw }}
{% endfor %}
</tbody>
</table>
</div>
@ -59,7 +58,7 @@
<section class="notes">
<div id='note-header-left'>
<h2>Notes</h2>
<i id='save-check' class='fa fa-check' style='opacity:0;'></i>
<i id='save-check' class='fa fa-check'></i>
</div>
<div id='note-header-right'>
<select id='template' onchange="retrieveTemplate('template','notes')">
@ -68,8 +67,13 @@
<option value="{{ t.id }}">{{ t.name }}</option>
{% endfor %}
</select>&nbsp;
<input type="button" id="previewBtn" class='button' value="Preview" onclick='previewNote()' />&nbsp;
<input type='button' id='show-hide-btn' class='button' value='Show' onclick='toggleFields()' />
<button id="previewBtn" class='button' onclick='previewNote()'>
<i class='fa fa-eye'></i>
</button>
&nbsp;
<button id='show-hide-btn' class='button' onclick='toggleFields()'>
<i class='fa fa-table'></i>
</button>
</div>
<div id='fields-container'>
@ -117,9 +121,12 @@
<option value='wsc'>Shorter Catechism</option>
<option value='wlc'>Larger Catechism</option>
</select>
<select id='referenceBook' style='display:none;'>
</select><br/>
<input type="text" id="search" placeholder="Search"><br />
<select id='referenceBook' onchange='filterBooks()'>
</select>
<span id='chapter-range' style='color:white;'></span>
<input type="text" id="referenceSearch" placeholder="Search" onkeyup='filterVerse()'>
<span id='verse-range' style='color:white;'></span>
<br />
<button id="searchBtn" onclick="queryRef()">Search</button>
</div>

View File

@ -12,7 +12,6 @@
<!-- Menu -->
<nav id="menu">
<header class="major">
<h2>Menu</h2>
{% if app.user %}
<h3>Welcome {{ app.user.name }}</h3>
<a href='/index.php/logout'>Logout</a>