mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 13:20:43 +00:00
Merged feature/filter-json-field-improvements into dev
This commit is contained in:
@ -407,6 +407,7 @@ function EntityForm(props: Props): JSX.Element
|
|||||||
widgetMetaData={widgetMetaData}
|
widgetMetaData={widgetMetaData}
|
||||||
widgetData={widgetData}
|
widgetData={widgetData}
|
||||||
recordValues={formValues}
|
recordValues={formValues}
|
||||||
|
label={tableMetaData?.fields.get(widgetData?.filterFieldName ?? "queryFilterJson")?.label}
|
||||||
onSaveCallback={setFormFieldValuesFromWidget}
|
onSaveCallback={setFormFieldValuesFromWidget}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ function ScriptDocsForm({helpText, exampleCode, aceEditorHeight}: Props): JSX.El
|
|||||||
<Card sx={{width: "100%", height: "100%"}}>
|
<Card sx={{width: "100%", height: "100%"}}>
|
||||||
<Typography variant="h6" p={2} pb={1}>{heading}</Typography>
|
<Typography variant="h6" p={2} pb={1}>{heading}</Typography>
|
||||||
<Box className="devDocumentation" height="100%">
|
<Box className="devDocumentation" height="100%">
|
||||||
<Typography variant="body2" sx={{maxWidth: "1200px", margin: "auto", height: "100%"}}>
|
<Typography variant="body2" sx={{maxWidth: "1200px", margin: "auto", height: "calc(100% - 0.5rem)"}}>
|
||||||
<AceEditor
|
<AceEditor
|
||||||
mode={mode}
|
mode={mode}
|
||||||
theme="github"
|
theme="github"
|
||||||
@ -62,7 +62,7 @@ function ScriptDocsForm({helpText, exampleCode, aceEditorHeight}: Props): JSX.El
|
|||||||
width="100%"
|
width="100%"
|
||||||
showPrintMargin={false}
|
showPrintMargin={false}
|
||||||
height="100%"
|
height="100%"
|
||||||
style={{borderBottomRightRadius: "1rem", borderBottomLeftRadius: "1rem"}}
|
style={{borderBottomRightRadius: "0.75rem", borderBottomLeftRadius: "0.75rem"}}
|
||||||
/>
|
/>
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -46,11 +46,12 @@ import React, {useContext, useEffect, useRef, useState} from "react";
|
|||||||
|
|
||||||
interface FilterAndColumnsSetupWidgetProps
|
interface FilterAndColumnsSetupWidgetProps
|
||||||
{
|
{
|
||||||
isEditable: boolean;
|
isEditable: boolean,
|
||||||
widgetMetaData: QWidgetMetaData;
|
widgetMetaData: QWidgetMetaData,
|
||||||
widgetData: any;
|
widgetData: any,
|
||||||
recordValues: { [name: string]: any };
|
recordValues: { [name: string]: any },
|
||||||
onSaveCallback?: (values: { [name: string]: any }) => void;
|
onSaveCallback?: (values: { [name: string]: any }) => void,
|
||||||
|
label?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterAndColumnsSetupWidget.defaultProps = {
|
FilterAndColumnsSetupWidget.defaultProps = {
|
||||||
@ -83,13 +84,16 @@ const qController = Client.getInstance();
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Component for editing the main setup of a report - that is: filter & columns
|
** Component for editing the main setup of a report - that is: filter & columns
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
export default function FilterAndColumnsSetupWidget({isEditable, widgetMetaData, widgetData, recordValues, onSaveCallback}: FilterAndColumnsSetupWidgetProps): JSX.Element
|
export default function FilterAndColumnsSetupWidget({isEditable, widgetMetaData, widgetData, recordValues, onSaveCallback, label}: FilterAndColumnsSetupWidgetProps): JSX.Element
|
||||||
{
|
{
|
||||||
const [modalOpen, setModalOpen] = useState(false);
|
const [modalOpen, setModalOpen] = useState(false);
|
||||||
const [hideColumns, setHideColumns] = useState(widgetData?.hideColumns);
|
const [hideColumns] = useState(widgetData?.hideColumns);
|
||||||
const [hidePreview, setHidePreview] = useState(widgetData?.hidePreview);
|
const [hidePreview] = useState(widgetData?.hidePreview);
|
||||||
const [tableMetaData, setTableMetaData] = useState(null as QTableMetaData);
|
const [tableMetaData, setTableMetaData] = useState(null as QTableMetaData);
|
||||||
|
|
||||||
|
const [filterFieldName] = useState(widgetData?.filterFieldName ?? "queryFilterJson");
|
||||||
|
const [columnsFieldName] = useState(widgetData?.columnsFieldName ?? "columnsJson");
|
||||||
|
|
||||||
const [alertContent, setAlertContent] = useState(null as string);
|
const [alertContent, setAlertContent] = useState(null as string);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -108,7 +112,7 @@ export default function FilterAndColumnsSetupWidget({isEditable, widgetMetaData,
|
|||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
let columns: QQueryColumns = null;
|
let columns: QQueryColumns = null;
|
||||||
let usingDefaultEmptyFilter = false;
|
let usingDefaultEmptyFilter = false;
|
||||||
let queryFilter = recordValues["queryFilterJson"] && JSON.parse(recordValues["queryFilterJson"]) as QQueryFilter;
|
let queryFilter = recordValues[filterFieldName] && JSON.parse(recordValues[filterFieldName]) as QQueryFilter;
|
||||||
const defaultFilterFields = widgetData?.filterDefaultFieldNames;
|
const defaultFilterFields = widgetData?.filterDefaultFieldNames;
|
||||||
if (!queryFilter)
|
if (!queryFilter)
|
||||||
{
|
{
|
||||||
@ -142,9 +146,9 @@ export default function FilterAndColumnsSetupWidget({isEditable, widgetMetaData,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recordValues["columnsJson"])
|
if (recordValues[columnsFieldName])
|
||||||
{
|
{
|
||||||
columns = QQueryColumns.buildFromJSON(recordValues["columnsJson"]);
|
columns = QQueryColumns.buildFromJSON(recordValues[columnsFieldName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@ -230,7 +234,10 @@ export default function FilterAndColumnsSetupWidget({isEditable, widgetMetaData,
|
|||||||
setFrontendQueryFilter(view.queryFilter);
|
setFrontendQueryFilter(view.queryFilter);
|
||||||
const filter = FilterUtils.prepQueryFilterForBackend(tableMetaData, view.queryFilter);
|
const filter = FilterUtils.prepQueryFilterForBackend(tableMetaData, view.queryFilter);
|
||||||
|
|
||||||
onSaveCallback({queryFilterJson: JSON.stringify(filter), columnsJson: JSON.stringify(view.queryColumns)});
|
const rs: { [key: string]: any } = {};
|
||||||
|
rs[filterFieldName] = JSON.stringify(filter);
|
||||||
|
rs[columnsFieldName] = JSON.stringify(view.queryColumns);
|
||||||
|
onSaveCallback(rs);
|
||||||
|
|
||||||
closeEditor();
|
closeEditor();
|
||||||
}
|
}
|
||||||
@ -356,7 +363,7 @@ export default function FilterAndColumnsSetupWidget({isEditable, widgetMetaData,
|
|||||||
</Collapse>
|
</Collapse>
|
||||||
<Box pt="0.5rem">
|
<Box pt="0.5rem">
|
||||||
<Box display="flex" justifyContent="space-between" alignItems="center">
|
<Box display="flex" justifyContent="space-between" alignItems="center">
|
||||||
<h5>Query Filter</h5>
|
<h5>{label ?? "Query Filter"}</h5>
|
||||||
<Box fontSize="0.75rem" fontWeight="700">{mayShowQuery() && getCurrentSortIndicator(frontendQueryFilter, tableMetaData, null)}</Box>
|
<Box fontSize="0.75rem" fontWeight="700">{mayShowQuery() && getCurrentSortIndicator(frontendQueryFilter, tableMetaData, null)}</Box>
|
||||||
</Box>
|
</Box>
|
||||||
{
|
{
|
||||||
|
@ -393,7 +393,7 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container className="scriptViewer" m={-2} pt={4} width={"calc(100% + 2rem)"}>
|
<Grid container className="scriptViewer" my={-3} mx={-3} pt={4} width={"calc(100% + 3rem)"}>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Box>
|
<Box>
|
||||||
{
|
{
|
||||||
@ -530,7 +530,7 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
|
||||||
<TabPanel index={2} value={selectedTab}>
|
<TabPanel index={2} value={selectedTab}>
|
||||||
<Box sx={{height: "455px"}} px={2} pb={1}>
|
<Box sx={{height: "455px"}} px={2} pt={1}>
|
||||||
<ScriptTestForm scriptId={scriptId}
|
<ScriptTestForm scriptId={scriptId}
|
||||||
scriptType={scriptTypeRecord}
|
scriptType={scriptTypeRecord}
|
||||||
tableName={associatedScriptTableName}
|
tableName={associatedScriptTableName}
|
||||||
@ -543,7 +543,7 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
|
||||||
<TabPanel index={3} value={selectedTab}>
|
<TabPanel index={3} value={selectedTab}>
|
||||||
<Box sx={{height: "455px"}} px={2} pb={1}>
|
<Box sx={{height: "455px"}} px={2} pt={1}>
|
||||||
<ScriptDocsForm helpText={scriptTypeRecord?.values.get("helpText")} exampleCode={scriptTypeRecord?.values.get("sampleCode")} />
|
<ScriptDocsForm helpText={scriptTypeRecord?.values.get("helpText")} exampleCode={scriptTypeRecord?.values.get("sampleCode")} />
|
||||||
</Box>
|
</Box>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
@ -191,7 +191,7 @@ function RecordDeveloperView({table}: Props): JSX.Element
|
|||||||
<Card sx={{mb: 3}}>
|
<Card sx={{mb: 3}}>
|
||||||
<Typography variant="h6" p={2} pl={3} pb={3}>{field?.label}</Typography>
|
<Typography variant="h6" p={2} pl={3} pb={3}>{field?.label}</Typography>
|
||||||
|
|
||||||
<Box display="flex" alignItems="center" justifyContent="space-between" gap={2}>
|
<Box display="flex" alignItems="center" justifyContent="space-between" gap={2} mx={3} mb={3} mt={0}>
|
||||||
{scriptId ?
|
{scriptId ?
|
||||||
<ScriptViewer
|
<ScriptViewer
|
||||||
scriptId={scriptId}
|
scriptId={scriptId}
|
||||||
|
Reference in New Issue
Block a user