mirror of
https://github.com/edufeed-org/educards.git
synced 2025-12-07 23: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 -->
|
||||
<dialog id="add-board" class="modal" bind:this={modalRef}>
|
||||
<div class="modal-box">
|
||||
<h3 class="text-lg font-bold">Hello!</h3>
|
||||
<p class="py-4">Press ESC key or click the button below to close</p>
|
||||
<h3 class="text-lg font-bold">Gib deinem Board einen Titel</h3>
|
||||
<label class="input input-bordered">
|
||||
<input type="text" bind:value={title} />
|
||||
</label>
|
||||
<div class="modal-action">
|
||||
<form method="dialog">
|
||||
<button class="btn">Close</button>
|
||||
<button onclick={() => createBoard()}>Create Board!</button>
|
||||
<button class="btn btn-warning">Close</button>
|
||||
<button class="btn btn-success" onclick={() => createBoard()}>Create Board!</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
export let modalRef;
|
||||
|
||||
let title;
|
||||
let title = 'Titel';
|
||||
function handleAddColumn() {
|
||||
const column = {
|
||||
title
|
||||
|
|
@ -14,16 +14,15 @@
|
|||
|
||||
<dialog id="add-column" class="modal" bind:this={modalRef}>
|
||||
<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"
|
||||
>Titel
|
||||
<input type="text" bind:value={title} />
|
||||
</label>
|
||||
<p class="py-4">Press ESC key or click the button below to close</p>
|
||||
<div class="modal-action">
|
||||
<form method="dialog">
|
||||
<button class="btn">Close</button>
|
||||
<button on:click={handleAddColumn}>Add column</button>
|
||||
<button class="btn btn-warning">Close</button>
|
||||
<button class="btn btn-success" on:click={handleAddColumn}>Add column</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,8 +5,16 @@
|
|||
import Card from './Card.svelte';
|
||||
import PlusCircleFill from '$lib/icons/PlusCircleFill.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 { NDKEvent } from '@nostr-dev-kit/ndk';
|
||||
|
||||
export let column;
|
||||
export let flipDurationMs;
|
||||
|
|
@ -27,7 +35,13 @@
|
|||
const colIdx = items.findIndex((c) => c.id === cid);
|
||||
items[colIdx].items = e.detail.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>
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ export async function login(method) {
|
|||
user = await nip07signer.user();
|
||||
await user.fetchProfile();
|
||||
userStore.set(user);
|
||||
console.log('user', user);
|
||||
db.update((db) => {
|
||||
return { ...db, ndk, user };
|
||||
});
|
||||
|
|
@ -53,12 +52,6 @@ export async function addColumn(column) {
|
|||
|
||||
// add column to Board
|
||||
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));
|
||||
existingBoard.tags.push(['a', `30044:${user.pubkey}:${columnEvent.dTag}`]);
|
||||
existingBoard.publishReplaceable();
|
||||
|
|
@ -178,27 +171,37 @@ async function addressedEvents(event) {
|
|||
}
|
||||
|
||||
export async function publishBoard(board) {
|
||||
const ndk = getNdk();
|
||||
console.log(get(currentBoardAddress));
|
||||
const existingBoard = get(currentBoard);
|
||||
// const existingBoard = await ndk.fetchEvent({
|
||||
// kinds: [30043],
|
||||
// authors: [board.pubkey],
|
||||
// '#d': [board.dTag] // TODO does this work with address? guess it needs to be the tag
|
||||
// });
|
||||
const columnIds = board.items.map((e) => e.dTag);
|
||||
let tags = existingBoard.tags.filter((t) => t[0] !== 'a');
|
||||
columnIds.forEach((dTag) => {
|
||||
// TODO use user pubkey here so that
|
||||
// after a fork the correct column tags are assigned?
|
||||
tags.push(['a', `30044:${board.pubkey}:${dTag}`]);
|
||||
});
|
||||
existingBoard.tags = tags;
|
||||
existingBoard.publishReplaceable();
|
||||
try {
|
||||
const ndk = getNdk();
|
||||
const existingBoard = get(currentBoard);
|
||||
// const existingBoard = await ndk.fetchEvent({
|
||||
// kinds: [30043],
|
||||
// authors: [board.pubkey],
|
||||
// '#d': [board.dTag] // TODO does this work with address? guess it needs to be the tag
|
||||
// });
|
||||
const columnIds = board.items.map((e) => e.dTag);
|
||||
let tags = existingBoard.tags.filter((t) => t[0] !== 'a');
|
||||
columnIds.forEach((dTag) => {
|
||||
// TODO use user pubkey here so that
|
||||
// after a fork the correct column tags are assigned?
|
||||
tags.push(['a', `30044:${board.pubkey}:${dTag}`]);
|
||||
});
|
||||
existingBoard.tags = tags;
|
||||
await existingBoard.publishReplaceable();
|
||||
} catch (error) {
|
||||
alert('Please log in before dragging');
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue