From 3859ad30b136d550a7eb7b20dd87f132a429ab99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Sat, 24 Oct 2020 08:43:53 +0200 Subject: [PATCH] Moving header dots by menu into the new menu system --- webapp/src/components/boardComponent.tsx | 71 +++++++++---------- webapp/src/components/tableComponent.tsx | 89 +++++++++++++++++------- 2 files changed, 93 insertions(+), 67 deletions(-) diff --git a/webapp/src/components/boardComponent.tsx b/webapp/src/components/boardComponent.tsx index 8f4091388..87941ffe3 100644 --- a/webapp/src/components/boardComponent.tsx +++ b/webapp/src/components/boardComponent.tsx @@ -10,10 +10,10 @@ import {BlockIcons} from '../blockIcons' import {IPropertyOption, IPropertyTemplate} from '../blocks/board' import {Card, MutableCard} from '../blocks/card' import {BoardTree, BoardTreeGroup} from '../viewModel/boardTree' +import {CsvExporter} from '../csvExporter' import {CardFilter} from '../cardFilter' import ViewMenu from '../components/viewMenu' import {Constants} from '../constants' -import {Menu as OldMenu} from '../menu' import mutator from '../mutator' import {Utils} from '../utils' import Menu from '../widgets/menu' @@ -312,12 +312,36 @@ class BoardComponent extends React.Component { }} >Search } -
{ - this.optionsClicked(e) - }} - >
+ +
+ + CsvExporter.exportTableCsv(boardTree)} + /> + Archiver.exportBoardTree(boardTree)} + /> + this.testAddCards(100)} + /> + this.testAddCards(1000)} + /> + this.testRandomizeIcons()} + /> + +
{ @@ -624,39 +648,6 @@ class BoardComponent extends React.Component { this.props.showFilter(e.target as HTMLElement) } - private async optionsClicked(e: React.MouseEvent) { - const {boardTree} = this.props - - OldMenu.shared.options = [ - {id: 'exportBoardArchive', name: 'Export board archive'}, - {id: 'testAdd100Cards', name: 'TEST: Add 100 cards'}, - {id: 'testAdd1000Cards', name: 'TEST: Add 1,000 cards'}, - {id: 'testRandomizeIcons', name: 'TEST: Randomize icons'}, - ] - - OldMenu.shared.onMenuClicked = async (id: string) => { - switch (id) { - case 'exportBoardArchive': { - Archiver.exportBoardTree(boardTree) - break - } - case 'testAdd100Cards': { - this.testAddCards(100) - break - } - case 'testAdd1000Cards': { - this.testAddCards(1000) - break - } - case 'testRandomizeIcons': { - this.testRandomizeIcons() - break - } - } - } - OldMenu.shared.showAtElement(e.target as HTMLElement) - } - private async testAddCards(count: number) { const {boardTree} = this.props const {board, activeView} = boardTree diff --git a/webapp/src/components/tableComponent.tsx b/webapp/src/components/tableComponent.tsx index af12c27f6..0a719add4 100644 --- a/webapp/src/components/tableComponent.tsx +++ b/webapp/src/components/tableComponent.tsx @@ -11,6 +11,7 @@ import {Card, MutableCard} from '../blocks/card' import {BoardTree} from '../viewModel/boardTree' import ViewMenu from '../components/viewMenu' import {CsvExporter} from '../csvExporter' +import {CardFilter} from '../cardFilter' import {Menu as OldMenu} from '../menu' import mutator from '../mutator' import {Utils} from '../utils' @@ -291,10 +292,36 @@ class TableComponent extends React.Component { defaultMessage='Search' />
} -
this.optionsClicked(e)} - >
+ +
+ + CsvExporter.exportTableCsv(boardTree)} + /> + Archiver.exportBoardTree(boardTree)} + /> + this.testAddCards(100)} + /> + this.testAddCards(1000)} + /> + this.testRandomizeIcons()} + /> + +
{ @@ -434,29 +461,6 @@ class TableComponent extends React.Component { this.props.showFilter(e.target as HTMLElement) } - private async optionsClicked(e: React.MouseEvent) { - const {boardTree} = this.props - - OldMenu.shared.options = [ - {id: 'exportCsv', name: 'Export to CSV'}, - {id: 'exportBoardArchive', name: 'Export board archive'}, - ] - - OldMenu.shared.onMenuClicked = async (id: string) => { - switch (id) { - case 'exportCsv': { - CsvExporter.exportTableCsv(boardTree) - break - } - case 'exportBoardArchive': { - Archiver.exportBoardTree(boardTree) - break - } - } - } - OldMenu.shared.showAtElement(e.target as HTMLElement) - } - private async headerClicked(e: React.MouseEvent, templateId: string) { const {boardTree} = this.props const {board} = boardTree @@ -589,6 +593,37 @@ class TableComponent extends React.Component { private searchChanged(text?: string) { this.props.setSearchText(text) } + + private async testAddCards(count: number) { + const {boardTree} = this.props + const {board, activeView} = boardTree + + const startCount = boardTree?.cards?.length + let optionIndex = 0 + + for (let i = 0; i < count; i++) { + const card = new MutableCard() + card.parentId = boardTree.board.id + card.properties = CardFilter.propertiesThatMeetFilterGroup(activeView.filter, board.cardProperties) + if (boardTree.groupByProperty && boardTree.groupByProperty.options.length > 0) { + // Cycle through options + const option = boardTree.groupByProperty.options[optionIndex] + optionIndex = (optionIndex + 1) % boardTree.groupByProperty.options.length + card.properties[boardTree.groupByProperty.id] = option.id + card.title = `Test Card ${startCount + i + 1}` + card.icon = BlockIcons.shared.randomIcon() + } + await mutator.insertBlock(card, 'test add card') + } + } + + private async testRandomizeIcons() { + const {boardTree} = this.props + + for (const card of boardTree.cards) { + mutator.changeIcon(card, BlockIcons.shared.randomIcon(), 'randomize icon') + } + } } export {TableComponent}