mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 13:20:43 +00:00
CE-938: updated to get filter and column setup values from widget data, rather than 'default values'
This commit is contained in:
@ -97,7 +97,7 @@ export const getAutocompleteOutlinedStyle = (isDisabled: boolean) =>
|
|||||||
borderColor: inputBorderColor
|
borderColor: inputBorderColor
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
const qController = Client.getInstance();
|
const qController = Client.getInstance();
|
||||||
@ -108,36 +108,36 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
const [options, setOptions] = useState<readonly QPossibleValue[]>([]);
|
const [options, setOptions] = useState<readonly QPossibleValue[]>([]);
|
||||||
const [searchTerm, setSearchTerm] = useState(null);
|
const [searchTerm, setSearchTerm] = useState(null);
|
||||||
const [firstRender, setFirstRender] = useState(true);
|
const [firstRender, setFirstRender] = useState(true);
|
||||||
const [otherValuesWhenResultsWereLoaded, setOtherValuesWhenResultsWereLoaded] = useState(JSON.stringify(Object.fromEntries((otherValues))))
|
const [otherValuesWhenResultsWereLoaded, setOtherValuesWhenResultsWereLoaded] = useState(JSON.stringify(Object.fromEntries((otherValues))));
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
if(tableName && processName)
|
if (tableName && processName)
|
||||||
{
|
{
|
||||||
console.log("DynamicSelect - you may not provide both a tableName and a processName")
|
console.log("DynamicSelect - you may not provide both a tableName and a processName");
|
||||||
}
|
}
|
||||||
if(tableName && !fieldName)
|
if (tableName && !fieldName)
|
||||||
{
|
{
|
||||||
console.log("DynamicSelect - if you provide a tableName, you must also provide a fieldName");
|
console.log("DynamicSelect - if you provide a tableName, you must also provide a fieldName");
|
||||||
}
|
}
|
||||||
if(processName && !fieldName)
|
if (processName && !fieldName)
|
||||||
{
|
{
|
||||||
console.log("DynamicSelect - if you provide a processName, you must also provide a fieldName");
|
console.log("DynamicSelect - if you provide a processName, you must also provide a fieldName");
|
||||||
}
|
}
|
||||||
if(!fieldName && !possibleValueSourceName)
|
if (!fieldName && !possibleValueSourceName)
|
||||||
{
|
{
|
||||||
console.log("DynamicSelect - you must provide either a fieldName (and a tableName or processName) or a possibleValueSourceName");
|
console.log("DynamicSelect - you must provide either a fieldName (and a tableName or processName) or a possibleValueSourceName");
|
||||||
}
|
}
|
||||||
if(fieldName && !possibleValueSourceName)
|
if (fieldName && !possibleValueSourceName)
|
||||||
{
|
{
|
||||||
if(!tableName || !processName)
|
if (!tableName || !processName)
|
||||||
{
|
{
|
||||||
console.log("DynamicSelect - if you provide a fieldName and not a possibleValueSourceName, then you must also provide a tableName or processName");
|
console.log("DynamicSelect - if you provide a fieldName and not a possibleValueSourceName, then you must also provide a tableName or processName");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(possibleValueSourceName)
|
if (possibleValueSourceName)
|
||||||
{
|
{
|
||||||
if(tableName || processName)
|
if (tableName || processName)
|
||||||
{
|
{
|
||||||
console.log("DynamicSelect - if you provide a possibleValueSourceName, you should not also provide a tableName or processName");
|
console.log("DynamicSelect - if you provide a possibleValueSourceName, you should not also provide a tableName or processName");
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
if(firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
// console.log("First render, so not searching...");
|
// console.log("First render, so not searching...");
|
||||||
setFirstRender(false);
|
setFirstRender(false);
|
||||||
@ -196,7 +196,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
// console.log(`doing a search with ${searchTerm}`);
|
// console.log(`doing a search with ${searchTerm}`);
|
||||||
const results: QPossibleValue[] = await qController.possibleValues(tableName, processName, possibleValueSourceName ?? fieldName, searchTerm ?? "", null, otherValues);
|
const results: QPossibleValue[] = await qController.possibleValues(tableName, processName, possibleValueSourceName ?? fieldName, searchTerm ?? "", null, otherValues);
|
||||||
|
|
||||||
if(tableMetaData == null && tableName)
|
if (tableMetaData == null && tableName)
|
||||||
{
|
{
|
||||||
let tableMetaData: QTableMetaData = await qController.loadTableMetaData(tableName);
|
let tableMetaData: QTableMetaData = await qController.loadTableMetaData(tableName);
|
||||||
setTableMetaData(tableMetaData);
|
setTableMetaData(tableMetaData);
|
||||||
@ -207,7 +207,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
// console.log(`${results}`);
|
// console.log(`${results}`);
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
setOptions([ ...results ]);
|
setOptions([...results]);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@ -215,12 +215,12 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
{
|
{
|
||||||
active = false;
|
active = false;
|
||||||
};
|
};
|
||||||
}, [ searchTerm ]);
|
}, [searchTerm]);
|
||||||
|
|
||||||
// todo - finish... call it in onOpen?
|
// todo - finish... call it in onOpen?
|
||||||
const reloadIfOtherValuesAreChanged = () =>
|
const reloadIfOtherValuesAreChanged = () =>
|
||||||
{
|
{
|
||||||
if(JSON.stringify(Object.fromEntries(otherValues)) != otherValuesWhenResultsWereLoaded)
|
if (JSON.stringify(Object.fromEntries(otherValues)) != otherValuesWhenResultsWereLoaded)
|
||||||
{
|
{
|
||||||
(async () =>
|
(async () =>
|
||||||
{
|
{
|
||||||
@ -229,16 +229,16 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
console.log("Refreshing possible values...");
|
console.log("Refreshing possible values...");
|
||||||
const results: QPossibleValue[] = await qController.possibleValues(tableName, processName, possibleValueSourceName ?? fieldName, searchTerm ?? "", null, otherValues);
|
const results: QPossibleValue[] = await qController.possibleValues(tableName, processName, possibleValueSourceName ?? fieldName, searchTerm ?? "", null, otherValues);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setOptions([ ...results ]);
|
setOptions([...results]);
|
||||||
setOtherValuesWhenResultsWereLoaded(JSON.stringify(Object.fromEntries(otherValues)));
|
setOtherValuesWhenResultsWereLoaded(JSON.stringify(Object.fromEntries(otherValues)));
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const inputChanged = (event: React.SyntheticEvent, value: string, reason: string) =>
|
const inputChanged = (event: React.SyntheticEvent, value: string, reason: string) =>
|
||||||
{
|
{
|
||||||
// console.log(`input changed. Reason: ${reason}, setting search term to ${value}`);
|
// console.log(`input changed. Reason: ${reason}, setting search term to ${value}`);
|
||||||
if(reason !== "reset")
|
if (reason !== "reset")
|
||||||
{
|
{
|
||||||
// console.log(` -> setting search term to ${value}`);
|
// console.log(` -> setting search term to ${value}`);
|
||||||
setSearchTerm(value);
|
setSearchTerm(value);
|
||||||
@ -248,7 +248,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
const handleBlur = (x: any) =>
|
const handleBlur = (x: any) =>
|
||||||
{
|
{
|
||||||
setSearchTerm(null);
|
setSearchTerm(null);
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleChanged = (event: React.SyntheticEvent, value: any | any[], reason: string, details?: string) =>
|
const handleChanged = (event: React.SyntheticEvent, value: any | any[], reason: string, details?: string) =>
|
||||||
{
|
{
|
||||||
@ -256,9 +256,9 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
// console.log(value);
|
// console.log(value);
|
||||||
setSearchTerm(null);
|
setSearchTerm(null);
|
||||||
|
|
||||||
if(onChange)
|
if (onChange)
|
||||||
{
|
{
|
||||||
if(isMultiple)
|
if (isMultiple)
|
||||||
{
|
{
|
||||||
onChange(value);
|
onChange(value);
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
onChange(value ? new QPossibleValue(value) : null);
|
onChange(value ? new QPossibleValue(value) : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(setFieldValueRef && fieldName)
|
else if (setFieldValueRef && fieldName)
|
||||||
{
|
{
|
||||||
setFieldValueRef(fieldName, value ? value.id : null);
|
setFieldValueRef(fieldName, value ? value.id : null);
|
||||||
}
|
}
|
||||||
@ -280,7 +280,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
// get options whose text/label matches the input (e.g., not ids that match) //
|
// get options whose text/label matches the input (e.g., not ids that match) //
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
return (options);
|
return (options);
|
||||||
}
|
};
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const renderOption = (props: Object, option: any, {selected}) =>
|
const renderOption = (props: Object, option: any, {selected}) =>
|
||||||
@ -289,23 +289,24 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const field = tableMetaData?.fields.get(fieldName)
|
const field = tableMetaData?.fields.get(fieldName);
|
||||||
if(field)
|
if (field)
|
||||||
{
|
{
|
||||||
const adornment = field.getAdornment(AdornmentType.CHIP);
|
const adornment = field.getAdornment(AdornmentType.CHIP);
|
||||||
if(adornment)
|
if (adornment)
|
||||||
{
|
{
|
||||||
const color = adornment.getValue("color." + option.id) ?? "default"
|
const color = adornment.getValue("color." + option.id) ?? "default";
|
||||||
const iconName = adornment.getValue("icon." + option.id) ?? null;
|
const iconName = adornment.getValue("icon." + option.id) ?? null;
|
||||||
const iconElement = iconName ? <Icon>{iconName}</Icon> : null;
|
const iconElement = iconName ? <Icon>{iconName}</Icon> : null;
|
||||||
content = (<Chip label={option.label} color={color} icon={iconElement} size="small" variant="outlined" sx={{fontWeight: 500}} />);
|
content = (<Chip label={option.label} color={color} icon={iconElement} size="small" variant="outlined" sx={{fontWeight: 500}} />);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(e)
|
catch (e)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
if(isMultiple)
|
if (isMultiple)
|
||||||
{
|
{
|
||||||
content = (
|
content = (
|
||||||
<>
|
<>
|
||||||
@ -327,7 +328,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
{content}
|
{content}
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
const bulkEditSwitchChanged = () =>
|
const bulkEditSwitchChanged = () =>
|
||||||
{
|
{
|
||||||
@ -357,7 +358,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
{
|
{
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
// console.log("setting open...");
|
// console.log("setting open...");
|
||||||
if(options.length == 0)
|
if (options.length == 0)
|
||||||
{
|
{
|
||||||
// console.log("no options yet, so setting search term to ''...");
|
// console.log("no options yet, so setting search term to ''...");
|
||||||
setSearchTerm("");
|
setSearchTerm("");
|
||||||
@ -370,19 +371,19 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
isOptionEqualToValue={(option, value) => value !== null && value !== undefined && option.id === value.id}
|
isOptionEqualToValue={(option, value) => value !== null && value !== undefined && option.id === value.id}
|
||||||
getOptionLabel={(option) =>
|
getOptionLabel={(option) =>
|
||||||
{
|
{
|
||||||
if(option === null || option === undefined)
|
if (option === null || option === undefined)
|
||||||
{
|
{
|
||||||
return ("");
|
return ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if(option && option.length)
|
if (option && option.length)
|
||||||
{
|
{
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
option = option[0];
|
option = option[0];
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return option.label
|
return option.label;
|
||||||
}}
|
}}
|
||||||
options={options}
|
options={options}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
@ -446,7 +447,8 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
id={`bulkEditSwitch-${fieldName}`}
|
id={`bulkEditSwitch-${fieldName}`}
|
||||||
checked={switchChecked}
|
checked={switchChecked}
|
||||||
onClick={bulkEditSwitchChanged}
|
onClick={bulkEditSwitchChanged}
|
||||||
sx={{top: "-4px",
|
sx={{
|
||||||
|
top: "-4px",
|
||||||
"& .MuiSwitch-track": {
|
"& .MuiSwitch-track": {
|
||||||
height: 20,
|
height: 20,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
@ -465,7 +467,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
<Box mb={1.5}>
|
<Box>
|
||||||
{autocomplete}
|
{autocomplete}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
@ -396,15 +396,16 @@ function EntityForm(props: Props): JSX.Element
|
|||||||
// if the widget metadata specifies a table name, set form values to that so widget knows which to use //
|
// if the widget metadata specifies a table name, set form values to that so widget knows which to use //
|
||||||
// (for the case when it is not being specified by a separate field in the record) //
|
// (for the case when it is not being specified by a separate field in the record) //
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if (widgetMetaData?.defaultValues?.has("tableName"))
|
if (widgetData?.tableName)
|
||||||
{
|
{
|
||||||
formValues["tableName"] = widgetMetaData?.defaultValues.get("tableName");
|
formValues["tableName"] = widgetData?.tableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <FilterAndColumnsSetupWidget
|
return <FilterAndColumnsSetupWidget
|
||||||
key={formValues["tableName"]} // todo, is this good? it was added so that editing values actually re-renders...
|
key={formValues["tableName"]} // todo, is this good? it was added so that editing values actually re-renders...
|
||||||
isEditable={true}
|
isEditable={true}
|
||||||
widgetMetaData={widgetMetaData}
|
widgetMetaData={widgetMetaData}
|
||||||
|
widgetData={widgetData}
|
||||||
recordValues={formValues}
|
recordValues={formValues}
|
||||||
onSaveCallback={setFormFieldValuesFromWidget}
|
onSaveCallback={setFormFieldValuesFromWidget}
|
||||||
/>;
|
/>;
|
||||||
|
@ -79,6 +79,8 @@ interface BasicAndAdvancedQueryControlsProps
|
|||||||
|
|
||||||
queryScreenUsage: QueryScreenUsage;
|
queryScreenUsage: QueryScreenUsage;
|
||||||
|
|
||||||
|
allowVariables?: boolean;
|
||||||
|
|
||||||
mode: string;
|
mode: string;
|
||||||
setMode: (mode: string) => void;
|
setMode: (mode: string) => void;
|
||||||
}
|
}
|
||||||
@ -676,6 +678,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
|
|
||||||
return (<QuickFilter
|
return (<QuickFilter
|
||||||
key={fieldName}
|
key={fieldName}
|
||||||
|
allowVariables={props.allowVariables}
|
||||||
fullFieldName={fieldName}
|
fullFieldName={fieldName}
|
||||||
tableMetaData={tableMetaData}
|
tableMetaData={tableMetaData}
|
||||||
updateCriteria={updateQuickCriteria}
|
updateCriteria={updateQuickCriteria}
|
||||||
@ -701,6 +704,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
updateCriteria={updateQuickCriteria}
|
updateCriteria={updateQuickCriteria}
|
||||||
criteriaParam={getQuickCriteriaParam(fieldName)}
|
criteriaParam={getQuickCriteriaParam(fieldName)}
|
||||||
fieldMetaData={field}
|
fieldMetaData={field}
|
||||||
|
allowVariables={props.allowVariables}
|
||||||
defaultOperator={defaultOperator}
|
defaultOperator={defaultOperator}
|
||||||
queryScreenUsage={queryScreenUsage}
|
queryScreenUsage={queryScreenUsage}
|
||||||
handleRemoveQuickFilterField={handleRemoveQuickFilterField} />);
|
handleRemoveQuickFilterField={handleRemoveQuickFilterField} />);
|
||||||
|
@ -179,6 +179,7 @@ export const CustomFilterPanel = forwardRef<any, GridFilterPanelProps>(
|
|||||||
updateCriteria={(newCriteria, needDebounce) => updateCriteria(newCriteria, index, needDebounce)}
|
updateCriteria={(newCriteria, needDebounce) => updateCriteria(newCriteria, index, needDebounce)}
|
||||||
removeCriteria={() => removeCriteria(index)}
|
removeCriteria={() => removeCriteria(index)}
|
||||||
updateBooleanOperator={(newValue) => updateBooleanOperator(newValue)}
|
updateBooleanOperator={(newValue) => updateBooleanOperator(newValue)}
|
||||||
|
allowVariables={props.allowVariables}
|
||||||
queryScreenUsage={props.queryScreenUsage}
|
queryScreenUsage={props.queryScreenUsage}
|
||||||
/>
|
/>
|
||||||
{/*JSON.stringify(criteria)*/}
|
{/*JSON.stringify(criteria)*/}
|
||||||
|
@ -199,6 +199,7 @@ interface FilterCriteriaRowProps
|
|||||||
removeCriteria: () => void;
|
removeCriteria: () => void;
|
||||||
updateBooleanOperator: (newValue: string) => void;
|
updateBooleanOperator: (newValue: string) => void;
|
||||||
queryScreenUsage?: QueryScreenUsage;
|
queryScreenUsage?: QueryScreenUsage;
|
||||||
|
allowVariables?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterCriteriaRow.defaultProps =
|
FilterCriteriaRow.defaultProps =
|
||||||
@ -267,7 +268,7 @@ export function validateCriteria(criteria: QFilterCriteria, operatorSelectedValu
|
|||||||
return {criteriaIsValid, criteriaStatusTooltip};
|
return {criteriaIsValid, criteriaStatusTooltip};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FilterCriteriaRow({id, index, tableMetaData, metaData, criteria, booleanOperator, updateCriteria, removeCriteria, updateBooleanOperator, queryScreenUsage}: FilterCriteriaRowProps): JSX.Element
|
export function FilterCriteriaRow({id, index, tableMetaData, metaData, criteria, booleanOperator, updateCriteria, removeCriteria, updateBooleanOperator, queryScreenUsage, allowVariables}: FilterCriteriaRowProps): JSX.Element
|
||||||
{
|
{
|
||||||
// console.log(`FilterCriteriaRow: criteria: ${JSON.stringify(criteria)}`);
|
// console.log(`FilterCriteriaRow: criteria: ${JSON.stringify(criteria)}`);
|
||||||
const [operatorSelectedValue, setOperatorSelectedValue] = useState(null as OperatorOption);
|
const [operatorSelectedValue, setOperatorSelectedValue] = useState(null as OperatorOption);
|
||||||
@ -516,6 +517,7 @@ export function FilterCriteriaRow({id, index, tableMetaData, metaData, criteria,
|
|||||||
table={fieldTable}
|
table={fieldTable}
|
||||||
valueChangeHandler={(event, valueIndex, newValue) => handleValueChange(event, valueIndex, newValue)}
|
valueChangeHandler={(event, valueIndex, newValue) => handleValueChange(event, valueIndex, newValue)}
|
||||||
queryScreenUsage={queryScreenUsage}
|
queryScreenUsage={queryScreenUsage}
|
||||||
|
allowVariables={allowVariables}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box display="inline-block">
|
<Box display="inline-block">
|
||||||
|
@ -39,7 +39,7 @@ import FilterCriteriaPaster from "qqq/components/query/FilterCriteriaPaster";
|
|||||||
import {OperatorOption, ValueMode} from "qqq/components/query/FilterCriteriaRow";
|
import {OperatorOption, ValueMode} from "qqq/components/query/FilterCriteriaRow";
|
||||||
import {QueryScreenUsage} from "qqq/pages/records/query/RecordQuery";
|
import {QueryScreenUsage} from "qqq/pages/records/query/RecordQuery";
|
||||||
import ValueUtils from "qqq/utils/qqq/ValueUtils";
|
import ValueUtils from "qqq/utils/qqq/ValueUtils";
|
||||||
import React, {SyntheticEvent, useReducer, useState} from "react";
|
import React, {SyntheticEvent, useReducer} from "react";
|
||||||
|
|
||||||
interface Props
|
interface Props
|
||||||
{
|
{
|
||||||
@ -50,6 +50,7 @@ interface Props
|
|||||||
valueChangeHandler: (event: React.ChangeEvent | SyntheticEvent, valueIndex?: number | "all", newValue?: any) => void;
|
valueChangeHandler: (event: React.ChangeEvent | SyntheticEvent, valueIndex?: number | "all", newValue?: any) => void;
|
||||||
initiallyOpenMultiValuePvs?: boolean;
|
initiallyOpenMultiValuePvs?: boolean;
|
||||||
queryScreenUsage?: QueryScreenUsage;
|
queryScreenUsage?: QueryScreenUsage;
|
||||||
|
allowVariables?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterCriteriaRowValues.defaultProps =
|
FilterCriteriaRowValues.defaultProps =
|
||||||
@ -187,10 +188,9 @@ export const makeTextField = (field: QFieldMetaData, criteria: QFilterCriteriaWi
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function FilterCriteriaRowValues({operatorOption, criteria, field, table, valueChangeHandler, initiallyOpenMultiValuePvs, queryScreenUsage}: Props): JSX.Element
|
function FilterCriteriaRowValues({operatorOption, criteria, field, table, valueChangeHandler, initiallyOpenMultiValuePvs, queryScreenUsage, allowVariables}: Props): JSX.Element
|
||||||
{
|
{
|
||||||
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
||||||
const [allowVariables, setAllowVariables] = useState(queryScreenUsage == "reportSetup");
|
|
||||||
|
|
||||||
if (!operatorOption)
|
if (!operatorOption)
|
||||||
{
|
{
|
||||||
|
@ -52,6 +52,7 @@ interface QuickFilterProps
|
|||||||
defaultOperator?: QCriteriaOperator;
|
defaultOperator?: QCriteriaOperator;
|
||||||
handleRemoveQuickFilterField?: (fieldName: string) => void;
|
handleRemoveQuickFilterField?: (fieldName: string) => void;
|
||||||
queryScreenUsage?: QueryScreenUsage;
|
queryScreenUsage?: QueryScreenUsage;
|
||||||
|
allowVariables?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickFilter.defaultProps =
|
QuickFilter.defaultProps =
|
||||||
@ -141,7 +142,7 @@ const getOperatorSelectedValue = (operatorOptions: OperatorOption[], criteria: Q
|
|||||||
** Component to render a QuickFilter - that is - a button, with a Menu under it,
|
** Component to render a QuickFilter - that is - a button, with a Menu under it,
|
||||||
** with Operator and Value controls.
|
** with Operator and Value controls.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData, criteriaParam, updateCriteria, defaultOperator, handleRemoveQuickFilterField, queryScreenUsage}: QuickFilterProps): JSX.Element
|
export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData, criteriaParam, updateCriteria, defaultOperator, handleRemoveQuickFilterField, queryScreenUsage, allowVariables}: QuickFilterProps): JSX.Element
|
||||||
{
|
{
|
||||||
const operatorOptions = fieldMetaData ? getOperatorOptions(tableMetaData, fullFieldName) : [];
|
const operatorOptions = fieldMetaData ? getOperatorOptions(tableMetaData, fullFieldName) : [];
|
||||||
const [_, tableForField] = TableUtils.getFieldAndTable(tableMetaData, fullFieldName);
|
const [_, tableForField] = TableUtils.getFieldAndTable(tableMetaData, fullFieldName);
|
||||||
@ -549,6 +550,7 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
criteria={criteria}
|
criteria={criteria}
|
||||||
field={fieldMetaData}
|
field={fieldMetaData}
|
||||||
table={tableForField}
|
table={tableForField}
|
||||||
|
allowVariables={allowVariables}
|
||||||
valueChangeHandler={(event, valueIndex, newValue) => handleValueChange(event, valueIndex, newValue)}
|
valueChangeHandler={(event, valueIndex, newValue) => handleValueChange(event, valueIndex, newValue)}
|
||||||
initiallyOpenMultiValuePvs={true} // todo - maybe not?
|
initiallyOpenMultiValuePvs={true} // todo - maybe not?
|
||||||
/>
|
/>
|
||||||
|
@ -599,8 +599,8 @@ function DashboardWidgets({widgetMetaDataList, tableName, entityPrimaryKey, reco
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
widgetMetaData.type === "filterAndColumnsSetup" && (
|
widgetMetaData.type === "filterAndColumnsSetup" && (
|
||||||
widgetData && widgetData[i] && widgetData[i].queryParams &&
|
widgetData && widgetData[i] &&
|
||||||
<FilterAndColumnsSetupWidget isEditable={false} widgetMetaData={widgetMetaData} recordValues={convertQRecordValuesFromMapToObject(record)} onSaveCallback={() =>
|
<FilterAndColumnsSetupWidget isEditable={false} widgetMetaData={widgetMetaData} widgetData={widgetData[i]} recordValues={convertQRecordValuesFromMapToObject(record)} onSaveCallback={() =>
|
||||||
{
|
{
|
||||||
}} />
|
}} />
|
||||||
)
|
)
|
||||||
|
@ -48,6 +48,7 @@ interface FilterAndColumnsSetupWidgetProps
|
|||||||
{
|
{
|
||||||
isEditable: boolean;
|
isEditable: boolean;
|
||||||
widgetMetaData: QWidgetMetaData;
|
widgetMetaData: QWidgetMetaData;
|
||||||
|
widgetData: any;
|
||||||
recordValues: { [name: string]: any };
|
recordValues: { [name: string]: any };
|
||||||
onSaveCallback?: (values: { [name: string]: any }) => void;
|
onSaveCallback?: (values: { [name: string]: any }) => void;
|
||||||
}
|
}
|
||||||
@ -82,10 +83,10 @@ 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, recordValues, onSaveCallback}: FilterAndColumnsSetupWidgetProps): JSX.Element
|
export default function FilterAndColumnsSetupWidget({isEditable, widgetMetaData, widgetData, recordValues, onSaveCallback}: FilterAndColumnsSetupWidgetProps): JSX.Element
|
||||||
{
|
{
|
||||||
const [modalOpen, setModalOpen] = useState(false);
|
const [modalOpen, setModalOpen] = useState(false);
|
||||||
const [hideColumns, setHideColumns] = useState(widgetMetaData?.defaultValues?.has("hideColumns") && widgetMetaData?.defaultValues?.get("hideColumns"));
|
const [hideColumns, setHideColumns] = useState(widgetData?.hideColumns);
|
||||||
const [tableMetaData, setTableMetaData] = useState(null as QTableMetaData);
|
const [tableMetaData, setTableMetaData] = useState(null as QTableMetaData);
|
||||||
|
|
||||||
const [alertContent, setAlertContent] = useState(null as string);
|
const [alertContent, setAlertContent] = useState(null as string);
|
||||||
@ -107,7 +108,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["queryFilterJson"] && JSON.parse(recordValues["queryFilterJson"]) as QQueryFilter;
|
||||||
const defaultFilterFields = getDefaultFilterFieldNames(widgetMetaData);
|
const defaultFilterFields = widgetData?.filterDefaultFieldNames;
|
||||||
if (!queryFilter)
|
if (!queryFilter)
|
||||||
{
|
{
|
||||||
queryFilter = new QQueryFilter();
|
queryFilter = new QQueryFilter();
|
||||||
@ -153,7 +154,7 @@ export default function FilterAndColumnsSetupWidget({isEditable, widgetMetaData,
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// if a default table name specified, use it, otherwise use it from the record values //
|
// if a default table name specified, use it, otherwise use it from the record values //
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
let tableName = widgetMetaData?.defaultValues?.get("tableName");
|
let tableName = widgetData?.tableName;
|
||||||
if (!tableName && recordValues["tableName"] && (tableMetaData == null || tableMetaData.name != recordValues["tableName"]))
|
if (!tableName && recordValues["tableName"] && (tableMetaData == null || tableMetaData.name != recordValues["tableName"]))
|
||||||
{
|
{
|
||||||
tableName = recordValues["tableName"];
|
tableName = recordValues["tableName"];
|
||||||
@ -174,27 +175,13 @@ export default function FilterAndColumnsSetupWidget({isEditable, widgetMetaData,
|
|||||||
}, [JSON.stringify(recordValues)]);
|
}, [JSON.stringify(recordValues)]);
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
**
|
|
||||||
*******************************************************************************/
|
|
||||||
function getDefaultFilterFieldNames(widgetMetaData: QWidgetMetaData)
|
|
||||||
{
|
|
||||||
if (widgetMetaData?.defaultValues?.has("filterDefaultFieldNames"))
|
|
||||||
{
|
|
||||||
return (widgetMetaData.defaultValues.get("filterDefaultFieldNames").split(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function openEditor()
|
function openEditor()
|
||||||
{
|
{
|
||||||
let missingRequiredFields = [] as string[];
|
let missingRequiredFields = [] as string[];
|
||||||
getDefaultFilterFieldNames(widgetMetaData)?.forEach((fieldName: string) =>
|
widgetData?.filterDefaultFieldNames?.forEach((fieldName: string) =>
|
||||||
{
|
{
|
||||||
if (!recordValues[fieldName])
|
if (!recordValues[fieldName])
|
||||||
{
|
{
|
||||||
@ -430,6 +417,7 @@ export default function FilterAndColumnsSetupWidget({isEditable, widgetMetaData,
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
tableMetaData && <RecordQuery
|
tableMetaData && <RecordQuery
|
||||||
|
allowVariables={widgetData?.allowVariables}
|
||||||
ref={recordQueryRef}
|
ref={recordQueryRef}
|
||||||
table={tableMetaData}
|
table={tableMetaData}
|
||||||
usage="reportSetup"
|
usage="reportSetup"
|
||||||
|
@ -94,6 +94,7 @@ interface Props
|
|||||||
isModal?: boolean;
|
isModal?: boolean;
|
||||||
initialQueryFilter?: QQueryFilter;
|
initialQueryFilter?: QQueryFilter;
|
||||||
initialColumns?: QQueryColumns;
|
initialColumns?: QQueryColumns;
|
||||||
|
allowVariables?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
@ -125,7 +126,7 @@ const getLoadingScreen = (isModal: boolean) =>
|
|||||||
**
|
**
|
||||||
** Yuge component. The best. Lots of very smart people are saying so.
|
** Yuge component. The best. Lots of very smart people are saying so.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, initialColumns}: Props, ref) =>
|
const RecordQuery = forwardRef(({table, usage, isModal, allowVariables, initialQueryFilter, initialColumns}: Props, ref) =>
|
||||||
{
|
{
|
||||||
const tableName = table.name;
|
const tableName = table.name;
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
@ -2884,6 +2885,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
gridApiRef={gridApiRef}
|
gridApiRef={gridApiRef}
|
||||||
mode={mode}
|
mode={mode}
|
||||||
queryScreenUsage={usage}
|
queryScreenUsage={usage}
|
||||||
|
allowVariables={allowVariables}
|
||||||
setMode={doSetMode}
|
setMode={doSetMode}
|
||||||
savedViewsComponent={savedViewsComponent}
|
savedViewsComponent={savedViewsComponent}
|
||||||
columnMenuComponent={buildColumnMenu()}
|
columnMenuComponent={buildColumnMenu()}
|
||||||
@ -2912,6 +2914,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
metaData: metaData,
|
metaData: metaData,
|
||||||
queryFilter: queryFilter,
|
queryFilter: queryFilter,
|
||||||
updateFilter: doSetQueryFilter,
|
updateFilter: doSetQueryFilter,
|
||||||
|
allowVariables: allowVariables
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
localeText={{
|
localeText={{
|
||||||
|
Reference in New Issue
Block a user