mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Use of quoteStrings in export, added many additional export fields. Replaced line feeds with spaces in export data.
This commit is contained in:
@@ -29,6 +29,7 @@ type LocalityPreFilter = {
|
||||
frac_max: string | null
|
||||
frac_min: string | null
|
||||
chron: string | null
|
||||
age_comm: string | null
|
||||
basin: string | null
|
||||
subbasin: string | null
|
||||
dms_lat: string | null
|
||||
@@ -71,6 +72,7 @@ export const getAllLocalities = async (user?: User) => {
|
||||
frac_max: true,
|
||||
frac_min: true,
|
||||
chron: true,
|
||||
age_comm: true,
|
||||
basin: true,
|
||||
subbasin: true,
|
||||
dms_lat: true,
|
||||
@@ -81,6 +83,7 @@ export const getAllLocalities = async (user?: User) => {
|
||||
country: true,
|
||||
state: true,
|
||||
county: true,
|
||||
appr_num_spm: true,
|
||||
site_area: true,
|
||||
gen_loc: true,
|
||||
plate: true,
|
||||
@@ -88,6 +91,26 @@ export const getAllLocalities = async (user?: User) => {
|
||||
member: true,
|
||||
bed: true,
|
||||
loc_status: true,
|
||||
estimate_precip: true,
|
||||
estimate_temp: true,
|
||||
estimate_npp: true,
|
||||
pers_woody_cover: true,
|
||||
pers_pollen_ap: true,
|
||||
pers_pollen_nap: true,
|
||||
pers_pollen_other: true,
|
||||
hominin_skeletal_remains: true,
|
||||
bipedal_footprints: true,
|
||||
stone_tool_cut_marks_on_bones: true,
|
||||
stone_tool_technology: true,
|
||||
technological_mode_1: true,
|
||||
technological_mode_2: true,
|
||||
technological_mode_3: true,
|
||||
cultural_stage_1: true,
|
||||
cultural_stage_2: true,
|
||||
cultural_stage_3: true,
|
||||
regional_culture_1: true,
|
||||
regional_culture_2: true,
|
||||
regional_culture_3: true,
|
||||
now_plr: {
|
||||
select: { pid: true },
|
||||
},
|
||||
|
||||
@@ -32,90 +32,6 @@ export const LocalityTable = ({ selectorFn }: { selectorFn?: (newObject: Localit
|
||||
enableHiding: false,
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'country',
|
||||
accessorFn: row => row.country || '',
|
||||
header: 'Country',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'state',
|
||||
accessorFn: row => row.state || '',
|
||||
header: 'State',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'county',
|
||||
accessorFn: row => row.county || '',
|
||||
header: 'County',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'bfa_max',
|
||||
accessorFn: row => row.bfa_max || '',
|
||||
header: 'BFA max',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'bfa_min',
|
||||
accessorFn: row => row.bfa_min || '',
|
||||
header: 'BFA min',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
accessorKey: 'max_age',
|
||||
header: 'Max age',
|
||||
filterVariant: 'range',
|
||||
enableColumnFilterModes: false,
|
||||
Cell: ({ cell }) => {
|
||||
const cellVal = cell.getValue() as number
|
||||
if (decimalCount(cellVal) > 3) {
|
||||
return cellVal.toFixed(3)
|
||||
}
|
||||
return cellVal
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'min_age',
|
||||
header: 'Min age',
|
||||
filterVariant: 'range',
|
||||
enableColumnFilterModes: false,
|
||||
Cell: ({ cell }) => {
|
||||
const cellVal = cell.getValue() as number
|
||||
if (decimalCount(cellVal) > 3) {
|
||||
return cellVal.toFixed(3)
|
||||
}
|
||||
return cellVal
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'frac_max',
|
||||
header: 'Frac max',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'frac_min',
|
||||
header: 'Frac min',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
id: 'chron',
|
||||
accessorFn: row => row.chron || '',
|
||||
header: 'Chron',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'basin',
|
||||
accessorFn: row => row.basin || '',
|
||||
header: 'Basin',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'subbasin',
|
||||
accessorFn: row => row.subbasin || '',
|
||||
header: 'Subbasin',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
accessorKey: 'dms_lat',
|
||||
header: 'DMS lat',
|
||||
@@ -144,8 +60,112 @@ export const LocalityTable = ({ selectorFn }: { selectorFn?: (newObject: Localit
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'site_area',
|
||||
header: 'Site area',
|
||||
accessorKey: 'max_age',
|
||||
header: 'Max age',
|
||||
filterVariant: 'range',
|
||||
enableColumnFilterModes: false,
|
||||
Cell: ({ cell }) => {
|
||||
const cellVal = cell.getValue() as number
|
||||
if (decimalCount(cellVal) > 3) {
|
||||
return cellVal.toFixed(3)
|
||||
}
|
||||
return cellVal
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'bfa_max',
|
||||
accessorFn: row => row.bfa_max || '',
|
||||
header: 'BFA max',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'bfa_max_abs',
|
||||
accessorFn: row => row.bfa_max_abs || '',
|
||||
header: 'BFA max abs',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
accessorKey: 'frac_max',
|
||||
header: 'Frac max',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'min_age',
|
||||
header: 'Min age',
|
||||
filterVariant: 'range',
|
||||
enableColumnFilterModes: false,
|
||||
Cell: ({ cell }) => {
|
||||
const cellVal = cell.getValue() as number
|
||||
if (decimalCount(cellVal) > 3) {
|
||||
return cellVal.toFixed(3)
|
||||
}
|
||||
return cellVal
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'bfa_min',
|
||||
accessorFn: row => row.bfa_min || '',
|
||||
header: 'BFA min',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'bfa_min_abs',
|
||||
accessorFn: row => row.bfa_min_abs || '',
|
||||
header: 'BFA min abs',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
accessorKey: 'frac_min',
|
||||
header: 'Frac min',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
id: 'chron',
|
||||
accessorFn: row => row.chron || '',
|
||||
header: 'Chron',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'age_comm',
|
||||
accessorFn: row => row.age_comm || '',
|
||||
header: 'Age Comment',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'basin',
|
||||
accessorFn: row => row.basin || '',
|
||||
header: 'Basin',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'subbasin',
|
||||
accessorFn: row => row.subbasin || '',
|
||||
header: 'Subbasin',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'country',
|
||||
accessorFn: row => row.country || '',
|
||||
header: 'Country',
|
||||
enableHiding: false,
|
||||
enableColumnFilterModes: false,
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'state',
|
||||
accessorFn: row => row.state || '',
|
||||
header: 'State',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'county',
|
||||
accessorFn: row => row.county || '',
|
||||
header: 'County',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
accessorKey: 'appr_num_spm',
|
||||
header: 'Approx. Number of Specimens',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
@@ -153,6 +173,12 @@ export const LocalityTable = ({ selectorFn }: { selectorFn?: (newObject: Localit
|
||||
header: 'Gen locality',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'site_area',
|
||||
header: 'Site area',
|
||||
enableColumnFilterModes: false,
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'plate',
|
||||
accessorFn: row => row.plate || '',
|
||||
@@ -175,6 +201,113 @@ export const LocalityTable = ({ selectorFn }: { selectorFn?: (newObject: Localit
|
||||
id: 'bed',
|
||||
accessorFn: row => row.bed || '',
|
||||
header: 'Bed',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
accessorKey: 'estimate_precip',
|
||||
header: 'Estimate of annual precipitation (mm)',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'estimate_temp',
|
||||
header: 'Estimate MAT',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'estimate_npp',
|
||||
header: 'Estimate NPP',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'pers_woody_cover',
|
||||
header: 'Woody cover percentage',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'pers_pollen_ap',
|
||||
header: 'Arboreal pollen percentage',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'pers_pollen_nap',
|
||||
header: 'Non-arboreal pollen percentage',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'pers_pollen_other',
|
||||
header: 'Other pollen percentage',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'hominin_skeletal_remains',
|
||||
header: 'Hominin skeletal remains',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'bipedal_footprints',
|
||||
header: 'Bipedal footprints',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'stone_tool_cut_marks_on_bones',
|
||||
header: 'Stone tool cut marks on bones',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'stone_tool_technology',
|
||||
header: 'Stone tool technology',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'technological_mode_1',
|
||||
header: 'Technological mode 1',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'technological_mode_2',
|
||||
header: 'Technological mode 2',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
accessorKey: 'technological_mode_3',
|
||||
header: 'Technological mode 3',
|
||||
enableColumnFilterModes: false,
|
||||
},
|
||||
{
|
||||
id: 'cultural_stage_1',
|
||||
accessorFn: row => row.cultural_stage_1 || '',
|
||||
header: 'Cultural stage 1',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'cultural_stage_2',
|
||||
accessorFn: row => row.cultural_stage_2 || '',
|
||||
header: 'Cultural stage 2',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'cultural_stage_3',
|
||||
accessorFn: row => row.cultural_stage_3 || '',
|
||||
header: 'Cultural stage 3',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'regional_culture_1',
|
||||
accessorFn: row => row.regional_culture_1 || '',
|
||||
header: 'Regional culture 1',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'regional_culture_2',
|
||||
accessorFn: row => row.regional_culture_2 || '',
|
||||
header: 'Regional culture 2',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
{
|
||||
id: 'regional_culture_3',
|
||||
accessorFn: row => row.regional_culture_3 || '',
|
||||
header: 'Regional culture 3',
|
||||
filterFn: 'contains',
|
||||
},
|
||||
],
|
||||
[]
|
||||
@@ -189,6 +322,7 @@ export const LocalityTable = ({ selectorFn }: { selectorFn?: (newObject: Localit
|
||||
frac_max: false,
|
||||
frac_min: false,
|
||||
chron: false,
|
||||
age_comm: false,
|
||||
basin: false,
|
||||
subbasin: false,
|
||||
dms_lat: false,
|
||||
@@ -204,6 +338,27 @@ export const LocalityTable = ({ selectorFn }: { selectorFn?: (newObject: Localit
|
||||
formation: false,
|
||||
member: false,
|
||||
bed: false,
|
||||
appr_num_spm: false,
|
||||
estimate_precip: false,
|
||||
estimate_temp: false,
|
||||
estimate_npp: false,
|
||||
pers_woody_cover: false,
|
||||
pers_pollen_ap: false,
|
||||
pers_pollen_nap: false,
|
||||
pers_pollen_other: false,
|
||||
hominin_skeletal_remains: false,
|
||||
bipedal_footprints: false,
|
||||
stone_tool_cut_marks_on_bones: false,
|
||||
stone_tool_technology: false,
|
||||
technological_mode_1: false,
|
||||
technological_mode_2: false,
|
||||
technological_mode_3: false,
|
||||
cultural_stage_1: false,
|
||||
cultural_stage_2: false,
|
||||
cultural_stage_3: false,
|
||||
regional_culture_1: false,
|
||||
regional_culture_2: false,
|
||||
regional_culture_3: false,
|
||||
}
|
||||
|
||||
const combinedExport = async (lids: number[]) => {
|
||||
|
||||
@@ -15,12 +15,17 @@ const exportRows = <T extends MRT_RowData>(table: MRT_TableInstance<T>) => {
|
||||
fieldSeparator: ',',
|
||||
decimalSeparator: '.',
|
||||
useKeysAsHeaders: true,
|
||||
quoteStrings: true, // If true, will wrap all values in double quotes
|
||||
})
|
||||
const rowData = table.getPrePaginationRowModel().rows.map(row => {
|
||||
const r = {} as Record<string, AcceptedData>
|
||||
row.getVisibleCells().map(cell => {
|
||||
const columnHeader = table.getColumn(cell.column.id).columnDef.header
|
||||
const value = cell.getValue() as AcceptedData
|
||||
let value = cell.getValue() as AcceptedData;
|
||||
if (typeof value === 'string') {
|
||||
value = value.replace(/[\r\n]+/g, ' '); // Replace line feeds with spaces
|
||||
}
|
||||
// const value = cell.getValue() as AcceptedData
|
||||
// Action row has no header; skipping it. Will cause trouble if some actual column's header is empty
|
||||
if (columnHeader !== '') r[columnHeader] = value !== null ? value : ''
|
||||
})
|
||||
|
||||
@@ -49,6 +49,7 @@ export type Locality = {
|
||||
frac_max: string | null
|
||||
frac_min: string | null
|
||||
chron: string | null
|
||||
age_comm: string | null
|
||||
basin: string | null
|
||||
subbasin: string | null
|
||||
dms_lat: string | null
|
||||
@@ -59,6 +60,7 @@ export type Locality = {
|
||||
country: string
|
||||
state: string | null
|
||||
county: string | null
|
||||
appr_num_spm: number
|
||||
site_area: string | null
|
||||
gen_loc: string | null
|
||||
plate: string | null
|
||||
@@ -66,6 +68,26 @@ export type Locality = {
|
||||
member: string | null
|
||||
bed: string | null
|
||||
loc_status: boolean | null
|
||||
estimate_precip: number | null
|
||||
estimate_temp: number | null
|
||||
estimate_npp: number | null
|
||||
pers_woody_cover: number | null
|
||||
pers_pollen_ap: number | null
|
||||
pers_pollen_nap: number | null
|
||||
pers_pollen_other: number | null
|
||||
hominin_skeletal_remains: boolean | null
|
||||
bipedal_footprints: boolean | null
|
||||
stone_tool_cut_marks_on_bones: boolean | null
|
||||
stone_tool_technology: boolean | null
|
||||
technological_mode_1: number | null
|
||||
technological_mode_2: number | null
|
||||
technological_mode_3: number | null
|
||||
cultural_stage_1: string | null
|
||||
cultural_stage_2: string | null
|
||||
cultural_stage_3: string | null
|
||||
regional_culture_1: string | null
|
||||
regional_culture_2: string | null
|
||||
regional_culture_3: string | null
|
||||
}
|
||||
export type CrossSearch = {
|
||||
lid: number
|
||||
|
||||
Reference in New Issue
Block a user