Compare commits

..

No commits in common. "020f3cbd740bca83faa244520d80b02e0ea49408" and "a3cd614c61c44e09f39e09073704cbc57fdb566b" have entirely different histories.

3 changed files with 18 additions and 38 deletions

View file

@ -33,17 +33,16 @@
You have no lists yet! <Link to="/lists/create" class="text-blue-400" You have no lists yet! <Link to="/lists/create" class="text-blue-400"
>Create one now</Link >Create one now</Link
> >
{:else}
{#each lists.teams as list}
<Link class="text-blue-400" to="/list/{list['$id']}"
>{list["name"]}</Link
><br />
{/each}
<Link
class="text-blue-400 dark:bg-gray-600 bg-gray-400 border p-1 mt-4 rounded"
to="/lists/create">Create new list</Link
>
{/if} {/if}
{#each lists.teams as list}
<Link class="text-blue-400" to="/list/{list['$id']}"
>{list["name"]}</Link
><br />
{/each}
<Link
class="text-blue-400 dark:bg-gray-600 bg-gray-400 border p-1 mt-4 rounded"
to="/lists/create">Create new list</Link
>
{/await} {/await}
</div> </div>
</main> </main>

View file

@ -15,7 +15,6 @@
let listname = ""; let listname = "";
let requireLoggedIn = false; let requireLoggedIn = false;
let list_type = "";
function createList(e) { function createList(e) {
e.preventDefault(); e.preventDefault();
@ -23,9 +22,8 @@
database database
.createDocument("tehillim-split", "lists", ID.unique(), { .createDocument("tehillim-split", "lists", ID.unique(), {
title: listname, title: listname,
require_logged_in: !!requireLoggedIn, require_logged_in: requireLoggedIn,
owner_id: loggedInUser["$id"], owner_id: loggedInUser["$id"],
list_type: list_type
}) })
.then((r) => { .then((r) => {
teams.create(r["$id"], listname, ["owner"]).then((r) => { teams.create(r["$id"], listname, ["owner"]).then((r) => {
@ -68,24 +66,13 @@
<legend class="text-2xl">Create new list</legend> <legend class="text-2xl">Create new list</legend>
<input <input
class="dark:bg-gray-500 dark:placeholder-white border border-black dark:border-current rounded p-2 w-72" class="dark:bg-gray-500 dark:placeholder-white border border-black dark:border-current rounded p-1"
type="text" type="text"
placeholder="List name" placeholder="List name"
bind:value={listname} bind:value={listname}
required required
/> <br /> /> <br />
<select
class="dark:bg-gray-500 dark:placeholder-white border border-black dark:border-current rounded p-2 mt-2 w-72"
placeholder="Split Tehillim by"
bind:value={list_type}
required
>
<option value="" selected disabled>Split Tehillim by</option>
<option value="perakim">Perakim</option>
<option value="month">Days of the month</option>
</select> <br />
<input <input
class="w-5 h-5 border-solid border-white my-3" class="w-5 h-5 border-solid border-white my-3"
name="requireLoggedIn" name="requireLoggedIn"

View file

@ -7,14 +7,7 @@
export let id; export let id;
let elementsNumbers = 0;
let list = database.getDocument("tehillim-split", "lists", id); let list = database.getDocument("tehillim-split", "lists", id);
list.then((r) => {
if (r.list_type == "perakim") elementsNumbers = 151;
if (r.list_type == "month") elementsNumbers = 31;
});
let perakim = []; let perakim = [];
let perakimPromise = database let perakimPromise = database
.listDocuments("tehillim-split", "perakim", [Query.equal("list_id", [id])]) .listDocuments("tehillim-split", "perakim", [Query.equal("list_id", [id])])
@ -149,7 +142,6 @@
Loading... Loading...
{:then list} {:then list}
<h1 class="text-2xl">List {list.title}</h1> <h1 class="text-2xl">List {list.title}</h1>
<p>List split by {list.list_type=="perakim"?"perek":""}{list.list_type=="month"?"days of month":""}</p>
<br /> <br />
<Link class="text-blue-400" to="/list/{id}/members">Members</Link> <Link class="text-blue-400" to="/list/{id}/members">Members</Link>
{#await teamDetails then team} {#await teamDetails then team}
@ -163,17 +155,17 @@
{/if} {/if}
{/await}<br /> {/await}<br />
{#await perakimPromise then perakimResolved} {#await perakimPromise then perakimResolved}
{#each Array.from(Array(elementsNumbers).keys()).slice(1) as i} {#each Array.from(Array(150 + 1).keys()).slice(1) as i}
{list.list_type == "perakim" ? "Perek " + i : ""}
{list.list_type == "month" ? "Day " + i : ""}
{#if perekIndex(i) !== -1} {#if perekIndex(i) !== -1}
{#if perakim[perekIndex(i)].taken == false} {#if perakim[perekIndex(i)].taken == false}
Perek {i}
<button <button
on:click={() => takePerek(i)} on:click={() => takePerek(i)}
class="dark:bg-gray-600 bg-gray-400 border p-1 mt-2 rounded" class="dark:bg-gray-600 bg-gray-400 border p-1 mt-2 rounded"
>Take</button >Take</button
> >
{:else if perakim[perekIndex(i)].taken_by == loggedInUser["$id"] && perakim[perekIndex(i)].completed !== true} {:else if perakim[perekIndex(i)].taken_by == loggedInUser["$id"] && perakim[perekIndex(i)].completed !== true}
Perek {i}
<button <button
on:click={() => untakePerek(i)} on:click={() => untakePerek(i)}
class="dark:bg-gray-600 bg-gray-400 border p-1 mt-2 rounded" class="dark:bg-gray-600 bg-gray-400 border p-1 mt-2 rounded"
@ -185,17 +177,19 @@
>Complete</button >Complete</button
> >
{:else if perakim[perekIndex(i)].taken_by == loggedInUser["$id"] && perakim[perekIndex(i)].completed == true} {:else if perakim[perekIndex(i)].taken_by == loggedInUser["$id"] && perakim[perekIndex(i)].completed == true}
Perek {i}
<button <button
on:click={() => uncompletePerek(i)} on:click={() => uncompletePerek(i)}
class="dark:bg-gray-600 bg-gray-400 border p-1 mt-2 rounded" class="dark:bg-gray-600 bg-gray-400 border p-1 mt-2 rounded"
>Uncomplete</button >Uncomplete</button
> >
{:else if perakim[perekIndex(i)].completed == false} {:else if perakim[perekIndex(i)].completed == false}
- Taken by {perakim[perekIndex(i)].taken_by_name} Perek {i} - Taken by {perakim[perekIndex(i)].taken_by_name}
{:else} {:else}
- Completed by {perakim[perekIndex(i)].taken_by_name} Perek {i} - Completed by {perakim[perekIndex(i)].taken_by_name}
{/if} {/if}
{:else} {:else}
Perek {i}
<button <button
on:click={() => takeNewPerek(i)} on:click={() => takeNewPerek(i)}
class="dark:bg-gray-600 bg-gray-400 border p-1 mt-2 rounded" class="dark:bg-gray-600 bg-gray-400 border p-1 mt-2 rounded"