mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-21 22:58:43 +00:00
Compare commits
45 Commits
snapshot-H
...
snapshot-f
Author | SHA1 | Date | |
---|---|---|---|
0831a87674 | |||
dd5cd459ce | |||
c200cc9fab | |||
17f378131d | |||
376a7a342e | |||
fcadea3192 | |||
086ab775fc | |||
5693661d20 | |||
8c9224aceb | |||
1859dd603d | |||
74f8f11737 | |||
0629172270 | |||
1bf1f09e9d | |||
e0f689544d | |||
f3d08ef683 | |||
1aff749f72 | |||
ccc622e0e9 | |||
a6662eeb07 | |||
c8b673fb46 | |||
f19e36a6bf | |||
c708ec3b9a | |||
7e40fa90e9 | |||
680d185eb5 | |||
4f37488d37 | |||
d20700edb1 | |||
d17c7f6990 | |||
0d7849b7dc | |||
57098b5f05 | |||
7316b6141b | |||
8bc2479716 | |||
010f80def3 | |||
13d7cc6825 | |||
ca715af84a | |||
65aaf4fce1 | |||
8dc8ae0b6d | |||
8707aa8a94 | |||
e7d870a7fa | |||
38b8f47409 | |||
de8594bfe1 | |||
3c8180cf51 | |||
2e48aa3eba | |||
feb1cc5c86 | |||
c2ad1c34be | |||
4c6955b6ed | |||
11f1250d73 |
18466
package-lock.json
generated
18466
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
|||||||
"@auth0/auth0-react": "1.10.2",
|
"@auth0/auth0-react": "1.10.2",
|
||||||
"@emotion/react": "11.7.1",
|
"@emotion/react": "11.7.1",
|
||||||
"@emotion/styled": "11.6.0",
|
"@emotion/styled": "11.6.0",
|
||||||
"@kingsrook/qqq-frontend-core": "1.0.97",
|
"@kingsrook/qqq-frontend-core": "1.0.100",
|
||||||
"@mui/icons-material": "5.4.1",
|
"@mui/icons-material": "5.4.1",
|
||||||
"@mui/material": "5.11.1",
|
"@mui/material": "5.11.1",
|
||||||
"@mui/styles": "5.11.1",
|
"@mui/styles": "5.11.1",
|
||||||
|
16
src/App.tsx
16
src/App.tsx
@ -49,6 +49,7 @@ import EntityEdit from "qqq/pages/records/edit/RecordEdit";
|
|||||||
import RecordQuery from "qqq/pages/records/query/RecordQuery";
|
import RecordQuery from "qqq/pages/records/query/RecordQuery";
|
||||||
import RecordDeveloperView from "qqq/pages/records/view/RecordDeveloperView";
|
import RecordDeveloperView from "qqq/pages/records/view/RecordDeveloperView";
|
||||||
import RecordView from "qqq/pages/records/view/RecordView";
|
import RecordView from "qqq/pages/records/view/RecordView";
|
||||||
|
import RecordViewByUniqueKey from "qqq/pages/records/view/RecordViewByUniqueKey";
|
||||||
import GoogleAnalyticsUtils, {AnalyticsModel} from "qqq/utils/GoogleAnalyticsUtils";
|
import GoogleAnalyticsUtils, {AnalyticsModel} from "qqq/utils/GoogleAnalyticsUtils";
|
||||||
import Client from "qqq/utils/qqq/Client";
|
import Client from "qqq/utils/qqq/Client";
|
||||||
import ProcessUtils from "qqq/utils/qqq/ProcessUtils";
|
import ProcessUtils from "qqq/utils/qqq/ProcessUtils";
|
||||||
@ -392,6 +393,13 @@ export default function App()
|
|||||||
component: <RecordView table={table} />,
|
component: <RecordView table={table} />,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
routeList.push({
|
||||||
|
name: `${app.label} View`,
|
||||||
|
key: `${app.name}.view`,
|
||||||
|
route: `${path}/key`,
|
||||||
|
component: <RecordViewByUniqueKey table={table} />,
|
||||||
|
});
|
||||||
|
|
||||||
routeList.push({
|
routeList.push({
|
||||||
name: `${app.label}`,
|
name: `${app.label}`,
|
||||||
key: `${app.name}.edit`,
|
key: `${app.name}.edit`,
|
||||||
@ -664,8 +672,14 @@ export default function App()
|
|||||||
const [dotMenuOpen, setDotMenuOpen] = useState(false);
|
const [dotMenuOpen, setDotMenuOpen] = useState(false);
|
||||||
const [keyboardHelpOpen, setKeyboardHelpOpen] = useState(false);
|
const [keyboardHelpOpen, setKeyboardHelpOpen] = useState(false);
|
||||||
const [helpHelpActive] = useState(queryParams.has("helpHelp"));
|
const [helpHelpActive] = useState(queryParams.has("helpHelp"));
|
||||||
const [userId] = useState(user.email);
|
const [userId, setUserId] = useState(user?.email);
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
setUserId(user?.email)
|
||||||
|
}, [user]);
|
||||||
|
|
||||||
|
|
||||||
const [googleAnalyticsUtils] = useState(new GoogleAnalyticsUtils());
|
const [googleAnalyticsUtils] = useState(new GoogleAnalyticsUtils());
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
@ -134,17 +134,36 @@ public class MaterialDashboardTableMetaData extends QSupplementalTableMetaData
|
|||||||
|
|
||||||
for(FieldRule fieldRule : CollectionUtils.nonNullList(fieldRules))
|
for(FieldRule fieldRule : CollectionUtils.nonNullList(fieldRules))
|
||||||
{
|
{
|
||||||
qInstanceValidator.assertCondition(fieldRule.getTrigger() != null, prefix + "has a fieldRule without a trigger");
|
validateFieldRule(qInstance, tableMetaData, qInstanceValidator, fieldRule, prefix);
|
||||||
qInstanceValidator.assertCondition(fieldRule.getAction() != null, prefix + "has a fieldRule without an action");
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(qInstanceValidator.assertCondition(StringUtils.hasContent(fieldRule.getSourceField()), prefix + "has a fieldRule without a sourceField"))
|
|
||||||
{
|
|
||||||
qInstanceValidator.assertNoException(() -> tableMetaData.getField(fieldRule.getSourceField()), prefix + "has a fieldRule with an unrecognized sourceField: " + fieldRule.getSourceField());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(qInstanceValidator.assertCondition(StringUtils.hasContent(fieldRule.getTargetField()), prefix + "has a fieldRule without a targetField"))
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
static void validateFieldRule(QInstance qInstance, QTableMetaData tableMetaData, QInstanceValidator qInstanceValidator, FieldRule fieldRule, String prefix)
|
||||||
|
{
|
||||||
|
qInstanceValidator.assertCondition(fieldRule.getTrigger() != null, prefix + "has a fieldRule without a trigger");
|
||||||
|
qInstanceValidator.assertCondition(fieldRule.getAction() != null, prefix + "has a fieldRule without an action");
|
||||||
|
|
||||||
|
if(qInstanceValidator.assertCondition(StringUtils.hasContent(fieldRule.getSourceField()), prefix + "has a fieldRule without a sourceField"))
|
||||||
|
{
|
||||||
|
qInstanceValidator.assertNoException(() -> tableMetaData.getField(fieldRule.getSourceField()), prefix + "has a fieldRule with an unrecognized sourceField: " + fieldRule.getSourceField());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.hasContent(fieldRule.getTargetField()))
|
||||||
|
{
|
||||||
|
qInstanceValidator.assertNoException(() -> tableMetaData.getField(fieldRule.getTargetField()), prefix + "has a fieldRule with an unrecognized targetField: " + fieldRule.getTargetField());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.hasContent(fieldRule.getTargetWidget()))
|
||||||
|
{
|
||||||
|
if(qInstanceValidator.assertCondition(qInstance.getWidget(fieldRule.getTargetWidget()) != null, prefix + "has a widgetRule with an unrecognized targetWidget: " + fieldRule.getTargetWidget()))
|
||||||
{
|
{
|
||||||
qInstanceValidator.assertNoException(() -> tableMetaData.getField(fieldRule.getTargetField()), prefix + "has a fieldRule with an unrecognized targetField: " + fieldRule.getTargetField());
|
qInstanceValidator.assertCondition(CollectionUtils.nonNullList(tableMetaData.getSections()).stream().anyMatch(s -> fieldRule.getTargetWidget().equals(s.getWidgetName())),
|
||||||
|
prefix + "has a widgetRule with a targetWidget which is not used in any sections on the table");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ public class FieldRule implements Serializable
|
|||||||
private FieldRuleAction action;
|
private FieldRuleAction action;
|
||||||
private String targetField;
|
private String targetField;
|
||||||
|
|
||||||
|
private String targetWidget;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -162,4 +164,35 @@ public class FieldRule implements Serializable
|
|||||||
return (this);
|
return (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Getter for targetWidget
|
||||||
|
*******************************************************************************/
|
||||||
|
public String getTargetWidget()
|
||||||
|
{
|
||||||
|
return (this.targetWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Setter for targetWidget
|
||||||
|
*******************************************************************************/
|
||||||
|
public void setTargetWidget(String targetWidget)
|
||||||
|
{
|
||||||
|
this.targetWidget = targetWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Fluent setter for targetWidget
|
||||||
|
*******************************************************************************/
|
||||||
|
public FieldRule withTargetWidget(String targetWidget)
|
||||||
|
{
|
||||||
|
this.targetWidget = targetWidget;
|
||||||
|
return (this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,5 +27,6 @@ package com.kingsrook.qqq.frontend.materialdashboard.model.metadata.fieldrules;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public enum FieldRuleAction
|
public enum FieldRuleAction
|
||||||
{
|
{
|
||||||
CLEAR_TARGET_FIELD
|
CLEAR_TARGET_FIELD,
|
||||||
|
RELOAD_WIDGET
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,8 @@ function QDynamicForm({formData, formLabel, bulkEditMode, bulkEditSwitchChangeHa
|
|||||||
<DynamicSelect
|
<DynamicSelect
|
||||||
tableName={field.possibleValueProps.tableName}
|
tableName={field.possibleValueProps.tableName}
|
||||||
processName={field.possibleValueProps.processName}
|
processName={field.possibleValueProps.processName}
|
||||||
fieldName={fieldName}
|
possibleValueSourceName={field.possibleValueProps.possibleValueSourceName}
|
||||||
|
fieldName={field.possibleValueProps.fieldName}
|
||||||
isEditable={field.isEditable}
|
isEditable={field.isEditable}
|
||||||
fieldLabel=""
|
fieldLabel=""
|
||||||
initialValue={values[fieldName]}
|
initialValue={values[fieldName]}
|
||||||
|
@ -172,6 +172,17 @@ class DynamicFormUtils
|
|||||||
{
|
{
|
||||||
isPossibleValue: true,
|
isPossibleValue: true,
|
||||||
tableName: tableName,
|
tableName: tableName,
|
||||||
|
fieldName: field.name,
|
||||||
|
initialDisplayValue: initialDisplayValue,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if(processName)
|
||||||
|
{
|
||||||
|
dynamicFormFields[field.name].possibleValueProps =
|
||||||
|
{
|
||||||
|
isPossibleValue: true,
|
||||||
|
processName: processName,
|
||||||
|
fieldName: field.name,
|
||||||
initialDisplayValue: initialDisplayValue,
|
initialDisplayValue: initialDisplayValue,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -180,8 +191,9 @@ class DynamicFormUtils
|
|||||||
dynamicFormFields[field.name].possibleValueProps =
|
dynamicFormFields[field.name].possibleValueProps =
|
||||||
{
|
{
|
||||||
isPossibleValue: true,
|
isPossibleValue: true,
|
||||||
processName: processName,
|
|
||||||
initialDisplayValue: initialDisplayValue,
|
initialDisplayValue: initialDisplayValue,
|
||||||
|
fieldName: field.name,
|
||||||
|
possibleValueSourceName: field.possibleValueSourceName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,19 +124,15 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
{
|
{
|
||||||
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)
|
|
||||||
{
|
|
||||||
console.log("DynamicSelect - if you provide a fieldName and a possibleValueSourceName, the possibleValueSourceName will be ignored");
|
|
||||||
}
|
|
||||||
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)
|
if(fieldName && !possibleValueSourceName)
|
||||||
{
|
{
|
||||||
if(!tableName || !processName)
|
if(!tableName || !processName)
|
||||||
{
|
{
|
||||||
console.log("DynamicSelect - if you provide a fieldName, 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)
|
||||||
@ -198,7 +194,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
(async () =>
|
(async () =>
|
||||||
{
|
{
|
||||||
// console.log(`doing a search with ${searchTerm}`);
|
// console.log(`doing a search with ${searchTerm}`);
|
||||||
const results: QPossibleValue[] = await qController.possibleValues(tableName, processName, fieldName ?? possibleValueSourceName, searchTerm ?? "", null, otherValues);
|
const results: QPossibleValue[] = await qController.possibleValues(tableName, processName, possibleValueSourceName ?? fieldName, searchTerm ?? "", null, otherValues);
|
||||||
|
|
||||||
if(tableMetaData == null && tableName)
|
if(tableMetaData == null && tableName)
|
||||||
{
|
{
|
||||||
@ -231,7 +227,7 @@ function DynamicSelect({tableName, processName, fieldName, possibleValueSourceNa
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
setOptions([]);
|
setOptions([]);
|
||||||
console.log("Refreshing possible values...");
|
console.log("Refreshing possible values...");
|
||||||
const results: QPossibleValue[] = await qController.possibleValues(tableName, processName, fieldName ?? possibleValueSourceName, 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)));
|
||||||
|
@ -43,6 +43,7 @@ import DynamicFormUtils from "qqq/components/forms/DynamicFormUtils";
|
|||||||
import MDTypography from "qqq/components/legacy/MDTypography";
|
import MDTypography from "qqq/components/legacy/MDTypography";
|
||||||
import HelpContent from "qqq/components/misc/HelpContent";
|
import HelpContent from "qqq/components/misc/HelpContent";
|
||||||
import QRecordSidebar from "qqq/components/misc/RecordSidebar";
|
import QRecordSidebar from "qqq/components/misc/RecordSidebar";
|
||||||
|
import DynamicFormWidget from "qqq/components/widgets/misc/DynamicFormWidget";
|
||||||
import PivotTableSetupWidget from "qqq/components/widgets/misc/PivotTableSetupWidget";
|
import PivotTableSetupWidget from "qqq/components/widgets/misc/PivotTableSetupWidget";
|
||||||
import RecordGridWidget, {ChildRecordListData} from "qqq/components/widgets/misc/RecordGridWidget";
|
import RecordGridWidget, {ChildRecordListData} from "qqq/components/widgets/misc/RecordGridWidget";
|
||||||
import ReportSetupWidget from "qqq/components/widgets/misc/ReportSetupWidget";
|
import ReportSetupWidget from "qqq/components/widgets/misc/ReportSetupWidget";
|
||||||
@ -409,6 +410,19 @@ function EntityForm(props: Props): JSX.Element
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(widgetMetaData.type == "dynamicForm")
|
||||||
|
{
|
||||||
|
return <DynamicFormWidget
|
||||||
|
key={formValues["savedReportId"]} // todo - pull this from the metaData (could do so above too...)
|
||||||
|
isEditable={true}
|
||||||
|
widgetMetaData={widgetMetaData}
|
||||||
|
widgetData={widgetData}
|
||||||
|
recordValues={formValues}
|
||||||
|
record={record}
|
||||||
|
onSaveCallback={setFormFieldValuesFromWidget}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
|
||||||
return (<Box>Unsupported widget type: {widgetMetaData.type}</Box>)
|
return (<Box>Unsupported widget type: {widgetMetaData.type}</Box>)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,7 +496,7 @@ function EntityForm(props: Props): JSX.Element
|
|||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(widget.type == "reportSetup" || widget.type == "pivotTableSetup")
|
if(widget.type == "reportSetup" || widget.type == "pivotTableSetup" || widget.type == "dynamicForm")
|
||||||
{
|
{
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
@ -706,7 +720,8 @@ function EntityForm(props: Props): JSX.Element
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const widgetMetaData = metaData.widgets.get(section.widgetName);
|
const widgetMetaData = metaData.widgets.get(section.widgetName);
|
||||||
const widgetData = await qController.widget(widgetMetaData.name, props.id ? `${tableMetaData.primaryKeyField}=${props.id}` : "");
|
const widgetData = await qController.widget(widgetMetaData.name, makeQueryStringWithIdAndObject(tableMetaData, defaultValues));
|
||||||
|
|
||||||
newRenderedWidgetSections[section.widgetName] = getWidgetSection(widgetMetaData, widgetData);
|
newRenderedWidgetSections[section.widgetName] = getWidgetSection(widgetMetaData, widgetData);
|
||||||
newChildListWidgetData[section.widgetName] = widgetData;
|
newChildListWidgetData[section.widgetName] = widgetData;
|
||||||
}
|
}
|
||||||
@ -912,7 +927,7 @@ function EntityForm(props: Props): JSX.Element
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
setAlertContent(error.message);
|
setAlertContent(error.message);
|
||||||
HtmlUtils.autoScroll(0);
|
scrollToTopToShowAlert();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -958,7 +973,7 @@ function EntityForm(props: Props): JSX.Element
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
setAlertContent(error.message);
|
setAlertContent(error.message);
|
||||||
HtmlUtils.autoScroll(0);
|
scrollToTopToShowAlert();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -966,6 +981,67 @@ function EntityForm(props: Props): JSX.Element
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
function scrollToTopToShowAlert()
|
||||||
|
{
|
||||||
|
if (props.isModal)
|
||||||
|
{
|
||||||
|
document.getElementById("modalTopReference")?.scrollIntoView();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HtmlUtils.autoScroll(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
function makeQueryStringWithIdAndObject(tableMetaData: QTableMetaData, object: {[key: string]: any})
|
||||||
|
{
|
||||||
|
const queryParamsArray: string[] = [];
|
||||||
|
if(props.id)
|
||||||
|
{
|
||||||
|
queryParamsArray.push(`${tableMetaData.primaryKeyField}=${encodeURIComponent(props.id)}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(object)
|
||||||
|
{
|
||||||
|
for (let key in object)
|
||||||
|
{
|
||||||
|
queryParamsArray.push(`${key}=${encodeURIComponent(object[key])}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (queryParamsArray.join("&"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
async function reloadWidget(widgetName: string, additionalQueryParamsForWidget: {[key: string]: any })
|
||||||
|
{
|
||||||
|
const widgetData = await qController.widget(widgetName, makeQueryStringWithIdAndObject(tableMetaData, additionalQueryParamsForWidget));
|
||||||
|
const widgetMetaData = metaData.widgets.get(widgetName);
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// todo - rename this - it holds all widget dta, not just child-lists. also, the type is wrong... //
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const newChildListWidgetData: { [name: string]: ChildRecordListData } = Object.assign({}, childListWidgetData);
|
||||||
|
newChildListWidgetData[widgetName] = widgetData;
|
||||||
|
setChildListWidgetData(newChildListWidgetData);
|
||||||
|
|
||||||
|
const newRenderedWidgetSections = Object.assign({}, renderedWidgetSections);
|
||||||
|
newRenderedWidgetSections[widgetName] = getWidgetSection(widgetMetaData, widgetData);
|
||||||
|
setRenderedWidgetSections(newRenderedWidgetSections);
|
||||||
|
forceUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** process a form-field having a changed value (e.g., apply field rules).
|
** process a form-field having a changed value (e.g., apply field rules).
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -981,6 +1057,10 @@ function EntityForm(props: Props): JSX.Element
|
|||||||
console.log(`Clearing value from [${fieldRule.targetField}] due to change in [${fieldName}]`);
|
console.log(`Clearing value from [${fieldRule.targetField}] due to change in [${fieldName}]`);
|
||||||
valueChangesToMake[fieldRule.targetField] = null;
|
valueChangesToMake[fieldRule.targetField] = null;
|
||||||
break;
|
break;
|
||||||
|
case FieldRuleAction.RELOAD_WIDGET:
|
||||||
|
const additionalQueryParamsForWidget: {[key: string]: any} = {};
|
||||||
|
additionalQueryParamsForWidget[fieldRule.sourceField] = newValue;
|
||||||
|
reloadWidget(fieldRule.targetWidget, additionalQueryParamsForWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1201,6 +1281,7 @@ function EntityForm(props: Props): JSX.Element
|
|||||||
return (
|
return (
|
||||||
<Box sx={{position: "absolute", overflowY: "auto", maxHeight: "100%", width: "100%"}}>
|
<Box sx={{position: "absolute", overflowY: "auto", maxHeight: "100%", width: "100%"}}>
|
||||||
<Card sx={{my: 5, mx: "auto", p: 6, pb: 0, maxWidth: "1024px"}}>
|
<Card sx={{my: 5, mx: "auto", p: 6, pb: 0, maxWidth: "1024px"}}>
|
||||||
|
<span id="modalTopReference"></span>
|
||||||
{body}
|
{body}
|
||||||
</Card>
|
</Card>
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -94,16 +94,19 @@ function QBreadcrumbs({icon, title, route, light}: Props): JSX.Element
|
|||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
// avoid showing "saved view" as a breadcrumb element //
|
// avoid showing "saved view" as a breadcrumb element //
|
||||||
|
// e.g., if at /app/table/savedView/1 (so where i==2) //
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
if(routes[i] === "savedView")
|
if(routes[i] === "savedView" && i == 2)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
// avoid showing the table name if it's the element before savedView //
|
// avoid showing the table name if it's the element before savedView //
|
||||||
|
// e.g., when at /app/table/savedView/1 (so where i==1) //
|
||||||
|
// we want to just be showing "App" //
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
if(i < routes.length - 1 && routes[i+1] == "savedView")
|
if(i < routes.length - 1 && routes[i+1] == "savedView" && i == 1)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ import DialogTitle from "@mui/material/DialogTitle";
|
|||||||
import Grid from "@mui/material/Grid";
|
import Grid from "@mui/material/Grid";
|
||||||
import Icon from "@mui/material/Icon";
|
import Icon from "@mui/material/Icon";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
|
import {any} from "prop-types";
|
||||||
import React, {useState} from "react";
|
import React, {useState} from "react";
|
||||||
import {useNavigate} from "react-router-dom";
|
import {useNavigate} from "react-router-dom";
|
||||||
import {QCancelButton} from "qqq/components/buttons/DefaultButtons";
|
import {QCancelButton} from "qqq/components/buttons/DefaultButtons";
|
||||||
@ -71,7 +72,12 @@ function hasGotoFieldNames(tableMetaData: QTableMetaData): boolean
|
|||||||
|
|
||||||
function GotoRecordDialog(props: Props): JSX.Element
|
function GotoRecordDialog(props: Props): JSX.Element
|
||||||
{
|
{
|
||||||
const fields: QFieldMetaData[] = [];
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// this is an array of array of fields. //
|
||||||
|
// that is - each entry in the top-level array is a set of fields that can be used together to goto a record //
|
||||||
|
// such as (pkey), (ukey-field1,ukey-field2). //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const options: QFieldMetaData[][] = [];
|
||||||
|
|
||||||
let pkey = props?.tableMetaData?.fields.get(props?.tableMetaData?.primaryKeyField);
|
let pkey = props?.tableMetaData?.fields.get(props?.tableMetaData?.primaryKeyField);
|
||||||
let addedPkey = false;
|
let addedPkey = false;
|
||||||
@ -82,31 +88,38 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
{
|
{
|
||||||
for (let i = 0; i < mdbMetaData.gotoFieldNames.length; i++)
|
for (let i = 0; i < mdbMetaData.gotoFieldNames.length; i++)
|
||||||
{
|
{
|
||||||
// todo - multi-field keys!!
|
const option: QFieldMetaData[] = [];
|
||||||
let fieldName = mdbMetaData.gotoFieldNames[i][0];
|
options.push(option);
|
||||||
let field = props.tableMetaData.fields.get(fieldName);
|
for (let j = 0; j < mdbMetaData.gotoFieldNames[i].length; j++)
|
||||||
if (field)
|
|
||||||
{
|
{
|
||||||
fields.push(field);
|
let fieldName = mdbMetaData.gotoFieldNames[i][j];
|
||||||
|
let field = props.tableMetaData.fields.get(fieldName);
|
||||||
if (field.name == pkey.name)
|
if (field)
|
||||||
{
|
{
|
||||||
addedPkey = true;
|
option.push(field);
|
||||||
|
|
||||||
|
if (pkey != null && field.name == pkey.name)
|
||||||
|
{
|
||||||
|
addedPkey = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// if pkey wasn't in the gotoField options meta-data, go ahead add it as an option here //
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if (pkey && !addedPkey)
|
if (pkey && !addedPkey)
|
||||||
{
|
{
|
||||||
fields.unshift(pkey);
|
options.unshift([pkey]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const makeInitialValues = () =>
|
const makeInitialValues = () =>
|
||||||
{
|
{
|
||||||
const rs = {} as { [field: string]: string };
|
const rs = {} as { [field: string]: string };
|
||||||
fields.forEach((field) => rs[field.name] = "");
|
options.forEach((option) => option.forEach((field) => rs[field.name] = ""));
|
||||||
return (rs);
|
return (rs);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -141,11 +154,16 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
}
|
}
|
||||||
else if (e.key == "Enter" && targetId?.startsWith("gotoInput-"))
|
else if (e.key == "Enter" && targetId?.startsWith("gotoInput-"))
|
||||||
{
|
{
|
||||||
const index = targetId?.replaceAll("gotoInput-", "");
|
const parts = targetId?.split(/-/);
|
||||||
|
const index = parts[1];
|
||||||
document.getElementById("gotoButton-" + index).click();
|
document.getElementById("gotoButton-" + index).click();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
** event handler for close button
|
||||||
|
***************************************************************************/
|
||||||
const closeRequested = () =>
|
const closeRequested = () =>
|
||||||
{
|
{
|
||||||
if (props.mayClose)
|
if (props.mayClose)
|
||||||
@ -154,10 +172,47 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const goClicked = async (fieldName: string) =>
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** function to say if an option's submit button should be disabled
|
||||||
|
*******************************************************************************/
|
||||||
|
const isOptionSubmitButtonDisabled = (optionIndex: number) =>
|
||||||
|
{
|
||||||
|
let anyFieldsInThisOptionHaveAValue = false;
|
||||||
|
|
||||||
|
options[optionIndex].forEach((field) =>
|
||||||
|
{
|
||||||
|
if(values[field.name])
|
||||||
|
{
|
||||||
|
anyFieldsInThisOptionHaveAValue = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if(!anyFieldsInThisOptionHaveAValue)
|
||||||
|
{
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
** event handler for clicking an 'option's go/submit button
|
||||||
|
***************************************************************************/
|
||||||
|
const optionGoClicked = async (optionIndex: number) =>
|
||||||
{
|
{
|
||||||
setError("");
|
setError("");
|
||||||
const filter = new QQueryFilter([new QFilterCriteria(fieldName, QCriteriaOperator.EQUALS, [values[fieldName]])], null, null, "AND", null, 10);
|
|
||||||
|
const criteria: QFilterCriteria[] = [];
|
||||||
|
const queryStringParts: string[] = [];
|
||||||
|
options[optionIndex].forEach((field) =>
|
||||||
|
{
|
||||||
|
criteria.push(new QFilterCriteria(field.name, QCriteriaOperator.EQUALS, [values[field.name]]))
|
||||||
|
queryStringParts.push(`${field.name}=${encodeURIComponent(values[field.name])}`)
|
||||||
|
})
|
||||||
|
|
||||||
|
const filter = new QQueryFilter(criteria, null, null, "AND", null, 10);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const queryResult = await qController.query(props.tableMetaData.name, filter, null, props.tableVariant);
|
const queryResult = await qController.query(props.tableMetaData.name, filter, null, props.tableVariant);
|
||||||
@ -168,12 +223,26 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
}
|
}
|
||||||
else if (queryResult.length == 1)
|
else if (queryResult.length == 1)
|
||||||
{
|
{
|
||||||
navigate(`${props.metaData.getTablePathByName(props.tableMetaData.name)}/${encodeURIComponent(queryResult[0].values.get(props.tableMetaData.primaryKeyField))}`);
|
if(options[optionIndex].length == 1 && options[optionIndex][0].name == pkey?.name)
|
||||||
|
{
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
// navigate by pkey, if that's how we searched //
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
navigate(`${props.metaData.getTablePathByName(props.tableMetaData.name)}/${encodeURIComponent(queryResult[0].values.get(props.tableMetaData.primaryKeyField))}`);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/////////////////////////////////
|
||||||
|
// else navigate by unique-key //
|
||||||
|
/////////////////////////////////
|
||||||
|
navigate(`${props.metaData.getTablePathByName(props.tableMetaData.name)}/key/?${queryStringParts.join("&")}`);
|
||||||
|
}
|
||||||
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setError("More than 1 record found...");
|
setError("More than 1 record was found...");
|
||||||
setTimeout(() => setError(""), 3000);
|
setTimeout(() => setError(""), 3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,7 +256,7 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
|
|
||||||
if (props.tableMetaData)
|
if (props.tableMetaData)
|
||||||
{
|
{
|
||||||
if (fields.length == 0 && !error)
|
if (options.length == 0 && !error)
|
||||||
{
|
{
|
||||||
setError("This table is not configured for this feature.");
|
setError("This table is not configured for this feature.");
|
||||||
}
|
}
|
||||||
@ -200,31 +269,38 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
<DialogContent>
|
<DialogContent>
|
||||||
{props.subHeader}
|
{props.subHeader}
|
||||||
{
|
{
|
||||||
fields.map((field, index) =>
|
options.map((option, optionIndex) =>
|
||||||
(
|
<Box key={optionIndex}>
|
||||||
<Grid key={field.name} container alignItems="center" py={1}>
|
{
|
||||||
<Grid item xs={3} textAlign="right" pr={2}>
|
option.map((field, index) =>
|
||||||
{field.label}
|
(
|
||||||
</Grid>
|
<Grid key={field.name} container alignItems="center" py={1}>
|
||||||
<Grid item xs={6}>
|
<Grid item xs={3} textAlign="right" pr={2}>
|
||||||
<TextField
|
{field.label}
|
||||||
id={`gotoInput-${index}`}
|
</Grid>
|
||||||
autoFocus={index == 0}
|
<Grid item xs={6}>
|
||||||
autoComplete="off"
|
<TextField
|
||||||
inputProps={{width: "100%"}}
|
id={`gotoInput-${optionIndex}-${index}`}
|
||||||
onChange={(e) => handleChange(field.name, e.target.value)}
|
autoFocus={optionIndex == 0 && index == 0}
|
||||||
value={values[field.name]}
|
autoComplete="off"
|
||||||
sx={{width: "100%"}}
|
inputProps={{width: "100%"}}
|
||||||
onFocus={event => event.target.select()}
|
onChange={(e) => handleChange(field.name, e.target.value)}
|
||||||
/>
|
value={values[field.name]}
|
||||||
</Grid>
|
sx={{width: "100%"}}
|
||||||
<Grid item xs={1} pl={2}>
|
onFocus={event => event.target.select()}
|
||||||
<MDButton id={`gotoButton-${index}`} type="submit" variant="gradient" color="info" size="small" onClick={() => goClicked(field.name)} fullWidth startIcon={<Icon>double_arrow</Icon>} disabled={`${values[field.name]}`.length == 0}>
|
/>
|
||||||
Go
|
</Grid>
|
||||||
</MDButton>
|
<Grid item xs={1} pl={2}>
|
||||||
</Grid>
|
{
|
||||||
</Grid>
|
(index == option.length - 1) &&
|
||||||
))
|
<MDButton id={`gotoButton-${optionIndex}`} type="submit" variant="gradient" color="info" size="small" onClick={() => optionGoClicked(optionIndex)} fullWidth startIcon={<Icon>double_arrow</Icon>} disabled={isOptionSubmitButtonDisabled(optionIndex)}>Go</MDButton>
|
||||||
|
}
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
error &&
|
error &&
|
||||||
|
@ -25,8 +25,7 @@ import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QT
|
|||||||
import {QJobComplete} from "@kingsrook/qqq-frontend-core/lib/model/processes/QJobComplete";
|
import {QJobComplete} from "@kingsrook/qqq-frontend-core/lib/model/processes/QJobComplete";
|
||||||
import {QJobError} from "@kingsrook/qqq-frontend-core/lib/model/processes/QJobError";
|
import {QJobError} from "@kingsrook/qqq-frontend-core/lib/model/processes/QJobError";
|
||||||
import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord";
|
import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord";
|
||||||
import {Alert, Button} from "@mui/material";
|
import {Alert, Box, Button} from "@mui/material";
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Dialog from "@mui/material/Dialog";
|
import Dialog from "@mui/material/Dialog";
|
||||||
import DialogActions from "@mui/material/DialogActions";
|
import DialogActions from "@mui/material/DialogActions";
|
||||||
import DialogContent from "@mui/material/DialogContent";
|
import DialogContent from "@mui/material/DialogContent";
|
||||||
@ -60,7 +59,7 @@ interface Props
|
|||||||
view?: RecordQueryView;
|
view?: RecordQueryView;
|
||||||
viewAsJson?: string;
|
viewAsJson?: string;
|
||||||
viewOnChangeCallback?: (selectedSavedViewId: number) => void;
|
viewOnChangeCallback?: (selectedSavedViewId: number) => void;
|
||||||
loadingSavedView: boolean
|
loadingSavedView: boolean;
|
||||||
queryScreenUsage: QueryScreenUsage;
|
queryScreenUsage: QueryScreenUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +68,8 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [savedViews, setSavedViews] = useState([] as QRecord[]);
|
const [savedViews, setSavedViews] = useState([] as QRecord[]);
|
||||||
|
const [yourSavedViews, setYourSavedViews] = useState([] as QRecord[]);
|
||||||
|
const [viewsSharedWithYou, setViewsSharedWithYou] = useState([] as QRecord[]);
|
||||||
const [savedViewsMenu, setSavedViewsMenu] = useState(null);
|
const [savedViewsMenu, setSavedViewsMenu] = useState(null);
|
||||||
const [savedViewsHaveLoaded, setSavedViewsHaveLoaded] = useState(false);
|
const [savedViewsHaveLoaded, setSavedViewsHaveLoaded] = useState(false);
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
@ -91,7 +92,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
const CLEAR_OPTION = "New View";
|
const CLEAR_OPTION = "New View";
|
||||||
const NEW_REPORT_OPTION = "Create Report from Current View";
|
const NEW_REPORT_OPTION = "Create Report from Current View";
|
||||||
|
|
||||||
const {accentColor, accentColorLight} = useContext(QContext);
|
const {accentColor, accentColorLight, userId: currentUserId} = useContext(QContext);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// this component is used by <RecordQuery> - but that component has different usages - //
|
// this component is used by <RecordQuery> - but that component has different usages - //
|
||||||
@ -114,13 +115,13 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
{
|
{
|
||||||
setSavedViewsHaveLoaded(true);
|
setSavedViewsHaveLoaded(true);
|
||||||
});
|
});
|
||||||
}, [location, tableMetaData])
|
}, [location, tableMetaData]);
|
||||||
|
|
||||||
|
|
||||||
const baseView = currentSavedView ? JSON.parse(currentSavedView.values.get("viewJson")) as RecordQueryView : tableDefaultView;
|
const baseView = currentSavedView ? JSON.parse(currentSavedView.values.get("viewJson")) as RecordQueryView : tableDefaultView;
|
||||||
const viewDiffs = SavedViewUtils.diffViews(tableMetaData, baseView, view);
|
const viewDiffs = SavedViewUtils.diffViews(tableMetaData, baseView, view);
|
||||||
let viewIsModified = false;
|
let viewIsModified = false;
|
||||||
if(viewDiffs.length > 0)
|
if (viewDiffs.length > 0)
|
||||||
{
|
{
|
||||||
viewIsModified = true;
|
viewIsModified = true;
|
||||||
}
|
}
|
||||||
@ -130,7 +131,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
async function loadSavedViews()
|
async function loadSavedViews()
|
||||||
{
|
{
|
||||||
if (! tableMetaData)
|
if (!tableMetaData)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -140,8 +141,24 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
|
|
||||||
let savedViews = await makeSavedViewRequest("querySavedView", formData);
|
let savedViews = await makeSavedViewRequest("querySavedView", formData);
|
||||||
setSavedViews(savedViews);
|
setSavedViews(savedViews);
|
||||||
}
|
|
||||||
|
|
||||||
|
const yourSavedViews: QRecord[] = [];
|
||||||
|
const viewsSharedWithYou: QRecord[] = [];
|
||||||
|
for (let i = 0; i < savedViews.length; i++)
|
||||||
|
{
|
||||||
|
const record = savedViews[i];
|
||||||
|
if (record.values.get("userId") == currentUserId)
|
||||||
|
{
|
||||||
|
yourSavedViews.push(record);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
viewsSharedWithYou.push(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setYourSavedViews(yourSavedViews);
|
||||||
|
setViewsSharedWithYou(viewsSharedWithYou);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -152,14 +169,13 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
setSaveFilterPopupOpen(false);
|
setSaveFilterPopupOpen(false);
|
||||||
closeSavedViewsMenu();
|
closeSavedViewsMenu();
|
||||||
viewOnChangeCallback(record.values.get("id"));
|
viewOnChangeCallback(record.values.get("id"));
|
||||||
if(isQueryScreen)
|
if (isQueryScreen)
|
||||||
{
|
{
|
||||||
navigate(`${metaData.getTablePathByName(tableMetaData.name)}/savedView/${record.values.get("id")}`);
|
navigate(`${metaData.getTablePathByName(tableMetaData.name)}/savedView/${record.values.get("id")}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** fired when a save option is selected from the save... button/dropdown combo
|
** fired when a save option is selected from the save... button/dropdown combo
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -171,12 +187,12 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
setSaveFilterPopupOpen(true);
|
setSaveFilterPopupOpen(true);
|
||||||
setIsSaveFilterAs(false);
|
setIsSaveFilterAs(false);
|
||||||
setIsRenameFilter(false);
|
setIsRenameFilter(false);
|
||||||
setIsDeleteFilter(false)
|
setIsDeleteFilter(false);
|
||||||
|
|
||||||
switch(optionName)
|
switch (optionName)
|
||||||
{
|
{
|
||||||
case SAVE_OPTION:
|
case SAVE_OPTION:
|
||||||
if(currentSavedView == null)
|
if (currentSavedView == null)
|
||||||
{
|
{
|
||||||
setSavedViewNameInputValue("");
|
setSavedViewNameInputValue("");
|
||||||
}
|
}
|
||||||
@ -186,28 +202,28 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
setIsSaveFilterAs(true);
|
setIsSaveFilterAs(true);
|
||||||
break;
|
break;
|
||||||
case CLEAR_OPTION:
|
case CLEAR_OPTION:
|
||||||
setSaveFilterPopupOpen(false)
|
setSaveFilterPopupOpen(false);
|
||||||
viewOnChangeCallback(null);
|
viewOnChangeCallback(null);
|
||||||
if(isQueryScreen)
|
if (isQueryScreen)
|
||||||
{
|
{
|
||||||
navigate(metaData.getTablePathByName(tableMetaData.name));
|
navigate(metaData.getTablePathByName(tableMetaData.name));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RENAME_OPTION:
|
case RENAME_OPTION:
|
||||||
if(currentSavedView != null)
|
if (currentSavedView != null)
|
||||||
{
|
{
|
||||||
setSavedViewNameInputValue(currentSavedView.values.get("label"));
|
setSavedViewNameInputValue(currentSavedView.values.get("label"));
|
||||||
}
|
}
|
||||||
setIsRenameFilter(true);
|
setIsRenameFilter(true);
|
||||||
break;
|
break;
|
||||||
case DELETE_OPTION:
|
case DELETE_OPTION:
|
||||||
setIsDeleteFilter(true)
|
setIsDeleteFilter(true);
|
||||||
break;
|
break;
|
||||||
case NEW_REPORT_OPTION:
|
case NEW_REPORT_OPTION:
|
||||||
createNewReport();
|
createNewReport();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -215,11 +231,11 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function createNewReport()
|
function createNewReport()
|
||||||
{
|
{
|
||||||
const defaultValues: {[key: string]: any} = {};
|
const defaultValues: { [key: string]: any } = {};
|
||||||
defaultValues.tableName = tableMetaData.name;
|
defaultValues.tableName = tableMetaData.name;
|
||||||
|
|
||||||
let filterForBackend = JSON.parse(JSON.stringify(view.queryFilter));
|
let filterForBackend = JSON.parse(JSON.stringify(view.queryFilter));
|
||||||
filterForBackend = FilterUtils.prepQueryFilterForBackend(tableMetaData, filterForBackend);
|
filterForBackend = FilterUtils.prepQueryFilterForBackend(tableMetaData, filterForBackend);
|
||||||
|
|
||||||
defaultValues.queryFilterJson = JSON.stringify(filterForBackend);
|
defaultValues.queryFilterJson = JSON.stringify(filterForBackend);
|
||||||
defaultValues.columnsJson = JSON.stringify(view.queryColumns);
|
defaultValues.columnsJson = JSON.stringify(view.queryColumns);
|
||||||
@ -227,7 +243,6 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** fired when save or delete button saved on confirmation dialogs
|
** fired when save or delete button saved on confirmation dialogs
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -247,7 +262,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
setSaveFilterPopupOpen(false);
|
setSaveFilterPopupOpen(false);
|
||||||
setSaveOptionsOpen(false);
|
setSaveOptionsOpen(false);
|
||||||
|
|
||||||
await(async() =>
|
await (async () =>
|
||||||
{
|
{
|
||||||
handleDropdownOptionClick(CLEAR_OPTION);
|
handleDropdownOptionClick(CLEAR_OPTION);
|
||||||
})();
|
})();
|
||||||
@ -267,14 +282,14 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// strip away incomplete filters too, just for cleaner saved view filters //
|
// strip away incomplete filters too, just for cleaner saved view filters //
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
FilterUtils.stripAwayIncompleteCriteria(viewObject.queryFilter)
|
FilterUtils.stripAwayIncompleteCriteria(viewObject.queryFilter);
|
||||||
|
|
||||||
formData.append("viewJson", JSON.stringify(viewObject));
|
formData.append("viewJson", JSON.stringify(viewObject));
|
||||||
|
|
||||||
if (isSaveFilterAs || isRenameFilter || currentSavedView == null)
|
if (isSaveFilterAs || isRenameFilter || currentSavedView == null)
|
||||||
{
|
{
|
||||||
formData.append("label", savedViewNameInputValue);
|
formData.append("label", savedViewNameInputValue);
|
||||||
if(currentSavedView != null && isRenameFilter)
|
if (currentSavedView != null && isRenameFilter)
|
||||||
{
|
{
|
||||||
formData.append("id", currentSavedView.values.get("id"));
|
formData.append("id", currentSavedView.values.get("id"));
|
||||||
}
|
}
|
||||||
@ -285,7 +300,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
formData.append("label", currentSavedView?.values.get("label"));
|
formData.append("label", currentSavedView?.values.get("label"));
|
||||||
}
|
}
|
||||||
const recordList = await makeSavedViewRequest("storeSavedView", formData);
|
const recordList = await makeSavedViewRequest("storeSavedView", formData);
|
||||||
await(async() =>
|
await (async () =>
|
||||||
{
|
{
|
||||||
if (recordList && recordList.length > 0)
|
if (recordList && recordList.length > 0)
|
||||||
{
|
{
|
||||||
@ -302,11 +317,11 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
catch (e: any)
|
catch (e: any)
|
||||||
{
|
{
|
||||||
let message = JSON.stringify(e);
|
let message = JSON.stringify(e);
|
||||||
if(typeof e == "string")
|
if (typeof e == "string")
|
||||||
{
|
{
|
||||||
message = e;
|
message = e;
|
||||||
}
|
}
|
||||||
else if(typeof e == "object" && e.message)
|
else if (typeof e == "object" && e.message)
|
||||||
{
|
{
|
||||||
message = e.message;
|
message = e.message;
|
||||||
}
|
}
|
||||||
@ -321,7 +336,6 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** hides/shows the save options
|
** hides/shows the save options
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -331,7 +345,6 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** closes save options menu (on clickaway)
|
** closes save options menu (on clickaway)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -346,7 +359,6 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** stores the current dialog input text to state
|
** stores the current dialog input text to state
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -356,7 +368,6 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** closes current dialog
|
** closes current dialog
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -366,7 +377,6 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** make a request to the backend for various savedView processes
|
** make a request to the backend for various savedView processes
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -375,7 +385,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
/////////////////////////
|
/////////////////////////
|
||||||
// fetch saved filters //
|
// fetch saved filters //
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
let savedViews = [] as QRecord[]
|
let savedViews = [] as QRecord[];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
@ -386,12 +396,12 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
if (processResult instanceof QJobError)
|
if (processResult instanceof QJobError)
|
||||||
{
|
{
|
||||||
const jobError = processResult as QJobError;
|
const jobError = processResult as QJobError;
|
||||||
throw(jobError.error);
|
throw (jobError.error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const result = processResult as QJobComplete;
|
const result = processResult as QJobComplete;
|
||||||
if(result.values.savedViewList)
|
if (result.values.savedViewList)
|
||||||
{
|
{
|
||||||
for (let i = 0; i < result.values.savedViewList.length; i++)
|
for (let i = 0; i < result.values.savedViewList.length; i++)
|
||||||
{
|
{
|
||||||
@ -403,7 +413,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
throw(e);
|
throw (e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (savedViews);
|
return (savedViews);
|
||||||
@ -416,17 +426,27 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
|
|
||||||
const tooltipMaxWidth = (maxWidth: string) =>
|
const tooltipMaxWidth = (maxWidth: string) =>
|
||||||
{
|
{
|
||||||
return ({slotProps: {
|
return ({
|
||||||
tooltip: {
|
slotProps: {
|
||||||
sx: {
|
tooltip: {
|
||||||
maxWidth: maxWidth
|
sx: {
|
||||||
|
maxWidth: maxWidth
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}})
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
const menuTooltipAttribs = {...tooltipMaxWidth("250px"), placement: "left", enterDelay: 1000} as TooltipProps;
|
const menuTooltipAttribs = {...tooltipMaxWidth("250px"), placement: "left", enterDelay: 1000} as TooltipProps;
|
||||||
|
|
||||||
|
let disabledBecauseNotOwner = false;
|
||||||
|
let notOwnerTooltipText = null;
|
||||||
|
if (currentSavedView && currentSavedView.values.get("userId") != currentUserId)
|
||||||
|
{
|
||||||
|
disabledBecauseNotOwner = true;
|
||||||
|
notOwnerTooltipText = "You may not save changes to this view, because you are not its owner.";
|
||||||
|
}
|
||||||
|
|
||||||
const renderSavedViewsMenu = tableMetaData && (
|
const renderSavedViewsMenu = tableMetaData && (
|
||||||
<Menu
|
<Menu
|
||||||
anchorEl={savedViewsMenu}
|
anchorEl={savedViewsMenu}
|
||||||
@ -443,75 +463,101 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
isQueryScreen && hasStorePermission &&
|
isQueryScreen && hasStorePermission &&
|
||||||
<Tooltip {...menuTooltipAttribs} title={<>Save your current filters, columns and settings, for quick re-use at a later time.<br /><br />You will be prompted to enter a name if you choose this option.</>}>
|
<Tooltip {...menuTooltipAttribs} title={notOwnerTooltipText ?? <>Save your current filters, columns and settings, for quick re-use at a later time.<br /><br />You will be prompted to enter a name if you choose this option.</>}>
|
||||||
<MenuItem onClick={() => handleDropdownOptionClick(SAVE_OPTION)}>
|
<span>
|
||||||
<ListItemIcon><Icon>save</Icon></ListItemIcon>
|
<MenuItem disabled={disabledBecauseNotOwner} onClick={() => handleDropdownOptionClick(SAVE_OPTION)}>
|
||||||
{currentSavedView ? "Save..." : "Save As..."}
|
<ListItemIcon><Icon>save</Icon></ListItemIcon>
|
||||||
</MenuItem>
|
{currentSavedView ? "Save..." : "Save As..."}
|
||||||
|
</MenuItem>
|
||||||
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
isQueryScreen && hasStorePermission && currentSavedView != null &&
|
isQueryScreen && hasStorePermission && currentSavedView != null &&
|
||||||
<Tooltip {...menuTooltipAttribs} title="Change the name for this saved view.">
|
<Tooltip {...menuTooltipAttribs} title={notOwnerTooltipText ?? "Change the name for this saved view."}>
|
||||||
<MenuItem disabled={currentSavedView === null} onClick={() => handleDropdownOptionClick(RENAME_OPTION)}>
|
<span>
|
||||||
<ListItemIcon><Icon>edit</Icon></ListItemIcon>
|
<MenuItem disabled={currentSavedView === null || disabledBecauseNotOwner} onClick={() => handleDropdownOptionClick(RENAME_OPTION)}>
|
||||||
Rename...
|
<ListItemIcon><Icon>edit</Icon></ListItemIcon>
|
||||||
</MenuItem>
|
Rename...
|
||||||
|
</MenuItem>
|
||||||
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
isQueryScreen && hasStorePermission && currentSavedView != null &&
|
isQueryScreen && hasStorePermission && currentSavedView != null &&
|
||||||
<Tooltip {...menuTooltipAttribs} title="Save a new copy this view, with a different name, separate from the original.">
|
<Tooltip {...menuTooltipAttribs} title="Save a new copy this view, with a different name, separate from the original.">
|
||||||
<MenuItem disabled={currentSavedView === null} onClick={() => handleDropdownOptionClick(DUPLICATE_OPTION)}>
|
<span>
|
||||||
<ListItemIcon><Icon>content_copy</Icon></ListItemIcon>
|
<MenuItem disabled={currentSavedView === null} onClick={() => handleDropdownOptionClick(DUPLICATE_OPTION)}>
|
||||||
Save As...
|
<ListItemIcon><Icon>content_copy</Icon></ListItemIcon>
|
||||||
</MenuItem>
|
Save As...
|
||||||
|
</MenuItem>
|
||||||
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
isQueryScreen && hasDeletePermission && currentSavedView != null &&
|
isQueryScreen && hasDeletePermission && currentSavedView != null &&
|
||||||
<Tooltip {...menuTooltipAttribs} title="Delete this saved view.">
|
<Tooltip {...menuTooltipAttribs} title={notOwnerTooltipText ?? "Delete this saved view."}>
|
||||||
<MenuItem disabled={currentSavedView === null} onClick={() => handleDropdownOptionClick(DELETE_OPTION)}>
|
<span>
|
||||||
<ListItemIcon><Icon>delete</Icon></ListItemIcon>
|
<MenuItem disabled={currentSavedView === null || disabledBecauseNotOwner} onClick={() => handleDropdownOptionClick(DELETE_OPTION)}>
|
||||||
Delete...
|
<ListItemIcon><Icon>delete</Icon></ListItemIcon>
|
||||||
</MenuItem>
|
Delete...
|
||||||
|
</MenuItem>
|
||||||
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
isQueryScreen &&
|
isQueryScreen &&
|
||||||
<Tooltip {...menuTooltipAttribs} title="Create a new view of this table, resetting the filters and columns to their defaults.">
|
<Tooltip {...menuTooltipAttribs} title="Create a new view of this table, resetting the filters and columns to their defaults.">
|
||||||
<MenuItem onClick={() => handleDropdownOptionClick(CLEAR_OPTION)}>
|
<span>
|
||||||
<ListItemIcon><Icon>monitor</Icon></ListItemIcon>
|
<MenuItem onClick={() => handleDropdownOptionClick(CLEAR_OPTION)}>
|
||||||
New View
|
<ListItemIcon><Icon>monitor</Icon></ListItemIcon>
|
||||||
</MenuItem>
|
New View
|
||||||
|
</MenuItem>
|
||||||
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
isQueryScreen && hasSavedReportsPermission &&
|
isQueryScreen && hasSavedReportsPermission &&
|
||||||
<Tooltip {...menuTooltipAttribs} title="Create a new Saved Report using your current view of this table as a starting point.">
|
<Tooltip {...menuTooltipAttribs} title="Create a new Saved Report using your current view of this table as a starting point.">
|
||||||
<MenuItem onClick={() => handleDropdownOptionClick(NEW_REPORT_OPTION)}>
|
<span>
|
||||||
<ListItemIcon><Icon>article</Icon></ListItemIcon>
|
<MenuItem onClick={() => handleDropdownOptionClick(NEW_REPORT_OPTION)}>
|
||||||
Create Report from Current View
|
<ListItemIcon><Icon>article</Icon></ListItemIcon>
|
||||||
</MenuItem>
|
Create Report from Current View
|
||||||
|
</MenuItem>
|
||||||
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
isQueryScreen && <Divider/>
|
isQueryScreen && <Divider />
|
||||||
}
|
}
|
||||||
<MenuItem disabled style={{"opacity": "initial"}}><b>Your Saved Views</b></MenuItem>
|
<MenuItem disabled style={{"opacity": "initial"}}><b>Your Saved Views</b></MenuItem>
|
||||||
{
|
{
|
||||||
savedViews && savedViews.length > 0 ? (
|
yourSavedViews && yourSavedViews.length > 0 ? (
|
||||||
savedViews.map((record: QRecord, index: number) =>
|
yourSavedViews.map((record: QRecord, index: number) =>
|
||||||
<MenuItem sx={{paddingLeft: "50px"}} key={`savedFiler-${index}`} onClick={() => handleSavedViewRecordOnClick(record)}>
|
<MenuItem sx={{paddingLeft: "50px"}} key={`savedFiler-${index}`} onClick={() => handleSavedViewRecordOnClick(record)}>
|
||||||
{record.values.get("label")}
|
{record.values.get("label")}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)
|
)
|
||||||
): (
|
) : (
|
||||||
<MenuItem disabled sx={{opacity: "1 !important"}}>
|
<MenuItem disabled sx={{opacity: "1 !important"}}>
|
||||||
<i>You do not have any saved views for this table.</i>
|
<i>You do not have any saved views for this table.</i>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
<MenuItem disabled style={{"opacity": "initial"}}><b>Views Shared with you</b></MenuItem>
|
||||||
|
{
|
||||||
|
viewsSharedWithYou && viewsSharedWithYou.length > 0 ? (
|
||||||
|
viewsSharedWithYou.map((record: QRecord, index: number) =>
|
||||||
|
<MenuItem sx={{paddingLeft: "50px"}} key={`savedFiler-${index}`} onClick={() => handleSavedViewRecordOnClick(record)}>
|
||||||
|
{record.values.get("label")}
|
||||||
|
</MenuItem>
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
<MenuItem disabled sx={{opacity: "1 !important"}}>
|
||||||
|
<i>You do not have any views shared with you for this table.</i>
|
||||||
|
</MenuItem>
|
||||||
|
)
|
||||||
|
}
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -520,7 +566,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
let buttonBorder = colors.grayLines.main;
|
let buttonBorder = colors.grayLines.main;
|
||||||
let buttonColor = colors.gray.main;
|
let buttonColor = colors.gray.main;
|
||||||
|
|
||||||
if(currentSavedView)
|
if (currentSavedView)
|
||||||
{
|
{
|
||||||
if (viewIsModified)
|
if (viewIsModified)
|
||||||
{
|
{
|
||||||
@ -548,23 +594,23 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
color: buttonColor,
|
color: buttonColor,
|
||||||
backgroundColor: buttonBackground,
|
backgroundColor: buttonBackground,
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function isSaveButtonDisabled(): boolean
|
function isSaveButtonDisabled(): boolean
|
||||||
{
|
{
|
||||||
if(isSubmitting)
|
if (isSubmitting)
|
||||||
{
|
{
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const haveInputText = (savedViewNameInputValue != null && savedViewNameInputValue.trim() != "")
|
const haveInputText = (savedViewNameInputValue != null && savedViewNameInputValue.trim() != "");
|
||||||
|
|
||||||
if(isSaveFilterAs || isRenameFilter || currentSavedView == null)
|
if (isSaveFilterAs || isRenameFilter || currentSavedView == null)
|
||||||
{
|
{
|
||||||
if(!haveInputText)
|
if (!haveInputText)
|
||||||
{
|
{
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
@ -593,7 +639,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
fontSize: "0.875rem",
|
fontSize: "0.875rem",
|
||||||
p: "0.5rem",
|
p: "0.5rem",
|
||||||
... buttonStyles
|
...buttonStyles
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon sx={{mr: "0.5rem"}}>save</Icon>
|
<Icon sx={{mr: "0.5rem"}}>save</Icon>
|
||||||
@ -624,7 +670,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
<Button disableRipple={true} sx={{color: colors.gray.main, ... linkButtonStyle}} onClick={() => handleDropdownOptionClick(CLEAR_OPTION)}>Reset All Changes</Button>
|
<Button disableRipple={true} sx={{color: colors.gray.main, ...linkButtonStyle}} onClick={() => handleDropdownOptionClick(CLEAR_OPTION)}>Reset All Changes</Button>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -635,16 +681,20 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
{
|
{
|
||||||
viewDiffs.map((s: string, i: number) => <li key={i}>{s}</li>)
|
viewDiffs.map((s: string, i: number) => <li key={i}>{s}</li>)
|
||||||
}
|
}
|
||||||
</ul></>}>
|
</ul>
|
||||||
|
{
|
||||||
|
notOwnerTooltipText && <i>{notOwnerTooltipText}</i>
|
||||||
|
}
|
||||||
|
</>}>
|
||||||
<Box display="inline" sx={{...linkButtonStyle, p: 0, cursor: "default", position: "relative", top: "-1px"}}>{viewDiffs.length} Unsaved Change{viewDiffs.length == 1 ? "" : "s"}</Box>
|
<Box display="inline" sx={{...linkButtonStyle, p: 0, cursor: "default", position: "relative", top: "-1px"}}>{viewDiffs.length} Unsaved Change{viewDiffs.length == 1 ? "" : "s"}</Box>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
<Button disableRipple={true} sx={linkButtonStyle} onClick={() => handleDropdownOptionClick(SAVE_OPTION)}>Save…</Button>
|
{disabledBecauseNotOwner ? <> </> : <Button disableRipple={true} sx={linkButtonStyle} onClick={() => handleDropdownOptionClick(SAVE_OPTION)}>Save…</Button>}
|
||||||
|
|
||||||
{/* vertical rule */}
|
{/* vertical rule */}
|
||||||
<Box display="inline-block" borderLeft={`1px solid ${colors.grayLines.main}`} height="1rem" width="1px" position="relative" />
|
<Box display="inline-block" borderLeft={`1px solid ${colors.grayLines.main}`} height="1rem" width="1px" position="relative" />
|
||||||
|
|
||||||
<Button disableRipple={true} sx={{color: colors.gray.main, ... linkButtonStyle}} onClick={() => handleSavedViewRecordOnClick(currentSavedView)}>Reset All Changes</Button>
|
<Button disableRipple={true} sx={{color: colors.gray.main, ...linkButtonStyle}} onClick={() => handleSavedViewRecordOnClick(currentSavedView)}>Reset All Changes</Button>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -663,16 +713,17 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
{
|
{
|
||||||
viewDiffs.map((s: string, i: number) => <li key={i}>{s}</li>)
|
viewDiffs.map((s: string, i: number) => <li key={i}>{s}</li>)
|
||||||
}
|
}
|
||||||
</ul></>}>
|
</ul>
|
||||||
|
</>}>
|
||||||
<Box display="inline" ml="0.25rem" mr="0.25rem" sx={{...linkButtonStyle, p: 0, cursor: "default", position: "relative", top: "-1px"}}>with {viewDiffs.length} Change{viewDiffs.length == 1 ? "" : "s"}</Box>
|
<Box display="inline" ml="0.25rem" mr="0.25rem" sx={{...linkButtonStyle, p: 0, cursor: "default", position: "relative", top: "-1px"}}>with {viewDiffs.length} Change{viewDiffs.length == 1 ? "" : "s"}</Box>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Button disableRipple={true} sx={{color: colors.gray.main, ... linkButtonStyle}} onClick={() => handleSavedViewRecordOnClick(currentSavedView)}>Reset Changes</Button>
|
<Button disableRipple={true} sx={{color: colors.gray.main, ...linkButtonStyle}} onClick={() => handleSavedViewRecordOnClick(currentSavedView)}>Reset Changes</Button>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
{/* vertical rule */}
|
{/* vertical rule */}
|
||||||
<Box display="inline-block" ml="0.25rem" borderLeft={`1px solid ${colors.grayLines.main}`} height="1rem" width="1px" position="relative" />
|
<Box display="inline-block" ml="0.25rem" borderLeft={`1px solid ${colors.grayLines.main}`} height="1rem" width="1px" position="relative" />
|
||||||
<Button disableRipple={true} sx={{color: colors.gray.main, ... linkButtonStyle}} onClick={() => handleDropdownOptionClick(CLEAR_OPTION)}>Reset to New View</Button>
|
<Button disableRipple={true} sx={{color: colors.gray.main, ...linkButtonStyle}} onClick={() => handleDropdownOptionClick(CLEAR_OPTION)}>Reset to New View</Button>
|
||||||
</Box>
|
</Box>
|
||||||
}
|
}
|
||||||
</Box>
|
</Box>
|
||||||
@ -702,15 +753,15 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
) : (
|
) : (
|
||||||
isSaveFilterAs ? (
|
isSaveFilterAs ? (
|
||||||
<DialogTitle id="alert-dialog-title">Save View As</DialogTitle>
|
<DialogTitle id="alert-dialog-title">Save View As</DialogTitle>
|
||||||
):(
|
) : (
|
||||||
isRenameFilter ? (
|
isRenameFilter ? (
|
||||||
<DialogTitle id="alert-dialog-title">Rename View</DialogTitle>
|
<DialogTitle id="alert-dialog-title">Rename View</DialogTitle>
|
||||||
):(
|
) : (
|
||||||
<DialogTitle id="alert-dialog-title">Update Existing View</DialogTitle>
|
<DialogTitle id="alert-dialog-title">Update Existing View</DialogTitle>
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
):(
|
) : (
|
||||||
<DialogTitle id="alert-dialog-title">Save New View</DialogTitle>
|
<DialogTitle id="alert-dialog-title">Save New View</DialogTitle>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -721,12 +772,12 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
</Box>
|
</Box>
|
||||||
) : ("")}
|
) : ("")}
|
||||||
{
|
{
|
||||||
(! currentSavedView || isSaveFilterAs || isRenameFilter) && ! isDeleteFilter ? (
|
(!currentSavedView || isSaveFilterAs || isRenameFilter) && !isDeleteFilter ? (
|
||||||
<Box>
|
<Box>
|
||||||
{
|
{
|
||||||
isSaveFilterAs ? (
|
isSaveFilterAs ? (
|
||||||
<Box mb={3}>Enter a name for this new saved view.</Box>
|
<Box mb={3}>Enter a name for this new saved view.</Box>
|
||||||
):(
|
) : (
|
||||||
<Box mb={3}>Enter a new name for this saved view.</Box>
|
<Box mb={3}>Enter a new name for this saved view.</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -744,10 +795,10 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
):(
|
) : (
|
||||||
isDeleteFilter ? (
|
isDeleteFilter ? (
|
||||||
<Box>Are you sure you want to delete the view {`'${currentSavedView?.values.get("label")}'`}?</Box>
|
<Box>Are you sure you want to delete the view {`'${currentSavedView?.values.get("label")}'`}?</Box>
|
||||||
):(
|
) : (
|
||||||
<Box>Are you sure you want to update the view {`'${currentSavedView?.values.get("label")}'`}?</Box>
|
<Box>Are you sure you want to update the view {`'${currentSavedView?.values.get("label")}'`}?</Box>
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -759,7 +810,7 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
isDeleteFilter ?
|
isDeleteFilter ?
|
||||||
<QDeleteButton onClickHandler={handleFilterDialogButtonOnClick} disabled={isSubmitting} />
|
<QDeleteButton onClickHandler={handleFilterDialogButtonOnClick} disabled={isSubmitting} />
|
||||||
:
|
:
|
||||||
<QSaveButton label="Save" onClickHandler={handleFilterDialogButtonOnClick} disabled={isSaveButtonDisabled()}/>
|
<QSaveButton label="Save" onClickHandler={handleFilterDialogButtonOnClick} disabled={isSaveButtonDisabled()} />
|
||||||
}
|
}
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
66
src/qqq/components/query/AssignFilterVariable.tsx
Normal file
66
src/qqq/components/query/AssignFilterVariable.tsx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2023. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
||||||
|
import {FilterVariableExpression} from "@kingsrook/qqq-frontend-core/lib/model/query/FilterVariableExpression";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import Icon from "@mui/material/Icon";
|
||||||
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
|
import CriteriaDateField from "qqq/components/query/CriteriaDateField";
|
||||||
|
import React, {SyntheticEvent, useState} from "react";
|
||||||
|
|
||||||
|
|
||||||
|
export type Expression = FilterVariableExpression;
|
||||||
|
|
||||||
|
|
||||||
|
interface AssignFilterButtonProps
|
||||||
|
{
|
||||||
|
valueIndex: number;
|
||||||
|
field: QFieldMetaData;
|
||||||
|
valueChangeHandler: (event: React.ChangeEvent | SyntheticEvent, valueIndex?: number | "all", newValue?: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
CriteriaDateField.defaultProps = {
|
||||||
|
valueIndex: 0,
|
||||||
|
label: "Value",
|
||||||
|
idPrefix: "value-"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function AssignFilterVariable({valueIndex, field, valueChangeHandler}: AssignFilterButtonProps): JSX.Element
|
||||||
|
{
|
||||||
|
const [isValueAVariable, setIsValueAVariable] = useState(false);
|
||||||
|
|
||||||
|
const handleVariableButtonOnClick = () =>
|
||||||
|
{
|
||||||
|
setIsValueAVariable(!isValueAVariable);
|
||||||
|
const expression = new FilterVariableExpression({fieldName: field.name, valueIndex: valueIndex});
|
||||||
|
valueChangeHandler(null, valueIndex, expression);
|
||||||
|
};
|
||||||
|
|
||||||
|
return <Box display="flex" alignItems="flex-end">
|
||||||
|
<Box>
|
||||||
|
<Tooltip title={`Use a variable as the value for the ${field.label} field`} placement="bottom">
|
||||||
|
<Icon fontSize="small" color="info" sx={{mx: 0.25, cursor: "pointer", position: "relative", top: "2px"}} onClick={handleVariableButtonOnClick}>functions</Icon>
|
||||||
|
</Tooltip>
|
||||||
|
</Box>
|
||||||
|
</Box>;
|
||||||
|
}
|
||||||
|
|
@ -114,7 +114,7 @@ export function getCurrentSortIndicator(queryFilter: QQueryFilter, tableMetaData
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryControlsProps, ref) =>
|
const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryControlsProps, ref) =>
|
||||||
{
|
{
|
||||||
const {metaData, tableMetaData, savedViewsComponent, columnMenuComponent, quickFilterFieldNames, setQuickFilterFieldNames, setQueryFilter, queryFilter, gridApiRef, queryFilterJSON, mode, setMode} = props;
|
const {metaData, tableMetaData, savedViewsComponent, columnMenuComponent, quickFilterFieldNames, setQuickFilterFieldNames, setQueryFilter, queryFilter, gridApiRef, queryFilterJSON, mode, setMode, queryScreenUsage} = props;
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// state variables //
|
// state variables //
|
||||||
@ -682,6 +682,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
criteriaParam={getQuickCriteriaParam(fieldName)}
|
criteriaParam={getQuickCriteriaParam(fieldName)}
|
||||||
fieldMetaData={field}
|
fieldMetaData={field}
|
||||||
defaultOperator={defaultOperator}
|
defaultOperator={defaultOperator}
|
||||||
|
queryScreenUsage={queryScreenUsage}
|
||||||
handleRemoveQuickFilterField={null} />);
|
handleRemoveQuickFilterField={null} />);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -701,6 +702,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
criteriaParam={getQuickCriteriaParam(fieldName)}
|
criteriaParam={getQuickCriteriaParam(fieldName)}
|
||||||
fieldMetaData={field}
|
fieldMetaData={field}
|
||||||
defaultOperator={defaultOperator}
|
defaultOperator={defaultOperator}
|
||||||
|
queryScreenUsage={queryScreenUsage}
|
||||||
handleRemoveQuickFilterField={handleRemoveQuickFilterField} />);
|
handleRemoveQuickFilterField={handleRemoveQuickFilterField} />);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
||||||
import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
||||||
|
import {FilterVariableExpression} from "@kingsrook/qqq-frontend-core/lib/model/query/FilterVariableExpression";
|
||||||
import {NowExpression} from "@kingsrook/qqq-frontend-core/lib/model/query/NowExpression";
|
import {NowExpression} from "@kingsrook/qqq-frontend-core/lib/model/query/NowExpression";
|
||||||
import {NowWithOffsetExpression, NowWithOffsetOperator, NowWithOffsetUnit} from "@kingsrook/qqq-frontend-core/lib/model/query/NowWithOffsetExpression";
|
import {NowWithOffsetExpression, NowWithOffsetOperator, NowWithOffsetUnit} from "@kingsrook/qqq-frontend-core/lib/model/query/NowWithOffsetExpression";
|
||||||
import {ThisOrLastPeriodExpression, ThisOrLastPeriodOperator, ThisOrLastPeriodUnit} from "@kingsrook/qqq-frontend-core/lib/model/query/ThisOrLastPeriodExpression";
|
import {ThisOrLastPeriodExpression, ThisOrLastPeriodOperator, ThisOrLastPeriodUnit} from "@kingsrook/qqq-frontend-core/lib/model/query/ThisOrLastPeriodExpression";
|
||||||
@ -34,14 +35,14 @@ import MenuItem from "@mui/material/MenuItem";
|
|||||||
import {styled} from "@mui/material/styles";
|
import {styled} from "@mui/material/styles";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import Tooltip, {tooltipClasses, TooltipProps} from "@mui/material/Tooltip";
|
import Tooltip, {tooltipClasses, TooltipProps} from "@mui/material/Tooltip";
|
||||||
import React, {SyntheticEvent, useEffect, useReducer, useState} from "react";
|
|
||||||
import AdvancedDateTimeFilterValues from "qqq/components/query/AdvancedDateTimeFilterValues";
|
import AdvancedDateTimeFilterValues from "qqq/components/query/AdvancedDateTimeFilterValues";
|
||||||
import {QFilterCriteriaWithId} from "qqq/components/query/CustomFilterPanel";
|
import {QFilterCriteriaWithId} from "qqq/components/query/CustomFilterPanel";
|
||||||
import {EvaluatedExpression} from "qqq/components/query/EvaluatedExpression";
|
import {EvaluatedExpression} from "qqq/components/query/EvaluatedExpression";
|
||||||
import {makeTextField} from "qqq/components/query/FilterCriteriaRowValues";
|
import {makeTextField} from "qqq/components/query/FilterCriteriaRowValues";
|
||||||
|
import React, {SyntheticEvent, useReducer, useState} from "react";
|
||||||
|
|
||||||
|
|
||||||
export type Expression = NowWithOffsetExpression | ThisOrLastPeriodExpression | NowExpression;
|
export type Expression = NowWithOffsetExpression | ThisOrLastPeriodExpression | NowExpression | FilterVariableExpression;
|
||||||
|
|
||||||
|
|
||||||
interface CriteriaDateFieldProps
|
interface CriteriaDateFieldProps
|
||||||
@ -52,6 +53,7 @@ interface CriteriaDateFieldProps
|
|||||||
field: QFieldMetaData;
|
field: QFieldMetaData;
|
||||||
criteria: QFilterCriteriaWithId;
|
criteria: QFilterCriteriaWithId;
|
||||||
valueChangeHandler: (event: React.ChangeEvent | SyntheticEvent, valueIndex?: number | "all", newValue?: any) => void;
|
valueChangeHandler: (event: React.ChangeEvent | SyntheticEvent, valueIndex?: number | "all", newValue?: any) => void;
|
||||||
|
allowVariables?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
CriteriaDateField.defaultProps = {
|
CriteriaDateField.defaultProps = {
|
||||||
@ -60,19 +62,30 @@ CriteriaDateField.defaultProps = {
|
|||||||
idPrefix: "value-"
|
idPrefix: "value-"
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function CriteriaDateField({valueIndex, label, idPrefix, field, criteria, valueChangeHandler}: CriteriaDateFieldProps): JSX.Element
|
export const NoWrapTooltip = styled(({className, children, ...props}: TooltipProps) => (
|
||||||
|
<Tooltip {...props} classes={{popper: className}}>{children}</Tooltip>
|
||||||
|
))({
|
||||||
|
[`& .${tooltipClasses.tooltip}`]: {
|
||||||
|
whiteSpace: "nowrap"
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function CriteriaDateField({valueIndex, label, idPrefix, field, criteria, valueChangeHandler, allowVariables}: CriteriaDateFieldProps): JSX.Element
|
||||||
{
|
{
|
||||||
|
const [relativeDateTimeOpen, setRelativeDateTimeOpen] = useState(false);
|
||||||
const [relativeDateTimeMenuAnchorElement, setRelativeDateTimeMenuAnchorElement] = useState(null);
|
const [relativeDateTimeMenuAnchorElement, setRelativeDateTimeMenuAnchorElement] = useState(null);
|
||||||
const [forceAdvancedDateTimeDialogOpen, setForceAdvancedDateTimeDialogOpen] = useState(false)
|
const [forceAdvancedDateTimeDialogOpen, setForceAdvancedDateTimeDialogOpen] = useState(false);
|
||||||
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
||||||
|
|
||||||
const openRelativeDateTimeMenu = (event: React.MouseEvent<HTMLElement>) =>
|
const openRelativeDateTimeMenu = (event: React.MouseEvent<HTMLElement>) =>
|
||||||
{
|
{
|
||||||
|
setRelativeDateTimeOpen(true);
|
||||||
setRelativeDateTimeMenuAnchorElement(event.currentTarget);
|
setRelativeDateTimeMenuAnchorElement(event.currentTarget);
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeRelativeDateTimeMenu = () =>
|
const closeRelativeDateTimeMenu = () =>
|
||||||
{
|
{
|
||||||
|
setRelativeDateTimeOpen(false);
|
||||||
setRelativeDateTimeMenuAnchorElement(null);
|
setRelativeDateTimeMenuAnchorElement(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -137,20 +150,12 @@ export default function CriteriaDateField({valueIndex, label, idPrefix, field, c
|
|||||||
const isExpression = criteria.values && criteria.values[valueIndex] && criteria.values[valueIndex].type;
|
const isExpression = criteria.values && criteria.values[valueIndex] && criteria.values[valueIndex].type;
|
||||||
const currentExpression = isExpression ? criteria.values[valueIndex] : null;
|
const currentExpression = isExpression ? criteria.values[valueIndex] : null;
|
||||||
|
|
||||||
const NoWrapTooltip = styled(({className, children, ...props}: TooltipProps) => (
|
|
||||||
<Tooltip {...props} classes={{popper: className}}>{children}</Tooltip>
|
|
||||||
))({
|
|
||||||
[`& .${tooltipClasses.tooltip}`]: {
|
|
||||||
whiteSpace: "nowrap"
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const tooltipMenuItemFromExpression = (valueIndex: number, tooltipPlacement: "left" | "right", expression: Expression) =>
|
const tooltipMenuItemFromExpression = (valueIndex: number, tooltipPlacement: "left" | "right", expression: Expression) =>
|
||||||
{
|
{
|
||||||
let startOfPrefix = "";
|
let startOfPrefix = "";
|
||||||
if(expression.type == "ThisOrLastPeriod")
|
if (expression.type == "ThisOrLastPeriod")
|
||||||
{
|
{
|
||||||
if(field.type == QFieldType.DATE_TIME || expression.timeUnit != "DAYS")
|
if (field.type == QFieldType.DATE_TIME || expression.timeUnit != "DAYS")
|
||||||
{
|
{
|
||||||
startOfPrefix = "start of ";
|
startOfPrefix = "start of ";
|
||||||
}
|
}
|
||||||
@ -191,84 +196,120 @@ export default function CriteriaDateField({valueIndex, label, idPrefix, field, c
|
|||||||
setTimeout(() => setForceAdvancedDateTimeDialogOpen(false), 100);
|
setTimeout(() => setForceAdvancedDateTimeDialogOpen(false), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const makeFilterVariableTextField = (expression: FilterVariableExpression, valueIndex: number = 0, label = "Value", idPrefix = "value-") =>
|
||||||
|
{
|
||||||
|
const clearValue = (event: React.MouseEvent<HTMLAnchorElement> | React.MouseEvent<HTMLButtonElement>, index: number) =>
|
||||||
|
{
|
||||||
|
valueChangeHandler(event, index, "");
|
||||||
|
document.getElementById(`${idPrefix}${criteria.id}`).focus();
|
||||||
|
};
|
||||||
|
|
||||||
|
const inputProps2: any = {};
|
||||||
|
inputProps2.endAdornment = (
|
||||||
|
<InputAdornment position="end">
|
||||||
|
<IconButton sx={{visibility: expression ? "visible" : "hidden"}} onClick={(event) => clearValue(event, valueIndex)}>
|
||||||
|
<Icon>closer</Icon>
|
||||||
|
</IconButton>
|
||||||
|
</InputAdornment>
|
||||||
|
);
|
||||||
|
|
||||||
|
return <NoWrapTooltip title={<EvaluatedExpression field={field} expression={expression} />} placement="bottom" enterDelay={1000} sx={{marginLeft: "-75px !important", marginTop: "-8px !important"}}><TextField
|
||||||
|
id={`${idPrefix}${criteria.id}`}
|
||||||
|
label={label}
|
||||||
|
variant="standard"
|
||||||
|
autoComplete="off"
|
||||||
|
InputProps={{disabled: true, readOnly: true, unselectable: "off", ...inputProps2}}
|
||||||
|
InputLabelProps={{shrink: true}}
|
||||||
|
value="${VARIABLE}"
|
||||||
|
fullWidth
|
||||||
|
/></NoWrapTooltip>;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return <Box display="flex" alignItems="flex-end">
|
return <Box display="flex" alignItems="flex-end">
|
||||||
{
|
{
|
||||||
isExpression ? makeDateTimeExpressionTextField(criteria.values[valueIndex], valueIndex, label, idPrefix)
|
isExpression ?
|
||||||
: makeTextField(field, criteria, valueChangeHandler, valueIndex, label, idPrefix)
|
currentExpression?.type == "FilterVariableExpression" ? (
|
||||||
|
makeFilterVariableTextField(criteria.values[valueIndex], valueIndex, label, idPrefix)
|
||||||
|
) : (
|
||||||
|
makeDateTimeExpressionTextField(criteria.values[valueIndex], valueIndex, label, idPrefix)
|
||||||
|
)
|
||||||
|
: makeTextField(field, criteria, valueChangeHandler, valueIndex, label, idPrefix, allowVariables)
|
||||||
}
|
}
|
||||||
<Box>
|
{
|
||||||
<Tooltip title={`Choose a common relative ${field.type == QFieldType.DATE ? "date" : "date-time"} expression`} placement="bottom">
|
(!isExpression || currentExpression?.type != "FilterVariableExpression") && (
|
||||||
<Icon fontSize="small" color="info" sx={{mx: 0.25, cursor: "pointer", position: "relative", top: "2px"}} onClick={openRelativeDateTimeMenu}>date_range</Icon>
|
<><Box>
|
||||||
</Tooltip>
|
<Tooltip title={`Choose a common relative ${field.type == QFieldType.DATE ? "date" : "date-time"} expression`} placement="bottom">
|
||||||
<Menu
|
<Icon fontSize="small" color="info" sx={{mx: 0.25, cursor: "pointer", position: "relative", top: "2px"}} onClick={openRelativeDateTimeMenu}>date_range</Icon>
|
||||||
open={relativeDateTimeMenuAnchorElement}
|
</Tooltip>
|
||||||
anchorEl={relativeDateTimeMenuAnchorElement}
|
<Menu
|
||||||
transformOrigin={{horizontal: "left", vertical: "top"}}
|
open={relativeDateTimeOpen}
|
||||||
onClose={closeRelativeDateTimeMenu}
|
anchorEl={relativeDateTimeMenuAnchorElement}
|
||||||
>
|
transformOrigin={{horizontal: "left", vertical: "top"}}
|
||||||
{
|
onClose={closeRelativeDateTimeMenu}
|
||||||
field.type == QFieldType.DATE ?
|
>
|
||||||
<Box display="flex">
|
{field.type == QFieldType.DATE ?
|
||||||
<Box>
|
<Box display="flex">
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 7, "DAYS"))}
|
<Box>
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 14, "DAYS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 7, "DAYS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 30, "DAYS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 14, "DAYS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 90, "DAYS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 30, "DAYS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 180, "DAYS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 90, "DAYS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 1, "YEARS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 180, "DAYS"))}
|
||||||
<Divider />
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 1, "YEARS"))}
|
||||||
<Tooltip title="Define a custom expression" placement="left">
|
<Divider />
|
||||||
<MenuItem onClick={doForceAdvancedDateTimeDialogOpen}>Custom</MenuItem>
|
<Tooltip title="Define a custom expression" placement="left">
|
||||||
</Tooltip>
|
<MenuItem onClick={doForceAdvancedDateTimeDialogOpen}>Custom</MenuItem>
|
||||||
|
</Tooltip>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "DAYS"))}
|
||||||
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "DAYS"))}
|
||||||
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "WEEKS"))}
|
||||||
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "WEEKS"))}
|
||||||
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "MONTHS"))}
|
||||||
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "MONTHS"))}
|
||||||
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "YEARS"))}
|
||||||
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "YEARS"))}
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
:
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "DAYS"))}
|
<Box display="flex">
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "DAYS"))}
|
<Box>
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "WEEKS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 1, "HOURS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "WEEKS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 12, "HOURS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "MONTHS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 24, "HOURS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "MONTHS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 7, "DAYS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "YEARS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 14, "DAYS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "YEARS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 30, "DAYS"))}
|
||||||
</Box>
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 90, "DAYS"))}
|
||||||
</Box>
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 180, "DAYS"))}
|
||||||
:
|
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 1, "YEARS"))}
|
||||||
<Box display="flex">
|
<Divider />
|
||||||
<Box>
|
<Tooltip title="Define a custom expression" placement="left">
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 1, "HOURS"))}
|
<MenuItem onClick={doForceAdvancedDateTimeDialogOpen}>Custom</MenuItem>
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 12, "HOURS"))}
|
</Tooltip>
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 24, "HOURS"))}
|
</Box>
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 7, "DAYS"))}
|
<Box>
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 14, "DAYS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "right", newNowExpression())}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 30, "DAYS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "HOURS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 90, "DAYS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "HOURS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 180, "DAYS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "DAYS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "left", newNowWithOffsetExpression("MINUS", 1, "YEARS"))}
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "DAYS"))}
|
||||||
<Divider />
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "WEEKS"))}
|
||||||
<Tooltip title="Define a custom expression" placement="left">
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "WEEKS"))}
|
||||||
<MenuItem onClick={doForceAdvancedDateTimeDialogOpen}>Custom</MenuItem>
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "MONTHS"))}
|
||||||
</Tooltip>
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "MONTHS"))}
|
||||||
</Box>
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "YEARS"))}
|
||||||
<Box>
|
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "YEARS"))}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newNowExpression())}
|
</Box>
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "HOURS"))}
|
</Box>}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "HOURS"))}
|
</Menu>
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "DAYS"))}
|
</Box><Box>
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "DAYS"))}
|
<AdvancedDateTimeFilterValues type={field.type} expression={currentExpression} onSave={(expression: any) => saveNewDateTimeExpression(valueIndex, expression)} forcedOpen={forceAdvancedDateTimeDialogOpen} />
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "WEEKS"))}
|
</Box></>
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "WEEKS"))}
|
)
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "MONTHS"))}
|
}
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "MONTHS"))}
|
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("THIS", "YEARS"))}
|
|
||||||
{tooltipMenuItemFromExpression(valueIndex, "right", newThisOrLastPeriodExpression("LAST", "YEARS"))}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
}
|
|
||||||
</Menu>
|
|
||||||
</Box>
|
|
||||||
<Box>
|
|
||||||
<AdvancedDateTimeFilterValues type={field.type} expression={currentExpression} onSave={(expression: any) => saveNewDateTimeExpression(valueIndex, expression)} forcedOpen={forceAdvancedDateTimeDialogOpen} />
|
|
||||||
</Box>
|
|
||||||
</Box>;
|
</Box>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
import {QInstance} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QInstance";
|
import {QInstance} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QInstance";
|
||||||
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
||||||
import {Box, FormControlLabel, FormGroup} from "@mui/material";
|
|
||||||
|
import {FormControlLabel, FormGroup} from "@mui/material";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Icon from "@mui/material/Icon";
|
import Icon from "@mui/material/Icon";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
@ -56,7 +58,7 @@ export const CustomColumnsPanel = forwardRef<any, GridColumnsPanelProps>(
|
|||||||
const someRef = createRef();
|
const someRef = createRef();
|
||||||
|
|
||||||
const textRef = useRef(null);
|
const textRef = useRef(null);
|
||||||
const [didInitialFocus, setDidInitialFocus] = useState(false)
|
const [didInitialFocus, setDidInitialFocus] = useState(false);
|
||||||
|
|
||||||
const [openGroups, setOpenGroups] = useState(props.initialOpenedGroups || {});
|
const [openGroups, setOpenGroups] = useState(props.initialOpenedGroups || {});
|
||||||
const openGroupsBecauseOfFilter = {} as { [name: string]: boolean };
|
const openGroupsBecauseOfFilter = {} as { [name: string]: boolean };
|
||||||
@ -71,9 +73,9 @@ export const CustomColumnsPanel = forwardRef<any, GridColumnsPanelProps>(
|
|||||||
|
|
||||||
console.log(`Open groups: ${JSON.stringify(openGroups)}`);
|
console.log(`Open groups: ${JSON.stringify(openGroups)}`);
|
||||||
|
|
||||||
if(!didInitialFocus)
|
if (!didInitialFocus)
|
||||||
{
|
{
|
||||||
if(textRef.current)
|
if (textRef.current)
|
||||||
{
|
{
|
||||||
textRef.current.select();
|
textRef.current.select();
|
||||||
setDidInitialFocus(true);
|
setDidInitialFocus(true);
|
||||||
@ -189,11 +191,11 @@ export const CustomColumnsPanel = forwardRef<any, GridColumnsPanelProps>(
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// always sort columns by label. note, in future may offer different sorts - here's where to do it. //
|
// always sort columns by label. note, in future may offer different sorts - here's where to do it. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
const sortedColumns = [... columns];
|
const sortedColumns = [...columns];
|
||||||
sortedColumns.sort((a, b): number =>
|
sortedColumns.sort((a, b): number =>
|
||||||
{
|
{
|
||||||
return a.headerName.localeCompare(b.headerName);
|
return a.headerName.localeCompare(b.headerName);
|
||||||
})
|
});
|
||||||
|
|
||||||
for (let i = 0; i < sortedColumns.length; i++)
|
for (let i = 0; i < sortedColumns.length; i++)
|
||||||
{
|
{
|
||||||
@ -361,7 +363,7 @@ export const CustomColumnsPanel = forwardRef<any, GridColumnsPanelProps>(
|
|||||||
const changeFilterText = (newValue: string) =>
|
const changeFilterText = (newValue: string) =>
|
||||||
{
|
{
|
||||||
setFilterText(newValue);
|
setFilterText(newValue);
|
||||||
props.filterTextChanger(newValue)
|
props.filterTextChanger(newValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterTextChanged = (event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) =>
|
const filterTextChanged = (event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) =>
|
||||||
|
@ -28,8 +28,8 @@ import Box from "@mui/material/Box";
|
|||||||
import Button from "@mui/material/Button/Button";
|
import Button from "@mui/material/Button/Button";
|
||||||
import Icon from "@mui/material/Icon/Icon";
|
import Icon from "@mui/material/Icon/Icon";
|
||||||
import {GridFilterPanelProps, GridSlotsComponentsProps} from "@mui/x-data-grid-pro";
|
import {GridFilterPanelProps, GridSlotsComponentsProps} from "@mui/x-data-grid-pro";
|
||||||
import React, {forwardRef, useReducer} from "react";
|
|
||||||
import {FilterCriteriaRow, getDefaultCriteriaValue} from "qqq/components/query/FilterCriteriaRow";
|
import {FilterCriteriaRow, getDefaultCriteriaValue} from "qqq/components/query/FilterCriteriaRow";
|
||||||
|
import React, {forwardRef, useReducer} from "react";
|
||||||
|
|
||||||
|
|
||||||
declare module "@mui/x-data-grid"
|
declare module "@mui/x-data-grid"
|
||||||
@ -49,7 +49,7 @@ declare module "@mui/x-data-grid"
|
|||||||
|
|
||||||
export class QFilterCriteriaWithId extends QFilterCriteria
|
export class QFilterCriteriaWithId extends QFilterCriteria
|
||||||
{
|
{
|
||||||
id: number
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -62,6 +62,7 @@ export const CustomFilterPanel = forwardRef<any, GridFilterPanelProps>(
|
|||||||
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
||||||
|
|
||||||
const queryFilter = props.queryFilter;
|
const queryFilter = props.queryFilter;
|
||||||
|
|
||||||
// console.log(`CustomFilterPanel: filter: ${JSON.stringify(queryFilter)}`);
|
// console.log(`CustomFilterPanel: filter: ${JSON.stringify(queryFilter)}`);
|
||||||
|
|
||||||
function focusLastField()
|
function focusLastField()
|
||||||
@ -124,7 +125,7 @@ export const CustomFilterPanel = forwardRef<any, GridFilterPanelProps>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(queryFilter.criteria.length == 1 && !queryFilter.criteria[0].fieldName)
|
if (queryFilter.criteria.length == 1 && !queryFilter.criteria[0].fieldName)
|
||||||
{
|
{
|
||||||
focusLastField();
|
focusLastField();
|
||||||
}
|
}
|
||||||
@ -142,7 +143,7 @@ export const CustomFilterPanel = forwardRef<any, GridFilterPanelProps>(
|
|||||||
{
|
{
|
||||||
queryFilter.criteria[index] = newCriteria;
|
queryFilter.criteria[index] = newCriteria;
|
||||||
|
|
||||||
clearTimeout(debounceTimeout)
|
clearTimeout(debounceTimeout);
|
||||||
debounceTimeout = setTimeout(() => props.updateFilter(queryFilter), needDebounce ? 500 : 1);
|
debounceTimeout = setTimeout(() => props.updateFilter(queryFilter), needDebounce ? 500 : 1);
|
||||||
|
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
@ -178,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)}
|
||||||
|
queryScreenUsage={props.queryScreenUsage}
|
||||||
/>
|
/>
|
||||||
{/*JSON.stringify(criteria)*/}
|
{/*JSON.stringify(criteria)*/}
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -21,9 +21,9 @@
|
|||||||
|
|
||||||
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
||||||
import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
||||||
import React, {useEffect, useState} from "react";
|
|
||||||
import {Expression} from "qqq/components/query/CriteriaDateField";
|
import {Expression} from "qqq/components/query/CriteriaDateField";
|
||||||
import ValueUtils from "qqq/utils/qqq/ValueUtils";
|
import ValueUtils from "qqq/utils/qqq/ValueUtils";
|
||||||
|
import React, {useEffect, useState} from "react";
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Helper component to show value inside tooltips that ticks up every second.
|
** Helper component to show value inside tooltips that ticks up every second.
|
||||||
@ -57,6 +57,11 @@ const HOUR_MS = 60 * 60 * 1000;
|
|||||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
||||||
const evaluateExpression = (time: Date, field: QFieldMetaData, expression: Expression): string =>
|
const evaluateExpression = (time: Date, field: QFieldMetaData, expression: Expression): string =>
|
||||||
{
|
{
|
||||||
|
if (expression.type == "FilterVariableExpression")
|
||||||
|
{
|
||||||
|
return (expression.toString());
|
||||||
|
}
|
||||||
|
|
||||||
let rs: Date = null;
|
let rs: Date = null;
|
||||||
if (expression.type == "NowWithOffset")
|
if (expression.type == "NowWithOffset")
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,7 @@ import TextField from "@mui/material/TextField";
|
|||||||
import Tooltip from "@mui/material/Tooltip";
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
import FieldAutoComplete from "qqq/components/misc/FieldAutoComplete";
|
import FieldAutoComplete from "qqq/components/misc/FieldAutoComplete";
|
||||||
import FilterCriteriaRowValues from "qqq/components/query/FilterCriteriaRowValues";
|
import FilterCriteriaRowValues from "qqq/components/query/FilterCriteriaRowValues";
|
||||||
|
import {QueryScreenUsage} from "qqq/pages/records/query/RecordQuery";
|
||||||
import FilterUtils from "qqq/utils/qqq/FilterUtils";
|
import FilterUtils from "qqq/utils/qqq/FilterUtils";
|
||||||
import React, {ReactNode, SyntheticEvent, useState} from "react";
|
import React, {ReactNode, SyntheticEvent, useState} from "react";
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ export const getValueModeRequiredCount = (valueMode: ValueMode): number =>
|
|||||||
case ValueMode.PVS_MULTI:
|
case ValueMode.PVS_MULTI:
|
||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
export interface OperatorOption
|
export interface OperatorOption
|
||||||
{
|
{
|
||||||
@ -183,7 +184,7 @@ export const getOperatorOptions = (tableMetaData: QTableMetaData, fieldName: str
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (operatorOptions);
|
return (operatorOptions);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
interface FilterCriteriaRowProps
|
interface FilterCriteriaRowProps
|
||||||
@ -197,13 +198,13 @@ interface FilterCriteriaRowProps
|
|||||||
updateCriteria: (newCriteria: QFilterCriteria, needDebounce: boolean) => void;
|
updateCriteria: (newCriteria: QFilterCriteria, needDebounce: boolean) => void;
|
||||||
removeCriteria: () => void;
|
removeCriteria: () => void;
|
||||||
updateBooleanOperator: (newValue: string) => void;
|
updateBooleanOperator: (newValue: string) => void;
|
||||||
|
queryScreenUsage?: QueryScreenUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterCriteriaRow.defaultProps =
|
FilterCriteriaRow.defaultProps =
|
||||||
{
|
{};
|
||||||
};
|
|
||||||
|
|
||||||
export function validateCriteria(criteria: QFilterCriteria, operatorSelectedValue?: OperatorOption): {criteriaIsValid: boolean, criteriaStatusTooltip: string}
|
export function validateCriteria(criteria: QFilterCriteria, operatorSelectedValue?: OperatorOption): { criteriaIsValid: boolean, criteriaStatusTooltip: string }
|
||||||
{
|
{
|
||||||
let criteriaIsValid = true;
|
let criteriaIsValid = true;
|
||||||
let criteriaStatusTooltip = "This condition is fully defined and is part of your filter.";
|
let criteriaStatusTooltip = "This condition is fully defined and is part of your filter.";
|
||||||
@ -213,7 +214,7 @@ export function validateCriteria(criteria: QFilterCriteria, operatorSelectedValu
|
|||||||
return (value === null || value == undefined || String(value).trim() === "");
|
return (value === null || value == undefined || String(value).trim() === "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!criteria)
|
if (!criteria)
|
||||||
{
|
{
|
||||||
criteriaIsValid = false;
|
criteriaIsValid = false;
|
||||||
criteriaStatusTooltip = "This condition is not defined.";
|
criteriaStatusTooltip = "This condition is not defined.";
|
||||||
@ -266,7 +267,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}: FilterCriteriaRowProps): JSX.Element
|
export function FilterCriteriaRow({id, index, tableMetaData, metaData, criteria, booleanOperator, updateCriteria, removeCriteria, updateBooleanOperator, queryScreenUsage}: 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);
|
||||||
@ -284,7 +285,7 @@ export function FilterCriteriaRow({id, index, tableMetaData, metaData, criteria,
|
|||||||
let defaultFieldValue;
|
let defaultFieldValue;
|
||||||
let field = null;
|
let field = null;
|
||||||
let fieldTable = null;
|
let fieldTable = null;
|
||||||
if(criteria && criteria.fieldName)
|
if (criteria && criteria.fieldName)
|
||||||
{
|
{
|
||||||
[field, fieldTable] = FilterUtils.getField(tableMetaData, criteria.fieldName);
|
[field, fieldTable] = FilterUtils.getField(tableMetaData, criteria.fieldName);
|
||||||
if (field && fieldTable)
|
if (field && fieldTable)
|
||||||
@ -303,9 +304,9 @@ export function FilterCriteriaRow({id, index, tableMetaData, metaData, criteria,
|
|||||||
|
|
||||||
let newOperatorSelectedValue = operatorOptions.filter(option =>
|
let newOperatorSelectedValue = operatorOptions.filter(option =>
|
||||||
{
|
{
|
||||||
if(option.value == criteria.operator)
|
if (option.value == criteria.operator)
|
||||||
{
|
{
|
||||||
if(option.implicitValues)
|
if (option.implicitValues)
|
||||||
{
|
{
|
||||||
return (JSON.stringify(option.implicitValues) == JSON.stringify(criteria.values));
|
return (JSON.stringify(option.implicitValues) == JSON.stringify(criteria.values));
|
||||||
}
|
}
|
||||||
@ -316,7 +317,7 @@ export function FilterCriteriaRow({id, index, tableMetaData, metaData, criteria,
|
|||||||
}
|
}
|
||||||
return (false);
|
return (false);
|
||||||
})[0];
|
})[0];
|
||||||
if(newOperatorSelectedValue?.label !== operatorSelectedValue?.label)
|
if (newOperatorSelectedValue?.label !== operatorSelectedValue?.label)
|
||||||
{
|
{
|
||||||
setOperatorSelectedValue(newOperatorSelectedValue);
|
setOperatorSelectedValue(newOperatorSelectedValue);
|
||||||
setOperatorInputValue(newOperatorSelectedValue?.label);
|
setOperatorInputValue(newOperatorSelectedValue?.label);
|
||||||
@ -379,12 +380,12 @@ export function FilterCriteriaRow({id, index, tableMetaData, metaData, criteria,
|
|||||||
{
|
{
|
||||||
criteria.operator = newValue ? newValue.value : null;
|
criteria.operator = newValue ? newValue.value : null;
|
||||||
|
|
||||||
if(newValue)
|
if (newValue)
|
||||||
{
|
{
|
||||||
setOperatorSelectedValue(newValue);
|
setOperatorSelectedValue(newValue);
|
||||||
setOperatorInputValue(newValue.label);
|
setOperatorInputValue(newValue.label);
|
||||||
|
|
||||||
if(newValue.implicitValues)
|
if (newValue.implicitValues)
|
||||||
{
|
{
|
||||||
criteria.values = newValue.implicitValues;
|
criteria.values = newValue.implicitValues;
|
||||||
}
|
}
|
||||||
@ -393,15 +394,15 @@ export function FilterCriteriaRow({id, index, tableMetaData, metaData, criteria,
|
|||||||
// we've seen cases where switching operators can sometimes put a null in as the first value... //
|
// we've seen cases where switching operators can sometimes put a null in as the first value... //
|
||||||
// that just causes a bad time (e.g., null pointers in Autocomplete), so, get rid of that. //
|
// that just causes a bad time (e.g., null pointers in Autocomplete), so, get rid of that. //
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if(criteria.values && criteria.values.length == 1 && criteria.values[0] == null)
|
if (criteria.values && criteria.values.length == 1 && criteria.values[0] == null)
|
||||||
{
|
{
|
||||||
criteria.values = [];
|
criteria.values = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newValue.valueMode && !newValue.implicitValues)
|
if (newValue.valueMode && !newValue.implicitValues)
|
||||||
{
|
{
|
||||||
const requiredValueCount = getValueModeRequiredCount(newValue.valueMode);
|
const requiredValueCount = getValueModeRequiredCount(newValue.valueMode);
|
||||||
if(requiredValueCount != null && criteria.values.length > requiredValueCount)
|
if (requiredValueCount != null && criteria.values.length > requiredValueCount)
|
||||||
{
|
{
|
||||||
criteria.values.splice(requiredValueCount);
|
criteria.values.splice(requiredValueCount);
|
||||||
}
|
}
|
||||||
@ -424,12 +425,12 @@ export function FilterCriteriaRow({id, index, tableMetaData, metaData, criteria,
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const value = newValue !== undefined ? newValue : event ? event.target.value : null;
|
const value = newValue !== undefined ? newValue : event ? event.target.value : null;
|
||||||
|
|
||||||
if(!criteria.values)
|
if (!criteria.values)
|
||||||
{
|
{
|
||||||
criteria.values = [];
|
criteria.values = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(valueIndex == "all")
|
if (valueIndex == "all")
|
||||||
{
|
{
|
||||||
criteria.values = value;
|
criteria.values = value;
|
||||||
}
|
}
|
||||||
@ -514,6 +515,7 @@ export function FilterCriteriaRow({id, index, tableMetaData, metaData, criteria,
|
|||||||
field={field}
|
field={field}
|
||||||
table={fieldTable}
|
table={fieldTable}
|
||||||
valueChangeHandler={(event, valueIndex, newValue) => handleValueChange(event, valueIndex, newValue)}
|
valueChangeHandler={(event, valueIndex, newValue) => handleValueChange(event, valueIndex, newValue)}
|
||||||
|
queryScreenUsage={queryScreenUsage}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box display="inline-block">
|
<Box display="inline-block">
|
||||||
|
@ -23,19 +23,23 @@
|
|||||||
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
||||||
import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
||||||
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
||||||
|
import {FilterVariableExpression} from "@kingsrook/qqq-frontend-core/lib/model/query/FilterVariableExpression";
|
||||||
import Autocomplete from "@mui/material/Autocomplete";
|
import Autocomplete from "@mui/material/Autocomplete";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Icon from "@mui/material/Icon";
|
import Icon from "@mui/material/Icon";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import InputAdornment from "@mui/material/InputAdornment/InputAdornment";
|
import InputAdornment from "@mui/material/InputAdornment/InputAdornment";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import React, {SyntheticEvent, useReducer} from "react";
|
|
||||||
import DynamicSelect from "qqq/components/forms/DynamicSelect";
|
import DynamicSelect from "qqq/components/forms/DynamicSelect";
|
||||||
import CriteriaDateField from "qqq/components/query/CriteriaDateField";
|
import AssignFilterVariable from "qqq/components/query/AssignFilterVariable";
|
||||||
|
import CriteriaDateField, {NoWrapTooltip} from "qqq/components/query/CriteriaDateField";
|
||||||
import {QFilterCriteriaWithId} from "qqq/components/query/CustomFilterPanel";
|
import {QFilterCriteriaWithId} from "qqq/components/query/CustomFilterPanel";
|
||||||
|
import {EvaluatedExpression} from "qqq/components/query/EvaluatedExpression";
|
||||||
import FilterCriteriaPaster from "qqq/components/query/FilterCriteriaPaster";
|
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 ValueUtils from "qqq/utils/qqq/ValueUtils";
|
import ValueUtils from "qqq/utils/qqq/ValueUtils";
|
||||||
|
import React, {SyntheticEvent, useReducer, useState} from "react";
|
||||||
|
|
||||||
interface Props
|
interface Props
|
||||||
{
|
{
|
||||||
@ -44,7 +48,8 @@ interface Props
|
|||||||
field: QFieldMetaData;
|
field: QFieldMetaData;
|
||||||
table: QTableMetaData;
|
table: QTableMetaData;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterCriteriaRowValues.defaultProps =
|
FilterCriteriaRowValues.defaultProps =
|
||||||
@ -72,8 +77,10 @@ export const getTypeForTextField = (field: QFieldMetaData): string =>
|
|||||||
return (type);
|
return (type);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const makeTextField = (field: QFieldMetaData, criteria: QFilterCriteriaWithId, valueChangeHandler?: (event: (React.ChangeEvent | React.SyntheticEvent), valueIndex?: (number | "all"), newValue?: any) => void, valueIndex: number = 0, label = "Value", idPrefix = "value-") =>
|
export const makeTextField = (field: QFieldMetaData, criteria: QFilterCriteriaWithId, valueChangeHandler?: (event: (React.ChangeEvent | React.SyntheticEvent), valueIndex?: (number | "all"), newValue?: any) => void, valueIndex: number = 0, label = "Value", idPrefix = "value-", allowVariables = false) =>
|
||||||
{
|
{
|
||||||
|
const isExpression = criteria.values && criteria.values[valueIndex] && criteria.values[valueIndex].type;
|
||||||
|
|
||||||
let type = getTypeForTextField(field);
|
let type = getTypeForTextField(field);
|
||||||
const inputLabelProps: any = {};
|
const inputLabelProps: any = {};
|
||||||
|
|
||||||
@ -95,7 +102,6 @@ export const makeTextField = (field: QFieldMetaData, criteria: QFilterCriteriaWi
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Event handler for key-down events - specifically added here, to stop pressing
|
** Event handler for key-down events - specifically added here, to stop pressing
|
||||||
** 'tab' in a date or date-time from closing the quick-filter...
|
** 'tab' in a date or date-time from closing the quick-filter...
|
||||||
@ -104,7 +110,7 @@ export const makeTextField = (field: QFieldMetaData, criteria: QFilterCriteriaWi
|
|||||||
{
|
{
|
||||||
if (field.type == QFieldType.DATE || field.type == QFieldType.DATE_TIME)
|
if (field.type == QFieldType.DATE || field.type == QFieldType.DATE_TIME)
|
||||||
{
|
{
|
||||||
if(e.code == "Tab")
|
if (e.code == "Tab")
|
||||||
{
|
{
|
||||||
console.log("Tab on date or date-time - don't close me, just move to the next sub-field!...");
|
console.log("Tab on date or date-time - don't close me, just move to the next sub-field!...");
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@ -112,6 +118,36 @@ export const makeTextField = (field: QFieldMetaData, criteria: QFilterCriteriaWi
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const makeFilterVariableTextField = (expression: FilterVariableExpression, valueIndex: number = 0, label = "Value", idPrefix = "value-") =>
|
||||||
|
{
|
||||||
|
const clearValue = (event: React.MouseEvent<HTMLAnchorElement> | React.MouseEvent<HTMLButtonElement>, index: number) =>
|
||||||
|
{
|
||||||
|
valueChangeHandler(event, index, "");
|
||||||
|
document.getElementById(`${idPrefix}${criteria.id}`).focus();
|
||||||
|
};
|
||||||
|
|
||||||
|
const inputProps2: any = {};
|
||||||
|
inputProps2.endAdornment = (
|
||||||
|
<InputAdornment position="end">
|
||||||
|
<IconButton sx={{visibility: expression ? "visible" : "hidden"}} onClick={(event) => clearValue(event, valueIndex)}>
|
||||||
|
<Icon>closer</Icon>
|
||||||
|
</IconButton>
|
||||||
|
</InputAdornment>
|
||||||
|
);
|
||||||
|
|
||||||
|
return <NoWrapTooltip title={<EvaluatedExpression field={field} expression={expression} />} placement="bottom" enterDelay={1000} sx={{marginLeft: "-75px !important", marginTop: "-8px !important"}}><TextField
|
||||||
|
id={`${idPrefix}${criteria.id}`}
|
||||||
|
label={label}
|
||||||
|
variant="standard"
|
||||||
|
autoComplete="off"
|
||||||
|
InputProps={{disabled: true, readOnly: true, unselectable: "off", ...inputProps2}}
|
||||||
|
InputLabelProps={{shrink: true}}
|
||||||
|
value="${VARIABLE}"
|
||||||
|
fullWidth
|
||||||
|
/></NoWrapTooltip>;
|
||||||
|
};
|
||||||
|
|
||||||
const inputProps: any = {};
|
const inputProps: any = {};
|
||||||
inputProps.endAdornment = (
|
inputProps.endAdornment = (
|
||||||
<InputAdornment position="end">
|
<InputAdornment position="end">
|
||||||
@ -121,25 +157,40 @@ export const makeTextField = (field: QFieldMetaData, criteria: QFilterCriteriaWi
|
|||||||
</InputAdornment>
|
</InputAdornment>
|
||||||
);
|
);
|
||||||
|
|
||||||
return <TextField
|
return <Box sx={{margin: 0, padding: 0, display: "flex"}}>
|
||||||
id={`${idPrefix}${criteria.id}`}
|
{
|
||||||
label={label}
|
isExpression ? (
|
||||||
variant="standard"
|
makeFilterVariableTextField(criteria.values[valueIndex], valueIndex, label, idPrefix)
|
||||||
autoComplete="off"
|
) : (
|
||||||
type={type}
|
<TextField
|
||||||
onChange={(event) => valueChangeHandler(event, valueIndex)}
|
id={`${idPrefix}${criteria.id}`}
|
||||||
onKeyDown={handleKeyDown}
|
label={label}
|
||||||
value={value}
|
variant="standard"
|
||||||
InputLabelProps={inputLabelProps}
|
autoComplete="off"
|
||||||
InputProps={inputProps}
|
type={type}
|
||||||
fullWidth
|
onChange={(event) => valueChangeHandler(event, valueIndex)}
|
||||||
autoFocus={true}
|
onKeyDown={handleKeyDown}
|
||||||
/>;
|
value={value}
|
||||||
|
InputLabelProps={inputLabelProps}
|
||||||
|
InputProps={inputProps}
|
||||||
|
fullWidth
|
||||||
|
autoFocus={true}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
allowVariables && (
|
||||||
|
<AssignFilterVariable field={field} valueChangeHandler={valueChangeHandler} valueIndex={valueIndex} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</Box>;
|
||||||
};
|
};
|
||||||
|
|
||||||
function FilterCriteriaRowValues({operatorOption, criteria, field, table, valueChangeHandler, initiallyOpenMultiValuePvs}: Props): JSX.Element
|
|
||||||
|
function FilterCriteriaRowValues({operatorOption, criteria, field, table, valueChangeHandler, initiallyOpenMultiValuePvs, queryScreenUsage}: 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)
|
||||||
{
|
{
|
||||||
@ -169,33 +220,35 @@ function FilterCriteriaRowValues({operatorOption, criteria, field, table, valueC
|
|||||||
forceUpdate();
|
forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isExpression = criteria.values && criteria.values[0] && criteria.values[0].type;
|
||||||
|
|
||||||
switch (operatorOption.valueMode)
|
switch (operatorOption.valueMode)
|
||||||
{
|
{
|
||||||
case ValueMode.NONE:
|
case ValueMode.NONE:
|
||||||
return null;
|
return null;
|
||||||
case ValueMode.SINGLE:
|
case ValueMode.SINGLE:
|
||||||
return makeTextField(field, criteria, valueChangeHandler);
|
return makeTextField(field, criteria, valueChangeHandler, 0, undefined, undefined, allowVariables);
|
||||||
case ValueMode.SINGLE_DATE:
|
case ValueMode.SINGLE_DATE:
|
||||||
return <CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} />;
|
return <CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} allowVariables={allowVariables} />;
|
||||||
case ValueMode.DOUBLE_DATE:
|
case ValueMode.DOUBLE_DATE:
|
||||||
return <Box>
|
return <Box>
|
||||||
<CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} valueIndex={0} label="From" idPrefix="from-" />
|
<CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} valueIndex={0} label="From" idPrefix="from-" allowVariables={allowVariables} />
|
||||||
<CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} valueIndex={1} label="To" idPrefix="to-" />
|
<CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} valueIndex={1} label="To" idPrefix="to-" allowVariables={allowVariables} />
|
||||||
</Box>;
|
</Box>;
|
||||||
case ValueMode.SINGLE_DATE_TIME:
|
case ValueMode.SINGLE_DATE_TIME:
|
||||||
return <CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} />;
|
return <CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} allowVariables={allowVariables} />;
|
||||||
case ValueMode.DOUBLE_DATE_TIME:
|
case ValueMode.DOUBLE_DATE_TIME:
|
||||||
return <Box>
|
return <Box>
|
||||||
<CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} valueIndex={0} label="From" idPrefix="from-" />
|
<CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} valueIndex={0} label="From" idPrefix="from-" allowVariables={allowVariables} />
|
||||||
<CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} valueIndex={1} label="To" idPrefix="to-" />
|
<CriteriaDateField field={field} valueChangeHandler={valueChangeHandler} criteria={criteria} valueIndex={1} label="To" idPrefix="to-" allowVariables={allowVariables} />
|
||||||
</Box>;
|
</Box>;
|
||||||
case ValueMode.DOUBLE:
|
case ValueMode.DOUBLE:
|
||||||
return <Box>
|
return <Box>
|
||||||
<Box width="50%" display="inline-block">
|
<Box width="50%" display="inline-block">
|
||||||
{makeTextField(field, criteria, valueChangeHandler, 0, "From", "from-")}
|
{makeTextField(field, criteria, valueChangeHandler, 0, "From", "from-", allowVariables)}
|
||||||
</Box>
|
</Box>
|
||||||
<Box width="50%" display="inline-block">
|
<Box width="50%" display="inline-block">
|
||||||
{makeTextField(field, criteria, valueChangeHandler, 1, "To", "to-")}
|
{makeTextField(field, criteria, valueChangeHandler, 1, "To", "to-", allowVariables)}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>;
|
</Box>;
|
||||||
case ValueMode.MULTI:
|
case ValueMode.MULTI:
|
||||||
@ -228,19 +281,30 @@ function FilterCriteriaRowValues({operatorOption, criteria, field, table, valueC
|
|||||||
{
|
{
|
||||||
selectedPossibleValue = criteria.values[0];
|
selectedPossibleValue = criteria.values[0];
|
||||||
}
|
}
|
||||||
return <Box mb={-1.5}>
|
return <Box display="flex">
|
||||||
<DynamicSelect
|
{
|
||||||
tableName={table.name}
|
isExpression ? (
|
||||||
fieldName={field.name}
|
makeTextField(field, criteria, valueChangeHandler, 0, undefined, undefined, allowVariables)
|
||||||
overrideId={field.name + "-single-" + criteria.id}
|
) : (
|
||||||
key={field.name + "-single-" + criteria.id}
|
<Box width={"100%"}>
|
||||||
fieldLabel="Value"
|
<DynamicSelect
|
||||||
initialValue={selectedPossibleValue?.id}
|
tableName={table.name}
|
||||||
initialDisplayValue={selectedPossibleValue?.label}
|
fieldName={field.name}
|
||||||
inForm={false}
|
overrideId={field.name + "-single-" + criteria.id}
|
||||||
onChange={(value: any) => valueChangeHandler(null, 0, value)}
|
key={field.name + "-single-" + criteria.id}
|
||||||
variant="standard"
|
fieldLabel="Value"
|
||||||
/>
|
initialValue={selectedPossibleValue?.id}
|
||||||
|
initialDisplayValue={selectedPossibleValue?.label}
|
||||||
|
inForm={false}
|
||||||
|
onChange={(value: any) => valueChangeHandler(null, 0, value)}
|
||||||
|
variant="standard"
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
allowVariables && !isExpression && <Box mt={2.0}><AssignFilterVariable field={field} valueChangeHandler={valueChangeHandler} valueIndex={0} /></Box>
|
||||||
|
}
|
||||||
</Box>;
|
</Box>;
|
||||||
case ValueMode.PVS_MULTI:
|
case ValueMode.PVS_MULTI:
|
||||||
console.log("Doing pvs multi: " + criteria.values);
|
console.log("Doing pvs multi: " + criteria.values);
|
||||||
@ -276,4 +340,4 @@ function FilterCriteriaRowValues({operatorOption, criteria, field, table, valueC
|
|||||||
return (<br />);
|
return (<br />);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FilterCriteriaRowValues;
|
export default FilterCriteriaRowValues;
|
||||||
|
@ -30,14 +30,15 @@ import Box from "@mui/material/Box";
|
|||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Menu from "@mui/material/Menu";
|
import Menu from "@mui/material/Menu";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import React, {SyntheticEvent, useContext, useReducer, useState} from "react";
|
|
||||||
import QContext from "QContext";
|
import QContext from "QContext";
|
||||||
import {QFilterCriteriaWithId} from "qqq/components/query/CustomFilterPanel";
|
import {QFilterCriteriaWithId} from "qqq/components/query/CustomFilterPanel";
|
||||||
import {getDefaultCriteriaValue, getOperatorOptions, getValueModeRequiredCount, OperatorOption, validateCriteria} from "qqq/components/query/FilterCriteriaRow";
|
import {getDefaultCriteriaValue, getOperatorOptions, getValueModeRequiredCount, OperatorOption, validateCriteria} from "qqq/components/query/FilterCriteriaRow";
|
||||||
import FilterCriteriaRowValues from "qqq/components/query/FilterCriteriaRowValues";
|
import FilterCriteriaRowValues from "qqq/components/query/FilterCriteriaRowValues";
|
||||||
import XIcon from "qqq/components/query/XIcon";
|
import XIcon from "qqq/components/query/XIcon";
|
||||||
|
import {QueryScreenUsage} from "qqq/pages/records/query/RecordQuery";
|
||||||
import FilterUtils from "qqq/utils/qqq/FilterUtils";
|
import FilterUtils from "qqq/utils/qqq/FilterUtils";
|
||||||
import TableUtils from "qqq/utils/qqq/TableUtils";
|
import TableUtils from "qqq/utils/qqq/TableUtils";
|
||||||
|
import React, {SyntheticEvent, useContext, useReducer, useState} from "react";
|
||||||
|
|
||||||
export type CriteriaParamType = QFilterCriteriaWithId | null | "tooComplex";
|
export type CriteriaParamType = QFilterCriteriaWithId | null | "tooComplex";
|
||||||
|
|
||||||
@ -50,6 +51,7 @@ interface QuickFilterProps
|
|||||||
updateCriteria: (newCriteria: QFilterCriteria, needDebounce: boolean, doRemoveCriteria: boolean) => void;
|
updateCriteria: (newCriteria: QFilterCriteria, needDebounce: boolean, doRemoveCriteria: boolean) => void;
|
||||||
defaultOperator?: QCriteriaOperator;
|
defaultOperator?: QCriteriaOperator;
|
||||||
handleRemoveQuickFilterField?: (fieldName: string) => void;
|
handleRemoveQuickFilterField?: (fieldName: string) => void;
|
||||||
|
queryScreenUsage?: QueryScreenUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickFilter.defaultProps =
|
QuickFilter.defaultProps =
|
||||||
@ -71,7 +73,7 @@ export const quickFilterButtonStyles = {
|
|||||||
minHeight: "auto",
|
minHeight: "auto",
|
||||||
padding: "0.375rem 0.625rem", whiteSpace: "nowrap",
|
padding: "0.375rem 0.625rem", whiteSpace: "nowrap",
|
||||||
marginBottom: "0.5rem"
|
marginBottom: "0.5rem"
|
||||||
}
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Test if a CriteriaParamType represents an actual query criteria - or, if it's
|
** Test if a CriteriaParamType represents an actual query criteria - or, if it's
|
||||||
@ -89,11 +91,11 @@ const criteriaParamIsCriteria = (param: CriteriaParamType): boolean =>
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const doesOperatorOptionEqualCriteria = (operatorOption: OperatorOption, criteria: QFilterCriteriaWithId): boolean =>
|
const doesOperatorOptionEqualCriteria = (operatorOption: OperatorOption, criteria: QFilterCriteriaWithId): boolean =>
|
||||||
{
|
{
|
||||||
if(operatorOption.value == criteria.operator)
|
if (operatorOption.value == criteria.operator)
|
||||||
{
|
{
|
||||||
if(operatorOption.implicitValues)
|
if (operatorOption.implicitValues)
|
||||||
{
|
{
|
||||||
if(JSON.stringify(operatorOption.implicitValues) == JSON.stringify(criteria.values))
|
if (JSON.stringify(operatorOption.implicitValues) == JSON.stringify(criteria.values))
|
||||||
{
|
{
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
@ -107,7 +109,7 @@ const doesOperatorOptionEqualCriteria = (operatorOption: OperatorOption, criteri
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (false);
|
return (false);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -117,29 +119,29 @@ const doesOperatorOptionEqualCriteria = (operatorOption: OperatorOption, criteri
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const getOperatorSelectedValue = (operatorOptions: OperatorOption[], criteria: QFilterCriteriaWithId, defaultOperator: QCriteriaOperator): OperatorOption =>
|
const getOperatorSelectedValue = (operatorOptions: OperatorOption[], criteria: QFilterCriteriaWithId, defaultOperator: QCriteriaOperator): OperatorOption =>
|
||||||
{
|
{
|
||||||
if(criteria)
|
if (criteria)
|
||||||
{
|
{
|
||||||
const filteredOptions = operatorOptions.filter(o => doesOperatorOptionEqualCriteria(o, criteria));
|
const filteredOptions = operatorOptions.filter(o => doesOperatorOptionEqualCriteria(o, criteria));
|
||||||
if(filteredOptions.length > 0)
|
if (filteredOptions.length > 0)
|
||||||
{
|
{
|
||||||
return (filteredOptions[0]);
|
return (filteredOptions[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const filteredOptions = operatorOptions.filter(o => o.value == defaultOperator);
|
const filteredOptions = operatorOptions.filter(o => o.value == defaultOperator);
|
||||||
if(filteredOptions.length > 0)
|
if (filteredOptions.length > 0)
|
||||||
{
|
{
|
||||||
return (filteredOptions[0]);
|
return (filteredOptions[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (null);
|
return (null);
|
||||||
}
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** 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}: QuickFilterProps): JSX.Element
|
export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData, criteriaParam, updateCriteria, defaultOperator, handleRemoveQuickFilterField, queryScreenUsage}: 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);
|
||||||
@ -190,7 +192,7 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if (criteriaParamIsCriteria(criteriaParam) && JSON.stringify(criteriaParam) !== JSON.stringify(criteria))
|
if (criteriaParamIsCriteria(criteriaParam) && JSON.stringify(criteriaParam) !== JSON.stringify(criteria))
|
||||||
{
|
{
|
||||||
if(isOpen)
|
if (isOpen)
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// this was firing too-often for case where: there was a criteria originally //
|
// this was firing too-often for case where: there was a criteria originally //
|
||||||
@ -217,12 +219,12 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const criteriaNeedsReset = (): boolean =>
|
const criteriaNeedsReset = (): boolean =>
|
||||||
{
|
{
|
||||||
if(criteria != null && criteriaParam == null)
|
if (criteria != null && criteriaParam == null)
|
||||||
{
|
{
|
||||||
const defaultOperatorOption = operatorOptions.filter(o => o.value == defaultOperator)[0];
|
const defaultOperatorOption = operatorOptions.filter(o => o.value == defaultOperator)[0];
|
||||||
if(criteria.operator !== defaultOperatorOption?.value || JSON.stringify(criteria.values) !== JSON.stringify(getDefaultCriteriaValue()))
|
if (criteria.operator !== defaultOperatorOption?.value || JSON.stringify(criteria.values) !== JSON.stringify(getDefaultCriteriaValue()))
|
||||||
{
|
{
|
||||||
if(isOpen)
|
if (isOpen)
|
||||||
{
|
{
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
// this was firing too-often for case where: there was no criteria originally, //
|
// this was firing too-often for case where: there was no criteria originally, //
|
||||||
@ -237,7 +239,7 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (false);
|
return (false);
|
||||||
}
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Construct a new criteria object - resetting the values tied to the operator
|
** Construct a new criteria object - resetting the values tied to the operator
|
||||||
@ -251,8 +253,8 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
setOperatorSelectedValue(operatorOption);
|
setOperatorSelectedValue(operatorOption);
|
||||||
setOperatorInputValue(operatorOption?.label);
|
setOperatorInputValue(operatorOption?.label);
|
||||||
setCriteria(criteria);
|
setCriteria(criteria);
|
||||||
return(criteria);
|
return (criteria);
|
||||||
}
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** event handler to open the menu in response to the button being clicked.
|
** event handler to open the menu in response to the button being clicked.
|
||||||
@ -266,7 +268,7 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
{
|
{
|
||||||
const element = document.getElementById("value-" + criteria.id);
|
const element = document.getElementById("value-" + criteria.id);
|
||||||
element?.focus();
|
element?.focus();
|
||||||
})
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -304,15 +306,15 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
// we've seen cases where switching operators can sometimes put a null in as the first value... //
|
// we've seen cases where switching operators can sometimes put a null in as the first value... //
|
||||||
// that just causes a bad time (e.g., null pointers in Autocomplete), so, get rid of that. //
|
// that just causes a bad time (e.g., null pointers in Autocomplete), so, get rid of that. //
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if(criteria.values && criteria.values.length == 1 && criteria.values[0] == null)
|
if (criteria.values && criteria.values.length == 1 && criteria.values[0] == null)
|
||||||
{
|
{
|
||||||
criteria.values = [];
|
criteria.values = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newValue.valueMode && !newValue.implicitValues)
|
if (newValue.valueMode && !newValue.implicitValues)
|
||||||
{
|
{
|
||||||
const requiredValueCount = getValueModeRequiredCount(newValue.valueMode);
|
const requiredValueCount = getValueModeRequiredCount(newValue.valueMode);
|
||||||
if(requiredValueCount != null && criteria.values.length > requiredValueCount)
|
if (requiredValueCount != null && criteria.values.length > requiredValueCount)
|
||||||
{
|
{
|
||||||
criteria.values.splice(requiredValueCount);
|
criteria.values.splice(requiredValueCount);
|
||||||
}
|
}
|
||||||
@ -345,6 +347,7 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const value = newValue !== undefined ? newValue : event ? event.target.value : null;
|
const value = newValue !== undefined ? newValue : event ? event.target.value : null;
|
||||||
|
|
||||||
|
console.log("IN HERE");
|
||||||
if (!criteria.values)
|
if (!criteria.values)
|
||||||
{
|
{
|
||||||
criteria.values = [];
|
criteria.values = [];
|
||||||
@ -376,13 +379,13 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const resetCriteria = (e: React.MouseEvent<HTMLSpanElement>) =>
|
const resetCriteria = (e: React.MouseEvent<HTMLSpanElement>) =>
|
||||||
{
|
{
|
||||||
if(criteriaIsValid)
|
if (criteriaIsValid)
|
||||||
{
|
{
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const newCriteria = makeNewCriteria();
|
const newCriteria = makeNewCriteria();
|
||||||
updateCriteria(newCriteria, false, true);
|
updateCriteria(newCriteria, false, true);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** event handler for clicking the (x) icon that turns off this quick filter field.
|
** event handler for clicking the (x) icon that turns off this quick filter field.
|
||||||
@ -390,17 +393,17 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const handleTurningOffQuickFilterField = () =>
|
const handleTurningOffQuickFilterField = () =>
|
||||||
{
|
{
|
||||||
closeMenu()
|
closeMenu();
|
||||||
if(handleRemoveQuickFilterField)
|
if (handleRemoveQuickFilterField)
|
||||||
{
|
{
|
||||||
handleRemoveQuickFilterField(criteria?.fieldName);
|
handleRemoveQuickFilterField(criteria?.fieldName);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
// if no field was input (e.g., record-query is still loading), return null early //
|
// if no field was input (e.g., record-query is still loading), return null early //
|
||||||
////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
if(!fieldMetaData)
|
if (!fieldMetaData)
|
||||||
{
|
{
|
||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
@ -410,10 +413,10 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
// from the last selected one, then set the state vars that control that autocomplete //
|
// from the last selected one, then set the state vars that control that autocomplete //
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
const maybeNewOperatorSelectedValue = getOperatorSelectedValue(operatorOptions, criteria, defaultOperator);
|
const maybeNewOperatorSelectedValue = getOperatorSelectedValue(operatorOptions, criteria, defaultOperator);
|
||||||
if(JSON.stringify(maybeNewOperatorSelectedValue) !== JSON.stringify(operatorSelectedValue))
|
if (JSON.stringify(maybeNewOperatorSelectedValue) !== JSON.stringify(operatorSelectedValue))
|
||||||
{
|
{
|
||||||
setOperatorSelectedValue(maybeNewOperatorSelectedValue)
|
setOperatorSelectedValue(maybeNewOperatorSelectedValue);
|
||||||
setOperatorInputValue(maybeNewOperatorSelectedValue?.label)
|
setOperatorInputValue(maybeNewOperatorSelectedValue?.label);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -431,7 +434,7 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
const tooltipEnterDelay = 500;
|
const tooltipEnterDelay = 500;
|
||||||
|
|
||||||
let buttonAdditionalStyles: any = {};
|
let buttonAdditionalStyles: any = {};
|
||||||
let buttonContent = <span>{tableForField?.name != tableMetaData.name ? `${tableForField.label}: ` : ""}{fieldMetaData.label}</span>
|
let buttonContent = <span>{tableForField?.name != tableMetaData.name ? `${tableForField.label}: ` : ""}{fieldMetaData.label}</span>;
|
||||||
let buttonClassName = "filterNotActive";
|
let buttonClassName = "filterNotActive";
|
||||||
if (criteriaIsValid)
|
if (criteriaIsValid)
|
||||||
{
|
{
|
||||||
@ -446,9 +449,9 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
// don't show the Equals or In operators //
|
// don't show the Equals or In operators //
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
let operatorString = (<>{operatorSelectedValue.label} </>);
|
let operatorString = (<>{operatorSelectedValue.label} </>);
|
||||||
if(operatorSelectedValue.value == QCriteriaOperator.EQUALS || operatorSelectedValue.value == QCriteriaOperator.IN)
|
if (operatorSelectedValue.value == QCriteriaOperator.EQUALS || operatorSelectedValue.value == QCriteriaOperator.IN)
|
||||||
{
|
{
|
||||||
operatorString = (<></>)
|
operatorString = (<></>);
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonContent = (<><span style={{fontWeight: 700}}>{buttonContent}:</span> <span style={{fontWeight: 400}}>{operatorString}{valuesString}</span></>);
|
buttonContent = (<><span style={{fontWeight: 700}}>{buttonContent}:</span> <span style={{fontWeight: 400}}>{operatorString}{valuesString}</span></>);
|
||||||
@ -491,7 +494,7 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
const xClicked = (e: React.MouseEvent<HTMLSpanElement>) =>
|
const xClicked = (e: React.MouseEvent<HTMLSpanElement>) =>
|
||||||
{
|
{
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if(criteriaIsValid)
|
if (criteriaIsValid)
|
||||||
{
|
{
|
||||||
resetCriteria(e);
|
resetCriteria(e);
|
||||||
}
|
}
|
||||||
@ -499,12 +502,12 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
{
|
{
|
||||||
handleTurningOffQuickFilterField();
|
handleTurningOffQuickFilterField();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// return the button & menu //
|
// return the button & menu //
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
const widthAndMaxWidth = fieldMetaData?.type == QFieldType.DATE_TIME ? 275 : 250
|
const widthAndMaxWidth = (fieldMetaData?.type == QFieldType.DATE_TIME) ? 315 : 250;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{button}
|
{button}
|
||||||
@ -541,6 +544,7 @@ export default function QuickFilter({tableMetaData, fullFieldName, fieldMetaData
|
|||||||
</Box>
|
</Box>
|
||||||
<Box width={widthAndMaxWidth} maxWidth={widthAndMaxWidth} className="quickFilter filterValuesColumn">
|
<Box width={widthAndMaxWidth} maxWidth={widthAndMaxWidth} className="quickFilter filterValuesColumn">
|
||||||
<FilterCriteriaRowValues
|
<FilterCriteriaRowValues
|
||||||
|
queryScreenUsage={queryScreenUsage}
|
||||||
operatorOption={operatorSelectedValue}
|
operatorOption={operatorSelectedValue}
|
||||||
criteria={criteria}
|
criteria={criteria}
|
||||||
field={fieldMetaData}
|
field={fieldMetaData}
|
||||||
|
@ -24,9 +24,8 @@ import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QT
|
|||||||
import {QJobComplete} from "@kingsrook/qqq-frontend-core/lib/model/processes/QJobComplete";
|
import {QJobComplete} from "@kingsrook/qqq-frontend-core/lib/model/processes/QJobComplete";
|
||||||
import {QJobError} from "@kingsrook/qqq-frontend-core/lib/model/processes/QJobError";
|
import {QJobError} from "@kingsrook/qqq-frontend-core/lib/model/processes/QJobError";
|
||||||
import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord";
|
import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord";
|
||||||
import {Alert} from "@mui/material";
|
import {Alert, Box} from "@mui/material";
|
||||||
import Autocomplete from "@mui/material/Autocomplete";
|
import Autocomplete from "@mui/material/Autocomplete";
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Card from "@mui/material/Card";
|
import Card from "@mui/material/Card";
|
||||||
import Icon from "@mui/material/Icon";
|
import Icon from "@mui/material/Icon";
|
||||||
@ -37,6 +36,7 @@ import Typography from "@mui/material/Typography";
|
|||||||
import FormData from "form-data";
|
import FormData from "form-data";
|
||||||
import colors from "qqq/assets/theme/base/colors";
|
import colors from "qqq/assets/theme/base/colors";
|
||||||
import {QCancelButton} from "qqq/components/buttons/DefaultButtons";
|
import {QCancelButton} from "qqq/components/buttons/DefaultButtons";
|
||||||
|
import DynamicSelect, {getAutocompleteOutlinedStyle} from "qqq/components/forms/DynamicSelect";
|
||||||
import Client from "qqq/utils/qqq/Client";
|
import Client from "qqq/utils/qqq/Client";
|
||||||
import React, {useEffect, useReducer, useState} from "react";
|
import React, {useEffect, useReducer, useState} from "react";
|
||||||
|
|
||||||
@ -75,6 +75,17 @@ const defaultScope = scopeOptions[0];
|
|||||||
|
|
||||||
const qController = Client.getInstance();
|
const qController = Client.getInstance();
|
||||||
|
|
||||||
|
interface ShareableTableMetaData
|
||||||
|
{
|
||||||
|
sharedRecordTableName: string;
|
||||||
|
assetIdFieldName: string;
|
||||||
|
scopeFieldName: string;
|
||||||
|
audienceTypesPossibleValueSourceName: string;
|
||||||
|
audiencePossibleValueSourceName: string;
|
||||||
|
thisTableOwnerIdFieldName: string;
|
||||||
|
audienceTypes: {[name: string]: any}; // values here are: ShareableAudienceType
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** component containing a Modal dialog for sharing records
|
** component containing a Modal dialog for sharing records
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -83,6 +94,7 @@ export default function ShareModal({open, onClose, tableMetaData, record}: Share
|
|||||||
const [statusString, setStatusString] = useState("Loading...");
|
const [statusString, setStatusString] = useState("Loading...");
|
||||||
const [alert, setAlert] = useState(null as string);
|
const [alert, setAlert] = useState(null as string);
|
||||||
|
|
||||||
|
const [selectedAudienceOption, setSelectedAudienceOption] = useState(null as {id: string, label: string});
|
||||||
const [selectedAudienceType, setSelectedAudienceType] = useState(null);
|
const [selectedAudienceType, setSelectedAudienceType] = useState(null);
|
||||||
const [selectedAudienceId, setSelectedAudienceId] = useState(null);
|
const [selectedAudienceId, setSelectedAudienceId] = useState(null);
|
||||||
const [selectedScopeId, setSelectedScopeId] = useState(defaultScope.id);
|
const [selectedScopeId, setSelectedScopeId] = useState(defaultScope.id);
|
||||||
@ -92,8 +104,14 @@ export default function ShareModal({open, onClose, tableMetaData, record}: Share
|
|||||||
const [needToLoadCurrentShares, setNeedToLoadCurrentShares] = useState(true);
|
const [needToLoadCurrentShares, setNeedToLoadCurrentShares] = useState(true);
|
||||||
const [everLoadedCurrentShares, setEverLoadedCurrentShares] = useState(false);
|
const [everLoadedCurrentShares, setEverLoadedCurrentShares] = useState(false);
|
||||||
|
|
||||||
|
const shareableTableMetaData = tableMetaData.shareableTableMetaData as ShareableTableMetaData;
|
||||||
|
|
||||||
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
||||||
|
|
||||||
|
if(!shareableTableMetaData)
|
||||||
|
{
|
||||||
|
console.error(`Did not find a shareableTableMetaData on table ${tableMetaData.name}`);
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
// trigger initial load, and post any changes, re-load //
|
// trigger initial load, and post any changes, re-load //
|
||||||
@ -124,7 +142,7 @@ export default function ShareModal({open, onClose, tableMetaData, record}: Share
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function handleAudienceChange(event: React.SyntheticEvent, value: any | any[], reason: string)
|
function handleAudienceChange(value: any | any[], reason: string)
|
||||||
{
|
{
|
||||||
if(value)
|
if(value)
|
||||||
{
|
{
|
||||||
@ -260,6 +278,7 @@ export default function ShareModal({open, onClose, tableMetaData, record}: Share
|
|||||||
const result = processResult as QJobComplete;
|
const result = processResult as QJobComplete;
|
||||||
setStatusString(null);
|
setStatusString(null);
|
||||||
setAlert(null);
|
setAlert(null);
|
||||||
|
setSelectedAudienceOption(null);
|
||||||
setNeedToLoadCurrentShares(true);
|
setNeedToLoadCurrentShares(true);
|
||||||
setSubmitting(false)
|
setSubmitting(false)
|
||||||
}
|
}
|
||||||
@ -297,16 +316,6 @@ export default function ShareModal({open, onClose, tableMetaData, record}: Share
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// todo - need this to be real
|
|
||||||
const audienceOptions = [
|
|
||||||
{id: "user:1", label: "Darin Kelkhoff"},
|
|
||||||
{id: "user:2", label: "Tom Chutterloin"},
|
|
||||||
{id: "user:3", label: "Tylers Ample"},
|
|
||||||
{id: "user:4", label: "Mames Mames"},
|
|
||||||
{id: "group:2", label: "Cold Track Engineering"}
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -329,10 +338,11 @@ export default function ShareModal({open, onClose, tableMetaData, record}: Share
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function renderScopeDropdown(id: string, defaultValue: Scope, onChange: (event: React.SyntheticEvent, value: any | any[], reason: string) => void)
|
function renderScopeDropdown(id: string, defaultValue: Scope, onChange: (event: React.SyntheticEvent, value: any | any[], reason: string) => void)
|
||||||
{
|
{
|
||||||
|
const isDisabled = (id == "new-share-scope" && submitting);
|
||||||
return (
|
return (
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
id={id}
|
id={id}
|
||||||
disabled={id == "new-share-scope" && submitting}
|
disabled={isDisabled}
|
||||||
renderInput={(params) => (<TextField {...params} label="Scope" variant="outlined" autoComplete="off" type="search" InputProps={{...params.InputProps}} />)}
|
renderInput={(params) => (<TextField {...params} label="Scope" variant="outlined" autoComplete="off" type="search" InputProps={{...params.InputProps}} />)}
|
||||||
options={scopeOptions}
|
options={scopeOptions}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -345,7 +355,7 @@ export default function ShareModal({open, onClose, tableMetaData, record}: Share
|
|||||||
autoHighlight={true}
|
autoHighlight={true}
|
||||||
disableClearable
|
disableClearable
|
||||||
fullWidth
|
fullWidth
|
||||||
sx={autocompleteSX}
|
sx={getAutocompleteOutlinedStyle(isDisabled)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -359,17 +369,18 @@ export default function ShareModal({open, onClose, tableMetaData, record}: Share
|
|||||||
<Card sx={{my: 5, mx: "auto", p: 3}}>
|
<Card sx={{my: 5, mx: "auto", p: 3}}>
|
||||||
|
|
||||||
{/* header */}
|
{/* header */}
|
||||||
<Box display="flex" flexDirection="row" justifyContent="space-between" alignItems="flex-start">
|
<Box display="flex" flexDirection="row" justifyContent="space-between" alignItems="flex-start" maxWidth="590px">
|
||||||
<Typography variant="h4" pb={1} fontWeight="600">
|
<Typography variant="h4" pb={1} fontWeight="600">
|
||||||
Share {tableMetaData.label}: {record?.recordLabel ?? record?.values?.get(tableMetaData.primaryKeyField) ?? "Unknown"}
|
Share {tableMetaData.label}: {record?.recordLabel ?? record?.values?.get(tableMetaData.primaryKeyField) ?? "Unknown"}
|
||||||
<Box color={colors.gray.main} pb={"0.5rem"} fontSize={"0.875rem"} fontWeight="400" maxWidth="590px">
|
<Box color={colors.gray.main} pb={"0.5rem"} fontSize={"0.875rem"} fontWeight="400">
|
||||||
{/* todo move to helpContent (what do we attach the meta-data too??) */}
|
{/* todo move to helpContent (what do we attach the meta-data too??) */}
|
||||||
Select a user or a group to share this record with.
|
Select a user or a group to share this record with.
|
||||||
You can choose if they should only be able to Read the record, or also make Edits to it.
|
{/*You can choose if they should only be able to Read the record, or also make Edits to it.*/}
|
||||||
</Box>
|
</Box>
|
||||||
<Box fontSize={14} maxWidth="590px" pb={1} fontWeight="300">
|
<Box fontSize={14} pb={1} fontWeight="300">
|
||||||
{alert && <Alert color="error" onClose={() => setAlert(null)}>{alert}</Alert>}
|
{alert && <Alert color="error" onClose={() => setAlert(null)}>{alert}</Alert>}
|
||||||
{statusString}
|
{statusString}
|
||||||
|
{!alert && !statusString && (<> </>)}
|
||||||
</Box>
|
</Box>
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
@ -378,26 +389,22 @@ export default function ShareModal({open, onClose, tableMetaData, record}: Share
|
|||||||
<Box pb={3} display="flex" flexDirection="column">
|
<Box pb={3} display="flex" flexDirection="column">
|
||||||
{/* row for adding a new share */}
|
{/* row for adding a new share */}
|
||||||
<Box display="flex" flexDirection="row" alignItems="center">
|
<Box display="flex" flexDirection="row" alignItems="center">
|
||||||
<Box width="350px" pr={2}>
|
<Box width="550px" pr={2} mb={-1.5}>
|
||||||
<Autocomplete
|
<DynamicSelect
|
||||||
id="new-share-audience"
|
possibleValueSourceName={shareableTableMetaData.audiencePossibleValueSourceName}
|
||||||
disabled={submitting}
|
fieldLabel="User or Group" // todo should come from shareableTableMetaData
|
||||||
renderInput={(params) => (<TextField {...params} label="User or Group" variant="outlined" autoComplete="off" type="search" InputProps={{...params.InputProps}} />)}
|
initialValue={selectedAudienceOption?.id}
|
||||||
options={audienceOptions}
|
initialDisplayValue={selectedAudienceOption?.label}
|
||||||
|
inForm={false}
|
||||||
onChange={handleAudienceChange}
|
onChange={handleAudienceChange}
|
||||||
isOptionEqualToValue={(option, value) => option.id === value.id}
|
|
||||||
// @ts-ignore Property label does not exist on string | {thing with label}
|
|
||||||
getOptionLabel={(option) => option.label}
|
|
||||||
autoSelect={true}
|
|
||||||
autoHighlight={true}
|
|
||||||
disableClearable
|
|
||||||
fullWidth
|
|
||||||
sx={autocompleteSX}
|
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box width="180px" pr={2}>
|
{/*
|
||||||
{renderScopeDropdown("new-share-scope", defaultScope, handleScopeChange)}
|
when turning scope back on, change width of audience box to 350px
|
||||||
</Box>
|
<Box width="180px" pr={2}>
|
||||||
|
{renderScopeDropdown("new-share-scope", defaultScope, handleScopeChange)}
|
||||||
|
</Box>
|
||||||
|
*/}
|
||||||
<Box>
|
<Box>
|
||||||
<Tooltip title={selectedAudienceId == null ? "Select a user or group to share with." : null}>
|
<Tooltip title={selectedAudienceId == null ? "Select a user or group to share with." : null}>
|
||||||
<span>
|
<span>
|
||||||
@ -418,20 +425,25 @@ export default function ShareModal({open, onClose, tableMetaData, record}: Share
|
|||||||
}
|
}
|
||||||
</h5>
|
</h5>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{border: `1px solid ${colors.grayLines.main}`, borderRadius: "1rem", overflow: "auto"}} height="180px" pt="0.5rem">
|
<Box sx={{border: `1px solid ${colors.grayLines.main}`, borderRadius: "1rem", overflow: "hidden"}}>
|
||||||
{
|
<Box sx={{overflow: "auto"}} height="210px" pt="0.75rem">
|
||||||
currentShares.map((share) => (
|
{
|
||||||
<Box key={share.shareId} display="flex" justifyContent="space-between" alignItems="center" p="0.25rem" fontSize="1rem">
|
currentShares.map((share) => (
|
||||||
<Box display="flex" alignItems="center">
|
<Box key={share.shareId} display="flex" justifyContent="space-between" alignItems="center" p="0.25rem" pb="0.75rem" fontSize="1rem">
|
||||||
<Box width="310px" pl="1rem">{share.audienceLabel}</Box>
|
<Box display="flex" alignItems="center">
|
||||||
<Box width="160px">{renderScopeDropdown(`scope-${share.shareId}`, getScopeOption(share.scopeId), (event: React.SyntheticEvent, value: any | any[], reason: string) => editingExistingShareScope(share.shareId, value))}</Box>
|
<Box width="490px" pl="1rem">{share.audienceLabel}</Box>
|
||||||
|
{/*
|
||||||
|
when turning scope back on, change width of audience box to 310px
|
||||||
|
<Box width="160px">{renderScopeDropdown(`scope-${share.shareId}`, getScopeOption(share.scopeId), (event: React.SyntheticEvent, value: any | any[], reason: string) => editingExistingShareScope(share.shareId, value))}</Box>
|
||||||
|
*/}
|
||||||
|
</Box>
|
||||||
|
<Box pr="1rem">
|
||||||
|
<Button sx={{...iconButtonSX, ...redIconButton}} onClick={() => removeShare(share.shareId)}><Icon>clear</Icon></Button>
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box pr="1rem">
|
))
|
||||||
<Button sx={{...iconButtonSX, ...redIconButton}} onClick={() => removeShare(share.shareId)}><Icon>clear</Icon></Button>
|
}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
|
||||||
))
|
|
||||||
}
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
@ -448,12 +460,6 @@ export default function ShareModal({open, onClose, tableMetaData, record}: Share
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const autocompleteSX =
|
|
||||||
{
|
|
||||||
"& .MuiAutocomplete-input": {padding: "0.125rem 0.5rem !important"},
|
|
||||||
"& .MuiOutlinedInput-root": {borderRadius: "0.75rem !important"}
|
|
||||||
};
|
|
||||||
|
|
||||||
const iconButtonSX =
|
const iconButtonSX =
|
||||||
{
|
{
|
||||||
border: `1px solid ${colors.grayLines.main} !important`,
|
border: `1px solid ${colors.grayLines.main} !important`,
|
||||||
|
@ -38,6 +38,7 @@ import StackedBarChart from "qqq/components/widgets/charts/StackedBarChart";
|
|||||||
import CompositeWidget from "qqq/components/widgets/CompositeWidget";
|
import CompositeWidget from "qqq/components/widgets/CompositeWidget";
|
||||||
import DataBagViewer from "qqq/components/widgets/misc/DataBagViewer";
|
import DataBagViewer from "qqq/components/widgets/misc/DataBagViewer";
|
||||||
import DividerWidget from "qqq/components/widgets/misc/Divider";
|
import DividerWidget from "qqq/components/widgets/misc/Divider";
|
||||||
|
import DynamicFormWidget from "qqq/components/widgets/misc/DynamicFormWidget";
|
||||||
import FieldValueListWidget from "qqq/components/widgets/misc/FieldValueListWidget";
|
import FieldValueListWidget from "qqq/components/widgets/misc/FieldValueListWidget";
|
||||||
import PivotTableSetupWidget from "qqq/components/widgets/misc/PivotTableSetupWidget";
|
import PivotTableSetupWidget from "qqq/components/widgets/misc/PivotTableSetupWidget";
|
||||||
import QuickSightChart from "qqq/components/widgets/misc/QuickSightChart";
|
import QuickSightChart from "qqq/components/widgets/misc/QuickSightChart";
|
||||||
@ -261,7 +262,7 @@ function DashboardWidgets({widgetMetaDataList, tableName, entityPrimaryKey, reco
|
|||||||
{
|
{
|
||||||
const rs: {[name: string]: any} = {};
|
const rs: {[name: string]: any} = {};
|
||||||
|
|
||||||
if(record.values)
|
if(record && record.values)
|
||||||
{
|
{
|
||||||
record.values.forEach((value, key) => rs[key] = value);
|
record.values.forEach((value, key) => rs[key] = value);
|
||||||
}
|
}
|
||||||
@ -596,6 +597,12 @@ function DashboardWidgets({widgetMetaDataList, tableName, entityPrimaryKey, reco
|
|||||||
{}} />
|
{}} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
widgetMetaData.type === "dynamicForm" && (
|
||||||
|
widgetData && widgetData[i] &&
|
||||||
|
<DynamicFormWidget isEditable={false} widgetMetaData={widgetMetaData} widgetData={widgetData[i]} record={record} recordValues={convertQRecordValuesFromMapToObject(record)} />
|
||||||
|
)
|
||||||
|
}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
|
|
||||||
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
||||||
import {QWidgetMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QWidgetMetaData";
|
import {QWidgetMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QWidgetMetaData";
|
||||||
import {InputLabel} from "@mui/material";
|
import {Box, InputLabel} from "@mui/material";
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Card from "@mui/material/Card";
|
import Card from "@mui/material/Card";
|
||||||
import Icon from "@mui/material/Icon";
|
import Icon from "@mui/material/Icon";
|
||||||
@ -196,8 +195,6 @@ export function HeaderLinkButtonComponent({label, onClickCallback, disabled, dis
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -220,7 +217,7 @@ export function HeaderToggleComponent({label, getValue, onClickCallback, disable
|
|||||||
const onClick = () =>
|
const onClick = () =>
|
||||||
{
|
{
|
||||||
onClickCallback();
|
onClickCallback();
|
||||||
}
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box alignItems="baseline" mr="-0.75rem">
|
<Box alignItems="baseline" mr="-0.75rem">
|
||||||
@ -236,7 +233,6 @@ export function HeaderToggleComponent({label, getValue, onClickCallback, disable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -698,7 +694,7 @@ function Widget(props: React.PropsWithChildren<Props>): JSX.Element
|
|||||||
);
|
);
|
||||||
|
|
||||||
let sublabelElement = (
|
let sublabelElement = (
|
||||||
<Box height="20px">
|
<Box key="sublabel" height="20px">
|
||||||
<Typography sx={{position: "relative", top: "-18px"}} variant="caption">
|
<Typography sx={{position: "relative", top: "-18px"}} variant="caption">
|
||||||
{props.widgetData?.sublabel}
|
{props.widgetData?.sublabel}
|
||||||
</Typography>
|
</Typography>
|
||||||
@ -785,7 +781,7 @@ function Widget(props: React.PropsWithChildren<Props>): JSX.Element
|
|||||||
}
|
}
|
||||||
{localLabelAdditionalElementsLeft}
|
{localLabelAdditionalElementsLeft}
|
||||||
</Box>
|
</Box>
|
||||||
<Box display="flex">
|
<Box key="sublabelContainer" display="flex">
|
||||||
{
|
{
|
||||||
hasPermission && props.widgetData?.sublabel && (sublabelElement)
|
hasPermission && props.widgetData?.sublabel && (sublabelElement)
|
||||||
}
|
}
|
||||||
|
265
src/qqq/components/widgets/misc/DynamicFormWidget.tsx
Normal file
265
src/qqq/components/widgets/misc/DynamicFormWidget.tsx
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2024. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
||||||
|
import {QWidgetMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QWidgetMetaData";
|
||||||
|
import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import {FormikContextType, useFormikContext} from "formik";
|
||||||
|
import QDynamicForm from "qqq/components/forms/DynamicForm";
|
||||||
|
import DynamicFormUtils from "qqq/components/forms/DynamicFormUtils";
|
||||||
|
import Widget from "qqq/components/widgets/Widget";
|
||||||
|
import {renderSectionOfFields} from "qqq/pages/records/view/RecordView";
|
||||||
|
import Client from "qqq/utils/qqq/Client";
|
||||||
|
import React, {useEffect, useState} from "react";
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** component props
|
||||||
|
*******************************************************************************/
|
||||||
|
interface DynamicFormWidgetProps
|
||||||
|
{
|
||||||
|
isEditable: boolean;
|
||||||
|
widgetMetaData: QWidgetMetaData;
|
||||||
|
widgetData: any;
|
||||||
|
record: QRecord;
|
||||||
|
recordValues: { [name: string]: any };
|
||||||
|
onSaveCallback?: (values: { [name: string]: any }) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** default values for props
|
||||||
|
*******************************************************************************/
|
||||||
|
DynamicFormWidget.defaultProps = {
|
||||||
|
onSaveCallback: null
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Component to display a dynamic form - e.g., on a record edit or view screen,
|
||||||
|
** or even within a process.
|
||||||
|
*******************************************************************************/
|
||||||
|
export default function DynamicFormWidget({isEditable, widgetMetaData, widgetData, record, recordValues, onSaveCallback}: DynamicFormWidgetProps): JSX.Element
|
||||||
|
{
|
||||||
|
const [fields, setFields] = useState([] as QFieldMetaData[]);
|
||||||
|
|
||||||
|
const [effectiveIsEditable, setEffectiveIsEditable] = useState(isEditable);
|
||||||
|
if(widgetMetaData.defaultValues.has("isEditable"))
|
||||||
|
{
|
||||||
|
const defaultIsEditableValue = widgetMetaData.defaultValues.get("isEditable")
|
||||||
|
if(defaultIsEditableValue != effectiveIsEditable)
|
||||||
|
{
|
||||||
|
setEffectiveIsEditable(defaultIsEditableValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [dynamicFormFields, setDynamicFormFields] = useState(null as any);
|
||||||
|
const [formValidations, setFormValidations] = useState(null as any);
|
||||||
|
|
||||||
|
const [lastKnowFormValues, setLastKnowFormValues] = useState({} as {[name: string]: any});
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// on initial load, and any time widgetData changes (e.g., if widget gets re-rendered), //
|
||||||
|
// figure out what our form fields are //
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
setDynamicFormFields({})
|
||||||
|
setFormValidations({})
|
||||||
|
|
||||||
|
if(widgetData && widgetData.fieldList)
|
||||||
|
{
|
||||||
|
const newFields: QFieldMetaData[] = [];
|
||||||
|
for (let i = 0; i < widgetData.fieldList.length; i++)
|
||||||
|
{
|
||||||
|
newFields.push(new QFieldMetaData(widgetData.fieldList[i]));
|
||||||
|
}
|
||||||
|
setFields(newFields);
|
||||||
|
|
||||||
|
if(newFields.length > 0)
|
||||||
|
{
|
||||||
|
const recordOfFieldValues = widgetData.recordOfFieldValues ? new QRecord(widgetData.recordOfFieldValues) : null;
|
||||||
|
const {dynamicFormFields: newDynamicFormFields, formValidations: newFormValidations} = DynamicFormUtils.getFormData(newFields);
|
||||||
|
const defaultDisplayValues = new Map<string,string>(); // todo - seems not right?
|
||||||
|
DynamicFormUtils.addPossibleValueProps(newDynamicFormFields, newFields, recordValues.tableName, null, recordOfFieldValues ? recordOfFieldValues.displayValues : defaultDisplayValues);
|
||||||
|
setDynamicFormFields(newDynamicFormFields)
|
||||||
|
setFormValidations(newFormValidations)
|
||||||
|
}
|
||||||
|
|
||||||
|
setLastKnowFormValues({});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setFields([])
|
||||||
|
}
|
||||||
|
}, [widgetData]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
function checkForFormValueChanges(formikProps: FormikContextType<any>)
|
||||||
|
{
|
||||||
|
if(!fields || !fields.length)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let anyChanged = false;
|
||||||
|
for (let i = 0; i < fields.length; i++)
|
||||||
|
{
|
||||||
|
const name = fields[i].name;
|
||||||
|
if(formikProps.values[name] != lastKnowFormValues[name])
|
||||||
|
{
|
||||||
|
anyChanged = true;
|
||||||
|
lastKnowFormValues[name] = formikProps.values[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(anyChanged)
|
||||||
|
{
|
||||||
|
const mergedDynamicFormValuesIntoFieldName = widgetData.mergedDynamicFormValuesIntoFieldName;
|
||||||
|
if(mergedDynamicFormValuesIntoFieldName && onSaveCallback)
|
||||||
|
{
|
||||||
|
const onSaveCallbackParam: {[name: string]: any} = {};
|
||||||
|
onSaveCallbackParam[mergedDynamicFormValuesIntoFieldName] = JSON.stringify(lastKnowFormValues);
|
||||||
|
onSaveCallback(onSaveCallbackParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
function getInitialValue(fieldName: string)
|
||||||
|
{
|
||||||
|
for (let i = 0; i < fields?.length; i++)
|
||||||
|
{
|
||||||
|
if(fields[i].name == fieldName && fields[i].defaultValue)
|
||||||
|
{
|
||||||
|
return (fields[i].defaultValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
function renderEditForm()
|
||||||
|
{
|
||||||
|
const formikProps = useFormikContext();
|
||||||
|
if(!fields || !fields.length)
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Box fontSize="1rem">{widgetData && widgetData.noFieldsMessage}</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData: any = {};
|
||||||
|
formData.values = formikProps.values;
|
||||||
|
formData.touched = formikProps.touched;
|
||||||
|
formData.errors = formikProps.errors;
|
||||||
|
formData.formFields = {};
|
||||||
|
|
||||||
|
// todo - merge the formValidations object with formik's - maybe in the useEffect where we build it
|
||||||
|
// setValidations(Yup.object().shape(formValidations));
|
||||||
|
// formikProps.validationSchema.
|
||||||
|
|
||||||
|
for (let key of Object.keys(dynamicFormFields))
|
||||||
|
{
|
||||||
|
const dynamicFormField = dynamicFormFields[key];
|
||||||
|
formData.formFields[dynamicFormField.name] = dynamicFormField;
|
||||||
|
|
||||||
|
const initialValue = getInitialValue(dynamicFormField.name);
|
||||||
|
if(initialValue != null)
|
||||||
|
{
|
||||||
|
console.log(`@dk trying to set an initial value [${dynamicFormField.name}] to [${initialValue}]`);
|
||||||
|
// @ts-ignore some any
|
||||||
|
formikProps.initialValues[dynamicFormField.name] = initialValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(formData.values)
|
||||||
|
{
|
||||||
|
checkForFormValueChanges(formikProps);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<QDynamicForm formData={formData} record={record} />
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
function renderViewForm()
|
||||||
|
{
|
||||||
|
const fieldNames: string[] = [];
|
||||||
|
const fieldMap: {[name: string]: QFieldMetaData} = {};
|
||||||
|
const fakeRecord = new QRecord(widgetData.recordOfFieldValues ?? {});
|
||||||
|
|
||||||
|
const mergedDynamicFormValuesIntoFieldName = widgetData.mergedDynamicFormValuesIntoFieldName;
|
||||||
|
|
||||||
|
for (let i = 0; i < fields?.length; i++)
|
||||||
|
{
|
||||||
|
const fieldName = fields[i].name;
|
||||||
|
fieldNames.push(fieldName);
|
||||||
|
fieldMap[fieldName] = fields[i];
|
||||||
|
|
||||||
|
if(mergedDynamicFormValuesIntoFieldName && recordValues[mergedDynamicFormValuesIntoFieldName])
|
||||||
|
{
|
||||||
|
fakeRecord.values.set(fieldName, recordValues[mergedDynamicFormValuesIntoFieldName][fieldName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const section = renderSectionOfFields(`dynamicFormWidget:${widgetMetaData.name}`, fieldNames, null, false, fakeRecord, fieldMap);
|
||||||
|
|
||||||
|
return (<Box>
|
||||||
|
{section}
|
||||||
|
</Box>);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////
|
||||||
|
// render //
|
||||||
|
////////////
|
||||||
|
return (<Widget widgetMetaData={widgetMetaData}>
|
||||||
|
{
|
||||||
|
<React.Fragment>
|
||||||
|
{effectiveIsEditable ? renderEditForm() : renderViewForm()}
|
||||||
|
</React.Fragment>
|
||||||
|
}
|
||||||
|
</Widget>);
|
||||||
|
}
|
||||||
|
|
@ -280,7 +280,7 @@ export default function PivotTableSetupWidget({isEditable, widgetMetaData, recor
|
|||||||
}
|
}
|
||||||
|
|
||||||
modalPivotTableDefinition[rowsOrColumns].push(new PivotTableGroupBy());
|
modalPivotTableDefinition[rowsOrColumns].push(new PivotTableGroupBy());
|
||||||
validateForm()
|
validateForm();
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ export default function PivotTableSetupWidget({isEditable, widgetMetaData, recor
|
|||||||
{
|
{
|
||||||
updateUsedGroupByFieldNames(modalPivotTableDefinition);
|
updateUsedGroupByFieldNames(modalPivotTableDefinition);
|
||||||
updateUsedValueFieldNames(modalPivotTableDefinition);
|
updateUsedValueFieldNames(modalPivotTableDefinition);
|
||||||
validateForm()
|
validateForm();
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ export default function PivotTableSetupWidget({isEditable, widgetMetaData, recor
|
|||||||
}
|
}
|
||||||
|
|
||||||
modalPivotTableDefinition.values.push(new PivotTableValue());
|
modalPivotTableDefinition.values.push(new PivotTableValue());
|
||||||
validateForm()
|
validateForm();
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ export default function PivotTableSetupWidget({isEditable, widgetMetaData, recor
|
|||||||
function removeValue(index: number)
|
function removeValue(index: number)
|
||||||
{
|
{
|
||||||
modalPivotTableDefinition.values.splice(index, 1);
|
modalPivotTableDefinition.values.splice(index, 1);
|
||||||
validateForm()
|
validateForm();
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,7 +503,7 @@ export default function PivotTableSetupWidget({isEditable, widgetMetaData, recor
|
|||||||
const labelAdditionalElementsRight: JSX.Element[] = [];
|
const labelAdditionalElementsRight: JSX.Element[] = [];
|
||||||
if (isEditable)
|
if (isEditable)
|
||||||
{
|
{
|
||||||
labelAdditionalElementsRight.push(<HeaderToggleComponent disabled={editPopupDisabled} disabledTooltip={selectTableFirstTooltipTitle ?? selectColumnsFirstTooltipTitle} label="Use Pivot Table?" getValue={() => enabled} onClickCallback={toggleEnabled} />);
|
labelAdditionalElementsRight.push(<HeaderToggleComponent key="pivotTableHeader" disabled={editPopupDisabled} disabledTooltip={selectTableFirstTooltipTitle ?? selectColumnsFirstTooltipTitle} label="Use Pivot Table?" getValue={() => enabled} onClickCallback={toggleEnabled} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -659,7 +659,7 @@ export default function PivotTableSetupWidget({isEditable, widgetMetaData, recor
|
|||||||
// if this isn't a call from the on-submit handler, and we haven't previously attempted a submit, then return w/o setting any alerts //
|
// if this isn't a call from the on-submit handler, and we haven't previously attempted a submit, then return w/o setting any alerts //
|
||||||
// this is like a version of considering "touched"... //
|
// this is like a version of considering "touched"... //
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if(!submitting && !attemptedSubmit)
|
if (!submitting && !attemptedSubmit)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -703,7 +703,7 @@ export default function PivotTableSetupWidget({isEditable, widgetMetaData, recor
|
|||||||
// now they've fixed 'em - so go back to a 'clean' state - so if they add more //
|
// now they've fixed 'em - so go back to a 'clean' state - so if they add more //
|
||||||
// boxes, they won't immediately show errors, until a re-submit //
|
// boxes, they won't immediately show errors, until a re-submit //
|
||||||
////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
if(attemptedSubmit)
|
if (attemptedSubmit)
|
||||||
{
|
{
|
||||||
setAttemptedSubmit(false);
|
setAttemptedSubmit(false);
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ function RecordGridWidget({widgetMetaData, data, addNewRecordCallback, disableRo
|
|||||||
if(data && data.viewAllLink)
|
if(data && data.viewAllLink)
|
||||||
{
|
{
|
||||||
labelAdditionalElementsLeft.push(
|
labelAdditionalElementsLeft.push(
|
||||||
<Typography variant="body2" p={2} display="inline" fontSize=".875rem" pt="0" position="relative">
|
<Typography key={"viewAllLink"} variant="body2" p={2} display="inline" fontSize=".875rem" pt="0" position="relative">
|
||||||
<Link to={data.viewAllLink}>View All</Link>
|
<Link to={data.viewAllLink}>View All</Link>
|
||||||
</Typography>
|
</Typography>
|
||||||
)
|
)
|
||||||
@ -225,8 +225,8 @@ function RecordGridWidget({widgetMetaData, data, addNewRecordCallback, disableRo
|
|||||||
if(widgetMetaData?.showExportButton)
|
if(widgetMetaData?.showExportButton)
|
||||||
{
|
{
|
||||||
labelAdditionalElementsLeft.push(
|
labelAdditionalElementsLeft.push(
|
||||||
<Typography key={1} variant="body2" px={0} display="inline" position="relative">
|
<Typography key={"exportButton"} variant="body2" px={0} display="inline" position="relative">
|
||||||
<Tooltip title={tooltipTitle}><Button sx={{px: 1, py: 0, minWidth: "initial"}} onClick={onExportClick} disabled={isExportDisabled}><Icon sx={{color: "#757575", fontSize: 1.25}}>save_alt</Icon></Button></Tooltip>
|
<Tooltip title={tooltipTitle}><span><Button sx={{px: 1, py: 0, minWidth: "initial"}} onClick={onExportClick} disabled={isExportDisabled}><Icon sx={{color: "#757575", fontSize: 1.25}}>save_alt</Icon></Button></span></Tooltip>
|
||||||
</Typography>
|
</Typography>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -305,48 +305,50 @@ function RecordGridWidget({widgetMetaData, data, addNewRecordCallback, disableRo
|
|||||||
labelBoxAdditionalSx={{position: "relative", top: "-0.375rem"}}
|
labelBoxAdditionalSx={{position: "relative", top: "-0.375rem"}}
|
||||||
>
|
>
|
||||||
<Box mx={-2} mb={-3}>
|
<Box mx={-2} mb={-3}>
|
||||||
<DataGridPro
|
<Box className="recordGridWidget">
|
||||||
autoHeight
|
<DataGridPro
|
||||||
sx={{
|
autoHeight
|
||||||
borderBottom: "none",
|
sx={{
|
||||||
borderLeft: "none",
|
borderBottom: "none",
|
||||||
borderRight: "none"
|
borderLeft: "none",
|
||||||
}}
|
borderRight: "none"
|
||||||
rows={rows}
|
}}
|
||||||
disableSelectionOnClick
|
rows={rows}
|
||||||
columns={columns}
|
disableSelectionOnClick
|
||||||
rowBuffer={10}
|
columns={columns}
|
||||||
getRowClassName={(params) => (params.indexRelativeToCurrentPage % 2 === 0 ? "even" : "odd")}
|
rowBuffer={10}
|
||||||
onRowClick={handleRowClick}
|
getRowClassName={(params) => (params.indexRelativeToCurrentPage % 2 === 0 ? "even" : "odd")}
|
||||||
getRowId={(row) => row.__rowIndex}
|
onRowClick={handleRowClick}
|
||||||
// getRowHeight={() => "auto"} // maybe nice? wraps values in cells...
|
getRowId={(row) => row.__rowIndex}
|
||||||
components={{
|
// getRowHeight={() => "auto"} // maybe nice? wraps values in cells...
|
||||||
Toolbar: CustomToolbar
|
components={{
|
||||||
}}
|
Toolbar: CustomToolbar
|
||||||
// pinnedColumns={pinnedColumns}
|
}}
|
||||||
// onPinnedColumnsChange={handlePinnedColumnsChange}
|
// pinnedColumns={pinnedColumns}
|
||||||
// pagination
|
// onPinnedColumnsChange={handlePinnedColumnsChange}
|
||||||
// paginationMode="server"
|
// pagination
|
||||||
// rowsPerPageOptions={[20]}
|
// paginationMode="server"
|
||||||
// sortingMode="server"
|
// rowsPerPageOptions={[20]}
|
||||||
// filterMode="server"
|
// sortingMode="server"
|
||||||
// page={pageNumber}
|
// filterMode="server"
|
||||||
// checkboxSelection
|
// page={pageNumber}
|
||||||
rowCount={data && data.totalRows}
|
// checkboxSelection
|
||||||
// onPageSizeChange={handleRowsPerPageChange}
|
rowCount={data && data.totalRows}
|
||||||
// onStateChange={handleStateChange}
|
// onPageSizeChange={handleRowsPerPageChange}
|
||||||
// density={density}
|
// onStateChange={handleStateChange}
|
||||||
// loading={loading}
|
// density={density}
|
||||||
// filterModel={filterModel}
|
// loading={loading}
|
||||||
// onFilterModelChange={handleFilterChange}
|
// filterModel={filterModel}
|
||||||
// columnVisibilityModel={columnVisibilityModel}
|
// onFilterModelChange={handleFilterChange}
|
||||||
// onColumnVisibilityModelChange={handleColumnVisibilityChange}
|
// columnVisibilityModel={columnVisibilityModel}
|
||||||
// onColumnOrderChange={handleColumnOrderChange}
|
// onColumnVisibilityModelChange={handleColumnVisibilityChange}
|
||||||
// onSelectionModelChange={selectionChanged}
|
// onColumnOrderChange={handleColumnOrderChange}
|
||||||
// onSortModelChange={handleSortChange}
|
// onSelectionModelChange={selectionChanged}
|
||||||
// sortingOrder={[ "asc", "desc" ]}
|
// onSortModelChange={handleSortChange}
|
||||||
// sortModel={columnSortModel}
|
// sortingOrder={[ "asc", "desc" ]}
|
||||||
/>
|
// sortModel={columnSortModel}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Widget>
|
</Widget>
|
||||||
);
|
);
|
||||||
|
@ -46,8 +46,8 @@ interface ReportSetupWidgetProps
|
|||||||
{
|
{
|
||||||
isEditable: boolean;
|
isEditable: boolean;
|
||||||
widgetMetaData: QWidgetMetaData;
|
widgetMetaData: QWidgetMetaData;
|
||||||
recordValues: {[name: string]: any};
|
recordValues: { [name: string]: any };
|
||||||
onSaveCallback?: (values: {[name: string]: any}) => void;
|
onSaveCallback?: (values: { [name: string]: any }) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportSetupWidget.defaultProps = {
|
ReportSetupWidget.defaultProps = {
|
||||||
@ -103,14 +103,14 @@ export default function ReportSetupWidget({isEditable, widgetMetaData, recordVal
|
|||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
let queryFilter = recordValues["queryFilterJson"] && JSON.parse(recordValues["queryFilterJson"]) as QQueryFilter;
|
let queryFilter = recordValues["queryFilterJson"] && JSON.parse(recordValues["queryFilterJson"]) as QQueryFilter;
|
||||||
let usingDefaultEmptyFilter = false;
|
let usingDefaultEmptyFilter = false;
|
||||||
if(!queryFilter)
|
if (!queryFilter)
|
||||||
{
|
{
|
||||||
queryFilter = new QQueryFilter();
|
queryFilter = new QQueryFilter();
|
||||||
usingDefaultEmptyFilter = true;
|
usingDefaultEmptyFilter = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let columns: QQueryColumns = null;
|
let columns: QQueryColumns = null;
|
||||||
if(recordValues["columnsJson"])
|
if (recordValues["columnsJson"])
|
||||||
{
|
{
|
||||||
columns = QQueryColumns.buildFromJSON(recordValues["columnsJson"]);
|
columns = QQueryColumns.buildFromJSON(recordValues["columnsJson"]);
|
||||||
}
|
}
|
||||||
@ -124,12 +124,12 @@ export default function ReportSetupWidget({isEditable, widgetMetaData, recordVal
|
|||||||
{
|
{
|
||||||
(async () =>
|
(async () =>
|
||||||
{
|
{
|
||||||
const tableMetaData = await qController.loadTableMetaData(recordValues["tableName"])
|
const tableMetaData = await qController.loadTableMetaData(recordValues["tableName"]);
|
||||||
setTableMetaData(tableMetaData);
|
setTableMetaData(tableMetaData);
|
||||||
|
|
||||||
const queryFilterForFrontend = Object.assign({}, queryFilter);
|
const queryFilterForFrontend = Object.assign({}, queryFilter);
|
||||||
await FilterUtils.cleanupValuesInFilerFromQueryString(qController, tableMetaData, queryFilterForFrontend)
|
await FilterUtils.cleanupValuesInFilerFromQueryString(qController, tableMetaData, queryFilterForFrontend);
|
||||||
setFrontendQueryFilter(queryFilterForFrontend)
|
setFrontendQueryFilter(queryFilterForFrontend);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
}, [recordValues]);
|
}, [recordValues]);
|
||||||
@ -140,7 +140,7 @@ export default function ReportSetupWidget({isEditable, widgetMetaData, recordVal
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function openEditor()
|
function openEditor()
|
||||||
{
|
{
|
||||||
if(recordValues["tableName"])
|
if (recordValues["tableName"])
|
||||||
{
|
{
|
||||||
setModalOpen(true);
|
setModalOpen(true);
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ export default function ReportSetupWidget({isEditable, widgetMetaData, recordVal
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function saveClicked()
|
function saveClicked()
|
||||||
{
|
{
|
||||||
if(!onSaveCallback)
|
if (!onSaveCallback)
|
||||||
{
|
{
|
||||||
console.log("onSaveCallback was not defined");
|
console.log("onSaveCallback was not defined");
|
||||||
return;
|
return;
|
||||||
@ -181,7 +181,7 @@ export default function ReportSetupWidget({isEditable, widgetMetaData, recordVal
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function closeEditor(event?: {}, reason?: "backdropClick" | "escapeKeyDown")
|
function closeEditor(event?: {}, reason?: "backdropClick" | "escapeKeyDown")
|
||||||
{
|
{
|
||||||
if(reason == "backdropClick" || reason == "escapeKeyDown")
|
if (reason == "backdropClick" || reason == "escapeKeyDown")
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -195,9 +195,9 @@ export default function ReportSetupWidget({isEditable, widgetMetaData, recordVal
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function renderColumn(column: Column): JSX.Element
|
function renderColumn(column: Column): JSX.Element
|
||||||
{
|
{
|
||||||
const [field, table] = FilterUtils.getField(tableMetaData, column.name)
|
const [field, table] = FilterUtils.getField(tableMetaData, column.name);
|
||||||
|
|
||||||
if(!column || !column.isVisible || column.name == "__check__" || !field)
|
if (!column || !column.isVisible || column.name == "__check__" || !field)
|
||||||
{
|
{
|
||||||
return (<React.Fragment />);
|
return (<React.Fragment />);
|
||||||
}
|
}
|
||||||
@ -215,9 +215,9 @@ export default function ReportSetupWidget({isEditable, widgetMetaData, recordVal
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function mayShowQueryPreview(): boolean
|
function mayShowQueryPreview(): boolean
|
||||||
{
|
{
|
||||||
if(tableMetaData)
|
if (tableMetaData)
|
||||||
{
|
{
|
||||||
if(frontendQueryFilter?.criteria?.length > 0 || frontendQueryFilter?.subFilters?.length > 0)
|
if (frontendQueryFilter?.criteria?.length > 0 || frontendQueryFilter?.subFilters?.length > 0)
|
||||||
{
|
{
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
@ -231,11 +231,11 @@ export default function ReportSetupWidget({isEditable, widgetMetaData, recordVal
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function mayShowColumnsPreview(): boolean
|
function mayShowColumnsPreview(): boolean
|
||||||
{
|
{
|
||||||
if(tableMetaData)
|
if (tableMetaData)
|
||||||
{
|
{
|
||||||
for(let i = 0; i<columns?.columns?.length; i++)
|
for (let i = 0; i < columns?.columns?.length; i++)
|
||||||
{
|
{
|
||||||
if(columns.columns[i].isVisible && columns.columns[i].name != "__check__")
|
if (columns.columns[i].isVisible && columns.columns[i].name != "__check__")
|
||||||
{
|
{
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
@ -269,10 +269,10 @@ export default function ReportSetupWidget({isEditable, widgetMetaData, recordVal
|
|||||||
// add link to widget header for opening modal //
|
// add link to widget header for opening modal //
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
const selectTableFirstTooltipTitle = tableMetaData ? null : "You must select a table before you can set up your report filters and columns";
|
const selectTableFirstTooltipTitle = tableMetaData ? null : "You must select a table before you can set up your report filters and columns";
|
||||||
const labelAdditionalElementsRight: JSX.Element[] = []
|
const labelAdditionalElementsRight: JSX.Element[] = [];
|
||||||
if(isEditable)
|
if (isEditable)
|
||||||
{
|
{
|
||||||
labelAdditionalElementsRight.push(<HeaderLinkButtonComponent label="Edit Filters and Columns" onClickCallback={openEditor} disabled={tableMetaData == null} disabledTooltip={selectTableFirstTooltipTitle} />)
|
labelAdditionalElementsRight.push(<HeaderLinkButtonComponent key="filterAndColumnsHeader" label="Edit Filters and Columns" onClickCallback={openEditor} disabled={tableMetaData == null} disabledTooltip={selectTableFirstTooltipTitle} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ export default function ReportSetupWidget({isEditable, widgetMetaData, recordVal
|
|||||||
<Box display="flex" flexWrap="wrap" fontSize="1rem">
|
<Box display="flex" flexWrap="wrap" fontSize="1rem">
|
||||||
{
|
{
|
||||||
mayShowColumnsPreview() &&
|
mayShowColumnsPreview() &&
|
||||||
columns.columns.map((column, i) => <React.Fragment key={i}>{renderColumn(column)}</React.Fragment>)
|
columns.columns.map((column, i) => <React.Fragment key={`column-${i}`}>{renderColumn(column)}</React.Fragment>)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
!mayShowColumnsPreview() &&
|
!mayShowColumnsPreview() &&
|
||||||
|
@ -29,6 +29,7 @@ export interface FieldRule
|
|||||||
sourceField: string;
|
sourceField: string;
|
||||||
action: FieldRuleAction;
|
action: FieldRuleAction;
|
||||||
targetField: string;
|
targetField: string;
|
||||||
|
targetWidget: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -46,5 +47,6 @@ export enum FieldRuleTrigger
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
export enum FieldRuleAction
|
export enum FieldRuleAction
|
||||||
{
|
{
|
||||||
CLEAR_TARGET_FIELD = "CLEAR_TARGET_FIELD"
|
CLEAR_TARGET_FIELD = "CLEAR_TARGET_FIELD",
|
||||||
|
RELOAD_WIDGET = "RELOAD_WIDGET"
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,7 @@ import {QJobRunning} from "@kingsrook/qqq-frontend-core/lib/model/processes/QJob
|
|||||||
import {QJobStarted} from "@kingsrook/qqq-frontend-core/lib/model/processes/QJobStarted";
|
import {QJobStarted} from "@kingsrook/qqq-frontend-core/lib/model/processes/QJobStarted";
|
||||||
import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord";
|
import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord";
|
||||||
import {QQueryFilter} from "@kingsrook/qqq-frontend-core/lib/model/query/QQueryFilter";
|
import {QQueryFilter} from "@kingsrook/qqq-frontend-core/lib/model/query/QQueryFilter";
|
||||||
import {Alert, Button, CircularProgress, Icon, TablePagination} from "@mui/material";
|
import {Alert, Box, Button, CircularProgress, Icon, TablePagination} from "@mui/material";
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Card from "@mui/material/Card";
|
import Card from "@mui/material/Card";
|
||||||
import Grid from "@mui/material/Grid";
|
import Grid from "@mui/material/Grid";
|
||||||
import Step from "@mui/material/Step";
|
import Step from "@mui/material/Step";
|
||||||
@ -48,16 +47,19 @@ import FormData from "form-data";
|
|||||||
import {Form, Formik} from "formik";
|
import {Form, Formik} from "formik";
|
||||||
import parse from "html-react-parser";
|
import parse from "html-react-parser";
|
||||||
import QContext from "QContext";
|
import QContext from "QContext";
|
||||||
|
import colors from "qqq/assets/theme/base/colors";
|
||||||
import {QCancelButton, QSubmitButton} from "qqq/components/buttons/DefaultButtons";
|
import {QCancelButton, QSubmitButton} from "qqq/components/buttons/DefaultButtons";
|
||||||
import QDynamicForm from "qqq/components/forms/DynamicForm";
|
import QDynamicForm from "qqq/components/forms/DynamicForm";
|
||||||
import DynamicFormUtils from "qqq/components/forms/DynamicFormUtils";
|
import DynamicFormUtils from "qqq/components/forms/DynamicFormUtils";
|
||||||
import MDButton from "qqq/components/legacy/MDButton";
|
import MDButton from "qqq/components/legacy/MDButton";
|
||||||
import MDProgress from "qqq/components/legacy/MDProgress";
|
import MDProgress from "qqq/components/legacy/MDProgress";
|
||||||
import MDTypography from "qqq/components/legacy/MDTypography";
|
import MDTypography from "qqq/components/legacy/MDTypography";
|
||||||
|
import HelpContent from "qqq/components/misc/HelpContent";
|
||||||
import QRecordSidebar from "qqq/components/misc/RecordSidebar";
|
import QRecordSidebar from "qqq/components/misc/RecordSidebar";
|
||||||
import {GoogleDriveFolderPickerWrapper} from "qqq/components/processes/GoogleDriveFolderPickerWrapper";
|
import {GoogleDriveFolderPickerWrapper} from "qqq/components/processes/GoogleDriveFolderPickerWrapper";
|
||||||
import ProcessSummaryResults from "qqq/components/processes/ProcessSummaryResults";
|
import ProcessSummaryResults from "qqq/components/processes/ProcessSummaryResults";
|
||||||
import ValidationReview from "qqq/components/processes/ValidationReview";
|
import ValidationReview from "qqq/components/processes/ValidationReview";
|
||||||
|
import DashboardWidgets from "qqq/components/widgets/DashboardWidgets";
|
||||||
import BaseLayout from "qqq/layouts/BaseLayout";
|
import BaseLayout from "qqq/layouts/BaseLayout";
|
||||||
import {TABLE_VARIANT_LOCAL_STORAGE_KEY_ROOT} from "qqq/pages/records/query/RecordQuery";
|
import {TABLE_VARIANT_LOCAL_STORAGE_KEY_ROOT} from "qqq/pages/records/query/RecordQuery";
|
||||||
import Client from "qqq/utils/qqq/Client";
|
import Client from "qqq/utils/qqq/Client";
|
||||||
@ -86,6 +88,14 @@ const INITIAL_RETRY_MILLIS = 1_500;
|
|||||||
const RETRY_MAX_MILLIS = 12_000;
|
const RETRY_MAX_MILLIS = 12_000;
|
||||||
const BACKOFF_AMOUNT = 1.5;
|
const BACKOFF_AMOUNT = 1.5;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// define a function that we can make referenes to, which we'll overwrite //
|
||||||
|
// with formik's setFieldValue function, once we're inside formik. //
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
let formikSetFieldValueFunction = (field: string, value: any, shouldValidate?: boolean): void =>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, isReport, recordIds, closeModalHandler, forceReInit, overrideLabel}: Props): JSX.Element
|
function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, isReport, recordIds, closeModalHandler, forceReInit, overrideLabel}: Props): JSX.Element
|
||||||
{
|
{
|
||||||
const processNameParam = useParams().processName;
|
const processNameParam = useParams().processName;
|
||||||
@ -124,6 +134,8 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
const [showErrorDetail, setShowErrorDetail] = useState(false);
|
const [showErrorDetail, setShowErrorDetail] = useState(false);
|
||||||
const [showFullHelpText, setShowFullHelpText] = useState(false);
|
const [showFullHelpText, setShowFullHelpText] = useState(false);
|
||||||
|
|
||||||
|
const [renderedWidgets, setRenderedWidgets] = useState({} as {[step: string]: {[widgetName: string]: any}});
|
||||||
|
|
||||||
const {pageHeader, recordAnalytics, setPageHeader} = useContext(QContext);
|
const {pageHeader, recordAnalytics, setPageHeader} = useContext(QContext);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -273,6 +285,42 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
function renderWidget(widgetName: string)
|
||||||
|
{
|
||||||
|
if(!renderedWidgets[activeStep.name])
|
||||||
|
{
|
||||||
|
renderedWidgets[activeStep.name] = {};
|
||||||
|
setRenderedWidgets(renderedWidgets);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(renderedWidgets[activeStep.name][widgetName])
|
||||||
|
{
|
||||||
|
return renderedWidgets[activeStep.name][widgetName];
|
||||||
|
}
|
||||||
|
|
||||||
|
const widgetMetaData = qInstance.widgets.get(widgetName);
|
||||||
|
if(!widgetMetaData)
|
||||||
|
{
|
||||||
|
return (<Alert color="error">Unrecognized widget name: {widgetName}</Alert>);
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryStringParts: string[] = [];
|
||||||
|
for (let name in processValues)
|
||||||
|
{
|
||||||
|
queryStringParts.push(`${name}=${encodeURIComponent(processValues[name])}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const renderedWidget = (<Box m={-2}>
|
||||||
|
<DashboardWidgets widgetMetaDataList={[widgetMetaData]} omitWrappingGridContainer={true} childUrlParams={queryStringParts.join("&")} />
|
||||||
|
</Box>)
|
||||||
|
renderedWidgets[activeStep.name][widgetName] = renderedWidget;
|
||||||
|
return renderedWidget;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
// generate the main form body content for a step //
|
// generate the main form body content for a step //
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
@ -407,6 +455,15 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo not commit - not ready - need process (or screen) meta-data to have helpContents...
|
||||||
|
/*
|
||||||
|
///////////////////////////////
|
||||||
|
// screen-level help content //
|
||||||
|
///////////////////////////////
|
||||||
|
let helpRoles = ["PROCESS_SCREEN", "ALL_SCREENS"];
|
||||||
|
const formattedHelpContent = <HelpContent helpContents={process.helpContents} roles={helpRoles} helpContentKey={`table:${tableName};section:${section.name}`} />;
|
||||||
|
*/
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{
|
{
|
||||||
@ -421,6 +478,16 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
</MDTypography>
|
</MDTypography>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
// todo not commit - not ready - need process (or screen) meta-data to have helpContents...
|
||||||
|
formattedHelpContent &&
|
||||||
|
<Box px={"1.5rem"} fontSize={"0.875rem"} color={colors.blueGray.main}>
|
||||||
|
{formattedHelpContent}
|
||||||
|
</Box>
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
// render all of the components for this screen //
|
// render all of the components for this screen //
|
||||||
@ -433,6 +500,23 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
helpRoles = ["EDIT_SCREEN", "WRITE_SCREENS", "ALL_SCREENS"];
|
helpRoles = ["EDIT_SCREEN", "WRITE_SCREENS", "ALL_SCREENS"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// if the component specifies a sub-set of field names to include, then //
|
||||||
|
// edit the formData object to just include those. //
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
let formDataToUse = formData;
|
||||||
|
if(component.values && component.values.includeFieldNames)
|
||||||
|
{
|
||||||
|
formDataToUse = Object.assign({}, formData);
|
||||||
|
|
||||||
|
formDataToUse.formFields = {};
|
||||||
|
for (let i = 0; i < component.values.includeFieldNames.length; i++)
|
||||||
|
{
|
||||||
|
const fieldName = component.values.includeFieldNames[i];
|
||||||
|
formDataToUse.formFields[fieldName] = formData.formFields[fieldName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={index}>
|
<div key={index}>
|
||||||
{
|
{
|
||||||
@ -528,9 +612,22 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
component.type === QComponentType.EDIT_FORM && (
|
component.type === QComponentType.EDIT_FORM &&
|
||||||
<QDynamicForm formData={formData} helpRoles={helpRoles} helpContentKeyPrefix={`process:${processName};`} />
|
<>
|
||||||
)
|
{
|
||||||
|
component.values?.sectionLabel ?
|
||||||
|
<Box py={1.5}>
|
||||||
|
<Card sx={{scrollMarginTop: "20px"}}>
|
||||||
|
<MDTypography variant="h5" p={3} pl={2} pb={1}>
|
||||||
|
{component.values?.sectionLabel}
|
||||||
|
</MDTypography>
|
||||||
|
<Box pt={0} p={2}>
|
||||||
|
<QDynamicForm formData={formDataToUse} helpRoles={helpRoles} helpContentKeyPrefix={`process:${processName};`} />
|
||||||
|
</Box>
|
||||||
|
</Card>
|
||||||
|
</Box> : <QDynamicForm formData={formDataToUse} helpRoles={helpRoles} helpContentKeyPrefix={`process:${processName};`} />
|
||||||
|
}
|
||||||
|
</>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
component.type === QComponentType.VIEW_FORM && step.viewFields && (
|
component.type === QComponentType.VIEW_FORM && step.viewFields && (
|
||||||
@ -653,6 +750,12 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
component.type === QComponentType.WIDGET && (
|
||||||
|
component.values?.widgetName &&
|
||||||
|
renderWidget(component.values?.widgetName)
|
||||||
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}))
|
}))
|
||||||
@ -981,6 +1084,26 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
setProcessValues(qJobComplete.values);
|
setProcessValues(qJobComplete.values);
|
||||||
setQJobRunning(null);
|
setQJobRunning(null);
|
||||||
|
|
||||||
|
if(formikSetFieldValueFunction)
|
||||||
|
{
|
||||||
|
//////////////////////////////////
|
||||||
|
// reset field values in formik //
|
||||||
|
//////////////////////////////////
|
||||||
|
for (let key in qJobComplete.values)
|
||||||
|
{
|
||||||
|
formikSetFieldValueFunction(key, qJobComplete.values[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// if the process step sent a new frontend-step-list, then refresh what we have in state (constructing new full model objects) //
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const updatedFrontendStepList = qJobComplete.updatedFrontendStepList;
|
||||||
|
if(updatedFrontendStepList)
|
||||||
|
{
|
||||||
|
setSteps(updatedFrontendStepList);
|
||||||
|
}
|
||||||
|
|
||||||
if (activeStep && activeStep.recordListFields)
|
if (activeStep && activeStep.recordListFields)
|
||||||
{
|
{
|
||||||
setNeedRecords(true);
|
setNeedRecords(true);
|
||||||
@ -1340,89 +1463,98 @@ function ProcessRun({process, table, defaultProcessValues, isModal, isWidget, is
|
|||||||
>
|
>
|
||||||
{({
|
{({
|
||||||
values, errors, touched, isSubmitting, setFieldValue,
|
values, errors, touched, isSubmitting, setFieldValue,
|
||||||
}) => (
|
}) =>
|
||||||
<Form style={formStyles} id={formId} autoComplete="off">
|
{
|
||||||
<Card sx={mainCardStyles}>
|
///////////////////////////////////////////////////////////////////
|
||||||
{
|
// once we're in the formik form, use its setFieldValue function //
|
||||||
!isWidget && (
|
// over top of the default one we created globally //
|
||||||
<Box mx={2} mt={-3}>
|
///////////////////////////////////////////////////////////////////
|
||||||
<Stepper activeStep={activeStepIndex} alternativeLabel>
|
formikSetFieldValueFunction = setFieldValue;
|
||||||
{steps.map((step) => (
|
|
||||||
<Step key={step.name}>
|
|
||||||
<StepLabel>{step.label}</StepLabel>
|
|
||||||
</Step>
|
|
||||||
))}
|
|
||||||
</Stepper>
|
|
||||||
</Box>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
<Box p={3}>
|
return (
|
||||||
<Box pb={isWidget ? 6 : "initial"}>
|
<Form style={formStyles} id={formId} autoComplete="off">
|
||||||
{/***************************************************************************
|
<Card sx={mainCardStyles}>
|
||||||
|
{
|
||||||
|
!isWidget && (
|
||||||
|
<Box mx={2} mt={-3} sx={{"& .MuiStepper-horizontal": {minHeight: "5rem"}}}>
|
||||||
|
<Stepper activeStep={activeStepIndex} alternativeLabel>
|
||||||
|
{steps.map((step) => (
|
||||||
|
<Step key={step.name}>
|
||||||
|
<StepLabel>{step.label}</StepLabel>
|
||||||
|
</Step>
|
||||||
|
))}
|
||||||
|
</Stepper>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
<Box p={3}>
|
||||||
|
<Box pb={isWidget ? 6 : "initial"}>
|
||||||
|
{/***************************************************************************
|
||||||
** step content - e.g., the appropriate form or other screen for the step **
|
** step content - e.g., the appropriate form or other screen for the step **
|
||||||
***************************************************************************/}
|
***************************************************************************/}
|
||||||
{getDynamicStepContent(
|
{getDynamicStepContent(
|
||||||
activeStepIndex,
|
activeStepIndex,
|
||||||
activeStep,
|
activeStep,
|
||||||
{
|
{
|
||||||
values,
|
values,
|
||||||
touched,
|
touched,
|
||||||
formFields,
|
formFields,
|
||||||
errors,
|
errors,
|
||||||
},
|
},
|
||||||
processError,
|
processError,
|
||||||
processValues,
|
processValues,
|
||||||
recordConfig,
|
recordConfig,
|
||||||
setFieldValue,
|
setFieldValue,
|
||||||
)}
|
)}
|
||||||
{/********************************
|
{/********************************
|
||||||
** back &| next/submit buttons **
|
** back &| next/submit buttons **
|
||||||
********************************/}
|
********************************/}
|
||||||
<Box mt={6} width="100%" display="flex" justifyContent="space-between" position={isWidget ? "absolute" : "initial"} bottom={isWidget ? "3rem" : "initial"} right={isWidget ? "1.5rem" : "initial"}>
|
<Box mt={6} width="100%" display="flex" justifyContent="space-between" position={isWidget ? "absolute" : "initial"} bottom={isWidget ? "3rem" : "initial"} right={isWidget ? "1.5rem" : "initial"}>
|
||||||
{true || activeStepIndex === 0 ? (
|
{true || activeStepIndex === 0 ? (
|
||||||
<Box />
|
<Box />
|
||||||
) : (
|
) : (
|
||||||
<MDButton variant="gradient" color="light" onClick={handleBack}>back</MDButton>
|
<MDButton variant="gradient" color="light" onClick={handleBack}>back</MDButton>
|
||||||
)}
|
)}
|
||||||
{processError || qJobRunning || !activeStep ? (
|
{processError || qJobRunning || !activeStep ? (
|
||||||
<Box />
|
<Box />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{formError && (
|
{formError && (
|
||||||
<MDTypography component="div" variant="caption" color="error" fontWeight="regular" align="right" fullWidth>
|
<MDTypography component="div" variant="caption" color="error" fontWeight="regular" align="right" fullWidth>
|
||||||
{formError}
|
{formError}
|
||||||
</MDTypography>
|
</MDTypography>
|
||||||
)}
|
)}
|
||||||
{
|
{
|
||||||
noMoreSteps && <QCancelButton
|
noMoreSteps && <QCancelButton
|
||||||
onClickHandler={handleCancelClicked}
|
onClickHandler={handleCancelClicked}
|
||||||
label={isModal ? "Close" : "Return"}
|
label={isModal ? "Close" : "Return"}
|
||||||
iconName={isModal ? "cancel" : "arrow_back"}
|
iconName={isModal ? "cancel" : "arrow_back"}
|
||||||
disabled={isSubmitting} />
|
disabled={isSubmitting} />
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
!noMoreSteps && (
|
!noMoreSteps && (
|
||||||
<Box component="div" py={3}>
|
<Box component="div" py={3}>
|
||||||
<Grid container justifyContent="flex-end" spacing={3}>
|
<Grid container justifyContent="flex-end" spacing={3}>
|
||||||
{
|
{
|
||||||
!isWidget && (
|
!isWidget && (
|
||||||
<QCancelButton onClickHandler={handleCancelClicked} disabled={isSubmitting} />
|
<QCancelButton onClickHandler={handleCancelClicked} disabled={isSubmitting} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
<QSubmitButton label={nextButtonLabel} iconName={nextButtonIcon} disabled={isSubmitting} />
|
<QSubmitButton label={nextButtonLabel} iconName={nextButtonIcon} disabled={isSubmitting} />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Card>
|
||||||
</Card>
|
</Form>
|
||||||
</Form>
|
)
|
||||||
)}
|
}}
|
||||||
</Formik>
|
</Formik>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ const qController = Client.getInstance();
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const getLoadingScreen = (isModal: boolean) =>
|
const getLoadingScreen = (isModal: boolean) =>
|
||||||
{
|
{
|
||||||
if(isModal)
|
if (isModal)
|
||||||
{
|
{
|
||||||
return (<Box> </Box>);
|
return (<Box> </Box>);
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function localStorageSet(key: string, value: string)
|
function localStorageSet(key: string, value: string)
|
||||||
{
|
{
|
||||||
if(mayWriteLocalStorage)
|
if (mayWriteLocalStorage)
|
||||||
{
|
{
|
||||||
localStorage.setItem(key, value);
|
localStorage.setItem(key, value);
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function localStorageRemove(key: string)
|
function localStorageRemove(key: string)
|
||||||
{
|
{
|
||||||
if(mayWriteLocalStorage)
|
if (mayWriteLocalStorage)
|
||||||
{
|
{
|
||||||
localStorage.removeItem(key);
|
localStorage.removeItem(key);
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
{
|
{
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -256,7 +256,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
defaultView.mode = defaultMode;
|
defaultView.mode = defaultMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// allow a caller to send in an initial filter & set of columns. //
|
// allow a caller to send in an initial filter & set of columns. //
|
||||||
@ -408,7 +408,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
// we use our own header - so clear out the context page header //
|
// we use our own header - so clear out the context page header //
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
if(!isModal)
|
if (!isModal)
|
||||||
{
|
{
|
||||||
setPageHeader(null);
|
setPageHeader(null);
|
||||||
}
|
}
|
||||||
@ -486,7 +486,6 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -711,7 +710,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
{
|
{
|
||||||
if (localStorage.getItem(currentSavedViewLocalStorageKey))
|
if (localStorage.getItem(currentSavedViewLocalStorageKey))
|
||||||
{
|
{
|
||||||
if(usage == "queryScreen")
|
if (usage == "queryScreen")
|
||||||
{
|
{
|
||||||
currentSavedViewId = Number.parseInt(localStorage.getItem(currentSavedViewLocalStorageKey));
|
currentSavedViewId = Number.parseInt(localStorage.getItem(currentSavedViewLocalStorageKey));
|
||||||
navigate(`${metaData.getTablePathByName(tableName)}/savedView/${currentSavedViewId}`);
|
navigate(`${metaData.getTablePathByName(tableName)}/savedView/${currentSavedViewId}`);
|
||||||
@ -750,13 +749,13 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
const viewForLocalStorage: RecordQueryView = JSON.parse(viewAsJSON);
|
const viewForLocalStorage: RecordQueryView = JSON.parse(viewAsJSON);
|
||||||
if (viewForLocalStorage?.queryFilter?.criteria?.length > 0)
|
if (viewForLocalStorage?.queryFilter?.criteria?.length > 0)
|
||||||
{
|
{
|
||||||
FilterUtils.stripAwayIncompleteCriteria(viewForLocalStorage.queryFilter)
|
FilterUtils.stripAwayIncompleteCriteria(viewForLocalStorage.queryFilter);
|
||||||
}
|
}
|
||||||
localStorageSet(viewLocalStorageKey, JSON.stringify(viewForLocalStorage));
|
localStorageSet(viewLocalStorageKey, JSON.stringify(viewForLocalStorage));
|
||||||
}
|
}
|
||||||
catch(e)
|
catch (e)
|
||||||
{
|
{
|
||||||
console.log("Error storing view in local storage: " + e)
|
console.log("Error storing view in local storage: " + e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -868,7 +867,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
for (let i = 0; i < queryFilter?.orderBys?.length; i++)
|
for (let i = 0; i < queryFilter?.orderBys?.length; i++)
|
||||||
{
|
{
|
||||||
const fieldName = queryFilter.orderBys[i].fieldName;
|
const fieldName = queryFilter.orderBys[i].fieldName;
|
||||||
if (fieldName.indexOf(".") > -1)
|
if (fieldName != null && fieldName.indexOf(".") > -1)
|
||||||
{
|
{
|
||||||
const joinTableName = fieldName.replaceAll(/\..*/g, "");
|
const joinTableName = fieldName.replaceAll(/\..*/g, "");
|
||||||
if (!vjtToUse.has(joinTableName))
|
if (!vjtToUse.has(joinTableName))
|
||||||
@ -901,6 +900,26 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// if any values in the query are of type "FilterVariableExpression", display an error showing //
|
||||||
|
// that a backend query cannot be made because of missing values for that expression //
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
setWarningAlert(null);
|
||||||
|
for (var i = 0; i < queryFilter?.criteria?.length; i++)
|
||||||
|
{
|
||||||
|
for (var j = 0; j < queryFilter?.criteria[i]?.values?.length; j++)
|
||||||
|
{
|
||||||
|
const value = queryFilter.criteria[i].values[j];
|
||||||
|
if (value?.type == "FilterVariableExpression")
|
||||||
|
{
|
||||||
|
setWarningAlert("Cannot perform query because of a missing value for a variable.");
|
||||||
|
setLoading(false);
|
||||||
|
setRows([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
recordAnalytics({category: "tableEvents", action: "query", label: tableMetaData.label});
|
recordAnalytics({category: "tableEvents", action: "query", label: tableMetaData.label});
|
||||||
|
|
||||||
console.log(`In updateTable for ${reason} ${JSON.stringify(queryFilter)}`);
|
console.log(`In updateTable for ${reason} ${JSON.stringify(queryFilter)}`);
|
||||||
@ -939,7 +958,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
console.log(`Issuing query: ${thisQueryId}`);
|
console.log(`Issuing query: ${thisQueryId}`);
|
||||||
if (tableMetaData.capabilities.has(Capability.TABLE_COUNT))
|
if (tableMetaData.capabilities.has(Capability.TABLE_COUNT))
|
||||||
{
|
{
|
||||||
if(clearOutCount)
|
if (clearOutCount)
|
||||||
{
|
{
|
||||||
setTotalRecords(null);
|
setTotalRecords(null);
|
||||||
setDistinctRecords(null);
|
setDistinctRecords(null);
|
||||||
@ -1437,7 +1456,6 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
return (selectedIds.length);
|
return (selectedIds.length);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** get a query-string to put on the url to indicate what records are going into
|
** get a query-string to put on the url to indicate what records are going into
|
||||||
** a process.
|
** a process.
|
||||||
@ -2527,7 +2545,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
{
|
{
|
||||||
const currentSavedViewId = Number.parseInt(localStorage.getItem(currentSavedViewLocalStorageKey));
|
const currentSavedViewId = Number.parseInt(localStorage.getItem(currentSavedViewLocalStorageKey));
|
||||||
console.log(`returning to previously active saved view ${currentSavedViewId}`);
|
console.log(`returning to previously active saved view ${currentSavedViewId}`);
|
||||||
if(usage == "queryScreen")
|
if (usage == "queryScreen")
|
||||||
{
|
{
|
||||||
navigate(`${metaData.getTablePathByName(tableName)}/savedView/${currentSavedViewId}`);
|
navigate(`${metaData.getTablePathByName(tableName)}/savedView/${currentSavedViewId}`);
|
||||||
}
|
}
|
||||||
@ -2770,7 +2788,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
spaceAboveGrid += 60;
|
spaceAboveGrid += 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isModal)
|
if (isModal)
|
||||||
{
|
{
|
||||||
spaceAboveGrid += 130;
|
spaceAboveGrid += 130;
|
||||||
}
|
}
|
||||||
@ -2890,6 +2908,7 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
filterPanel:
|
filterPanel:
|
||||||
{
|
{
|
||||||
tableMetaData: tableMetaData,
|
tableMetaData: tableMetaData,
|
||||||
|
queryScreenUsage: usage,
|
||||||
metaData: metaData,
|
metaData: metaData,
|
||||||
queryFilter: queryFilter,
|
queryFilter: queryFilter,
|
||||||
updateFilter: doSetQueryFilter,
|
updateFilter: doSetQueryFilter,
|
||||||
@ -2976,15 +2995,15 @@ const RecordQuery = forwardRef(({table, usage, isModal, initialQueryFilter, init
|
|||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
|
||||||
if(isModal)
|
if (isModal)
|
||||||
{
|
{
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseLayout>{body}</BaseLayout>
|
<BaseLayout>{body}</BaseLayout>
|
||||||
)
|
);
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
RecordQuery.defaultProps = {
|
RecordQuery.defaultProps = {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
import {QException} from "@kingsrook/qqq-frontend-core/lib/exceptions/QException";
|
import {QException} from "@kingsrook/qqq-frontend-core/lib/exceptions/QException";
|
||||||
import {Capability} from "@kingsrook/qqq-frontend-core/lib/model/metaData/Capability";
|
import {Capability} from "@kingsrook/qqq-frontend-core/lib/model/metaData/Capability";
|
||||||
|
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
||||||
import {QInstance} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QInstance";
|
import {QInstance} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QInstance";
|
||||||
import {QProcessMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QProcessMetaData";
|
import {QProcessMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QProcessMetaData";
|
||||||
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
||||||
@ -73,22 +74,94 @@ const qController = Client.getInstance();
|
|||||||
interface Props
|
interface Props
|
||||||
{
|
{
|
||||||
table?: QTableMetaData;
|
table?: QTableMetaData;
|
||||||
|
record?: QRecord;
|
||||||
launchProcess?: QProcessMetaData;
|
launchProcess?: QProcessMetaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordView.defaultProps =
|
RecordView.defaultProps =
|
||||||
{
|
{
|
||||||
table: null,
|
table: null,
|
||||||
|
record: null,
|
||||||
launchProcess: null,
|
launchProcess: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const TABLE_VARIANT_LOCAL_STORAGE_KEY_ROOT = "qqq.tableVariant";
|
const TABLE_VARIANT_LOCAL_STORAGE_KEY_ROOT = "qqq.tableVariant";
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
export function renderSectionOfFields(key: string, fieldNames: string[], tableMetaData: QTableMetaData, helpHelpActive: boolean, record: QRecord, fieldMap?: {[name: string]: QFieldMetaData} )
|
||||||
|
{
|
||||||
|
return <Box key={key} display="flex" flexDirection="column" py={1} pr={2}>
|
||||||
|
{
|
||||||
|
fieldNames.map((fieldName: string) =>
|
||||||
|
{
|
||||||
|
let [field, tableForField] = tableMetaData ? TableUtils.getFieldAndTable(tableMetaData, fieldName) : fieldMap ? [fieldMap[fieldName], null] : [null, null];
|
||||||
|
|
||||||
|
if (field != null)
|
||||||
|
{
|
||||||
|
let label = field.label;
|
||||||
|
|
||||||
|
const helpRoles = ["VIEW_SCREEN", "READ_SCREENS", "ALL_SCREENS"];
|
||||||
|
const showHelp = helpHelpActive || hasHelpContent(field.helpContents, helpRoles);
|
||||||
|
const formattedHelpContent = <HelpContent helpContents={field.helpContents} roles={helpRoles} heading={label} helpContentKey={`table:${tableMetaData?.name};field:${fieldName}`} />;
|
||||||
|
|
||||||
|
const labelElement = <Typography variant="button" textTransform="none" fontWeight="bold" pr={1} color="rgb(52, 71, 103)" sx={{cursor: "default"}}>{label}:</Typography>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box key={fieldName} flexDirection="row" pr={2}>
|
||||||
|
<>
|
||||||
|
{
|
||||||
|
showHelp && formattedHelpContent ? <Tooltip title={formattedHelpContent}>{labelElement}</Tooltip> : labelElement
|
||||||
|
}
|
||||||
|
<div style={{display: "inline-block", width: 0}}> </div>
|
||||||
|
<Typography variant="button" textTransform="none" fontWeight="regular" color="rgb(123, 128, 154)">
|
||||||
|
{ValueUtils.getDisplayValue(field, record, "view", fieldName)}
|
||||||
|
</Typography>
|
||||||
|
</>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</Box>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
***************************************************************************/
|
||||||
|
export function getVisibleJoinTables(tableMetaData: QTableMetaData): Set<string>
|
||||||
|
{
|
||||||
|
const visibleJoinTables = new Set<string>();
|
||||||
|
|
||||||
|
for (let i = 0; i < tableMetaData?.sections.length; i++)
|
||||||
|
{
|
||||||
|
const section = tableMetaData?.sections[i];
|
||||||
|
if (section.isHidden || !section.fieldNames || !section.fieldNames.length)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
section.fieldNames.forEach((fieldName) =>
|
||||||
|
{
|
||||||
|
const [field, tableForField] = TableUtils.getFieldAndTable(tableMetaData, fieldName);
|
||||||
|
if (tableForField && tableForField.name != tableMetaData.name)
|
||||||
|
{
|
||||||
|
visibleJoinTables.add(tableForField.name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (visibleJoinTables);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Record View Screen component.
|
** Record View Screen component.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function RecordView({table, launchProcess}: Props): JSX.Element
|
function RecordView({table, record: overrideRecord, launchProcess}: Props): JSX.Element
|
||||||
{
|
{
|
||||||
const {id} = useParams();
|
const {id} = useParams();
|
||||||
|
|
||||||
@ -105,7 +178,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
const [adornmentFieldsMap, setAdornmentFieldsMap] = useState(new Map<string, boolean>);
|
const [adornmentFieldsMap, setAdornmentFieldsMap] = useState(new Map<string, boolean>);
|
||||||
const [deleteConfirmationOpen, setDeleteConfirmationOpen] = useState(false);
|
const [deleteConfirmationOpen, setDeleteConfirmationOpen] = useState(false);
|
||||||
const [metaData, setMetaData] = useState(null as QInstance);
|
const [metaData, setMetaData] = useState(null as QInstance);
|
||||||
const [record, setRecord] = useState(null as QRecord);
|
const [record, setRecord] = useState(overrideRecord ?? null as QRecord);
|
||||||
const [tableSections, setTableSections] = useState([] as QTableSection[]);
|
const [tableSections, setTableSections] = useState([] as QTableSection[]);
|
||||||
const [t1Section, setT1Section] = useState(null as QTableSection);
|
const [t1Section, setT1Section] = useState(null as QTableSection);
|
||||||
const [t1SectionName, setT1SectionName] = useState(null as string);
|
const [t1SectionName, setT1SectionName] = useState(null as string);
|
||||||
@ -130,7 +203,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
const openActionsMenu = (event: any) => setActionsMenu(event.currentTarget);
|
const openActionsMenu = (event: any) => setActionsMenu(event.currentTarget);
|
||||||
const closeActionsMenu = () => setActionsMenu(null);
|
const closeActionsMenu = () => setActionsMenu(null);
|
||||||
|
|
||||||
const {accentColor, setPageHeader, tableMetaData, setTableMetaData, tableProcesses, setTableProcesses, dotMenuOpen, keyboardHelpOpen, helpHelpActive, recordAnalytics} = useContext(QContext);
|
const {accentColor, setPageHeader, tableMetaData, setTableMetaData, tableProcesses, setTableProcesses, dotMenuOpen, keyboardHelpOpen, helpHelpActive, recordAnalytics, userId: currentUserId} = useContext(QContext);
|
||||||
|
|
||||||
if (localStorage.getItem(tableVariantLocalStorageKey))
|
if (localStorage.getItem(tableVariantLocalStorageKey))
|
||||||
{
|
{
|
||||||
@ -339,31 +412,6 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
reload();
|
reload();
|
||||||
}, [location.pathname, location.hash]);
|
}, [location.pathname, location.hash]);
|
||||||
|
|
||||||
const getVisibleJoinTables = (tableMetaData: QTableMetaData): Set<string> =>
|
|
||||||
{
|
|
||||||
const visibleJoinTables = new Set<string>();
|
|
||||||
|
|
||||||
for (let i = 0; i < tableMetaData?.sections.length; i++)
|
|
||||||
{
|
|
||||||
const section = tableMetaData?.sections[i];
|
|
||||||
if (section.isHidden || !section.fieldNames || !section.fieldNames.length)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
section.fieldNames.forEach((fieldName) =>
|
|
||||||
{
|
|
||||||
const [field, tableForField] = TableUtils.getFieldAndTable(tableMetaData, fieldName);
|
|
||||||
if (tableForField && tableForField.name != tableMetaData.name)
|
|
||||||
{
|
|
||||||
visibleJoinTables.add(tableForField.name);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return (visibleJoinTables);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** get an element (or empty) to use as help content for a section
|
** get an element (or empty) to use as help content for a section
|
||||||
@ -439,7 +487,18 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
let record: QRecord;
|
let record: QRecord;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
record = await qController.get(tableName, id, tableVariant, null, queryJoins);
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// if the component took in a record object, then we don't need to GET it //
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
if(overrideRecord)
|
||||||
|
{
|
||||||
|
record = overrideRecord;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
record = await qController.get(tableName, id, tableVariant, null, queryJoins);
|
||||||
|
}
|
||||||
|
|
||||||
setRecord(record);
|
setRecord(record);
|
||||||
recordAnalytics({category: "tableEvents", action: "view", label: tableMetaData?.label + " / " + record?.recordLabel});
|
recordAnalytics({category: "tableEvents", action: "view", label: tableMetaData?.label + " / " + record?.recordLabel});
|
||||||
}
|
}
|
||||||
@ -528,40 +587,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
// for a section with field names, render the field values. //
|
// for a section with field names, render the field values. //
|
||||||
// for the T1 section, the "wrapper" will come out below - but for other sections, produce a wrapper too. //
|
// for the T1 section, the "wrapper" will come out below - but for other sections, produce a wrapper too. //
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
const fields = (
|
const fields = renderSectionOfFields(section.name, section.fieldNames, tableMetaData, helpHelpActive, record);
|
||||||
<Box key={section.name} display="flex" flexDirection="column" py={1} pr={2}>
|
|
||||||
{
|
|
||||||
section.fieldNames.map((fieldName: string) =>
|
|
||||||
{
|
|
||||||
let [field, tableForField] = TableUtils.getFieldAndTable(tableMetaData, fieldName);
|
|
||||||
if (field != null)
|
|
||||||
{
|
|
||||||
let label = field.label;
|
|
||||||
|
|
||||||
const helpRoles = ["VIEW_SCREEN", "READ_SCREENS", "ALL_SCREENS"];
|
|
||||||
const showHelp = helpHelpActive || hasHelpContent(field.helpContents, helpRoles);
|
|
||||||
const formattedHelpContent = <HelpContent helpContents={field.helpContents} roles={helpRoles} heading={label} helpContentKey={`table:${tableName};field:${fieldName}`} />;
|
|
||||||
|
|
||||||
const labelElement = <Typography variant="button" textTransform="none" fontWeight="bold" pr={1} color="rgb(52, 71, 103)" sx={{cursor: "default"}}>{label}:</Typography>;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box key={fieldName} flexDirection="row" pr={2}>
|
|
||||||
<>
|
|
||||||
{
|
|
||||||
showHelp && formattedHelpContent ? <Tooltip title={formattedHelpContent}>{labelElement}</Tooltip> : labelElement
|
|
||||||
}
|
|
||||||
<div style={{display: "inline-block", width: 0}}> </div>
|
|
||||||
<Typography variant="button" textTransform="none" fontWeight="regular" color="rgb(123, 128, 154)">
|
|
||||||
{ValueUtils.getDisplayValue(field, record, "view", fieldName)}
|
|
||||||
</Typography>
|
|
||||||
</>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (section.tier === "T1")
|
if (section.tier === "T1")
|
||||||
{
|
{
|
||||||
@ -796,13 +822,37 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const renderShareButton = () =>
|
const renderShareButton = () =>
|
||||||
{
|
{
|
||||||
if (tableMetaData && (tableMetaData.name == "savedReport" || tableMetaData.name == "savedView")) // todo - not just based on name
|
if (tableMetaData && tableMetaData.shareableTableMetaData)
|
||||||
{
|
{
|
||||||
const shareDisabled = false; // todo - only share if you're the owner? or do that in the modal?
|
let shareDisabled = true;
|
||||||
return (<Box width={standardWidth} mr={3}>
|
let disabledTooltipText = "";
|
||||||
<MDButton id="shareButton" type="button" color="info" size="small" onClick={() => openShareModal()} fullWidth startIcon={<Icon>share</Icon>} disabled={shareDisabled}>
|
if(tableMetaData.shareableTableMetaData.thisTableOwnerIdFieldName && record)
|
||||||
Share
|
{
|
||||||
</MDButton>
|
const ownerId = record.values.get(tableMetaData.shareableTableMetaData.thisTableOwnerIdFieldName);
|
||||||
|
if(ownerId != currentUserId)
|
||||||
|
{
|
||||||
|
disabledTooltipText = `Only the owner of a ${tableMetaData.label} may share it.`
|
||||||
|
shareDisabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disabledTooltipText = "";
|
||||||
|
shareDisabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shareDisabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (<Box width={standardWidth} mr={2}>
|
||||||
|
<Tooltip title={disabledTooltipText}>
|
||||||
|
<span>
|
||||||
|
<MDButton id="shareButton" type="button" color="info" size="small" onClick={() => openShareModal()} fullWidth startIcon={<Icon>group_add</Icon>} disabled={shareDisabled}>
|
||||||
|
Share
|
||||||
|
</MDButton>
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
</Box>);
|
</Box>);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,7 +1081,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
|
|
||||||
{
|
{
|
||||||
showEditChildForm &&
|
showEditChildForm &&
|
||||||
<Modal open={showEditChildForm as boolean} onClose={(event, reason) => closeEditChildForm(event, reason)}>
|
<Modal open={showEditChildForm !== null} onClose={(event, reason) => closeEditChildForm(event, reason)}>
|
||||||
<div className="modalEditForm">
|
<div className="modalEditForm">
|
||||||
<EntityForm
|
<EntityForm
|
||||||
isModal={true}
|
isModal={true}
|
||||||
|
163
src/qqq/pages/records/view/RecordViewByUniqueKey.tsx
Normal file
163
src/qqq/pages/records/view/RecordViewByUniqueKey.tsx
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2024. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
||||||
|
import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord";
|
||||||
|
import {QCriteriaOperator} from "@kingsrook/qqq-frontend-core/lib/model/query/QCriteriaOperator";
|
||||||
|
import {QFilterCriteria} from "@kingsrook/qqq-frontend-core/lib/model/query/QFilterCriteria";
|
||||||
|
import {QQueryFilter} from "@kingsrook/qqq-frontend-core/lib/model/query/QQueryFilter";
|
||||||
|
import {QueryJoin} from "@kingsrook/qqq-frontend-core/lib/model/query/QueryJoin";
|
||||||
|
import {Alert, Box} from "@mui/material";
|
||||||
|
import Grid from "@mui/material/Grid";
|
||||||
|
import BaseLayout from "qqq/layouts/BaseLayout";
|
||||||
|
import RecordView, {getVisibleJoinTables} from "qqq/pages/records/view/RecordView";
|
||||||
|
import Client from "qqq/utils/qqq/Client";
|
||||||
|
import TableUtils from "qqq/utils/qqq/TableUtils";
|
||||||
|
import React, {useEffect, useState} from "react";
|
||||||
|
import {useSearchParams} from "react-router-dom";
|
||||||
|
|
||||||
|
interface RecordViewByUniqueKeyProps
|
||||||
|
{
|
||||||
|
table: QTableMetaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordViewByUniqueKey.defaultProps = {};
|
||||||
|
|
||||||
|
const qController = Client.getInstance();
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
** Wrapper around RecordView, that reads a unique key from the query string,
|
||||||
|
** looks for a record matching that key, and shows that record.
|
||||||
|
***************************************************************************/
|
||||||
|
export default function RecordViewByUniqueKey({table}: RecordViewByUniqueKeyProps): JSX.Element
|
||||||
|
{
|
||||||
|
const tableName = table.name;
|
||||||
|
|
||||||
|
const [asyncLoadInited, setAsyncLoadInited] = useState(false);
|
||||||
|
const [tableMetaData, setTableMetaData] = useState(null as QTableMetaData);
|
||||||
|
const [doneLoading, setDoneLoading] = useState(false);
|
||||||
|
const [record, setRecord] = useState(null as QRecord);
|
||||||
|
const [errorMessage, setErrorMessage] = useState(null as string);
|
||||||
|
|
||||||
|
const [queryParams] = useSearchParams();
|
||||||
|
|
||||||
|
if (!asyncLoadInited)
|
||||||
|
{
|
||||||
|
setAsyncLoadInited(true);
|
||||||
|
|
||||||
|
(async () =>
|
||||||
|
{
|
||||||
|
const tableMetaData = await qController.loadTableMetaData(tableName);
|
||||||
|
setTableMetaData(tableMetaData);
|
||||||
|
|
||||||
|
const criteria: QFilterCriteria[] = [];
|
||||||
|
for (let [name, value] of queryParams.entries())
|
||||||
|
{
|
||||||
|
criteria.push(new QFilterCriteria(name, QCriteriaOperator.EQUALS, [value]));
|
||||||
|
if(!tableMetaData.fields.has(name))
|
||||||
|
{
|
||||||
|
setErrorMessage(`Query-string parameter [${name}] is not a defined field on the ${tableMetaData.label} table.`);
|
||||||
|
setDoneLoading(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let queryJoins: QueryJoin[] = null;
|
||||||
|
const visibleJoinTables = getVisibleJoinTables(tableMetaData);
|
||||||
|
if (visibleJoinTables.size > 0)
|
||||||
|
{
|
||||||
|
queryJoins = TableUtils.getQueryJoins(tableMetaData, visibleJoinTables);
|
||||||
|
}
|
||||||
|
|
||||||
|
const filter = new QQueryFilter(criteria, null, null, "AND", 0, 2);
|
||||||
|
qController.query(tableName, filter, queryJoins)
|
||||||
|
.then((queryResult) =>
|
||||||
|
{
|
||||||
|
setDoneLoading(true);
|
||||||
|
if (queryResult.length == 1)
|
||||||
|
{
|
||||||
|
setRecord(queryResult[0]);
|
||||||
|
}
|
||||||
|
else if (queryResult.length == 0)
|
||||||
|
{
|
||||||
|
setErrorMessage(`No ${tableMetaData.label} record was found matching the given values.`);
|
||||||
|
}
|
||||||
|
else if (queryResult.length > 1)
|
||||||
|
{
|
||||||
|
setErrorMessage(`More than one ${tableMetaData.label} record was found matching the given values.`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) =>
|
||||||
|
{
|
||||||
|
setDoneLoading(true);
|
||||||
|
console.log(error);
|
||||||
|
if (error && error.message)
|
||||||
|
{
|
||||||
|
setErrorMessage(error.message);
|
||||||
|
}
|
||||||
|
else if (error && error.response && error.response.data && error.response.data.error)
|
||||||
|
{
|
||||||
|
setErrorMessage(error.response.data.error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setErrorMessage("Unexpected error running query");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
if (asyncLoadInited)
|
||||||
|
{
|
||||||
|
setAsyncLoadInited(false);
|
||||||
|
setDoneLoading(false);
|
||||||
|
setRecord(null);
|
||||||
|
}
|
||||||
|
}, [queryParams]);
|
||||||
|
|
||||||
|
if (!doneLoading)
|
||||||
|
{
|
||||||
|
return (<div>Loading...</div>);
|
||||||
|
}
|
||||||
|
else if (record)
|
||||||
|
{
|
||||||
|
return (<RecordView table={table} record={record} />);
|
||||||
|
}
|
||||||
|
else if (errorMessage)
|
||||||
|
{
|
||||||
|
return (<BaseLayout>
|
||||||
|
<Box className="recordView">
|
||||||
|
<Grid container>
|
||||||
|
<Grid item xs={12}>
|
||||||
|
<Box mb={3}>
|
||||||
|
{
|
||||||
|
<Alert color="error" sx={{mb: 3}}>{errorMessage}</Alert>
|
||||||
|
}
|
||||||
|
</Box>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Box>
|
||||||
|
</BaseLayout>);
|
||||||
|
}
|
||||||
|
}
|
@ -688,6 +688,21 @@ input[type="search"]::-webkit-search-results-decoration
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.recordView .widget
|
||||||
|
{
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entityForm .widget
|
||||||
|
{
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordView .widget .recordGridWidget
|
||||||
|
{
|
||||||
|
margin: -8px;
|
||||||
|
}
|
||||||
|
|
||||||
.MuiPickersDay-root.Mui-selected, .MuiPickersDay-root.MuiPickersDay-dayWithMargin:hover
|
.MuiPickersDay-root.Mui-selected, .MuiPickersDay-root.MuiPickersDay-dayWithMargin:hover
|
||||||
{
|
{
|
||||||
color: white;
|
color: white;
|
||||||
|
@ -23,6 +23,7 @@ import {QController} from "@kingsrook/qqq-frontend-core/lib/controllers/QControl
|
|||||||
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
||||||
import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType";
|
||||||
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData";
|
||||||
|
import {FilterVariableExpression} from "@kingsrook/qqq-frontend-core/lib/model/query/FilterVariableExpression";
|
||||||
import {NowExpression} from "@kingsrook/qqq-frontend-core/lib/model/query/NowExpression";
|
import {NowExpression} from "@kingsrook/qqq-frontend-core/lib/model/query/NowExpression";
|
||||||
import {NowWithOffsetExpression} from "@kingsrook/qqq-frontend-core/lib/model/query/NowWithOffsetExpression";
|
import {NowWithOffsetExpression} from "@kingsrook/qqq-frontend-core/lib/model/query/NowWithOffsetExpression";
|
||||||
import {QCriteriaOperator} from "@kingsrook/qqq-frontend-core/lib/model/query/QCriteriaOperator";
|
import {QCriteriaOperator} from "@kingsrook/qqq-frontend-core/lib/model/query/QCriteriaOperator";
|
||||||
@ -108,6 +109,8 @@ class FilterUtils
|
|||||||
let [field, fieldTable] = TableUtils.getFieldAndTable(tableMetaData, criteria.fieldName);
|
let [field, fieldTable] = TableUtils.getFieldAndTable(tableMetaData, criteria.fieldName);
|
||||||
|
|
||||||
let values = criteria.values;
|
let values = criteria.values;
|
||||||
|
let hasFilterVariable = false;
|
||||||
|
|
||||||
if (field.possibleValueSourceName)
|
if (field.possibleValueSourceName)
|
||||||
{
|
{
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -121,7 +124,17 @@ class FilterUtils
|
|||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
if (values && values.length > 0 && values[0] !== null && values[0] !== undefined && values[0] !== "")
|
if (values && values.length > 0 && values[0] !== null && values[0] !== undefined && values[0] !== "")
|
||||||
{
|
{
|
||||||
values = await qController.possibleValues(fieldTable.name, null, field.name, "", values);
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// do not do this lookup if the field is a filter variable expression //
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
if (values[0].type && values[0].type == "FilterVariableExpression")
|
||||||
|
{
|
||||||
|
hasFilterVariable = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
values = await qController.possibleValues(fieldTable.name, null, field.name, "", values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
@ -232,6 +245,10 @@ class FilterUtils
|
|||||||
{
|
{
|
||||||
return (new ThisOrLastPeriodExpression(value));
|
return (new ThisOrLastPeriodExpression(value));
|
||||||
}
|
}
|
||||||
|
else if (value.type == "FilterVariableExpression")
|
||||||
|
{
|
||||||
|
return (new FilterVariableExpression(value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (null);
|
return (null);
|
||||||
@ -365,7 +382,12 @@ class FilterUtils
|
|||||||
for (let i = 0; i < maxLoops; i++)
|
for (let i = 0; i < maxLoops; i++)
|
||||||
{
|
{
|
||||||
const value = criteria.values[i];
|
const value = criteria.values[i];
|
||||||
if (value.type == "NowWithOffset")
|
if (value.type == "FilterVariableExpression")
|
||||||
|
{
|
||||||
|
const expression = new FilterVariableExpression(value);
|
||||||
|
labels.push(expression.toString());
|
||||||
|
}
|
||||||
|
else if (value.type == "NowWithOffset")
|
||||||
{
|
{
|
||||||
const expression = new NowWithOffsetExpression(value);
|
const expression = new NowWithOffsetExpression(value);
|
||||||
labels.push(expression.toString());
|
labels.push(expression.toString());
|
||||||
@ -657,7 +679,7 @@ class FilterUtils
|
|||||||
|
|
||||||
filterForBackend.subFilters = subFilters;
|
filterForBackend.subFilters = subFilters;
|
||||||
|
|
||||||
if(pageNumber !== undefined && rowsPerPage !== undefined)
|
if (pageNumber !== undefined && rowsPerPage !== undefined)
|
||||||
{
|
{
|
||||||
filterForBackend.skip = pageNumber * rowsPerPage;
|
filterForBackend.skip = pageNumber * rowsPerPage;
|
||||||
filterForBackend.limit = rowsPerPage;
|
filterForBackend.limit = rowsPerPage;
|
||||||
|
@ -133,6 +133,11 @@ class TableUtils
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public static getFieldAndTable(tableMetaData: QTableMetaData, fieldName: string): [QFieldMetaData, QTableMetaData]
|
public static getFieldAndTable(tableMetaData: QTableMetaData, fieldName: string): [QFieldMetaData, QTableMetaData]
|
||||||
{
|
{
|
||||||
|
if(!fieldName)
|
||||||
|
{
|
||||||
|
return [null, null];
|
||||||
|
}
|
||||||
|
|
||||||
if (fieldName.indexOf(".") > -1)
|
if (fieldName.indexOf(".") > -1)
|
||||||
{
|
{
|
||||||
const nameParts = fieldName.split(".", 2);
|
const nameParts = fieldName.split(".", 2);
|
||||||
|
@ -47,6 +47,8 @@ module.exports = function (app)
|
|||||||
app.use("/download/*", getRequestHandler());
|
app.use("/download/*", getRequestHandler());
|
||||||
app.use("/metaData/*", getRequestHandler());
|
app.use("/metaData/*", getRequestHandler());
|
||||||
app.use("/data/*", getRequestHandler());
|
app.use("/data/*", getRequestHandler());
|
||||||
|
app.use("/possibleValues/*", getRequestHandler());
|
||||||
|
app.use("/possibleValues", getRequestHandler());
|
||||||
app.use("/widget/*", getRequestHandler());
|
app.use("/widget/*", getRequestHandler());
|
||||||
app.use("/serverInfo", getRequestHandler());
|
app.use("/serverInfo", getRequestHandler());
|
||||||
app.use("/manageSession", getRequestHandler());
|
app.use("/manageSession", getRequestHandler());
|
||||||
|
@ -29,6 +29,9 @@ import com.kingsrook.qqq.backend.core.instances.QInstanceValidator;
|
|||||||
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||||
import com.kingsrook.qqq.frontend.materialdashboard.junit.BaseTest;
|
import com.kingsrook.qqq.frontend.materialdashboard.junit.BaseTest;
|
||||||
import com.kingsrook.qqq.frontend.materialdashboard.junit.TestUtils;
|
import com.kingsrook.qqq.frontend.materialdashboard.junit.TestUtils;
|
||||||
|
import com.kingsrook.qqq.frontend.materialdashboard.model.metadata.fieldrules.FieldRule;
|
||||||
|
import com.kingsrook.qqq.frontend.materialdashboard.model.metadata.fieldrules.FieldRuleAction;
|
||||||
|
import com.kingsrook.qqq.frontend.materialdashboard.model.metadata.fieldrules.FieldRuleTrigger;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
@ -76,6 +79,37 @@ class MaterialDashboardTableMetaDataTest extends BaseTest
|
|||||||
|
|
||||||
assertValidationFailureReasons(qInstance -> qInstance.getTable(TestUtils.TABLE_NAME_PERSON).withSupplementalMetaData(new MaterialDashboardTableMetaData().withDefaultQuickFilterFieldNames(List.of("firstName", "lastName", "firstName"))),
|
assertValidationFailureReasons(qInstance -> qInstance.getTable(TestUtils.TABLE_NAME_PERSON).withSupplementalMetaData(new MaterialDashboardTableMetaData().withDefaultQuickFilterFieldNames(List.of("firstName", "lastName", "firstName"))),
|
||||||
"duplicated field name: firstName");
|
"duplicated field name: firstName");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
void testValidateFieldRules()
|
||||||
|
{
|
||||||
|
assertValidationFailureReasons(qInstance -> qInstance.getTable(TestUtils.TABLE_NAME_PERSON).withSupplementalMetaData(new MaterialDashboardTableMetaData().withFieldRule(new FieldRule())),
|
||||||
|
"without an action",
|
||||||
|
"without a trigger",
|
||||||
|
"without a sourceField");
|
||||||
|
|
||||||
|
assertValidationFailureReasons(qInstance -> qInstance.getTable(TestUtils.TABLE_NAME_PERSON).withSupplementalMetaData(new MaterialDashboardTableMetaData().withFieldRule(new FieldRule()
|
||||||
|
.withTrigger(FieldRuleTrigger.ON_CHANGE)
|
||||||
|
.withAction(FieldRuleAction.CLEAR_TARGET_FIELD)
|
||||||
|
.withSourceField("notAField")
|
||||||
|
.withTargetField("alsoNotAField")
|
||||||
|
)),
|
||||||
|
"unrecognized sourceField: notAField",
|
||||||
|
"unrecognized targetField: alsoNotAField");
|
||||||
|
|
||||||
|
assertValidationFailureReasons(qInstance -> qInstance.getTable(TestUtils.TABLE_NAME_PERSON).withSupplementalMetaData(new MaterialDashboardTableMetaData().withFieldRule(new FieldRule()
|
||||||
|
.withTrigger(FieldRuleTrigger.ON_CHANGE)
|
||||||
|
.withAction(FieldRuleAction.RELOAD_WIDGET)
|
||||||
|
.withSourceField("id")
|
||||||
|
.withTargetWidget("notAWidget")
|
||||||
|
)),
|
||||||
|
"unrecognized targetWidget: notAWidget");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import org.junit.jupiter.api.AfterEach;
|
|||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.TestInfo;
|
import org.junit.jupiter.api.TestInfo;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.openqa.selenium.Dimension;
|
import org.openqa.selenium.Dimension;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.chrome.ChromeDriver;
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
@ -43,6 +44,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Base class for Selenium tests
|
** Base class for Selenium tests
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ExtendWith(SeleniumTestWatcher.class)
|
||||||
public class QBaseSeleniumTest
|
public class QBaseSeleniumTest
|
||||||
{
|
{
|
||||||
protected static ChromeOptions chromeOptions;
|
protected static ChromeOptions chromeOptions;
|
||||||
@ -93,6 +95,8 @@ public class QBaseSeleniumTest
|
|||||||
driver.manage().window().setSize(new Dimension(1700, 1300));
|
driver.manage().window().setSize(new Dimension(1700, 1300));
|
||||||
qSeleniumLib = new QSeleniumLib(driver);
|
qSeleniumLib = new QSeleniumLib(driver);
|
||||||
|
|
||||||
|
SeleniumTestWatcher.setCurrentSeleniumLib(qSeleniumLib);
|
||||||
|
|
||||||
if(useInternalJavalin())
|
if(useInternalJavalin())
|
||||||
{
|
{
|
||||||
qSeleniumJavalin = new QSeleniumJavalin();
|
qSeleniumJavalin = new QSeleniumJavalin();
|
||||||
@ -197,10 +201,10 @@ public class QBaseSeleniumTest
|
|||||||
qSeleniumLib.takeScreenshotToFile(getClass().getSimpleName() + "/" + testInfo.getDisplayName());
|
qSeleniumLib.takeScreenshotToFile(getClass().getSimpleName() + "/" + testInfo.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(driver != null)
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
{
|
// note - at one time we did a driver.quit here - but we're moving that into //
|
||||||
driver.quit();
|
// SeleniumTestWatcher, so it can dump logs if it wants to (it runs after the @After) //
|
||||||
}
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if(qSeleniumJavalin != null)
|
if(qSeleniumJavalin != null)
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,8 @@ import org.openqa.selenium.StaleElementReferenceException;
|
|||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.interactions.Actions;
|
import org.openqa.selenium.interactions.Actions;
|
||||||
|
import org.openqa.selenium.logging.LogEntries;
|
||||||
|
import org.openqa.selenium.logging.LogEntry;
|
||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -333,7 +335,7 @@ public class QSeleniumLib
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(elements.stream().noneMatch(e -> e.getText().toLowerCase().contains(textContains)))
|
if(elements.stream().noneMatch(e -> e.getText().toLowerCase().contains(textContains.toLowerCase())))
|
||||||
{
|
{
|
||||||
LOG.debug("Found non-existence of element(s) matching selector [" + cssSelector + "] containing text [" + textContains + "]");
|
LOG.debug("Found non-existence of element(s) matching selector [" + cssSelector + "] containing text [" + textContains + "]");
|
||||||
return;
|
return;
|
||||||
@ -343,7 +345,7 @@ public class QSeleniumLib
|
|||||||
}
|
}
|
||||||
while(start + (1000 * WAIT_SECONDS) > System.currentTimeMillis());
|
while(start + (1000 * WAIT_SECONDS) > System.currentTimeMillis());
|
||||||
|
|
||||||
fail("Failed for non-existence of element matching selector [" + cssSelector + "] after [" + WAIT_SECONDS + "] seconds.");
|
fail("Failed for non-existence of element matching selector [" + cssSelector + "] containing text [" + textContains + "] after [" + WAIT_SECONDS + "] seconds.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -735,4 +737,22 @@ public class QSeleniumLib
|
|||||||
return (this);
|
return (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public void dumpConsole()
|
||||||
|
{
|
||||||
|
Set<String> availableLogTypes = driver.manage().logs().getAvailableLogTypes();
|
||||||
|
for(String logType : availableLogTypes)
|
||||||
|
{
|
||||||
|
LogEntries logEntries = driver.manage().logs().get(logType);
|
||||||
|
for(LogEntry logEntry : logEntries)
|
||||||
|
{
|
||||||
|
System.out.println(logEntry.toJson());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -261,9 +261,7 @@ public class QueryScreenLib
|
|||||||
if(StringUtils.hasContent(value))
|
if(StringUtils.hasContent(value))
|
||||||
{
|
{
|
||||||
qSeleniumLib.waitForSelector(".filterValuesColumn INPUT").click();
|
qSeleniumLib.waitForSelector(".filterValuesColumn INPUT").click();
|
||||||
// todo - no, not in a listbox/LI here...
|
qSeleniumLib.waitForSelector(".filterValuesColumn INPUT").sendKeys(value);
|
||||||
qSeleniumLib.waitForSelectorContaining(".MuiAutocomplete-listbox LI", value).click();
|
|
||||||
System.out.println(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qSeleniumLib.clickBackdrop();
|
qSeleniumLib.clickBackdrop();
|
||||||
@ -271,6 +269,21 @@ public class QueryScreenLib
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public void setBasicBooleanFilter(String fieldLabel, String operatorLabel)
|
||||||
|
{
|
||||||
|
qSeleniumLib.waitForSelectorContaining("BUTTON", fieldLabel).click();
|
||||||
|
qSeleniumLib.waitForMillis(250);
|
||||||
|
qSeleniumLib.waitForSelector("#criteriaOperator").click();
|
||||||
|
qSeleniumLib.waitForSelectorContaining("LI", operatorLabel).click();
|
||||||
|
|
||||||
|
qSeleniumLib.clickBackdrop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2024. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.kingsrook.qqq.frontend.materialdashboard.selenium.lib;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||||
|
import org.junit.jupiter.api.extension.TestWatcher;
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public class SeleniumTestWatcher implements TestWatcher
|
||||||
|
{
|
||||||
|
private static QSeleniumLib qSeleniumLib;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public static void setCurrentSeleniumLib(QSeleniumLib qSeleniumLib)
|
||||||
|
{
|
||||||
|
SeleniumTestWatcher.qSeleniumLib = qSeleniumLib;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Override
|
||||||
|
public void testFailed(ExtensionContext context, Throwable cause)
|
||||||
|
{
|
||||||
|
if(qSeleniumLib != null)
|
||||||
|
{
|
||||||
|
System.out.println("Dumping browser console after failed test: " + context.getDisplayName());
|
||||||
|
System.out.println("----------------------------------------------------------------------------");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
qSeleniumLib.dumpConsole();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Error dumping console:");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.out.println("----------------------------------------------------------------------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
tryToQuitSelenium();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
private void tryToQuitSelenium()
|
||||||
|
{
|
||||||
|
if(qSeleniumLib != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
qSeleniumLib.driver.quit();
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
System.err.println("Error quiting selenium driver: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Override
|
||||||
|
public void testSuccessful(ExtensionContext context)
|
||||||
|
{
|
||||||
|
tryToQuitSelenium();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Override
|
||||||
|
public void testAborted(ExtensionContext context, Throwable cause)
|
||||||
|
{
|
||||||
|
tryToQuitSelenium();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Override
|
||||||
|
public void testDisabled(ExtensionContext context, Optional<String> reason)
|
||||||
|
{
|
||||||
|
tryToQuitSelenium();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2024. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.kingsrook.qqq.frontend.materialdashboard.selenium.tests;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.kingsrook.qqq.frontend.materialdashboard.selenium.lib.QBaseSeleniumTest;
|
||||||
|
import com.kingsrook.qqq.frontend.materialdashboard.selenium.lib.QSeleniumLib;
|
||||||
|
import com.kingsrook.qqq.frontend.materialdashboard.selenium.lib.QueryScreenLib;
|
||||||
|
import com.kingsrook.qqq.frontend.materialdashboard.selenium.lib.javalin.QSeleniumJavalin;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.Keys;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Test for Saved Report screen (table has some special behaviors)
|
||||||
|
*******************************************************************************/
|
||||||
|
public class SavedReportTest extends QBaseSeleniumTest
|
||||||
|
{
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Override
|
||||||
|
protected void addJavalinRoutes(QSeleniumJavalin qSeleniumJavalin)
|
||||||
|
{
|
||||||
|
super.addJavalinRoutes(qSeleniumJavalin);
|
||||||
|
qSeleniumJavalin
|
||||||
|
.withRouteToFile("/metaData/table/savedReport", "metaData/table/savedReport.json")
|
||||||
|
.withRouteToFile("/widget/reportSetupWidget", "widget/reportSetupWidget.json")
|
||||||
|
.withRouteToFile("/widget/pivotTableSetupWidget", "widget/pivotTableSetupWidget.json")
|
||||||
|
.withRouteToFile("/data/savedReport/possibleValues/tableName", "data/savedReport/possibleValues/tableName.json")
|
||||||
|
|
||||||
|
.withRouteToFile("/data/person/count", "data/person/count.json")
|
||||||
|
.withRouteToFile("/data/person/query", "data/person/index.json")
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
void testCreate()
|
||||||
|
{
|
||||||
|
qSeleniumLib.gotoAndWaitForBreadcrumbHeaderToContain("/userCustomizations/savedReport/create", "Creating New Saved Report");
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
// make sure things are disabled before a table is selected //
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
WebElement webElement = qSeleniumLib.waitForSelectorContaining("button", "Edit Filters and Columns");
|
||||||
|
assertEquals("true", webElement.getAttribute("disabled"));
|
||||||
|
|
||||||
|
qSeleniumLib.waitForSelector("#label").click();
|
||||||
|
qSeleniumLib.waitForSelector("#label").sendKeys("My Report");
|
||||||
|
|
||||||
|
qSeleniumLib.waitForSelector("#tableName").click();
|
||||||
|
qSeleniumLib.waitForSelector("#tableName").sendKeys("Person" + Keys.DOWN + Keys.ENTER);
|
||||||
|
|
||||||
|
//////////////////////////////////
|
||||||
|
// make sure things enabled now //
|
||||||
|
//////////////////////////////////
|
||||||
|
webElement = qSeleniumLib.waitForSelectorContaining("button", "Edit Filters and Columns");
|
||||||
|
assertNull(webElement.getAttribute("disabled"));
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
// open query-screen popup, wait for query to run //
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
qSeleniumJavalin.beginCapture();
|
||||||
|
qSeleniumLib.waitForSelectorContaining("button", "Edit Filters and Columns").click();
|
||||||
|
qSeleniumJavalin.waitForCapturedPath("/data/person/count");
|
||||||
|
qSeleniumJavalin.waitForCapturedPath("/data/person/query");
|
||||||
|
qSeleniumJavalin.endCapture();
|
||||||
|
|
||||||
|
QueryScreenLib queryScreenLib = new QueryScreenLib(qSeleniumLib);
|
||||||
|
queryScreenLib.setBasicFilter("First Name", "contains", "Darin");
|
||||||
|
|
||||||
|
////////////////////////
|
||||||
|
// close query screen //
|
||||||
|
////////////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining("button", "OK").click();
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// make sure query things appear on edit screen now //
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".advancedQueryString", "First Name");
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".advancedQueryString", "contains");
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".advancedQueryString", "Darin");
|
||||||
|
List<WebElement> columns = qSeleniumLib.waitForSelectorContaining("h5", "Columns")
|
||||||
|
.findElement(QSeleniumLib.PARENT)
|
||||||
|
.findElements(By.cssSelector("DIV"));
|
||||||
|
|
||||||
|
assertThat(columns)
|
||||||
|
.hasSizeGreaterThanOrEqualTo(5) // at least this many
|
||||||
|
.anyMatch(we -> we.getText().equals("Home City")); // a few fields are found
|
||||||
|
|
||||||
|
///////////////////
|
||||||
|
// turn on pivot //
|
||||||
|
///////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining("label", "Use Pivot Table").click();
|
||||||
|
qSeleniumLib.waitForSelectorContaining("button", "Edit Pivot Table").click();
|
||||||
|
qSeleniumLib.waitForSelectorContaining("h3", "Edit Pivot Table");
|
||||||
|
|
||||||
|
///////////////
|
||||||
|
// add a row //
|
||||||
|
///////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".MuiModal-root button", "Add new row").click();
|
||||||
|
WebElement row0Input = qSeleniumLib.waitForSelector("#rows-0");
|
||||||
|
row0Input.click();
|
||||||
|
row0Input.sendKeys("Last Name" + Keys.ENTER);
|
||||||
|
|
||||||
|
//////////////////
|
||||||
|
// add a column //
|
||||||
|
//////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".MuiModal-root button", "Add new column").click();
|
||||||
|
WebElement column0Input = qSeleniumLib.waitForSelector("#columns-0");
|
||||||
|
column0Input.click();
|
||||||
|
column0Input.sendKeys("Home City" + Keys.ENTER);
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
// add a value //
|
||||||
|
/////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".MuiModal-root button", "Add new value").click();
|
||||||
|
WebElement value0Input = qSeleniumLib.waitForSelector("#values-field-0");
|
||||||
|
value0Input.click();
|
||||||
|
value0Input.sendKeys("Id" + Keys.ENTER);
|
||||||
|
|
||||||
|
/////////////////////////////////////////
|
||||||
|
// try to submit - but expect an error //
|
||||||
|
/////////////////////////////////////////
|
||||||
|
qSeleniumLib.waitForSelectorContaining("button", "OK").click();
|
||||||
|
qSeleniumLib.waitForSelectorContaining(".MuiAlert-standard", "Missing value in 1 field.").click();
|
||||||
|
|
||||||
|
///////////////////////////
|
||||||
|
// now select a function //
|
||||||
|
///////////////////////////
|
||||||
|
WebElement function0Input = qSeleniumLib.waitForSelector("#values-function-0");
|
||||||
|
function0Input.click();
|
||||||
|
function0Input.sendKeys("Count" + Keys.ENTER);
|
||||||
|
|
||||||
|
qSeleniumLib.waitForSelectorContaining("button", "OK").click();
|
||||||
|
qSeleniumLib.waitForSelectorContainingToNotExist("h3", "Edit Pivot Table");
|
||||||
|
|
||||||
|
// qSeleniumLib.waitForever();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -153,16 +153,16 @@ public class QueryScreenTest extends QBaseSeleniumTest
|
|||||||
|
|
||||||
queryScreenLib.addBasicFilter("Is Employed");
|
queryScreenLib.addBasicFilter("Is Employed");
|
||||||
|
|
||||||
testBasicCriteria(queryScreenLib, "Is Employed", "equals yes", null, "(?s).*Is Employed:.*yes.*", """
|
testBasicBooleanCriteria(queryScreenLib, "Is Employed", "equals yes", "(?s).*Is Employed:.*yes.*", """
|
||||||
{"fieldName":"isEmployed","operator":"EQUALS","values":[true]}""");
|
{"fieldName":"isEmployed","operator":"EQUALS","values":[true]}""");
|
||||||
|
|
||||||
testBasicCriteria(queryScreenLib, "Is Employed", "equals no", null, "(?s).*Is Employed:.*no.*", """
|
testBasicBooleanCriteria(queryScreenLib, "Is Employed", "equals no", "(?s).*Is Employed:.*no.*", """
|
||||||
{"fieldName":"isEmployed","operator":"EQUALS","values":[false]}""");
|
{"fieldName":"isEmployed","operator":"EQUALS","values":[false]}""");
|
||||||
|
|
||||||
testBasicCriteria(queryScreenLib, "Is Employed", "is empty", null, "(?s).*Is Employed:.*is empty.*", """
|
testBasicBooleanCriteria(queryScreenLib, "Is Employed", "is empty", "(?s).*Is Employed:.*is empty.*", """
|
||||||
{"fieldName":"isEmployed","operator":"IS_BLANK","values":[]}""");
|
{"fieldName":"isEmployed","operator":"IS_BLANK","values":[]}""");
|
||||||
|
|
||||||
testBasicCriteria(queryScreenLib, "Is Employed", "is not empty", null, "(?s).*Is Employed:.*is not empty.*", """
|
testBasicBooleanCriteria(queryScreenLib, "Is Employed", "is not empty", "(?s).*Is Employed:.*is not empty.*", """
|
||||||
{"fieldName":"isEmployed","operator":"IS_NOT_BLANK","values":[]}""");
|
{"fieldName":"isEmployed","operator":"IS_NOT_BLANK","values":[]}""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,10 +203,10 @@ public class QueryScreenTest extends QBaseSeleniumTest
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
private void testBasicCriteria(QueryScreenLib queryScreenLib, String fieldLabel, String operatorLabel, String value, String expectButtonStringRegex, String expectFilterJsonContains)
|
private void testBasicBooleanCriteria(QueryScreenLib queryScreenLib, String fieldLabel, String operatorLabel, String expectButtonStringRegex, String expectFilterJsonContains)
|
||||||
{
|
{
|
||||||
qSeleniumJavalin.beginCapture();
|
qSeleniumJavalin.beginCapture();
|
||||||
queryScreenLib.setBasicFilter(fieldLabel, operatorLabel, value);
|
queryScreenLib.setBasicBooleanFilter(fieldLabel, operatorLabel);
|
||||||
queryScreenLib.waitForBasicFilterButtonMatchingRegex(expectButtonStringRegex);
|
queryScreenLib.waitForBasicFilterButtonMatchingRegex(expectButtonStringRegex);
|
||||||
qSeleniumJavalin.waitForCapturedPathWithBodyContaining("/data/person/query", expectFilterJsonContains);
|
qSeleniumJavalin.waitForCapturedPathWithBodyContaining("/data/person/query", expectFilterJsonContains);
|
||||||
qSeleniumJavalin.endCapture();
|
qSeleniumJavalin.endCapture();
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"id": "person",
|
||||||
|
"label": "Person"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "city",
|
||||||
|
"label": "City"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "savedReport",
|
||||||
|
"label": "Saved Report"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -189,6 +189,26 @@
|
|||||||
"insertPermission": true,
|
"insertPermission": true,
|
||||||
"editPermission": true,
|
"editPermission": true,
|
||||||
"deletePermission": true
|
"deletePermission": true
|
||||||
|
},
|
||||||
|
"savedReport": {
|
||||||
|
"name": "savedReport",
|
||||||
|
"label": "Saved Report",
|
||||||
|
"isHidden": false,
|
||||||
|
"iconName": "article",
|
||||||
|
"capabilities": [
|
||||||
|
"TABLE_COUNT",
|
||||||
|
"TABLE_GET",
|
||||||
|
"TABLE_QUERY",
|
||||||
|
"QUERY_STATS",
|
||||||
|
"TABLE_UPDATE",
|
||||||
|
"TABLE_INSERT",
|
||||||
|
"TABLE_DELETE"
|
||||||
|
],
|
||||||
|
"readPermission": true,
|
||||||
|
"insertPermission": true,
|
||||||
|
"editPermission": true,
|
||||||
|
"deletePermission": true,
|
||||||
|
"usesVariants": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"processes": {
|
"processes": {
|
||||||
@ -420,6 +440,40 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"userCustomizations": {
|
||||||
|
"name": "userCustomizations",
|
||||||
|
"label": "User Customizations",
|
||||||
|
"iconName": "article",
|
||||||
|
"widgets": [],
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "TABLE",
|
||||||
|
"name": "savedReport",
|
||||||
|
"label": "Saved Report",
|
||||||
|
"iconName": "article"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"childMap": {
|
||||||
|
"savedReport": {
|
||||||
|
"type": "TABLE",
|
||||||
|
"name": "savedReport",
|
||||||
|
"label": "Saved Report",
|
||||||
|
"iconName": "article"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sections": [
|
||||||
|
{
|
||||||
|
"name": "userCustomizations",
|
||||||
|
"label": "User Customizations",
|
||||||
|
"icon": {
|
||||||
|
"name": "badge"
|
||||||
|
},
|
||||||
|
"tables": [
|
||||||
|
"savedReport"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"miscellaneous": {
|
"miscellaneous": {
|
||||||
"name": "miscellaneous",
|
"name": "miscellaneous",
|
||||||
"label": "Miscellaneous",
|
"label": "Miscellaneous",
|
||||||
@ -730,6 +784,20 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"iconName": "data_object"
|
"iconName": "data_object"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "APP",
|
||||||
|
"name": "userCustomizations",
|
||||||
|
"label": "User Customizations",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "TABLE",
|
||||||
|
"name": "savedReport",
|
||||||
|
"label": "Saved Report",
|
||||||
|
"iconName": "article"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"iconName": "data_object"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"branding": {
|
"branding": {
|
||||||
@ -750,6 +818,28 @@
|
|||||||
"isCard": true,
|
"isCard": true,
|
||||||
"storeDropdownSelections": false,
|
"storeDropdownSelections": false,
|
||||||
"hasPermission": true
|
"hasPermission": true
|
||||||
|
},
|
||||||
|
"reportSetupWidget": {
|
||||||
|
"name": "reportSetupWidget",
|
||||||
|
"label": "Filters and Columns",
|
||||||
|
"type": "reportSetup",
|
||||||
|
"isCard": true,
|
||||||
|
"storeDropdownSelections": false,
|
||||||
|
"showReloadButton": true,
|
||||||
|
"showExportButton": false,
|
||||||
|
"defaultValues": {},
|
||||||
|
"hasPermission": true
|
||||||
|
},
|
||||||
|
"pivotTableSetupWidget": {
|
||||||
|
"name": "pivotTableSetupWidget",
|
||||||
|
"label": "Pivot Table",
|
||||||
|
"type": "pivotTableSetup",
|
||||||
|
"isCard": true,
|
||||||
|
"storeDropdownSelections": false,
|
||||||
|
"showReloadButton": true,
|
||||||
|
"showExportButton": false,
|
||||||
|
"defaultValues": {},
|
||||||
|
"hasPermission": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"environmentValues": {
|
"environmentValues": {
|
||||||
|
218
src/test/resources/fixtures/metaData/table/savedReport.json
Normal file
218
src/test/resources/fixtures/metaData/table/savedReport.json
Normal file
@ -0,0 +1,218 @@
|
|||||||
|
{
|
||||||
|
"table": {
|
||||||
|
"name": "savedReport",
|
||||||
|
"label": "Saved Report",
|
||||||
|
"isHidden": false,
|
||||||
|
"primaryKeyField": "id",
|
||||||
|
"iconName": "article",
|
||||||
|
"fields": {
|
||||||
|
"queryFilterJson": {
|
||||||
|
"name": "queryFilterJson",
|
||||||
|
"label": "Query Filter",
|
||||||
|
"type": "STRING",
|
||||||
|
"isRequired": false,
|
||||||
|
"isEditable": true,
|
||||||
|
"isHeavy": false,
|
||||||
|
"displayFormat": "%s"
|
||||||
|
},
|
||||||
|
"columnsJson": {
|
||||||
|
"name": "columnsJson",
|
||||||
|
"label": "Columns",
|
||||||
|
"type": "STRING",
|
||||||
|
"isRequired": false,
|
||||||
|
"isEditable": true,
|
||||||
|
"isHeavy": false,
|
||||||
|
"displayFormat": "%s"
|
||||||
|
},
|
||||||
|
"inputFieldsJson": {
|
||||||
|
"name": "inputFieldsJson",
|
||||||
|
"label": "Input Fields",
|
||||||
|
"type": "STRING",
|
||||||
|
"isRequired": false,
|
||||||
|
"isEditable": true,
|
||||||
|
"isHeavy": false,
|
||||||
|
"displayFormat": "%s"
|
||||||
|
},
|
||||||
|
"pivotTableJson": {
|
||||||
|
"name": "pivotTableJson",
|
||||||
|
"label": "Pivot Table",
|
||||||
|
"type": "STRING",
|
||||||
|
"isRequired": false,
|
||||||
|
"isEditable": true,
|
||||||
|
"isHeavy": false,
|
||||||
|
"displayFormat": "%s"
|
||||||
|
},
|
||||||
|
"modifyDate": {
|
||||||
|
"name": "modifyDate",
|
||||||
|
"label": "Modify Date",
|
||||||
|
"type": "DATE_TIME",
|
||||||
|
"isRequired": false,
|
||||||
|
"isEditable": false,
|
||||||
|
"isHeavy": false,
|
||||||
|
"displayFormat": "%s"
|
||||||
|
},
|
||||||
|
"label": {
|
||||||
|
"name": "label",
|
||||||
|
"label": "Report Name",
|
||||||
|
"type": "STRING",
|
||||||
|
"isRequired": true,
|
||||||
|
"isEditable": true,
|
||||||
|
"isHeavy": false,
|
||||||
|
"displayFormat": "%s"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"label": "Id",
|
||||||
|
"type": "INTEGER",
|
||||||
|
"isRequired": false,
|
||||||
|
"isEditable": false,
|
||||||
|
"isHeavy": false,
|
||||||
|
"displayFormat": "%s"
|
||||||
|
},
|
||||||
|
"userId": {
|
||||||
|
"name": "userId",
|
||||||
|
"label": "User Id",
|
||||||
|
"type": "STRING",
|
||||||
|
"isRequired": false,
|
||||||
|
"isEditable": true,
|
||||||
|
"isHeavy": false,
|
||||||
|
"displayFormat": "%s"
|
||||||
|
},
|
||||||
|
"tableName": {
|
||||||
|
"name": "tableName",
|
||||||
|
"label": "Table",
|
||||||
|
"type": "STRING",
|
||||||
|
"isRequired": true,
|
||||||
|
"isEditable": true,
|
||||||
|
"isHeavy": false,
|
||||||
|
"possibleValueSourceName": "tables",
|
||||||
|
"displayFormat": "%s"
|
||||||
|
},
|
||||||
|
"createDate": {
|
||||||
|
"name": "createDate",
|
||||||
|
"label": "Create Date",
|
||||||
|
"type": "DATE_TIME",
|
||||||
|
"isRequired": false,
|
||||||
|
"isEditable": false,
|
||||||
|
"isHeavy": false,
|
||||||
|
"displayFormat": "%s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sections": [
|
||||||
|
{
|
||||||
|
"name": "identity",
|
||||||
|
"label": "Identity",
|
||||||
|
"tier": "T1",
|
||||||
|
"fieldNames": [
|
||||||
|
"id",
|
||||||
|
"label",
|
||||||
|
"tableName"
|
||||||
|
],
|
||||||
|
"icon": {
|
||||||
|
"name": "badge"
|
||||||
|
},
|
||||||
|
"isHidden": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "filtersAndColumns",
|
||||||
|
"label": "Filters and Columns",
|
||||||
|
"tier": "T2",
|
||||||
|
"widgetName": "reportSetupWidget",
|
||||||
|
"icon": {
|
||||||
|
"name": "table_chart"
|
||||||
|
},
|
||||||
|
"isHidden": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pivotTable",
|
||||||
|
"label": "Pivot Table",
|
||||||
|
"tier": "T2",
|
||||||
|
"widgetName": "pivotTableSetupWidget",
|
||||||
|
"icon": {
|
||||||
|
"name": "pivot_table_chart"
|
||||||
|
},
|
||||||
|
"isHidden": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "data",
|
||||||
|
"label": "Data",
|
||||||
|
"tier": "T2",
|
||||||
|
"fieldNames": [
|
||||||
|
"queryFilterJson",
|
||||||
|
"columnsJson",
|
||||||
|
"pivotTableJson"
|
||||||
|
],
|
||||||
|
"icon": {
|
||||||
|
"name": "text_snippet"
|
||||||
|
},
|
||||||
|
"isHidden": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "hidden",
|
||||||
|
"label": "Hidden",
|
||||||
|
"tier": "T2",
|
||||||
|
"fieldNames": [
|
||||||
|
"inputFieldsJson",
|
||||||
|
"userId"
|
||||||
|
],
|
||||||
|
"icon": {
|
||||||
|
"name": "text_snippet"
|
||||||
|
},
|
||||||
|
"isHidden": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dates",
|
||||||
|
"label": "Dates",
|
||||||
|
"tier": "T3",
|
||||||
|
"fieldNames": [
|
||||||
|
"createDate",
|
||||||
|
"modifyDate"
|
||||||
|
],
|
||||||
|
"icon": {
|
||||||
|
"name": "calendar_month"
|
||||||
|
},
|
||||||
|
"isHidden": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"exposedJoins": [],
|
||||||
|
"supplementalTableMetaData": {
|
||||||
|
"materialDashboard": {
|
||||||
|
"fieldRules": [
|
||||||
|
{
|
||||||
|
"trigger": "ON_CHANGE",
|
||||||
|
"sourceField": "tableName",
|
||||||
|
"action": "CLEAR_TARGET_FIELD",
|
||||||
|
"targetField": "queryFilterJson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"trigger": "ON_CHANGE",
|
||||||
|
"sourceField": "tableName",
|
||||||
|
"action": "CLEAR_TARGET_FIELD",
|
||||||
|
"targetField": "columnsJson"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"trigger": "ON_CHANGE",
|
||||||
|
"sourceField": "tableName",
|
||||||
|
"action": "CLEAR_TARGET_FIELD",
|
||||||
|
"targetField": "pivotTableJson"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "materialDashboard"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"capabilities": [
|
||||||
|
"TABLE_COUNT",
|
||||||
|
"TABLE_GET",
|
||||||
|
"TABLE_QUERY",
|
||||||
|
"QUERY_STATS",
|
||||||
|
"TABLE_UPDATE",
|
||||||
|
"TABLE_INSERT",
|
||||||
|
"TABLE_DELETE"
|
||||||
|
],
|
||||||
|
"readPermission": true,
|
||||||
|
"insertPermission": true,
|
||||||
|
"editPermission": true,
|
||||||
|
"deletePermission": true,
|
||||||
|
"usesVariants": false
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
{"type":"pivotTableSetup"}
|
@ -0,0 +1 @@
|
|||||||
|
{"type":"reportSetup"}
|
Reference in New Issue
Block a user