mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add Software column filter, sort all entities in hooks
This commit is contained in:
parent
39c979625a
commit
a1bcdaf4cf
8 changed files with 23 additions and 8 deletions
|
|
@ -12,7 +12,7 @@ import { nameof } from '../../utils';
|
|||
import { Description } from '../Description';
|
||||
import { LanguageCloud } from '../languageCloud';
|
||||
import { ListInfoButton } from '../ListInfoButton';
|
||||
import { SoftwareCloud } from '../softwareCloud';
|
||||
import { SoftwareCloud, SoftwareIcon } from '../softwareCloud';
|
||||
import { TagCloud } from '../tagCloud';
|
||||
import { arraySorter } from './arraySorter';
|
||||
import styles from './ListsTable.module.css';
|
||||
|
|
@ -87,6 +87,14 @@ export const ListsTable = (props: RouteComponentProps & Props) => {
|
|||
}}
|
||||
width={143}
|
||||
className={styles.nogrow}
|
||||
filters={software.map(s => ({
|
||||
text: <>
|
||||
<SoftwareIcon id={s.id} />
|
||||
{s.name}
|
||||
</>,
|
||||
value: s.name
|
||||
}))}
|
||||
onFilter={(value, record) => software.filter((s: Software) => s.name === value).flatMap(s => s.syntaxIds).includes(record.syntaxId)}
|
||||
render={(syntaxId: number) =>
|
||||
syntaxId
|
||||
? <SoftwareCloud software={software.filter((s: Software) => s.syntaxIds.includes(syntaxId))} />
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { SoftwareCloud } from './SoftwareCloud';
|
||||
import { SoftwareIcon } from './SoftwareIcon';
|
||||
|
||||
export { SoftwareCloud };
|
||||
export { SoftwareCloud, SoftwareIcon };
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { Language } from '../interfaces/Language';
|
||||
import { useApiData } from './useApiData';
|
||||
|
||||
export const useLanguages = () => useApiData<Language[]>("/api/v1/languages") || [];
|
||||
export const useLanguages = () => (useApiData<Language[]>("/api/v1/languages") || [])
|
||||
.sort((a: Language, b: Language) => a.name.localeCompare(b.name));
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { License } from '../interfaces/License';
|
||||
import { useApiData } from './useApiData';
|
||||
|
||||
export const useLicenses = () => useApiData<License[]>("/api/v1/licenses") || [];
|
||||
export const useLicenses = () => (useApiData<License[]>("/api/v1/licenses") || [])
|
||||
.sort((a: License, b: License) => a.name.localeCompare(b.name));
|
||||
|
|
@ -6,5 +6,6 @@ import { useApiData } from './useApiData';
|
|||
export const useLists = () => {
|
||||
const lists = useApiData<List[]>("/api/v1/lists");
|
||||
lists && lists.forEach(l => l.slug = slugify(l.name));
|
||||
return lists || [];
|
||||
return (lists || [])
|
||||
.sort((a: List, b: List) => a.name.localeCompare(b.name));
|
||||
};
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { Software } from '../interfaces/Software';
|
||||
import { useApiData } from './useApiData';
|
||||
|
||||
export const useSoftware = () => useApiData<Software[]>("/api/v1/software") || [];
|
||||
export const useSoftware = () => (useApiData<Software[]>("/api/v1/software") || [])
|
||||
.sort((a: Software, b: Software) => a.name.localeCompare(b.name));
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { Syntax } from '../interfaces/Syntax';
|
||||
import { useApiData } from './useApiData';
|
||||
|
||||
export const useSyntaxes = () => useApiData<Syntax[]>("/api/v1/syntaxes") || [];
|
||||
export const useSyntaxes = () => (useApiData<Syntax[]>("/api/v1/syntaxes") || [])
|
||||
.sort((a: Syntax, b: Syntax) => a.name.localeCompare(b.name));
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { Tag } from '../interfaces/Tag';
|
||||
import { useApiData } from './useApiData';
|
||||
|
||||
export const useTags = () => useApiData<Tag[]>("/api/v1/tags") || [];
|
||||
export const useTags = () => (useApiData<Tag[]>("/api/v1/tags") || [])
|
||||
.sort((a: Tag, b: Tag) => a.name.localeCompare(b.name));
|
||||
Loading…
Reference in a new issue