Compare commits
No commits in common. "32133a0d05bba793efe0e44bbcecbc0628a742ce" and "ce798e3b65af692702c168c032278449a4001aba" have entirely different histories.
32133a0d05
...
ce798e3b65
|
@ -11,8 +11,10 @@ function addAddress(url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function editAddress(id) {
|
function editAddress(id) {
|
||||||
|
console.log("editButon")
|
||||||
if (document.getElementById('edit_button_' + id).value === 'Save') {
|
if (document.getElementById('edit_button_' + id).value === 'Save') {
|
||||||
// save
|
// save
|
||||||
|
console.log("save")
|
||||||
const url = "/address/update";
|
const url = "/address/update";
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -30,8 +32,8 @@ function editAddress(id) {
|
||||||
.then(
|
.then(
|
||||||
response => response.text()
|
response => response.text()
|
||||||
).then(
|
).then(
|
||||||
html => console.log(html)
|
html => console.log(html)
|
||||||
);
|
);
|
||||||
|
|
||||||
document.getElementById('first_' + id).disabled = true
|
document.getElementById('first_' + id).disabled = true
|
||||||
document.getElementById('last_' + id).disabled = true
|
document.getElementById('last_' + id).disabled = true
|
||||||
|
@ -43,6 +45,7 @@ function editAddress(id) {
|
||||||
document.getElementById('edit_button_' + id).value = 'Edit'
|
document.getElementById('edit_button_' + id).value = 'Edit'
|
||||||
} else {
|
} else {
|
||||||
//switch to edit
|
//switch to edit
|
||||||
|
console.log("switch to edit")
|
||||||
document.getElementById('first_' + id).disabled = false
|
document.getElementById('first_' + id).disabled = false
|
||||||
document.getElementById('last_' + id).disabled = false
|
document.getElementById('last_' + id).disabled = false
|
||||||
document.getElementById('street_' + id).disabled = false
|
document.getElementById('street_' + id).disabled = false
|
||||||
|
@ -55,6 +58,7 @@ function editAddress(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteAddress(id) {
|
function deleteAddress(id) {
|
||||||
|
console.log("del")
|
||||||
if (confirm('Are you sure?')) {
|
if (confirm('Are you sure?')) {
|
||||||
const url = "/address/delete";
|
const url = "/address/delete";
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
|
@ -66,29 +70,25 @@ function deleteAddress(id) {
|
||||||
.then(
|
.then(
|
||||||
response => response.text()
|
response => response.text()
|
||||||
).then(
|
).then(
|
||||||
html => console.log(html)
|
html => console.log(html)
|
||||||
);
|
);
|
||||||
let row = document.getElementById('row_' + id)
|
let row = document.getElementById('row_' + id)
|
||||||
row.parentNode.removeChild(row)
|
row.parentNode.removeChild(row)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortBy(column) {
|
function sortBy(column) {
|
||||||
// switch direction on every call
|
console.log("sortby: " + column)
|
||||||
let currentSortOrder = document.getElementById(column + '_sort')
|
|
||||||
if (currentSortOrder.innerHTML === 'asc') {
|
|
||||||
currentSortOrder.innerHTML = 'desc'
|
|
||||||
} else {
|
|
||||||
currentSortOrder.innerHTML = 'asc'
|
|
||||||
}
|
|
||||||
|
|
||||||
const table = document.getElementById('address_table');
|
const table = document.getElementById('address_table');
|
||||||
let dirty = true;
|
let dirty = true;
|
||||||
// loop until clean
|
// loop until clean
|
||||||
while (dirty) {
|
while (dirty) {
|
||||||
|
console.log('dirty', dirty)
|
||||||
// assume we are finished
|
// assume we are finished
|
||||||
dirty = false
|
dirty = false
|
||||||
const rows = table.rows;
|
const rows = table.rows;
|
||||||
|
console.log(rows)
|
||||||
for (let i = 1; i < (rows.length - 2); i++) {
|
for (let i = 1; i < (rows.length - 2); i++) {
|
||||||
let x = rows[i]
|
let x = rows[i]
|
||||||
let rowXId = x.id
|
let rowXId = x.id
|
||||||
|
@ -100,14 +100,14 @@ function sortBy(column) {
|
||||||
let rowYNumber = rowYId.charAt(rowYId.length -1)
|
let rowYNumber = rowYId.charAt(rowYId.length -1)
|
||||||
let valueY = document.getElementById(column + '_' + rowYNumber).value
|
let valueY = document.getElementById(column + '_' + rowYNumber).value
|
||||||
|
|
||||||
let currentSortOrder = document.getElementById(column + '_sort')
|
console.log(valueX, valueY)
|
||||||
let sortOrder = 0
|
// mind asc & desc
|
||||||
if (currentSortOrder.innerHTML === 'asc') {
|
let sortOrder = 1
|
||||||
sortOrder = 1
|
|
||||||
} else {
|
console.log(valueX.localeCompare(valueY))
|
||||||
sortOrder = -1
|
|
||||||
}
|
|
||||||
if (valueX.localeCompare(valueY) === sortOrder) {
|
if (valueX.localeCompare(valueY) === sortOrder) {
|
||||||
|
console.log('switch A')
|
||||||
|
// switch rows
|
||||||
x.parentNode.insertBefore(y, x);
|
x.parentNode.insertBefore(y, x);
|
||||||
dirty = true
|
dirty = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ class Router
|
||||||
|
|
||||||
foreach ($this->dynamicRoutes as $route) {
|
foreach ($this->dynamicRoutes as $route) {
|
||||||
// PHPStorm doesn't know that $parameters are always available,
|
// PHPStorm doesn't know that $parameters are always available,
|
||||||
// (as it is a dynamic route) so I init the array just to make PHPStorm happy.
|
// (as it is a dynamic route) so the init the array just to mke PHPstorm happy.
|
||||||
$parameters = [];
|
$parameters = [];
|
||||||
if (preg_match(pattern: $route->getRegex(), subject: $requestUri, matches: $matches)) {
|
if (preg_match(pattern: $route->getRegex(), subject: $requestUri, matches: $matches)) {
|
||||||
foreach ($route->getParameters() as $id => $parameter) {
|
foreach ($route->getParameters() as $id => $parameter) {
|
||||||
|
@ -104,6 +104,7 @@ class Router
|
||||||
public function path(string $routeName, array $vars = [])
|
public function path(string $routeName, array $vars = [])
|
||||||
{
|
{
|
||||||
foreach (array_merge($this->dynamicRoutes, $this->staticRoutes) as $route) {
|
foreach (array_merge($this->dynamicRoutes, $this->staticRoutes) as $route) {
|
||||||
|
|
||||||
if ($route->getName() == $routeName) {
|
if ($route->getName() == $routeName) {
|
||||||
if ($vars) {
|
if ($vars) {
|
||||||
// build route for dynamic routes
|
// build route for dynamic routes
|
||||||
|
@ -118,7 +119,16 @@ class Router
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no 404, this is reached only if the code is buggy
|
// no 404, this is reached only if the code is wrong
|
||||||
die("Missing Route: $routeName");
|
// 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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
die("Missing Route: $routeName");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue