Compare commits
5 Commits
ce798e3b65
...
32133a0d05
Author | SHA1 | Date |
---|---|---|
tracer | 32133a0d05 | |
tracer | 572cc1eb89 | |
tracer | 48585f14ab | |
tracer | 47439fe358 | |
tracer | 8e0a2ff6e8 |
|
@ -11,10 +11,8 @@ function addAddress(url) {
|
|||
}
|
||||
|
||||
function editAddress(id) {
|
||||
console.log("editButon")
|
||||
if (document.getElementById('edit_button_' + id).value === 'Save') {
|
||||
// save
|
||||
console.log("save")
|
||||
const url = "/address/update";
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
|
@ -45,7 +43,6 @@ function editAddress(id) {
|
|||
document.getElementById('edit_button_' + id).value = 'Edit'
|
||||
} else {
|
||||
//switch to edit
|
||||
console.log("switch to edit")
|
||||
document.getElementById('first_' + id).disabled = false
|
||||
document.getElementById('last_' + id).disabled = false
|
||||
document.getElementById('street_' + id).disabled = false
|
||||
|
@ -58,7 +55,6 @@ function editAddress(id) {
|
|||
}
|
||||
|
||||
function deleteAddress(id) {
|
||||
console.log("del")
|
||||
if (confirm('Are you sure?')) {
|
||||
const url = "/address/delete";
|
||||
fetch(url, {
|
||||
|
@ -78,17 +74,21 @@ function deleteAddress(id) {
|
|||
}
|
||||
|
||||
function sortBy(column) {
|
||||
console.log("sortby: " + column)
|
||||
// switch direction on every call
|
||||
let currentSortOrder = document.getElementById(column + '_sort')
|
||||
if (currentSortOrder.innerHTML === 'asc') {
|
||||
currentSortOrder.innerHTML = 'desc'
|
||||
} else {
|
||||
currentSortOrder.innerHTML = 'asc'
|
||||
}
|
||||
|
||||
const table = document.getElementById('address_table');
|
||||
let dirty = true;
|
||||
// loop until clean
|
||||
while (dirty) {
|
||||
console.log('dirty', dirty)
|
||||
// assume we are finished
|
||||
dirty = false
|
||||
const rows = table.rows;
|
||||
console.log(rows)
|
||||
for (let i = 1; i < (rows.length - 2); i++) {
|
||||
let x = rows[i]
|
||||
let rowXId = x.id
|
||||
|
@ -100,14 +100,14 @@ function sortBy(column) {
|
|||
let rowYNumber = rowYId.charAt(rowYId.length -1)
|
||||
let valueY = document.getElementById(column + '_' + rowYNumber).value
|
||||
|
||||
console.log(valueX, valueY)
|
||||
// mind asc & desc
|
||||
let sortOrder = 1
|
||||
|
||||
console.log(valueX.localeCompare(valueY))
|
||||
let currentSortOrder = document.getElementById(column + '_sort')
|
||||
let sortOrder = 0
|
||||
if (currentSortOrder.innerHTML === 'asc') {
|
||||
sortOrder = 1
|
||||
} else {
|
||||
sortOrder = -1
|
||||
}
|
||||
if (valueX.localeCompare(valueY) === sortOrder) {
|
||||
console.log('switch A')
|
||||
// switch rows
|
||||
x.parentNode.insertBefore(y, x);
|
||||
dirty = true
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class Router
|
|||
|
||||
foreach ($this->dynamicRoutes as $route) {
|
||||
// PHPStorm doesn't know that $parameters are always available,
|
||||
// (as it is a dynamic route) so the init the array just to mke PHPstorm happy.
|
||||
// (as it is a dynamic route) so I init the array just to make PHPStorm happy.
|
||||
$parameters = [];
|
||||
if (preg_match(pattern: $route->getRegex(), subject: $requestUri, matches: $matches)) {
|
||||
foreach ($route->getParameters() as $id => $parameter) {
|
||||
|
@ -104,7 +104,6 @@ class Router
|
|||
public function path(string $routeName, array $vars = [])
|
||||
{
|
||||
foreach (array_merge($this->dynamicRoutes, $this->staticRoutes) as $route) {
|
||||
|
||||
if ($route->getName() == $routeName) {
|
||||
if ($vars) {
|
||||
// build route for dynamic routes
|
||||
|
@ -119,16 +118,7 @@ class Router
|
|||
}
|
||||
}
|
||||
}
|
||||
// no 404, this is reached only if the code is wrong
|
||||
// TODO doesn't find the last route
|
||||
/*
|
||||
foreach (array_merge($this->dynamicRoutes, $this->staticRoutes) as $route) {
|
||||
echo $route->getRoute() . '<br>';
|
||||
if ($routeName == $route->getRoute()) {
|
||||
echo "equal";
|
||||
}
|
||||
}
|
||||
// no 404, this is reached only if the code is buggy
|
||||
die("Missing Route: $routeName");
|
||||
*/
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue