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) {
// clear titles
const titles = ['first', 'last', 'street', 'zip', 'city', 'phone']
titles.forEach((title) =>
document.getElementById(title).innerHTML = upCase(title)
)
// switch direction on every call
let currentSortOrder = document.getElementById(column + '_sort')
let currentTitleElement = document.getElementById(column)
let currentTitle = currentTitleElement.innerHTML
let newTitle
let currentSortOrder = document.getElementById(column + '_sort')
if (currentSortOrder.innerHTML === 'asc') {
currentSortOrder.innerHTML = 'desc'
newTitle = currentTitle[0] + currentTitle.substring(1) + ' ⬇'
} else {
currentSortOrder.innerHTML = 'asc'
newTitle = currentTitle[0] + currentTitle.substring(1) + ' ⬆'
}
currentTitleElement.innerHTML = newTitle
const table = document.getElementById('address_table');
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);
$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) {
$security->login();
});

View File

@ -10,12 +10,12 @@
<body>
<h1>Address Book</h1>
<a href="<?= $router->path('app_main'); ?>">&#8962;&nbsp;Home</a>
<a href="<?= $router->path('app_admin'); ?>">&#9881;&nbsp;Admin</a>
<a href="<?= $router->path('app_main'); ?>">🏠 Home</a>
<a href="<?= $router->path('app_admin'); ?>"> Admin</a>
<?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: ?>
<a href="<?= $router->path('app_logout'); ?>">&#9099;&nbsp;Logout</a>
<a href="<?= $router->path('app_logout'); ?>">🚪Logout</a>
<?php endif; ?>
<br>

View File

@ -1,6 +1,6 @@
<?php include dirname(path: __DIR__) . '/_header.html.php'; ?>
<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' ?>

View File

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