Added possibility for user to hide from global score list
This commit is contained in:
@@ -94,6 +94,7 @@
|
||||
</div>
|
||||
<div class="other-users-div">
|
||||
<h3>Andre aktive:</h3>
|
||||
<input type="checkbox" id="hideMeCheckbox" x-model="$store.state.data.isHidden" x-on:click="$store.state.onClickHideCheckbox" /><label id="hideMeLabel" for="hideMeCheckbox">Skjul meg fra den globale listen</label>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Navn</th><th>Total avstand</th><th>Første aktivitet</th><th>Siste aktivitet</th>
|
||||
|
||||
@@ -33,6 +33,8 @@ interface AlpineState {
|
||||
removeAdministrator: (userId: number) => void,
|
||||
deleteUser: (userId: number) => void,
|
||||
|
||||
onClickHideCheckbox: (event: Event) => void,
|
||||
|
||||
init: () => void,
|
||||
setServerMessage: (newMessage: Sykkelaksjon) => void,
|
||||
getServerMessage: () => Sykkelaksjon,
|
||||
@@ -59,6 +61,8 @@ let alpineState: AlpineState = {
|
||||
removeAdministrator: removeAdministrator,
|
||||
deleteUser: deleteUser,
|
||||
|
||||
onClickHideCheckbox: onClickHideCheckbox,
|
||||
|
||||
init() {
|
||||
this.data = defaultData;
|
||||
},
|
||||
@@ -290,4 +294,21 @@ await refreshData();
|
||||
if (receivedData) {
|
||||
loadingDiv?.setAttribute("style", "display: none");
|
||||
contentDiv?.setAttribute("style", "display: block");
|
||||
}
|
||||
|
||||
function onClickHideCheckbox(event: PointerEvent) {
|
||||
let possibleCheckbox = event.target;
|
||||
if (possibleCheckbox instanceof HTMLInputElement) {
|
||||
let formData = new FormData();
|
||||
let url;
|
||||
|
||||
let isChecked = possibleCheckbox.checked;
|
||||
if (isChecked) {
|
||||
url = apiUrl + "/hideMe"
|
||||
} else {
|
||||
url = apiUrl + "/showMe"
|
||||
}
|
||||
|
||||
submitFormToUrl(url, formData, "PUT");
|
||||
}
|
||||
}
|
||||
Vendored
+8
@@ -17,6 +17,10 @@ export interface Sykkelaksjon {
|
||||
* Whether the connected user is an administrator
|
||||
*/
|
||||
isAdmin: boolean;
|
||||
/**
|
||||
* Whether the connected user is hidden from the score lists
|
||||
*/
|
||||
isHidden?: boolean;
|
||||
/**
|
||||
* Available types of activities
|
||||
*/
|
||||
@@ -69,6 +73,10 @@ export interface Sykkelaksjon {
|
||||
* Administrator info: whether the user listed is an administrator
|
||||
*/
|
||||
isAdmin?: boolean;
|
||||
/**
|
||||
* Administrator info: whether the user is hidden from the global score table
|
||||
*/
|
||||
isHidden?: boolean;
|
||||
/**
|
||||
* Administrator info: the activity templates this user has defined
|
||||
*/
|
||||
|
||||
@@ -100,4 +100,8 @@ summary {
|
||||
font-weight: bold;
|
||||
margin: -0.5em -0.5em 0;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
#hideMeLabel {
|
||||
width: 80%;
|
||||
}
|
||||
Reference in New Issue
Block a user