mirror of
https://github.com/edufeed-org/educards.git
synced 2025-12-10 00:34:34 +00:00
align colors and clean up modals a bit
This commit is contained in:
parent
bb9f829b74
commit
90c49fc931
4 changed files with 51 additions and 36 deletions
|
|
@ -14,15 +14,14 @@
|
||||||
<!-- Open the modal using ID.showModal() method -->
|
<!-- Open the modal using ID.showModal() method -->
|
||||||
<dialog id="add-board" class="modal" bind:this={modalRef}>
|
<dialog id="add-board" class="modal" bind:this={modalRef}>
|
||||||
<div class="modal-box">
|
<div class="modal-box">
|
||||||
<h3 class="text-lg font-bold">Hello!</h3>
|
<h3 class="text-lg font-bold">Gib deinem Board einen Titel</h3>
|
||||||
<p class="py-4">Press ESC key or click the button below to close</p>
|
|
||||||
<label class="input input-bordered">
|
<label class="input input-bordered">
|
||||||
<input type="text" bind:value={title} />
|
<input type="text" bind:value={title} />
|
||||||
</label>
|
</label>
|
||||||
<div class="modal-action">
|
<div class="modal-action">
|
||||||
<form method="dialog">
|
<form method="dialog">
|
||||||
<button class="btn">Close</button>
|
<button class="btn btn-warning">Close</button>
|
||||||
<button onclick={() => createBoard()}>Create Board!</button>
|
<button class="btn btn-success" onclick={() => createBoard()}>Create Board!</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
export let modalRef;
|
export let modalRef;
|
||||||
|
|
||||||
let title;
|
let title = 'Titel';
|
||||||
function handleAddColumn() {
|
function handleAddColumn() {
|
||||||
const column = {
|
const column = {
|
||||||
title
|
title
|
||||||
|
|
@ -14,16 +14,15 @@
|
||||||
|
|
||||||
<dialog id="add-column" class="modal" bind:this={modalRef}>
|
<dialog id="add-column" class="modal" bind:this={modalRef}>
|
||||||
<div class="modal-box">
|
<div class="modal-box">
|
||||||
<h3 class="text-lg font-bold">Add Column</h3>
|
<h3 class="text-lg font-bold">Wie soll die Spalte heissen?</h3>
|
||||||
<label class="input input-bordered"
|
<label class="input input-bordered"
|
||||||
>Titel
|
>Titel
|
||||||
<input type="text" bind:value={title} />
|
<input type="text" bind:value={title} />
|
||||||
</label>
|
</label>
|
||||||
<p class="py-4">Press ESC key or click the button below to close</p>
|
|
||||||
<div class="modal-action">
|
<div class="modal-action">
|
||||||
<form method="dialog">
|
<form method="dialog">
|
||||||
<button class="btn">Close</button>
|
<button class="btn btn-warning">Close</button>
|
||||||
<button on:click={handleAddColumn}>Add column</button>
|
<button class="btn btn-success" on:click={handleAddColumn}>Add column</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,16 @@
|
||||||
import Card from './Card.svelte';
|
import Card from './Card.svelte';
|
||||||
import PlusCircleFill from '$lib/icons/PlusCircleFill.svelte';
|
import PlusCircleFill from '$lib/icons/PlusCircleFill.svelte';
|
||||||
import AddCardModal from './AddCardModal.svelte';
|
import AddCardModal from './AddCardModal.svelte';
|
||||||
import { selectedColumn, currentBoard, user, userAndBoardMatch, deleteColumn } from '$lib/db';
|
import {
|
||||||
|
selectedColumn,
|
||||||
|
currentBoard,
|
||||||
|
user,
|
||||||
|
userAndBoardMatch,
|
||||||
|
deleteColumn,
|
||||||
|
ndkStore
|
||||||
|
} from '$lib/db';
|
||||||
import { eventTitle, publishCards } from '$lib/ndk';
|
import { eventTitle, publishCards } from '$lib/ndk';
|
||||||
|
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
||||||
|
|
||||||
export let column;
|
export let column;
|
||||||
export let flipDurationMs;
|
export let flipDurationMs;
|
||||||
|
|
@ -27,7 +35,13 @@
|
||||||
const colIdx = items.findIndex((c) => c.id === cid);
|
const colIdx = items.findIndex((c) => c.id === cid);
|
||||||
items[colIdx].items = e.detail.items;
|
items[colIdx].items = e.detail.items;
|
||||||
items = [...items];
|
items = [...items];
|
||||||
publishCards(items[colIdx]);
|
|
||||||
|
const newColumn = new NDKEvent(ndkStore, items[colIdx]);
|
||||||
|
newColumn.tags = newColumn.tags.filter((e) => e[0] !== 'a');
|
||||||
|
e.detail.items.forEach((card) => {
|
||||||
|
newColumn.tags.push(['a', card.tagAddress()]);
|
||||||
|
});
|
||||||
|
publishCards(newColumn);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ export async function login(method) {
|
||||||
user = await nip07signer.user();
|
user = await nip07signer.user();
|
||||||
await user.fetchProfile();
|
await user.fetchProfile();
|
||||||
userStore.set(user);
|
userStore.set(user);
|
||||||
console.log('user', user);
|
|
||||||
db.update((db) => {
|
db.update((db) => {
|
||||||
return { ...db, ndk, user };
|
return { ...db, ndk, user };
|
||||||
});
|
});
|
||||||
|
|
@ -53,12 +52,6 @@ export async function addColumn(column) {
|
||||||
|
|
||||||
// add column to Board
|
// add column to Board
|
||||||
const boardD = get(currentBoard).dTag;
|
const boardD = get(currentBoard).dTag;
|
||||||
console.log('board dtag', boardD);
|
|
||||||
// const existingBoard = await ndk.fetchEvent({
|
|
||||||
// kinds: [30043],
|
|
||||||
// authors: [user.pubkey],
|
|
||||||
// '#d': [get(currentBoard).dTag]
|
|
||||||
// });
|
|
||||||
const existingBoard = new NDKEvent(ndk, get(currentBoard));
|
const existingBoard = new NDKEvent(ndk, get(currentBoard));
|
||||||
existingBoard.tags.push(['a', `30044:${user.pubkey}:${columnEvent.dTag}`]);
|
existingBoard.tags.push(['a', `30044:${user.pubkey}:${columnEvent.dTag}`]);
|
||||||
existingBoard.publishReplaceable();
|
existingBoard.publishReplaceable();
|
||||||
|
|
@ -178,8 +171,8 @@ async function addressedEvents(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function publishBoard(board) {
|
export async function publishBoard(board) {
|
||||||
|
try {
|
||||||
const ndk = getNdk();
|
const ndk = getNdk();
|
||||||
console.log(get(currentBoardAddress));
|
|
||||||
const existingBoard = get(currentBoard);
|
const existingBoard = get(currentBoard);
|
||||||
// const existingBoard = await ndk.fetchEvent({
|
// const existingBoard = await ndk.fetchEvent({
|
||||||
// kinds: [30043],
|
// kinds: [30043],
|
||||||
|
|
@ -194,11 +187,21 @@ export async function publishBoard(board) {
|
||||||
tags.push(['a', `30044:${board.pubkey}:${dTag}`]);
|
tags.push(['a', `30044:${board.pubkey}:${dTag}`]);
|
||||||
});
|
});
|
||||||
existingBoard.tags = tags;
|
existingBoard.tags = tags;
|
||||||
existingBoard.publishReplaceable();
|
await existingBoard.publishReplaceable();
|
||||||
|
} catch (error) {
|
||||||
|
alert('Please log in before dragging');
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function publishCards(column) {
|
export async function publishCards(column) {
|
||||||
column.publishReplaceable();
|
try {
|
||||||
|
const event = new NDKEvent(get(ndkStore), column);
|
||||||
|
await event.publishReplaceable();
|
||||||
|
} catch (error) {
|
||||||
|
alert('Please log in before dragging');
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** takes existing tags and replaces the pubkey in the Tag Addresses
|
/** takes existing tags and replaces the pubkey in the Tag Addresses
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue