mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
feat(web): ✨ re-enable langs column sort
This commit is contained in:
parent
cecf44a8ec
commit
8a1e608f3e
2 changed files with 36 additions and 4 deletions
|
|
@ -25,7 +25,7 @@ import { Software } from "../../interfaces/Software";
|
|||
import { Syntax } from "../../interfaces/Syntax";
|
||||
import { TagCloud } from "../tagCloud";
|
||||
import { Tag as TagInterface } from "../../interfaces/Tag";
|
||||
import { arraySorter } from "./arraySorter";
|
||||
import { arraySorter, languageArraySorter } from "./arraySorter";
|
||||
import { nameof } from "../../utils";
|
||||
import styles from "./ListsTable.module.css";
|
||||
import { TablePaginationConfig } from "antd/lib/table";
|
||||
|
|
@ -228,9 +228,13 @@ export const ListsTable = (props: RouteComponentProps & Props) => {
|
|||
title="Languages"
|
||||
key="Languages"
|
||||
dataIndex={nameof<List>("languageIso6391s")}
|
||||
// sorter={(a, b) =>
|
||||
// arraySorter(a.languageIso6391s, b.languageIso6391s, languages)
|
||||
// }
|
||||
sorter={(a, b) =>
|
||||
languageArraySorter(
|
||||
a.languageIso6391s,
|
||||
b.languageIso6391s,
|
||||
languages
|
||||
)
|
||||
}
|
||||
width={129}
|
||||
className={styles.nogrow}
|
||||
filters={languages.map((l) => ({
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { Language } from "../../interfaces/Language";
|
||||
|
||||
interface ArraySortableEntity {
|
||||
id: number;
|
||||
name: string;
|
||||
|
|
@ -28,3 +30,29 @@ export const arraySorter = (
|
|||
: 1
|
||||
: -1
|
||||
: 1;
|
||||
|
||||
export const languageArraySorter = (
|
||||
a: string[],
|
||||
b: string[],
|
||||
entities: Language[]
|
||||
) =>
|
||||
a && a.length
|
||||
? b && b.length
|
||||
? a.length === b.length
|
||||
? entities
|
||||
.filter((e: Language) => a.includes(e.iso6391))
|
||||
.map((e: Language) => e.name)
|
||||
.join()
|
||||
.toLowerCase() >
|
||||
entities
|
||||
.filter((e: Language) => b.includes(e.iso6391))
|
||||
.map((e: Language) => e.name)
|
||||
.join()
|
||||
.toLowerCase()
|
||||
? 1
|
||||
: -1
|
||||
: a.length > b.length
|
||||
? -1
|
||||
: 1
|
||||
: -1
|
||||
: 1;
|
||||
|
|
|
|||
Loading…
Reference in a new issue