|
@ -1,8 +1,13 @@ |
|
|
import React, { useEffect, useState } from 'react'; |
|
|
import React, { useEffect, useRef, useState } from 'react'; |
|
|
import { nanoid } from 'nanoid/non-secure'; |
|
|
import { nanoid } from 'nanoid/non-secure'; |
|
|
import settings from 'electron-settings'; |
|
|
import settings from 'electron-settings'; |
|
|
import { ControlLabel } from 'rsuite'; |
|
|
import { ControlLabel } from 'rsuite'; |
|
|
import { StyledInputNumber, StyledPanel, StyledTagPicker } from '../../shared/styled'; |
|
|
import { |
|
|
|
|
|
StyledInputNumber, |
|
|
|
|
|
StyledInputPickerContainer, |
|
|
|
|
|
StyledPanel, |
|
|
|
|
|
StyledTagPicker, |
|
|
|
|
|
} from '../../shared/styled'; |
|
|
import ListViewTable from '../../viewtypes/ListViewTable'; |
|
|
import ListViewTable from '../../viewtypes/ListViewTable'; |
|
|
import { useAppDispatch, useAppSelector } from '../../../redux/hooks'; |
|
|
import { useAppDispatch, useAppSelector } from '../../../redux/hooks'; |
|
|
import { |
|
|
import { |
|
@ -53,6 +58,7 @@ const ListViewConfig = ({ defaultColumns, columnPicker, columnList, settingsConf |
|
|
const config = useAppSelector((state) => state.config); |
|
|
const config = useAppSelector((state) => state.config); |
|
|
const [selectedColumns, setSelectedColumns] = useState([]); |
|
|
const [selectedColumns, setSelectedColumns] = useState([]); |
|
|
const columnListType = settingsConfig.columnList.split('List')[0]; |
|
|
const columnListType = settingsConfig.columnList.split('List')[0]; |
|
|
|
|
|
const columnPickerContainerRef = useRef(null); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
const cols = config.lookAndFeel.listView[columnListType].columns.map((col: any) => { |
|
|
const cols = config.lookAndFeel.listView[columnListType].columns.map((col: any) => { |
|
@ -100,46 +106,49 @@ const ListViewConfig = ({ defaultColumns, columnPicker, columnList, settingsConf |
|
|
<div style={{ width: '100%' }}> |
|
|
<div style={{ width: '100%' }}> |
|
|
<div> |
|
|
<div> |
|
|
<StyledPanel bordered bodyFill> |
|
|
<StyledPanel bordered bodyFill> |
|
|
<StyledTagPicker |
|
|
<StyledInputPickerContainer ref={columnPickerContainerRef}> |
|
|
data={columnPicker} |
|
|
<StyledTagPicker |
|
|
defaultValue={defaultColumns} |
|
|
container={() => columnPickerContainerRef.current} |
|
|
value={selectedColumns} |
|
|
data={columnPicker} |
|
|
style={{ width: '100%' }} |
|
|
defaultValue={defaultColumns} |
|
|
onChange={(e: any) => { |
|
|
value={selectedColumns} |
|
|
const columns: any[] = []; |
|
|
style={{ width: '100%' }} |
|
|
if (e) { |
|
|
onChange={(e: any) => { |
|
|
e.forEach((selected: string) => { |
|
|
const columns: any[] = []; |
|
|
const alreadySelectedColumn = config.lookAndFeel.listView[ |
|
|
if (e) { |
|
|
columnListType |
|
|
e.forEach((selected: string) => { |
|
|
].columns.find((column: any) => column.label === selected); |
|
|
const alreadySelectedColumn = config.lookAndFeel.listView[ |
|
|
|
|
|
columnListType |
|
|
if (alreadySelectedColumn) { |
|
|
].columns.find((column: any) => column.label === selected); |
|
|
return columns.push(alreadySelectedColumn); |
|
|
|
|
|
} |
|
|
if (alreadySelectedColumn) { |
|
|
|
|
|
return columns.push(alreadySelectedColumn); |
|
|
const selectedColumn = columnList.find( |
|
|
} |
|
|
(column: any) => column.label === selected |
|
|
|
|
|
); |
|
|
const selectedColumn = columnList.find( |
|
|
|
|
|
(column: any) => column.label === selected |
|
|
if (selectedColumn) { |
|
|
); |
|
|
return columns.push({ ...selectedColumn.value, uniqueId: nanoid() }); |
|
|
|
|
|
} |
|
|
if (selectedColumn) { |
|
|
|
|
|
return columns.push({ ...selectedColumn.value, uniqueId: nanoid() }); |
|
|
return null; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const cleanColumns = columns.map((col) => { |
|
|
|
|
|
const { uniqueId, ...rest } = col; |
|
|
|
|
|
return rest; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
dispatch(setColumnList({ listType: columnListType, entries: columns })); |
|
|
const cleanColumns = columns.map((col) => { |
|
|
settings.setSync(settingsConfig.columnList, cleanColumns); |
|
|
const { uniqueId, ...rest } = col; |
|
|
}} |
|
|
return rest; |
|
|
labelKey="label" |
|
|
}); |
|
|
valueKey="label" |
|
|
|
|
|
/> |
|
|
dispatch(setColumnList({ listType: columnListType, entries: columns })); |
|
|
</StyledInputPickerContainer> |
|
|
settings.setSync(settingsConfig.columnList, cleanColumns); |
|
|
|
|
|
}} |
|
|
|
|
|
labelKey="label" |
|
|
|
|
|
valueKey="label" |
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<ListViewTable |
|
|
<ListViewTable |
|
|
data={config.lookAndFeel.listView[columnListType].columns || []} |
|
|
data={config.lookAndFeel.listView[columnListType].columns || []} |
|
|