Initial commit - cloned the Svelte todo's app with google login enabled as a starting point. This system will initially be used to let the chrome extension for students report which computers are used by which students and when.
This commit is contained in:
56
imports/ui/Task.svelte
Normal file
56
imports/ui/Task.svelte
Normal file
@@ -0,0 +1,56 @@
|
||||
<script>
|
||||
import { useTracker } from 'meteor/rdb:svelte-meteor-data';
|
||||
import { Tasks } from "../api/tasks.js";
|
||||
|
||||
export let key;
|
||||
export let task;
|
||||
let showPrivateButton;
|
||||
|
||||
$: currentUser = useTracker(() => Meteor.user());
|
||||
|
||||
$: {
|
||||
showPrivateButton = false;
|
||||
if($currentUser){
|
||||
showPrivateButton = task.owner === $currentUser._id;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleChecked() {
|
||||
// Set the checked property to the opposite of its current value
|
||||
Meteor.call("tasks.setChecked", task._id, !task.checked);
|
||||
}
|
||||
|
||||
function deleteThisTask() {
|
||||
Meteor.call("tasks.remove", task._id);
|
||||
}
|
||||
|
||||
function togglePrivate() {
|
||||
Meteor.call("tasks.setPrivate", task._id, !task.private);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<li class:checked="{task.checked}"
|
||||
class:private="{task.private}" >
|
||||
<button class="delete" on:click={deleteThisTask}>
|
||||
×
|
||||
</button>
|
||||
|
||||
<input
|
||||
type="checkbox"
|
||||
readonly
|
||||
checked={!!task.checked}
|
||||
on:click={toggleChecked}
|
||||
/>
|
||||
|
||||
{#if showPrivateButton}
|
||||
<button className="toggle-private" on:click="{togglePrivate}">
|
||||
{ task.private ? "Private" : "Public" }
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<span class="text">
|
||||
<strong>{ task.username }</strong>
|
||||
: { task.text }
|
||||
</span>
|
||||
</li>
|
||||
Reference in New Issue
Block a user