Compare commits

..

No commits in common. "f46e73c64742446e722b151d0f8638307b280dab" and "78f25fdfd37806a8b5cfdb0df971586f26789a2c" have entirely different histories.

5 changed files with 16 additions and 34 deletions

View File

@ -73,31 +73,14 @@ function deleteAddress(id) {
} }
} }
function upCase(text) {
return text[0].toUpperCase() + text.substring(1);
}
function sortBy(column) { function sortBy(column) {
// clear titles
const titles = ['first', 'last', 'street', 'zip', 'city', 'phone']
titles.forEach((title) =>
document.getElementById(title).innerHTML = upCase(title)
)
// switch direction on every call // switch direction on every call
let currentSortOrder = document.getElementById(column + '_sort') let currentSortOrder = document.getElementById(column + '_sort')
let currentTitleElement = document.getElementById(column)
let currentTitle = currentTitleElement.innerHTML
let newTitle
if (currentSortOrder.innerHTML === 'asc') { if (currentSortOrder.innerHTML === 'asc') {
currentSortOrder.innerHTML = 'desc' currentSortOrder.innerHTML = 'desc'
newTitle = currentTitle[0] + currentTitle.substring(1) + ' ⬇'
} else { } else {
currentSortOrder.innerHTML = 'asc' currentSortOrder.innerHTML = 'asc'
newTitle = currentTitle[0] + currentTitle.substring(1) + ' ⬆'
} }
currentTitleElement.innerHTML = newTitle
const table = document.getElementById('address_table'); const table = document.getElementById('address_table');
let dirty = true; let dirty = true;
@ -131,8 +114,3 @@ function sortBy(column) {
} }
} }
} }
document.addEventListener('DOMContentLoaded', () => {
console.log('loaded')
sortBy('last')
})

View File

@ -28,6 +28,10 @@ $security = $container->get(className: SecurityController::class);
$addressBook = $container->get(className: AddressBookController::class); $addressBook = $container->get(className: AddressBookController::class);
$addressBookAdmin = $container->get(className: AddressBookAdminController::class); $addressBookAdmin = $container->get(className: AddressBookAdminController::class);
// TODO maybe refactor route adding to the controllers?
// I currently think that makes sense.
$router->addRoute(name: 'app_login', route: '/login', callback: function () use ($security) { $router->addRoute(name: 'app_login', route: '/login', callback: function () use ($security) {
$security->login(); $security->login();
}); });

View File

@ -10,12 +10,12 @@
<body> <body>
<h1>Address Book</h1> <h1>Address Book</h1>
<a href="<?= $router->path('app_main'); ?>">&#8962;&nbsp;Home</a> <a href="<?= $router->path('app_main'); ?>">🏠 Home</a>
<a href="<?= $router->path('app_admin'); ?>">&#9881;&nbsp;Admin</a> <a href="<?= $router->path('app_admin'); ?>"> Admin</a>
<?php if (empty($user) || $user->getAuth() == \App\Enums\UserAuth::AUTH_ANONYMOUS): ?> <?php if (empty($user) || $user->getAuth() == \App\Enums\UserAuth::AUTH_ANONYMOUS): ?>
<a href="<?= $router->path('app_login'); ?>">&#9094;&nbsp;Login</a> <a href="<?= $router->path('app_login'); ?>">🚪Login</a>
<?php else: ?> <?php else: ?>
<a href="<?= $router->path('app_logout'); ?>">&#9099;&nbsp;Logout</a> <a href="<?= $router->path('app_logout'); ?>">🚪Logout</a>
<?php endif; ?> <?php endif; ?>
<br> <br>

View File

@ -1,6 +1,6 @@
<?php include dirname(path: __DIR__) . '/_header.html.php'; ?> <?php include dirname(path: __DIR__) . '/_header.html.php'; ?>
<h1>Address Book - Admin</h1> <h1>Address Book - Admin</h1>
<a href="<?= $router->path('app_admin_users'); ?>">&#128113;&nbsp;Users</a> <a href="<?= $router->path('app_admin_users') ?>">👱Users</a>
<?php include dirname(path: __DIR__) . '/_footer.html.php' ?> <?php include dirname(path: __DIR__) . '/_footer.html.php' ?>

View File

@ -34,12 +34,12 @@
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<tr style="display:none;"> <tr style="display:none;">
<td id="first_sort">desc</td> <td id="first_sort">asc</td>
<td id="last_sort">desc</td> <td id="last_sort">asc</td>
<td id="street_sort">desc</td> <td id="street_sort">asc</td>
<td id="zip_sort">desc</td> <td id="zip_sort">asc</td>
<td id="city_sort">desc</td> <td id="city_sort">asc</td>
<td id="phone_sort">desc</td> <td id="phone_sort">asc</td>
</tr> </tr>
</table> </table>
</form> </form>