From f66e38d0de91f515257276db0359d4b2abbfd8f3 Mon Sep 17 00:00:00 2001 From: Eric Harris-Braun Date: Mon, 18 Dec 2023 17:43:38 -0500 Subject: [PATCH] adds duplicate board --- ui/src/AboutDialog.svelte | 38 +++++++++++++++++++++++++++++++++++++- ui/src/BoardMenu.svelte | 2 +- ui/src/svgIcons.ts | 3 ++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/ui/src/AboutDialog.svelte b/ui/src/AboutDialog.svelte index 1e11e74..c2b4b1e 100644 --- a/ui/src/AboutDialog.svelte +++ b/ui/src/AboutDialog.svelte @@ -4,6 +4,10 @@ import SvgIcon from "./SvgIcon.svelte"; import type { KanDoStore } from "./store"; import { v1 as uuidv1 } from "uuid"; + import {toPromise} from '@holochain-open-dev/stores' + import type { BoardAndLatestState } from "./boardList"; + import { cloneDeep } from "lodash"; + import type { BoardState } from "./board"; const { getStore } :any = getContext('store'); @@ -54,10 +58,19 @@ }, false); reader.readAsText(file); }; + const createBoardFrom = async (oldBoard: BoardAndLatestState) => { + const newBoard = cloneDeep(oldBoard.latestState) as BoardState + newBoard.cards = [] + Object.keys(newBoard.grouping).forEach(key=>newBoard.grouping[key] = []) + newBoard.name = `copy of ${newBoard.name}` + const board = await store.boardList.makeBoard(newBoard) + store.setUIprops({showMenu:false}) + store.setActiveBoard(board.hash) + } - +

KanDo! is a demonstration Holochain app built by the Holochain Foundation.

Developers: @@ -67,6 +80,27 @@

Copyright © 2023 Holochain Foundation. This software is distributed under the MIT License

{fileinput.click();}} title="Import Board">Import Board
+ + {#await toPromise(store.boardList.allBoards)} + Loading + {:then boards} + + Duplicate Board + + {#each Array.from(boards.entries()) as [key,board]} + { + createBoardFrom(board) + }} > + {board.latestState.name} + + {/each} + + + + {:catch err} + Error: {err} + {/await} + onFileSelected(e)} bind:this={fileinput} >
@@ -89,10 +123,12 @@ height: 50px; background: #243076; border: 1px solid #4A559D; + margin-top: 5px; color: #fff; display: flex; align-items: center; border-radius: 5px; + cursor: pointer; } .new-board span { diff --git a/ui/src/BoardMenu.svelte b/ui/src/BoardMenu.svelte index b285888..9598241 100644 --- a/ui/src/BoardMenu.svelte +++ b/ui/src/BoardMenu.svelte @@ -46,7 +46,7 @@
-
newBoardDialog.open()} title="New Board">New Board
+
newBoardDialog.open()} title="New Board">New Board
{#if $activeBoards.status == "complete" && $activeBoards.value.length > 0}

Active Boards

diff --git a/ui/src/svgIcons.ts b/ui/src/svgIcons.ts index df26a2c..13e7511 100644 --- a/ui/src/svgIcons.ts +++ b/ui/src/svgIcons.ts @@ -20,5 +20,6 @@ export const svgIcons = { faFileExport: ``, faClose: ``, faBug: ``, - faBars: `` + faBars: ``, + faClone: `` } \ No newline at end of file