From 5d1ce562f959808ce224b0803c977df98b9305e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Sat, 24 Oct 2020 00:32:09 +0200 Subject: [PATCH] Moving sort menu into the new menu system --- webapp/src/components/boardComponent.tsx | 40 +++++++++++++++++---- webapp/src/components/tableComponent.tsx | 44 +++++++++++++++++------- webapp/src/octoUtils.tsx | 37 ++------------------ 3 files changed, 67 insertions(+), 54 deletions(-) diff --git a/webapp/src/components/boardComponent.tsx b/webapp/src/components/boardComponent.tsx index 946b59af4..ee608d207 100644 --- a/webapp/src/components/boardComponent.tsx +++ b/webapp/src/components/boardComponent.tsx @@ -2,8 +2,10 @@ // See LICENSE.txt for license information. /* eslint-disable max-lines */ import React from 'react' +import {FormattedMessage} from 'react-intl' import {Archiver} from '../archiver' +import {ISortOption} from '../blocks/boardView' import {BlockIcons} from '../blockIcons' import {IPropertyOption} from '../blocks/board' import {Card, MutableCard} from '../blocks/card' @@ -13,7 +15,6 @@ import ViewMenu from '../components/viewMenu' import {Constants} from '../constants' import {Menu as OldMenu} from '../menu' import mutator from '../mutator' -import {OctoUtils} from '../octoUtils' import {Utils} from '../utils' import Menu from '../widgets/menu' import MenuWrapper from '../widgets/menuWrapper' @@ -219,12 +220,37 @@ class BoardComponent extends React.Component { this.filterClicked(e) }} >Filter -
{ - OctoUtils.showSortMenu(e, boardTree) - }} - >Sort
+ +
+ +
+ + {boardTree.board.cardProperties.map((option) => ( + { + let newSortOptions: ISortOption[] = [] + if (activeView.sortOptions[0] && activeView.sortOptions[0].propertyId === propertyId) { + // Already sorting by name, so reverse it + newSortOptions = [ + {propertyId, reversed: !activeView.sortOptions[0].reversed}, + ] + } else { + newSortOptions = [ + {propertyId, reversed: false}, + ] + } + mutator.changeViewSortOptions(activeView, newSortOptions) + }} + /> + ))} + +
{this.state.isSearching ? { defaultMessage='Filter' /> -
{ - OctoUtils.showSortMenu(e, boardTree) - }} - > - -
+ +
+ +
+ + {boardTree.board.cardProperties.map((option) => ( + { + let newSortOptions: ISortOption[] = [] + if (activeView.sortOptions[0] && activeView.sortOptions[0].propertyId === propertyId) { + // Already sorting by name, so reverse it + newSortOptions = [ + {propertyId, reversed: !activeView.sortOptions[0].reversed}, + ] + } else { + newSortOptions = [ + {propertyId, reversed: false}, + ] + } + mutator.changeViewSortOptions(activeView, newSortOptions) + }} + /> + ))} + +
{this.state.isSearching && 0 ? sortOptions[0] : undefined - - const propertyTemplates = boardTree.board.cardProperties - Menu.shared.options = propertyTemplates.map((o) => { - return { - id: o.id, - name: o.name, - icon: (sortOption?.propertyId === o.id) ? sortOption.reversed ? 'sortUp' : 'sortDown' : undefined, - } - }) - Menu.shared.onMenuClicked = async (propertyId: string) => { - let newSortOptions: ISortOption[] = [] - if (sortOption && sortOption.propertyId === propertyId) { - // Already sorting by name, so reverse it - newSortOptions = [ - {propertyId, reversed: !sortOption.reversed}, - ] - } else { - newSortOptions = [ - {propertyId, reversed: false}, - ] - } - - await mutator.changeViewSortOptions(activeView, newSortOptions) - } - Menu.shared.showAtElement(e.target as HTMLElement) - } - static hydrateBlock(block: IBlock): MutableBlock { switch (block.type) { case 'board': { return new MutableBoard(block) }