From 0d89ac65d1107e3feccd5f58c299d9b6d9501d11 Mon Sep 17 00:00:00 2001 From: Vasilev Sergey Date: Wed, 28 Feb 2024 16:57:22 +0400 Subject: [PATCH] Added API for track columns and pass default columns --- .../QueryBuilderModal/QueryBuilderModal.js | 4 ++++ src/QueryBuilder/QueryBuilder/TestQuery/TestQuery.js | 10 ++++++++-- src/QueryBuilder/propTypes.js | 2 ++ src/index.js | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.js b/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.js index e1c71426..0985ba42 100644 --- a/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.js +++ b/src/QueryBuilder/QueryBuilder/QueryBuilderModal/QueryBuilderModal.js @@ -37,6 +37,8 @@ export const QueryBuilderModal = ({ onQueryRunFail, onQueryExecutionSuccess, onQueryExecutionFail, + onSetDefaultVisibleColumns, + recordColumns, getParamsSource, recordsLimit, additionalControls, @@ -212,6 +214,8 @@ export const QueryBuilderModal = ({ testQuery={testQuery} isTestQueryLoading={isTestQueryLoading} fqlQuery={fqlQuery} + recordColumns={recordColumns} + onSetDefaultVisibleColumns={onSetDefaultVisibleColumns} testQueryDataSource={testQueryDataSource} entityTypeDataSource={entityTypeDataSource} queryDetailsDataSource={queryDetailsDataSource} diff --git a/src/QueryBuilder/QueryBuilder/TestQuery/TestQuery.js b/src/QueryBuilder/QueryBuilder/TestQuery/TestQuery.js index d1c66b81..5801b695 100644 --- a/src/QueryBuilder/QueryBuilder/TestQuery/TestQuery.js +++ b/src/QueryBuilder/QueryBuilder/TestQuery/TestQuery.js @@ -20,6 +20,8 @@ export const TestQuery = ({ onQueryExecutionSuccess, onQueryExecutionFail, onQueryRetrieved, + recordColumns = [], + onSetDefaultVisibleColumns, fqlQuery, entityTypeId, isPreviewLoading, @@ -31,7 +33,7 @@ export const TestQuery = ({ const queryClient = useQueryClient(); const [columns, setColumns] = useState([]); - const [visibleColumns, setVisibleColumns] = useState([]); + const [visibleColumns, setVisibleColumns] = useState(recordColumns); const [includeContent, setIncludeContent] = useState(true); const [recordsLimitExceeded, setRecordsLimitExceeded] = useState(false); @@ -106,11 +108,15 @@ export const TestQuery = ({ setIsPreviewLoading(false); }; - const handleColumnChange = ({ values }) => setVisibleColumns(values); + const handleColumnChange = ({ values }) => { + onSetDefaultVisibleColumns(values) + return setVisibleColumns(values) + }; const handleDefaultVisibleColumnsChange = (values) => { if (!visibleColumns.length) { setVisibleColumns(values); + onSetDefaultVisibleColumns(values) } }; diff --git a/src/QueryBuilder/propTypes.js b/src/QueryBuilder/propTypes.js index 5f709716..7bcb63a1 100644 --- a/src/QueryBuilder/propTypes.js +++ b/src/QueryBuilder/propTypes.js @@ -7,8 +7,10 @@ export const queryBuilderModalPropTypes = { testQueryDataSource: PropTypes.func, cancelQueryDataSource: PropTypes.func, queryDetailsDataSource: PropTypes.func, + recordColumns: PropTypes.arrayOf(PropTypes.string), initialValues: PropTypes.object, saveBtnLabel: PropTypes.oneOfType([PropTypes.element, PropTypes.string]), + onSetDefaultVisibleColumns: PropTypes.func, entityTypeDataSource: PropTypes.func, getParamsSource: PropTypes.func, onQueryRunSuccess: PropTypes.func, diff --git a/src/index.js b/src/index.js index f6dae5b1..45690dc4 100644 --- a/src/index.js +++ b/src/index.js @@ -1 +1,2 @@ export { QueryBuilderPlugin as default } from './QueryBuilder'; +export { QueryBuilderPlugin } from './QueryBuilder';