Skip to content

Commit

Permalink
adds duplicate board
Browse files Browse the repository at this point in the history
  • Loading branch information
zippy committed Dec 18, 2023
1 parent 1ed72c3 commit f66e38d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
38 changes: 37 additions & 1 deletion ui/src/AboutDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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)
}
</script>


<sl-dialog label="KanDo!: UI v0.6.3 for DNA v0.5.1" bind:this={dialog} width={600} >
<sl-dialog label="KanDo!: UI v0.6.4 for DNA v0.5.1" bind:this={dialog} width={600} >
<div class="about">
<p>KanDo! is a demonstration Holochain app built by the Holochain Foundation.</p>
<p> <b>Developers:</b>
Expand All @@ -67,6 +80,27 @@
</p>
<p class="small">Copyright © 2023 Holochain Foundation. This software is distributed under the MIT License</p>
<div class="new-board" on:click={()=>{fileinput.click();}} title="Import Board"><SvgIcon color="#fff" icon=faFileImport size=20px style="margin-left: 15px;"/><span>Import Board </span></div>

{#await toPromise(store.boardList.allBoards)}
Loading
{:then boards}
<sl-dropdown skidding=15>
<sl-button slot="trigger" caret><SvgIcon icon=faClone size=20px style="margin-right: 10px"/><span>Duplicate Board </span></sl-button>
<sl-menu>
{#each Array.from(boards.entries()) as [key,board]}
<sl-menu-item on:click={()=>{
createBoardFrom(board)
}} >
{board.latestState.name}
</sl-menu-item>
{/each}

</sl-menu>
</sl-dropdown>
{:catch err}
Error: {err}
{/await}

<input style="display:none" type="file" accept=".json" on:change={(e)=>onFileSelected(e)} bind:this={fileinput} >
</div>
</sl-dialog>
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/BoardMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<div class="board-menu"
class:wide={wide} >
<div style="display:flex;flex-direction: row;">
<div class="new-board" on:click={()=>newBoardDialog.open()} title="New Board"><SvgIcon color="white" size=25px icon=faSquarePlus style="margin-left: 15px;"/><span>New Board</span></div>
<div class="new-board" on:click={()=>newBoardDialog.open()} title="New Board"><SvgIcon color="white" size=25px icon=faSquarePlus style="margin-top:5px; margin-left: 15px;"/><span>New Board</span></div>
</div>
{#if $activeBoards.status == "complete" && $activeBoards.value.length > 0}
<h3 class="type-header">Active Boards</h3>
Expand Down
3 changes: 2 additions & 1 deletion ui/src/svgIcons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export const svgIcons = {
faFileExport: `<svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 576 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M0 64C0 28.7 28.7 0 64 0H224V128c0 17.7 14.3 32 32 32H384V288H216c-13.3 0-24 10.7-24 24s10.7 24 24 24H384V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V64zM384 336V288H494.1l-39-39c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l80 80c9.4 9.4 9.4 24.6 0 33.9l-80 80c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l39-39H384zm0-208H256V0L384 128z"/></svg>`,
faClose: `<svg xmlns="http://www.w3.org/2000/svg" height="16" width="12" viewBox="0 0 384 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>`,
faBug: `<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M256 0c53 0 96 43 96 96v3.6c0 15.7-12.7 28.4-28.4 28.4H188.4c-15.7 0-28.4-12.7-28.4-28.4V96c0-53 43-96 96-96zM41.4 105.4c12.5-12.5 32.8-12.5 45.3 0l64 64c.7 .7 1.3 1.4 1.9 2.1c14.2-7.3 30.4-11.4 47.5-11.4H312c17.1 0 33.2 4.1 47.5 11.4c.6-.7 1.2-1.4 1.9-2.1l64-64c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3l-64 64c-.7 .7-1.4 1.3-2.1 1.9c6.2 12 10.1 25.3 11.1 39.5H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H416c0 24.6-5.5 47.8-15.4 68.6c2.2 1.3 4.2 2.9 6 4.8l64 64c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0l-63.1-63.1c-24.5 21.8-55.8 36.2-90.3 39.6V240c0-8.8-7.2-16-16-16s-16 7.2-16 16V479.2c-34.5-3.4-65.8-17.8-90.3-39.6L86.6 502.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l64-64c1.9-1.9 3.9-3.4 6-4.8C101.5 367.8 96 344.6 96 320H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H96.3c1.1-14.1 5-27.5 11.1-39.5c-.7-.6-1.4-1.2-2.1-1.9l-64-64c-12.5-12.5-12.5-32.8 0-45.3z"/></svg>`,
faBars: `<svg xmlns="http://www.w3.org/2000/svg" height="16" width="14" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"/></svg>`
faBars: `<svg xmlns="http://www.w3.org/2000/svg" height="16" width="14" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"/></svg>`,
faClone: `<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M64 464H288c8.8 0 16-7.2 16-16V384h48v64c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V224c0-35.3 28.7-64 64-64h64v48H64c-8.8 0-16 7.2-16 16V448c0 8.8 7.2 16 16 16zM224 304H448c8.8 0 16-7.2 16-16V64c0-8.8-7.2-16-16-16H224c-8.8 0-16 7.2-16 16V288c0 8.8 7.2 16 16 16zm-64-16V64c0-35.3 28.7-64 64-64H448c35.3 0 64 28.7 64 64V288c0 35.3-28.7 64-64 64H224c-35.3 0-64-28.7-64-64z"/></svg>`
}

0 comments on commit f66e38d

Please sign in to comment.