From ac86fbfab8b244f68d9b87071451c1313ffc22be Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Fri, 16 Aug 2019 15:48:10 -0500 Subject: [PATCH] port sort by tags --- .../src/modules/allListsTable/AllListsTable.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx b/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx index 476ecbfc6..575286f12 100644 --- a/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx +++ b/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx @@ -1,5 +1,6 @@ import { Table } from 'antd'; import React from 'react'; + import { Description, SubscribeButton, TagCloud } from '../../shared'; import { nameof } from '../../utils'; import styles from './AllListsTable.module.css'; @@ -58,6 +59,20 @@ export class AllListsTable extends React.Component<{}, State> { }); } + private tagSorter = (a: number[], b: number[], tags: Tag[]): number => { + return a + ? b + ? a.length === b.length + ? tags.filter((t: Tag) => a.indexOf(t.id) > -1).map((t: Tag) => t.name).join().toLowerCase() > tags.filter((t: Tag) => b.indexOf(t.id) > -1).map((t: Tag) => t.name).join().toLowerCase() + ? 1 + : -1 + : a.length > b.length + ? -1 + : 1 + : -1 + : 1; + }; + render() { return ( @@ -100,6 +115,7 @@ export class AllListsTable extends React.Component<{}, State> { title="Tags" dataIndex={nameof("tagIds")} + sorter={(a, b) => this.tagSorter(a.tagIds, b.tagIds, this.state.tags)} width={275} className={styles.nogrow} render={(tagIds: number[]) =>