Compare commits
6 Commits
78f25fdfd3
...
f46e73c647
Author | SHA1 | Date |
---|---|---|
tracer | f46e73c647 | |
tracer | 1a8b31b3a2 | |
tracer | a832a3c60b | |
tracer | 904fd798f6 | |
tracer | 4ed3dcd603 | |
tracer | 8bc252ba4d |
|
@ -73,14 +73,31 @@ 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;
|
||||||
|
@ -114,3 +131,8 @@ function sortBy(column) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
console.log('loaded')
|
||||||
|
sortBy('last')
|
||||||
|
})
|
|
@ -28,10 +28,6 @@ $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();
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Address Book</h1>
|
<h1>Address Book</h1>
|
||||||
<a href="<?= $router->path('app_main'); ?>">🏠 Home</a>
|
<a href="<?= $router->path('app_main'); ?>">⌂ Home</a>
|
||||||
<a href="<?= $router->path('app_admin'); ?>">⚙ 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'); ?>">🚪Login</a>
|
<a href="<?= $router->path('app_login'); ?>">⎆ Login</a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a href="<?= $router->path('app_logout'); ?>">🚪Logout</a>
|
<a href="<?= $router->path('app_logout'); ?>">⎋ Logout</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
|
@ -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') ?>">👱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' ?>
|
||||||
|
|
|
@ -34,12 +34,12 @@
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<tr style="display:none;">
|
<tr style="display:none;">
|
||||||
<td id="first_sort">asc</td>
|
<td id="first_sort">desc</td>
|
||||||
<td id="last_sort">asc</td>
|
<td id="last_sort">desc</td>
|
||||||
<td id="street_sort">asc</td>
|
<td id="street_sort">desc</td>
|
||||||
<td id="zip_sort">asc</td>
|
<td id="zip_sort">desc</td>
|
||||||
<td id="city_sort">asc</td>
|
<td id="city_sort">desc</td>
|
||||||
<td id="phone_sort">asc</td>
|
<td id="phone_sort">desc</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue