Refactoring
This commit is contained in:
parent
a45a89a02a
commit
8ef5d987a1
|
@ -14,8 +14,8 @@ foreach(!is_null($result) ? $result : [] as $row){
|
||||||
$name_encoded = urlencode($user->name());
|
$name_encoded = urlencode($user->name());
|
||||||
$helmet_colour = $row["chief"] ? "red" : "black";
|
$helmet_colour = $row["chief"] ? "red" : "black";
|
||||||
$firstCellName = (time()-$row["online_time"])<=30 ? "<u>".$name."</u>" : $name;
|
$firstCellName = (time()-$row["online_time"])<=30 ? "<u>".$name."</u>" : $name;
|
||||||
$firstCell = "<a id='username-{$row['id']}' style='text-align: left;'><img alt='{$helmet_colour} helmet' src='./resources/images/{$helmet_colour}_helmet.png' width='20px'>$firstCellName</a>";
|
$firstCell = "<a data-clickable data-user='{$row['id']}' data-user-available='{$row['available']}' style='text-align: left;'><img alt='{$helmet_colour} helmet' src='./resources/images/{$helmet_colour}_helmet.png' width='20px'>$firstCellName</a>";
|
||||||
$secondCell = $row["available"] ? "<a><i class='fa fa-check' style='color:green'></i></a>" : "<a><i class='fa fa-times' style='color:red'></i></a>";
|
$secondCell = $row["available"] ? "<a data-clickable><i class='fa fa-check' style='color:green'></i></a>" : "<a data-clickable><i class='fa fa-times' style='color:red'></i></a>";
|
||||||
$response[] = [
|
$response[] = [
|
||||||
$firstCell,
|
$firstCell,
|
||||||
$secondCell,
|
$secondCell,
|
||||||
|
@ -30,7 +30,7 @@ foreach(!is_null($result) ? $result : [] as $row){
|
||||||
$name = $user->nameById($row["id"]);
|
$name = $user->nameById($row["id"]);
|
||||||
$helmet_colour = $row["chief"] ? "red" : "black";
|
$helmet_colour = $row["chief"] ? "red" : "black";
|
||||||
$firstCellName = (time()-$row["online_time"])<=30 ? "<u>".$name."</u>" : $name;
|
$firstCellName = (time()-$row["online_time"])<=30 ? "<u>".$name."</u>" : $name;
|
||||||
$firstCell = "<a id='username-{$row['id']}' style='text-align: left;'><img alt='{$helmet_colour} helmet' src='./resources/images/{$helmet_colour}_helmet.png' width='20px'>$firstCellName</a>";
|
$firstCell = "<a style='text-align: left;'><img alt='{$helmet_colour} helmet' src='./resources/images/{$helmet_colour}_helmet.png' width='20px'>$firstCellName</a>";
|
||||||
$secondCell = $row["available"] ? "<a><i class='fa fa-check' style='color:green'></i></a>" : "<a><i class='fa fa-times' style='color:red'></i></a>";
|
$secondCell = $row["available"] ? "<a><i class='fa fa-check' style='color:green'></i></a>" : "<a><i class='fa fa-times' style='color:red'></i></a>";
|
||||||
$response[] = [
|
$response[] = [
|
||||||
$firstCell,
|
$firstCell,
|
||||||
|
|
|
@ -75,18 +75,22 @@
|
||||||
$("#deactivate-btn").click(function(){
|
$("#deactivate-btn").click(function(){
|
||||||
allertaJS.main.deactivate('{{ user.id }}', '');
|
allertaJS.main.deactivate('{{ user.id }}', '');
|
||||||
});
|
});
|
||||||
allertaJS.main.loadTable({tablePage: "list", useCustomTableEngine: "default", callbackRepeat: true, callback: function() {
|
allertaJS.main.loadTable({tablePage: "list", useCustomTableEngine: "default", callback: function() {
|
||||||
$("tbody tr").each(function(key, el) {
|
$("tbody tr").on("click", function(key, el) {
|
||||||
$(el.children[1]).click(function(event) {
|
let targetElem = event.target;
|
||||||
console.log(event.target);
|
let userInfoElem = event.currentTarget.querySelector("[data-user]");
|
||||||
userId = event.target.parentElement.parentElement.parentElement.firstElementChild.firstElementChild.id.replace("username-","");
|
let userId = userInfoElem.dataset.user;
|
||||||
console.log(userId);
|
if(
|
||||||
if(event.target.classList.contains("fa-times")) {
|
targetElem.hasAttribute("data-clickable") ||
|
||||||
allertaJS.main.activate(userId,0);
|
targetElem.parentElement.hasAttribute("data-clickable") ||
|
||||||
} else {
|
(targetElem.childElementCount > 0 && targetElem.firstElementChild.hasAttribute("data-clickable"))
|
||||||
|
){
|
||||||
|
if(userInfoElem.dataset.userAvailable === "1") {
|
||||||
allertaJS.main.deactivate(userId,0);
|
allertaJS.main.deactivate(userId,0);
|
||||||
|
} else {
|
||||||
|
allertaJS.main.activate(userId,0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}});
|
}});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue