Skip to content

Commit f39ddc5

Browse files
Merge pull request #1767 from johnduprey/dev
CippTable tweaks and bug fixes
2 parents ff74503 + ffd0536 commit f39ddc5

File tree

3 files changed

+24
-27
lines changed

3 files changed

+24
-27
lines changed

src/components/tables/CippDatatable.js

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,23 @@ export default function CippDatatable({ path, params, ...rest }) {
1313
isFetching,
1414
error,
1515
} = useListDatatableQuery({ path, params: { refreshGuid, $filter: graphFilter, ...params } })
16+
17+
var defaultFilterText = ''
18+
if (params?.Parameters?.$filter) {
19+
defaultFilterText = 'Graph: ' + params?.Parameters?.$filter
20+
}
1621
return (
1722
<>
18-
{data[0]?.Queued ? (
19-
<>
20-
<CCallout color="info">{data[0]?.QueueMessage}</CCallout>
21-
<CippTable
22-
{...rest}
23-
data={[]}
24-
isFetching={isFetching}
25-
error={error}
26-
refreshFunction={setRefreshGuid}
27-
graphFilterFunction={setGraphFilter}
28-
/>
29-
</>
30-
) : (
31-
<CippTable
32-
{...rest}
33-
data={data}
34-
isFetching={isFetching}
35-
error={error}
36-
refreshFunction={setRefreshGuid}
37-
graphFilterFunction={setGraphFilter}
38-
/>
39-
)}
23+
{data[0]?.Queued && <CCallout color="info">{data[0]?.QueueMessage}</CCallout>}
24+
<CippTable
25+
{...rest}
26+
data={data[0]?.Queued ? [] : data}
27+
isFetching={isFetching}
28+
error={error}
29+
defaultFilterText={defaultFilterText}
30+
refreshFunction={setRefreshGuid}
31+
graphFilterFunction={setGraphFilter}
32+
/>
4033
</>
4134
)
4235
}

src/components/tables/CippTable.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ export default function CippTable({
111111
graphFilterFunction = null,
112112
columns = [],
113113
dynamicColumns = true,
114+
defaultFilterText = '',
115+
isModal = false,
114116
filterlist,
115117
tableProps: {
116118
keyField = 'id',
@@ -137,7 +139,7 @@ export default function CippTable({
137139
const inputRef = useRef('')
138140
const [loopRunning, setLoopRunning] = React.useState(false)
139141
const [massResults, setMassResults] = React.useState([])
140-
const [filterText, setFilterText] = React.useState('')
142+
const [filterText, setFilterText] = React.useState(defaultFilterText)
141143
const [filterviaURL, setFilterviaURL] = React.useState(false)
142144
const [updatedColumns, setUpdatedColumns] = React.useState(columns)
143145
const [selectedRows, setSelectedRows] = React.useState(false)
@@ -147,7 +149,7 @@ export default function CippTable({
147149
const [modalContent, setModalContent] = useState(null)
148150
//get the search params called "tableFilter" and set the filter to that.
149151
const [searchParams, setSearchParams] = useSearchParams()
150-
if (searchParams.get('tableFilter') && !filterviaURL) {
152+
if (searchParams.get('tableFilter') && !filterviaURL && !isModal) {
151153
setFilterText(searchParams.get('tableFilter'))
152154
setFilterviaURL(true)
153155
}
@@ -219,8 +221,10 @@ export default function CippTable({
219221
}, [filterText])
220222

221223
const filterData = (data, filterText) => {
222-
const debouncedSetSearchParams = debounce(debounceSetSearchParams, 1000)
223-
debouncedSetSearchParams()
224+
if (!isModal) {
225+
const debouncedSetSearchParams = debounce(debounceSetSearchParams, 1000)
226+
debouncedSetSearchParams()
227+
}
224228
if (filterText.startsWith('Graph:')) {
225229
var query = filterText.slice(6).trim()
226230
debounceSetGraphFilter(query)

src/components/utilities/SharedModal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { CippTable } from 'src/components/tables'
1313
function mapBodyComponent({ componentType, data, componentProps }) {
1414
switch (componentType) {
1515
case 'table':
16-
return <CippTable data={data || []} {...componentProps} />
16+
return <CippTable data={data || []} isModal={true} {...componentProps} />
1717
case 'list':
1818
return <div>{Array.isArray(data) && data.map((el, idx) => <div key={idx}>{el}</div>)}</div>
1919
case 'text':

0 commit comments

Comments
 (0)