mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
add synonym icon for species with synonym
This commit is contained in:
@@ -7,7 +7,7 @@ import { logDb, nowDb } from '../utils/db'
|
||||
import { getReferenceDetails } from './reference'
|
||||
|
||||
export const getAllSpecies = async () => {
|
||||
const result = await nowDb.com_species.findMany({
|
||||
const speciesResult = await nowDb.com_species.findMany({
|
||||
select: {
|
||||
species_id: true,
|
||||
order_name: true,
|
||||
@@ -54,6 +54,17 @@ export const getAllSpecies = async () => {
|
||||
},
|
||||
})
|
||||
|
||||
const synonyms: { species_id: number }[] = await nowDb.com_taxa_synonym.findMany({
|
||||
select: { species_id: true },
|
||||
distinct: ['species_id'],
|
||||
})
|
||||
|
||||
const synonymIdSet = new Set(synonyms.map(s => s.species_id))
|
||||
const result = speciesResult.map(sp => ({
|
||||
...sp,
|
||||
has_synonym: synonymIdSet.has(sp.species_id),
|
||||
}))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ export const TableView = <T extends MRT_RowData>({
|
||||
serverSidePagination,
|
||||
isFetching,
|
||||
}: {
|
||||
title?: string
|
||||
data: T[] | undefined
|
||||
columns: MRT_ColumnDef<T>[]
|
||||
visibleColumns: MRT_VisibilityState
|
||||
@@ -54,6 +53,7 @@ export const TableView = <T extends MRT_RowData>({
|
||||
checkRowRestriction?: (row: T) => boolean
|
||||
selectorFn?: (id: T) => void
|
||||
url?: string
|
||||
title?: string
|
||||
combinedExport?: (lids: number[]) => Promise<void>
|
||||
kmlExport?: (table: MRT_TableInstance<T>) => void
|
||||
svgExport?: (table: MRT_TableInstance<T>) => void
|
||||
@@ -127,7 +127,19 @@ export const TableView = <T extends MRT_RowData>({
|
||||
columnVisibility: visibleColumns,
|
||||
},
|
||||
onColumnFiltersChange: setColumnFilters,
|
||||
renderRowActions: ({ row }) => <ActionComponent {...{ selectorFn, url, checkRowRestriction, row, idFieldName }} />,
|
||||
renderRowActions: ({ row }) => {
|
||||
const hasSynonym = row.original.has_synonym ? true : false
|
||||
|
||||
return (
|
||||
<Box sx={{ display: 'flex', flexWrap: 'nowrap', gap: '8px' }}>
|
||||
<ActionComponent {...{ selectorFn, url, checkRowRestriction, row, idFieldName }} />
|
||||
{hasSynonym && (
|
||||
<button onClick={() => alert(`Synonym exists for id ${row.original[idFieldName]}`)}>Synonym icon</button>
|
||||
)}
|
||||
{/* {hasSynonym && <ActionComponent {...{ selectorFn, url, checkRowRestriction, row, idFieldName }} />} */}
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
displayColumnDefOptions: { 'mrt-row-actions': { size: 50, header: '' } },
|
||||
enableRowActions: true,
|
||||
enableMultiSort: !serverSidePagination,
|
||||
@@ -218,6 +230,7 @@ export const TableView = <T extends MRT_RowData>({
|
||||
)}
|
||||
|
||||
<MaterialReactTable table={table} />
|
||||
<p> moikka </p>
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user