Compare commits

...

2 commits

Author SHA1 Message Date
020f3cbd74
support months split type + fix requireloggedin bug 2023-11-01 21:28:48 +00:00
48964d27e4
hide duplicate button 2023-11-01 21:18:08 +00:00
3 changed files with 38 additions and 18 deletions

View file

@ -33,16 +33,17 @@
You have no lists yet! <Link to="/lists/create" class="text-blue-400"
>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}
{#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}
</div>
</main>

View file

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

View file

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