Compare commits
No commits in common. "f46e73c64742446e722b151d0f8638307b280dab" and "78f25fdfd37806a8b5cfdb0df971586f26789a2c" have entirely different histories.
f46e73c647
...
78f25fdfd3
|
@ -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')
|
|
||||||
})
|
|
|
@ -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();
|
||||||
});
|
});
|
||||||
|
|
|
@ -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">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>
|
||||||
|
|
Loading…
Reference in New Issue