mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-22 07:08:44 +00:00
Compare commits
9 Commits
snapshot-f
...
snapshot-f
Author | SHA1 | Date | |
---|---|---|---|
5e3991d9ae | |||
f1826c81a9 | |||
230aaeef8c | |||
edab918763 | |||
e34811354f | |||
ef85f5cd40 | |||
c36dfb5683 | |||
626ada3507 | |||
6cf1c2a0e4 |
@ -28,8 +28,7 @@
|
|||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"react",
|
"react",
|
||||||
"@typescript-eslint",
|
"@typescript-eslint"
|
||||||
"import"
|
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"brace-style": [
|
"brace-style": [
|
||||||
@ -43,41 +42,6 @@
|
|||||||
"SwitchCase": 1
|
"SwitchCase": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"import/extensions": [
|
|
||||||
"error",
|
|
||||||
"ignorePackages",
|
|
||||||
{
|
|
||||||
"ts": "never",
|
|
||||||
"tsx": "never",
|
|
||||||
"js": "never"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"import/no-extraneous-dependencies": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"devDependencies": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"import/order": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"groups": [
|
|
||||||
"builtin", // Built-in imports (come from NodeJS native) go first
|
|
||||||
"external", // <- External imports
|
|
||||||
"internal", // <- Absolute imports
|
|
||||||
["sibling", "parent"], // <- Relative imports, the sibling and parent types they can be mingled together
|
|
||||||
"index", // <- index imports
|
|
||||||
"unknown"
|
|
||||||
],
|
|
||||||
"newlines-between": "never",
|
|
||||||
"alphabetize": {
|
|
||||||
/* sort in ascending order. Options: ["ignore", "asc", "desc"] */
|
|
||||||
"order": "asc",
|
|
||||||
/* ignore case. Options: [true, false] */
|
|
||||||
"caseInsensitive": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"jsx-one-expression-per-line": "off",
|
"jsx-one-expression-per-line": "off",
|
||||||
"max-len": "off",
|
"max-len": "off",
|
||||||
"no-console": "off",
|
"no-console": "off",
|
||||||
@ -114,15 +78,6 @@
|
|||||||
"quotes": [
|
"quotes": [
|
||||||
"error",
|
"error",
|
||||||
"double"
|
"double"
|
||||||
],
|
|
||||||
"sort-imports": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"ignoreCase": false,
|
|
||||||
"ignoreDeclarationSort": true,
|
|
||||||
"ignoreMemberSort": true,
|
|
||||||
"allowSeparatedGroups": false
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
6820
package-lock.json
generated
6820
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.87",
|
"@kingsrook/qqq-frontend-core": "1.0.88",
|
||||||
"@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",
|
||||||
|
2
pom.xml
2
pom.xml
@ -66,7 +66,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.kingsrook.qqq</groupId>
|
<groupId>com.kingsrook.qqq</groupId>
|
||||||
<artifactId>qqq-backend-core</artifactId>
|
<artifactId>qqq-backend-core</artifactId>
|
||||||
<version>feature-CE-876-develop-missing-widget-types-20240221.002945-1</version>
|
<version>0.20.0-20240308.165846-65</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
@ -34,7 +34,7 @@ import ToggleButton from "@mui/material/ToggleButton";
|
|||||||
import ToggleButtonGroup from "@mui/material/ToggleButtonGroup";
|
import ToggleButtonGroup from "@mui/material/ToggleButtonGroup";
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import React, {JSXElementConstructor, useContext, useEffect, useState} from "react";
|
import React, {useContext, useEffect, useState} from "react";
|
||||||
import QContext from "QContext";
|
import QContext from "QContext";
|
||||||
import Client from "qqq/utils/qqq/Client";
|
import Client from "qqq/utils/qqq/Client";
|
||||||
import ValueUtils from "qqq/utils/qqq/ValueUtils";
|
import ValueUtils from "qqq/utils/qqq/ValueUtils";
|
||||||
@ -58,19 +58,19 @@ function AuditBody({tableMetaData, recordId, record}: Props): JSX.Element
|
|||||||
const [limit, setLimit] = useState(1000);
|
const [limit, setLimit] = useState(1000);
|
||||||
const [statusString, setStatusString] = useState("Loading audits...");
|
const [statusString, setStatusString] = useState("Loading audits...");
|
||||||
const [auditsByDate, setAuditsByDate] = useState([] as QRecord[][]);
|
const [auditsByDate, setAuditsByDate] = useState([] as QRecord[][]);
|
||||||
const [auditDetailMap, setAuditDetailMap] = useState(null as Map<number, JSX.Element[]>)
|
const [auditDetailMap, setAuditDetailMap] = useState(null as Map<number, JSX.Element[]>);
|
||||||
const [fieldChangeMap, setFieldChangeMap] = useState(null as Map<number, JSX.Element>)
|
const [fieldChangeMap, setFieldChangeMap] = useState(null as Map<number, JSX.Element>);
|
||||||
const [sortDirection, setSortDirection] = useState(localStorage.getItem("audit.sortDirection") === "true");
|
const [sortDirection, setSortDirection] = useState(localStorage.getItem("audit.sortDirection") === "true");
|
||||||
const {accentColor} = useContext(QContext);
|
const {accentColor} = useContext(QContext);
|
||||||
|
|
||||||
function wrapValue(value: any): JSX.Element
|
function wrapValue(value: any): JSX.Element
|
||||||
{
|
{
|
||||||
return <span style={{fontWeight: "500", color: " rgb(123, 128, 154)"}}>{value}</span>
|
return <span style={{fontWeight: "500", color: " rgb(123, 128, 154)"}}>{value}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function wasValue(value: any): JSX.Element
|
function wasValue(value: any): JSX.Element
|
||||||
{
|
{
|
||||||
return <span style={{fontWeight: "100", color: " rgb(123, 128, 154)"}}>{value}</span>
|
return <span style={{fontWeight: "100", color: " rgb(123, 128, 154)"}}>{value}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAuditDetailFieldChangeRow(qRecord: QRecord): JSX.Element | null
|
function getAuditDetailFieldChangeRow(qRecord: QRecord): JSX.Element | null
|
||||||
@ -81,8 +81,12 @@ function AuditBody({tableMetaData, recordId, record}: Props): JSX.Element
|
|||||||
const newValue = qRecord.values.get("auditDetail.newValue");
|
const newValue = qRecord.values.get("auditDetail.newValue");
|
||||||
if (fieldName && (oldValue !== null || newValue !== null))
|
if (fieldName && (oldValue !== null || newValue !== null))
|
||||||
{
|
{
|
||||||
const fieldLabel = tableMetaData?.fields?.get(fieldName)?.label ?? fieldName
|
const fieldLabel = tableMetaData?.fields?.get(fieldName)?.label ?? fieldName;
|
||||||
return (<tr><td>{fieldLabel}</td><td>{oldValue}</td><td>{newValue}</td></tr>)
|
return (<tr>
|
||||||
|
<td>{fieldLabel}</td>
|
||||||
|
<td>{oldValue}</td>
|
||||||
|
<td>{newValue}</td>
|
||||||
|
</tr>);
|
||||||
}
|
}
|
||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
@ -198,12 +202,12 @@ function AuditBody({tableMetaData, recordId, record}: Props): JSX.Element
|
|||||||
new QFilterOrderBy("timestamp", sortDirection),
|
new QFilterOrderBy("timestamp", sortDirection),
|
||||||
new QFilterOrderBy("id", sortDirection),
|
new QFilterOrderBy("id", sortDirection),
|
||||||
new QFilterOrderBy("auditDetail.id", true)
|
new QFilterOrderBy("auditDetail.id", true)
|
||||||
], "AND", 0, limit);
|
], null, "AND", 0, limit);
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// fetch audits in try-catch //
|
// fetch audits in try-catch //
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
let audits = [] as QRecord[]
|
let audits = [] as QRecord[];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
audits = await qController.query("audit", filter, [new QueryJoin("auditDetail", true, "LEFT")]);
|
audits = await qController.query("audit", filter, [new QueryJoin("auditDetail", true, "LEFT")]);
|
||||||
@ -233,7 +237,7 @@ function AuditBody({tableMetaData, recordId, record}: Props): JSX.Element
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// group the audits by auditId (e.g., this is a list that joined audit & auditDetail, so un-flatten it) //
|
// group the audits by auditId (e.g., this is a list that joined audit & auditDetail, so un-flatten it) //
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
const unflattenedAudits: QRecord[] = []
|
const unflattenedAudits: QRecord[] = [];
|
||||||
const detailMap: Map<number, JSX.Element[]> = new Map();
|
const detailMap: Map<number, JSX.Element[]> = new Map();
|
||||||
const fieldChangeRowsMap: Map<number, JSX.Element[]> = new Map();
|
const fieldChangeRowsMap: Map<number, JSX.Element[]> = new Map();
|
||||||
for (let i = 0; i < audits.length; i++)
|
for (let i = 0; i < audits.length; i++)
|
||||||
@ -252,7 +256,7 @@ function AuditBody({tableMetaData, recordId, record}: Props): JSX.Element
|
|||||||
detailMap.set(id, []);
|
detailMap.set(id, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
detailMap.get(id).push(auditDetail)
|
detailMap.get(id).push(auditDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
// table version, probably not to commit
|
// table version, probably not to commit
|
||||||
@ -288,11 +292,11 @@ function AuditBody({tableMetaData, recordId, record}: Props): JSX.Element
|
|||||||
{fieldChangeRowsMap.get(id).map((row, key) => <React.Fragment key={key}>{row}</React.Fragment>)}
|
{fieldChangeRowsMap.get(id).map((row, key) => <React.Fragment key={key}>{row}</React.Fragment>)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
)
|
);
|
||||||
fieldChangeMap.set(id, fieldChangeTable);
|
fieldChangeMap.set(id, fieldChangeTable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setFieldChangeMap(fieldChangeMap)
|
setFieldChangeMap(fieldChangeMap);
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// group the audits by date //
|
// group the audits by date //
|
||||||
@ -350,7 +354,7 @@ function AuditBody({tableMetaData, recordId, record}: Props): JSX.Element
|
|||||||
const changeSortDirection = () =>
|
const changeSortDirection = () =>
|
||||||
{
|
{
|
||||||
setAudits([]);
|
setAudits([]);
|
||||||
const newSortDirection = !sortDirection
|
const newSortDirection = !sortDirection;
|
||||||
setSortDirection(newSortDirection);
|
setSortDirection(newSortDirection);
|
||||||
localStorage.setItem("audit.sortDirection", String(newSortDirection));
|
localStorage.setItem("audit.sortDirection", String(newSortDirection));
|
||||||
};
|
};
|
||||||
|
@ -71,7 +71,7 @@ function hasGotoFieldNames(tableMetaData: QTableMetaData): boolean
|
|||||||
|
|
||||||
function GotoRecordDialog(props: Props): JSX.Element
|
function GotoRecordDialog(props: Props): JSX.Element
|
||||||
{
|
{
|
||||||
const fields: QFieldMetaData[] = []
|
const fields: 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;
|
||||||
@ -108,7 +108,7 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
const rs = {} as { [field: string]: string };
|
const rs = {} as { [field: string]: string };
|
||||||
fields.forEach((field) => rs[field.name] = "");
|
fields.forEach((field) => rs[field.name] = "");
|
||||||
return (rs);
|
return (rs);
|
||||||
}
|
};
|
||||||
|
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
const [values, setValues] = useState(makeInitialValues());
|
const [values, setValues] = useState(makeInitialValues());
|
||||||
@ -118,14 +118,14 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
{
|
{
|
||||||
values[fieldName] = newValue;
|
values[fieldName] = newValue;
|
||||||
setValues(JSON.parse(JSON.stringify(values)));
|
setValues(JSON.parse(JSON.stringify(values)));
|
||||||
}
|
};
|
||||||
|
|
||||||
const close = () =>
|
const close = () =>
|
||||||
{
|
{
|
||||||
setError("");
|
setError("");
|
||||||
setValues(makeInitialValues());
|
setValues(makeInitialValues());
|
||||||
props.closeHandler();
|
props.closeHandler();
|
||||||
}
|
};
|
||||||
|
|
||||||
const keyPressed = (e: React.KeyboardEvent<HTMLDivElement>) =>
|
const keyPressed = (e: React.KeyboardEvent<HTMLDivElement>) =>
|
||||||
{
|
{
|
||||||
@ -144,7 +144,7 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
const index = targetId?.replaceAll("gotoInput-", "");
|
const index = targetId?.replaceAll("gotoInput-", "");
|
||||||
document.getElementById("gotoButton-" + index).click();
|
document.getElementById("gotoButton-" + index).click();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const closeRequested = () =>
|
const closeRequested = () =>
|
||||||
{
|
{
|
||||||
@ -152,15 +152,15 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const goClicked = async (fieldName: string) =>
|
const goClicked = async (fieldName: string) =>
|
||||||
{
|
{
|
||||||
setError("");
|
setError("");
|
||||||
const filter = new QQueryFilter([new QFilterCriteria(fieldName, QCriteriaOperator.EQUALS, [values[fieldName]])], null, "AND", null, 10);
|
const filter = new QQueryFilter([new QFilterCriteria(fieldName, QCriteriaOperator.EQUALS, [values[fieldName]])], 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);
|
||||||
if (queryResult.length == 0)
|
if (queryResult.length == 0)
|
||||||
{
|
{
|
||||||
setError("Record not found.");
|
setError("Record not found.");
|
||||||
@ -183,13 +183,13 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
setError(`Error: ${(e && e.message) ? e.message : e}`);
|
setError(`Error: ${(e && e.message) ? e.message : e}`);
|
||||||
setTimeout(() => setError(""), 6000);
|
setTimeout(() => setError(""), 6000);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
if (props.tableMetaData)
|
if (props.tableMetaData)
|
||||||
{
|
{
|
||||||
if (fields.length == 0 && !error)
|
if (fields.length == 0 && !error)
|
||||||
{
|
{
|
||||||
setError("This table is not configured for this feature.")
|
setError("This table is not configured for this feature.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ function GotoRecordDialog(props: Props): JSX.Element
|
|||||||
: <Box> </Box>
|
: <Box> </Box>
|
||||||
}
|
}
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GotoRecordButtonProps
|
interface GotoRecordButtonProps
|
||||||
@ -266,7 +266,7 @@ GotoRecordButton.defaultProps = {
|
|||||||
|
|
||||||
export function GotoRecordButton(props: GotoRecordButtonProps): JSX.Element
|
export function GotoRecordButton(props: GotoRecordButtonProps): JSX.Element
|
||||||
{
|
{
|
||||||
const [gotoIsOpen, setGotoIsOpen] = useState(props.autoOpen)
|
const [gotoIsOpen, setGotoIsOpen] = useState(props.autoOpen);
|
||||||
|
|
||||||
function openGoto()
|
function openGoto()
|
||||||
{
|
{
|
||||||
|
@ -25,7 +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, Link} from "@mui/material";
|
import {Alert, Button} from "@mui/material";
|
||||||
import Box from "@mui/material/Box";
|
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";
|
||||||
@ -40,14 +40,14 @@ import TextField from "@mui/material/TextField";
|
|||||||
import Tooltip from "@mui/material/Tooltip";
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
import {TooltipProps} from "@mui/material/Tooltip/Tooltip";
|
import {TooltipProps} from "@mui/material/Tooltip/Tooltip";
|
||||||
import FormData from "form-data";
|
import FormData from "form-data";
|
||||||
import React, {useContext, useEffect, useRef, useState} from "react";
|
|
||||||
import {useLocation, useNavigate} from "react-router-dom";
|
|
||||||
import QContext from "QContext";
|
import QContext from "QContext";
|
||||||
import colors from "qqq/assets/theme/base/colors";
|
import colors from "qqq/assets/theme/base/colors";
|
||||||
import {QCancelButton, QDeleteButton, QSaveButton} from "qqq/components/buttons/DefaultButtons";
|
import {QCancelButton, QDeleteButton, QSaveButton} from "qqq/components/buttons/DefaultButtons";
|
||||||
import RecordQueryView from "qqq/models/query/RecordQueryView";
|
import RecordQueryView from "qqq/models/query/RecordQueryView";
|
||||||
import FilterUtils from "qqq/utils/qqq/FilterUtils";
|
import FilterUtils from "qqq/utils/qqq/FilterUtils";
|
||||||
import {SavedViewUtils} from "qqq/utils/qqq/SavedViewUtils";
|
import {SavedViewUtils} from "qqq/utils/qqq/SavedViewUtils";
|
||||||
|
import React, {useContext, useEffect, useRef, useState} from "react";
|
||||||
|
import {useLocation, useNavigate} from "react-router-dom";
|
||||||
|
|
||||||
interface Props
|
interface Props
|
||||||
{
|
{
|
||||||
@ -227,6 +227,12 @@ function SavedViews({qController, metaData, tableMetaData, currentSavedView, tab
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
const viewObject = JSON.parse(JSON.stringify(view));
|
const viewObject = JSON.parse(JSON.stringify(view));
|
||||||
viewObject.queryFilter = JSON.parse(JSON.stringify(FilterUtils.convertFilterPossibleValuesToIds(viewObject.queryFilter)));
|
viewObject.queryFilter = JSON.parse(JSON.stringify(FilterUtils.convertFilterPossibleValuesToIds(viewObject.queryFilter)));
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// strip away incomplete filters too, just for cleaner saved view filters //
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
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)
|
||||||
|
@ -29,7 +29,6 @@ import {QCriteriaOperator} from "@kingsrook/qqq-frontend-core/lib/model/query/QC
|
|||||||
import {QFilterCriteria} from "@kingsrook/qqq-frontend-core/lib/model/query/QFilterCriteria";
|
import {QFilterCriteria} from "@kingsrook/qqq-frontend-core/lib/model/query/QFilterCriteria";
|
||||||
import {QFilterOrderBy} from "@kingsrook/qqq-frontend-core/lib/model/query/QFilterOrderBy";
|
import {QFilterOrderBy} from "@kingsrook/qqq-frontend-core/lib/model/query/QFilterOrderBy";
|
||||||
import {QQueryFilter} from "@kingsrook/qqq-frontend-core/lib/model/query/QQueryFilter";
|
import {QQueryFilter} from "@kingsrook/qqq-frontend-core/lib/model/query/QQueryFilter";
|
||||||
import {Badge, ToggleButton, ToggleButtonGroup} from "@mui/material";
|
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Dialog from "@mui/material/Dialog";
|
import Dialog from "@mui/material/Dialog";
|
||||||
@ -38,9 +37,10 @@ import DialogContent from "@mui/material/DialogContent";
|
|||||||
import DialogContentText from "@mui/material/DialogContentText";
|
import DialogContentText from "@mui/material/DialogContentText";
|
||||||
import DialogTitle from "@mui/material/DialogTitle";
|
import DialogTitle from "@mui/material/DialogTitle";
|
||||||
import Icon from "@mui/material/Icon";
|
import Icon from "@mui/material/Icon";
|
||||||
|
import ToggleButton from "@mui/material/ToggleButton";
|
||||||
|
import ToggleButtonGroup from "@mui/material/ToggleButtonGroup";
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
import {GridApiPro} from "@mui/x-data-grid-pro/models/gridApiPro";
|
import {GridApiPro} from "@mui/x-data-grid-pro/models/gridApiPro";
|
||||||
import React, {forwardRef, useContext, useImperativeHandle, useReducer, useState} from "react";
|
|
||||||
import QContext from "QContext";
|
import QContext from "QContext";
|
||||||
import colors from "qqq/assets/theme/base/colors";
|
import colors from "qqq/assets/theme/base/colors";
|
||||||
import {QCancelButton, QSaveButton} from "qqq/components/buttons/DefaultButtons";
|
import {QCancelButton, QSaveButton} from "qqq/components/buttons/DefaultButtons";
|
||||||
@ -51,6 +51,7 @@ import QuickFilter, {quickFilterButtonStyles} from "qqq/components/query/QuickFi
|
|||||||
import XIcon from "qqq/components/query/XIcon";
|
import XIcon from "qqq/components/query/XIcon";
|
||||||
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, {forwardRef, useContext, useImperativeHandle, useReducer, useState} from "react";
|
||||||
|
|
||||||
interface BasicAndAdvancedQueryControlsProps
|
interface BasicAndAdvancedQueryControlsProps
|
||||||
{
|
{
|
||||||
@ -89,14 +90,14 @@ let debounceTimeout: string | number | NodeJS.Timeout;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
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} = props;
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// state variables //
|
// state variables //
|
||||||
/////////////////////
|
/////////////////////
|
||||||
const [defaultQuickFilterFieldNames, setDefaultQuickFilterFieldNames] = useState(getDefaultQuickFilterFieldNames(tableMetaData));
|
const [defaultQuickFilterFieldNames, setDefaultQuickFilterFieldNames] = useState(getDefaultQuickFilterFieldNames(tableMetaData));
|
||||||
const [defaultQuickFilterFieldNameMap, setDefaultQuickFilterFieldNameMap] = useState(Object.fromEntries(defaultQuickFilterFieldNames.map(k => [k, true])));
|
const [defaultQuickFilterFieldNameMap, setDefaultQuickFilterFieldNameMap] = useState(Object.fromEntries(defaultQuickFilterFieldNames.map(k => [k, true])));
|
||||||
const [addQuickFilterMenu, setAddQuickFilterMenu] = useState(null)
|
const [addQuickFilterMenu, setAddQuickFilterMenu] = useState(null);
|
||||||
const [addQuickFilterOpenCounter, setAddQuickFilterOpenCounter] = useState(0);
|
const [addQuickFilterOpenCounter, setAddQuickFilterOpenCounter] = useState(0);
|
||||||
const [showClearFiltersWarning, setShowClearFiltersWarning] = useState(false);
|
const [showClearFiltersWarning, setShowClearFiltersWarning] = useState(false);
|
||||||
const [mouseOverElement, setMouseOverElement] = useState(null as string);
|
const [mouseOverElement, setMouseOverElement] = useState(null as string);
|
||||||
@ -104,6 +105,11 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
|
|
||||||
const {accentColor} = useContext(QContext);
|
const {accentColor} = useContext(QContext);
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
// temporary, until we implement sub-filtering //
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
const [isQueryTooComplex, setIsQueryTooComplex] = useState(false);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
// make some functions available to our parent - so it can tell us to do things //
|
// make some functions available to our parent - so it can tell us to do things //
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -122,7 +128,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
{
|
{
|
||||||
return (mode);
|
return (mode);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -207,7 +213,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
clearTimeout(debounceTimeout)
|
clearTimeout(debounceTimeout);
|
||||||
debounceTimeout = setTimeout(() =>
|
debounceTimeout = setTimeout(() =>
|
||||||
{
|
{
|
||||||
setQueryFilter(queryFilter);
|
setQueryFilter(queryFilter);
|
||||||
@ -254,7 +260,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const handleRemoveQuickFilterField = (fieldName: string): void =>
|
const handleRemoveQuickFilterField = (fieldName: string): void =>
|
||||||
{
|
{
|
||||||
const index = quickFilterFieldNames.indexOf(fieldName)
|
const index = quickFilterFieldNames.indexOf(fieldName);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
@ -276,7 +282,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
{
|
{
|
||||||
setAddQuickFilterMenu(event.currentTarget);
|
setAddQuickFilterMenu(event.currentTarget);
|
||||||
setAddQuickFilterOpenCounter(addQuickFilterOpenCounter + 1);
|
setAddQuickFilterOpenCounter(addQuickFilterOpenCounter + 1);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -285,7 +291,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
const closeAddQuickFilterMenu = () =>
|
const closeAddQuickFilterMenu = () =>
|
||||||
{
|
{
|
||||||
setAddQuickFilterMenu(null);
|
setAddQuickFilterMenu(null);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -352,7 +358,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
addQuickFilterField({fieldName: fullFieldName}, "selectedFromAddFilterMenu");
|
addQuickFilterField({fieldName: fullFieldName}, "selectedFromAddFilterMenu");
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -360,8 +366,11 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
** filter panel
|
** filter panel
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const openFilterBuilder = (e: React.MouseEvent<HTMLAnchorElement> | React.MouseEvent<HTMLButtonElement>) =>
|
const openFilterBuilder = (e: React.MouseEvent<HTMLAnchorElement> | React.MouseEvent<HTMLButtonElement>) =>
|
||||||
|
{
|
||||||
|
if (!isQueryTooComplex)
|
||||||
{
|
{
|
||||||
gridApiRef.current.showFilterPanel();
|
gridApiRef.current.showFilterPanel();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -385,13 +394,13 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
{
|
{
|
||||||
queryFilter.criteria.splice(index, 1);
|
queryFilter.criteria.splice(index, 1);
|
||||||
setQueryFilter(queryFilter);
|
setQueryFilter(queryFilter);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** format the current query as a string for showing on-screen as a preview.
|
** format the current query as a string for showing on-screen as a preview.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const queryToAdvancedString = () =>
|
const queryToAdvancedString = (thisQueryFilter: QQueryFilter) =>
|
||||||
{
|
{
|
||||||
if (queryFilter == null || !queryFilter.criteria)
|
if (queryFilter == null || !queryFilter.criteria)
|
||||||
{
|
{
|
||||||
@ -401,19 +410,22 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box display="flex" flexWrap="wrap" fontSize="0.875rem">
|
<React.Fragment>
|
||||||
{queryFilter.criteria.map((criteria, i) =>
|
{thisQueryFilter.criteria?.map((criteria, i) =>
|
||||||
{
|
{
|
||||||
const {criteriaIsValid} = validateCriteria(criteria, null);
|
const {criteriaIsValid} = validateCriteria(criteria, null);
|
||||||
if (criteriaIsValid)
|
if (criteriaIsValid)
|
||||||
{
|
{
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span key={i} style={{marginBottom: "0.125rem"}} onMouseOver={() => handleMouseOverElement(`queryPreview-${i}`)} onMouseOut={() => handleMouseOutElement()}>
|
<span key={i} style={{marginBottom: "0.125rem"}} onMouseOver={() => handleMouseOverElement(`queryPreview-${i}`)} onMouseOut={() => handleMouseOutElement()}>
|
||||||
{counter > 1 ? <span style={{marginLeft: "0.25rem", marginRight: "0.25rem"}}>{queryFilter.booleanOperator} </span> : <span/>}
|
{counter > 1 ? <span style={{marginLeft: "0.25rem", marginRight: "0.25rem"}}>{thisQueryFilter.booleanOperator} </span> : <span />}
|
||||||
{FilterUtils.criteriaToHumanString(tableMetaData, criteria, true)}
|
{FilterUtils.criteriaToHumanString(tableMetaData, criteria, true)}
|
||||||
{mouseOverElement == `queryPreview-${i}` && <span className={`advancedQueryPreviewX-${counter - 1}`}><XIcon position="forAdvancedQueryPreview" onClick={() => removeCriteriaByIndex(i)} /></span>}
|
{!isQueryTooComplex && (
|
||||||
|
mouseOverElement == `queryPreview-${i}` && <span className={`advancedQueryPreviewX-${counter - 1}`}>
|
||||||
|
<XIcon position="forAdvancedQueryPreview" onClick={() => removeCriteriaByIndex(i)} /></span>
|
||||||
|
)}
|
||||||
|
{counter > 1 && i == thisQueryFilter.criteria?.length - 1 && thisQueryFilter.subFilters?.length > 0 ? <span style={{marginLeft: "0.25rem", marginRight: "0.25rem"}}>{thisQueryFilter.booleanOperator} </span> : <span />}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -422,7 +434,19 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
return (<span />);
|
return (<span />);
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
</Box>
|
|
||||||
|
{thisQueryFilter.subFilters?.length > 0 && (thisQueryFilter.subFilters.map((filter: QQueryFilter, j) =>
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<React.Fragment key={j}>
|
||||||
|
{j > 0 ? <span style={{marginLeft: "0.25rem", marginRight: "0.25rem"}}>{thisQueryFilter.booleanOperator} </span> : <span></span>}
|
||||||
|
<span style={{display: "flex", marginRight: "0.20rem"}}>(</span>
|
||||||
|
{queryToAdvancedString(filter)}
|
||||||
|
<span style={{display: "flex", marginRight: "0.20rem"}}>)</span>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}))}
|
||||||
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -443,7 +467,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
const {canFilterWorkAsBasic} = FilterUtils.canFilterWorkAsBasic(tableMetaData, queryFilter);
|
const {canFilterWorkAsBasic} = FilterUtils.canFilterWorkAsBasic(tableMetaData, queryFilter);
|
||||||
if (!canFilterWorkAsBasic)
|
if (!canFilterWorkAsBasic)
|
||||||
{
|
{
|
||||||
console.log("Query cannot work as basic - so - not allowing toggle to basic.")
|
console.log("Query cannot work as basic - so - not allowing toggle to basic.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,6 +499,11 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
// set a flag if the query is 'too complex' //
|
||||||
|
//////////////////////////////////////////////
|
||||||
|
setIsQueryTooComplex(queryFilter.subFilters?.length > 0);
|
||||||
|
|
||||||
const {canFilterWorkAsBasic} = FilterUtils.canFilterWorkAsBasic(tableMetaData, queryFilter);
|
const {canFilterWorkAsBasic} = FilterUtils.canFilterWorkAsBasic(tableMetaData, queryFilter);
|
||||||
if (!canFilterWorkAsBasic)
|
if (!canFilterWorkAsBasic)
|
||||||
{
|
{
|
||||||
@ -496,7 +525,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -513,9 +542,18 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return count;
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// recursively add any children filters to the total count //
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
for (let i = 0; i < queryFilter.subFilters?.length; i++)
|
||||||
|
{
|
||||||
|
count += countValidCriteria(queryFilter.subFilters[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Event handler for setting the sort from that menu
|
** Event handler for setting the sort from that menu
|
||||||
@ -523,11 +561,11 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
const handleSetSort = (field: QFieldMetaData, table: QTableMetaData, isAscending: boolean = true): void =>
|
const handleSetSort = (field: QFieldMetaData, table: QTableMetaData, isAscending: boolean = true): void =>
|
||||||
{
|
{
|
||||||
const fullFieldName = table && table.name != tableMetaData.name ? `${table.name}.${field.name}` : field.name;
|
const fullFieldName = table && table.name != tableMetaData.name ? `${table.name}.${field.name}` : field.name;
|
||||||
queryFilter.orderBys = [new QFilterOrderBy(fullFieldName, isAscending)]
|
queryFilter.orderBys = [new QFilterOrderBy(fullFieldName, isAscending)];
|
||||||
|
|
||||||
setQueryFilter(queryFilter);
|
setQueryFilter(queryFilter);
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -546,7 +584,7 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
{
|
{
|
||||||
handleSetSort(field, table, isAscending);
|
handleSetSort(field, table, isAscending);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -563,21 +601,21 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
console.log(`Error toggling sort: ${e}`)
|
console.log(`Error toggling sort: ${e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// set up the sort menu button //
|
// set up the sort menu button //
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
let sortButtonContents = <>Sort...</>
|
let sortButtonContents = <>Sort...</>;
|
||||||
if (queryFilter && queryFilter.orderBys && queryFilter.orderBys.length > 0)
|
if (queryFilter && queryFilter.orderBys && queryFilter.orderBys.length > 0)
|
||||||
{
|
{
|
||||||
const orderBy = queryFilter.orderBys[0];
|
const orderBy = queryFilter.orderBys[0];
|
||||||
const orderByFieldName = orderBy.fieldName;
|
const orderByFieldName = orderBy.fieldName;
|
||||||
const [field, fieldTable] = TableUtils.getFieldAndTable(tableMetaData, orderByFieldName);
|
const [field, fieldTable] = TableUtils.getFieldAndTable(tableMetaData, orderByFieldName);
|
||||||
const fieldLabel = fieldTable.name == tableMetaData.name ? field.label : `${fieldTable.label}: ${field.label}`;
|
const fieldLabel = fieldTable.name == tableMetaData.name ? field.label : `${fieldTable.label}: ${field.label}`;
|
||||||
sortButtonContents = <>Sort: {fieldLabel} <Icon onClick={toggleSortDirection} sx={{ml: "0.5rem"}}>{orderBy.isAscending ? "arrow_upward" : "arrow_downward"}</Icon></>
|
sortButtonContents = <>Sort: {fieldLabel} <Icon onClick={toggleSortDirection} sx={{ml: "0.5rem"}}>{orderBy.isAscending ? "arrow_upward" : "arrow_downward"}</Icon></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -594,16 +632,22 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
// set some status flags based on current filter //
|
// set some status flags based on current filter //
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
const hasValidFilters = queryFilter && countValidCriteria(queryFilter) > 0;
|
const hasValidFilters = queryFilter && countValidCriteria(queryFilter) > 0;
|
||||||
const {canFilterWorkAsBasic, reasonsWhyItCannot} = FilterUtils.canFilterWorkAsBasic(tableMetaData, queryFilter);
|
const {canFilterWorkAsBasic, canFilterWorkAsAdvanced, reasonsWhyItCannot} = FilterUtils.canFilterWorkAsBasic(tableMetaData, queryFilter);
|
||||||
let reasonWhyBasicIsDisabled = null;
|
let reasonWhyBasicIsDisabled = null;
|
||||||
if(reasonsWhyItCannot && reasonsWhyItCannot.length > 0)
|
if (canFilterWorkAsAdvanced && reasonsWhyItCannot && reasonsWhyItCannot.length > 0)
|
||||||
{
|
{
|
||||||
reasonWhyBasicIsDisabled = <>
|
reasonWhyBasicIsDisabled = <>
|
||||||
Your current Filter cannot be managed using Basic mode because:
|
Your current Filter cannot be managed using Basic mode because:
|
||||||
<ul style={{marginLeft: "1rem"}}>
|
<ul style={{marginLeft: "1rem"}}>
|
||||||
{reasonsWhyItCannot.map((reason, i) => <li key={i}>{reason}</li>)}
|
{reasonsWhyItCannot.map((reason, i) => <li key={i}>{reason}</li>)}
|
||||||
</ul>
|
</ul>
|
||||||
</>
|
</>;
|
||||||
|
}
|
||||||
|
if (isQueryTooComplex)
|
||||||
|
{
|
||||||
|
reasonWhyBasicIsDisabled = <>
|
||||||
|
Your current Filter is too complex to modify because it contains Sub-filters.
|
||||||
|
</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const borderGray = colors.grayLines.main;
|
const borderGray = colors.grayLines.main;
|
||||||
@ -777,7 +821,9 @@ const BasicAndAdvancedQueryControls = forwardRef((props: BasicAndAdvancedQueryCo
|
|||||||
pb={"0.125rem"}
|
pb={"0.125rem"}
|
||||||
boxShadow={"inset 0px 0px 4px 2px #EFEFED"}
|
boxShadow={"inset 0px 0px 4px 2px #EFEFED"}
|
||||||
>
|
>
|
||||||
{queryToAdvancedString()}
|
<Box display="flex" flexWrap="wrap" fontSize="0.875rem">
|
||||||
|
{queryToAdvancedString(queryFilter)}
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
}
|
}
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -25,14 +25,13 @@ import {QCriteriaOperator} from "@kingsrook/qqq-frontend-core/lib/model/query/QC
|
|||||||
import {QFilterCriteria} from "@kingsrook/qqq-frontend-core/lib/model/query/QFilterCriteria";
|
import {QFilterCriteria} from "@kingsrook/qqq-frontend-core/lib/model/query/QFilterCriteria";
|
||||||
import {QFilterOrderBy} from "@kingsrook/qqq-frontend-core/lib/model/query/QFilterOrderBy";
|
import {QFilterOrderBy} from "@kingsrook/qqq-frontend-core/lib/model/query/QFilterOrderBy";
|
||||||
import {QQueryFilter} from "@kingsrook/qqq-frontend-core/lib/model/query/QQueryFilter";
|
import {QQueryFilter} from "@kingsrook/qqq-frontend-core/lib/model/query/QQueryFilter";
|
||||||
|
import {Chip} from "@mui/material";
|
||||||
import Alert from "@mui/material/Alert";
|
import Alert from "@mui/material/Alert";
|
||||||
import Avatar from "@mui/material/Avatar";
|
import Avatar from "@mui/material/Avatar";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Chip from "@mui/material/Chip";
|
|
||||||
import Divider from "@mui/material/Divider";
|
import Divider from "@mui/material/Divider";
|
||||||
import Grid from "@mui/material/Grid";
|
import Grid from "@mui/material/Grid";
|
||||||
import Icon from "@mui/material/Icon";
|
|
||||||
import List from "@mui/material/List";
|
import List from "@mui/material/List";
|
||||||
import ListItem from "@mui/material/ListItem";
|
import ListItem from "@mui/material/ListItem";
|
||||||
import ListItemAvatar from "@mui/material/ListItemAvatar";
|
import ListItemAvatar from "@mui/material/ListItemAvatar";
|
||||||
@ -42,8 +41,6 @@ import Snackbar from "@mui/material/Snackbar";
|
|||||||
import Tab from "@mui/material/Tab";
|
import Tab from "@mui/material/Tab";
|
||||||
import Tabs from "@mui/material/Tabs";
|
import Tabs from "@mui/material/Tabs";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import React, {useReducer, useState} from "react";
|
|
||||||
import AceEditor from "react-ace";
|
|
||||||
import DataBagDataEditor, {DataBagDataEditorProps} from "qqq/components/databags/DataBagDataEditor";
|
import DataBagDataEditor, {DataBagDataEditorProps} from "qqq/components/databags/DataBagDataEditor";
|
||||||
import DataBagPreview from "qqq/components/databags/DataBagPreview";
|
import DataBagPreview from "qqq/components/databags/DataBagPreview";
|
||||||
import TabPanel from "qqq/components/misc/TabPanel";
|
import TabPanel from "qqq/components/misc/TabPanel";
|
||||||
@ -57,6 +54,8 @@ import "ace-builds/src-noconflict/mode-java";
|
|||||||
import "ace-builds/src-noconflict/mode-javascript";
|
import "ace-builds/src-noconflict/mode-javascript";
|
||||||
import "ace-builds/src-noconflict/mode-json";
|
import "ace-builds/src-noconflict/mode-json";
|
||||||
import "ace-builds/src-noconflict/theme-github";
|
import "ace-builds/src-noconflict/theme-github";
|
||||||
|
import React, {useReducer, useState} from "react";
|
||||||
|
import AceEditor from "react-ace";
|
||||||
import "ace-builds/src-noconflict/ext-language_tools";
|
import "ace-builds/src-noconflict/ext-language_tools";
|
||||||
|
|
||||||
const qController = Client.getInstance();
|
const qController = Client.getInstance();
|
||||||
@ -64,12 +63,11 @@ const qController = Client.getInstance();
|
|||||||
// Declaring props types for ViewForm
|
// Declaring props types for ViewForm
|
||||||
interface Props
|
interface Props
|
||||||
{
|
{
|
||||||
dataBagId: number
|
dataBagId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataBagViewer.defaultProps =
|
DataBagViewer.defaultProps =
|
||||||
{
|
{};
|
||||||
};
|
|
||||||
|
|
||||||
export default function DataBagViewer({dataBagId}: Props): JSX.Element
|
export default function DataBagViewer({dataBagId}: Props): JSX.Element
|
||||||
{
|
{
|
||||||
@ -82,7 +80,7 @@ export default function DataBagViewer({dataBagId}: Props): JSX.Element
|
|||||||
const [selectedTab, setSelectedTab] = useState(0);
|
const [selectedTab, setSelectedTab] = useState(0);
|
||||||
const [editorProps, setEditorProps] = useState(null as DataBagDataEditorProps);
|
const [editorProps, setEditorProps] = useState(null as DataBagDataEditorProps);
|
||||||
const [successText, setSuccessText] = useState(null as string);
|
const [successText, setSuccessText] = useState(null as string);
|
||||||
const [failText, setFailText] = useState(null as string)
|
const [failText, setFailText] = useState(null as string);
|
||||||
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
||||||
|
|
||||||
const [loadingSelectedVersion, _] = useState(new LoadingState(forceUpdate, "loading"));
|
const [loadingSelectedVersion, _] = useState(new LoadingState(forceUpdate, "loading"));
|
||||||
@ -100,7 +98,7 @@ export default function DataBagViewer({dataBagId}: Props): JSX.Element
|
|||||||
|
|
||||||
const criteria = [new QFilterCriteria("dataBagId", QCriteriaOperator.EQUALS, [dataBagId])];
|
const criteria = [new QFilterCriteria("dataBagId", QCriteriaOperator.EQUALS, [dataBagId])];
|
||||||
const orderBys = [new QFilterOrderBy("sequenceNo", false)];
|
const orderBys = [new QFilterOrderBy("sequenceNo", false)];
|
||||||
const filter = new QQueryFilter(criteria, orderBys, "AND", 0, 25);
|
const filter = new QQueryFilter(criteria, orderBys, null, "AND", 0, 25);
|
||||||
const versions = await qController.query("dataBagVersion", filter);
|
const versions = await qController.query("dataBagVersion", filter);
|
||||||
console.log("Fetched versions:");
|
console.log("Fetched versions:");
|
||||||
console.log(versions);
|
console.log(versions);
|
||||||
|
@ -46,9 +46,6 @@ import Snackbar from "@mui/material/Snackbar";
|
|||||||
import Tab from "@mui/material/Tab";
|
import Tab from "@mui/material/Tab";
|
||||||
import Tabs from "@mui/material/Tabs";
|
import Tabs from "@mui/material/Tabs";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import React, {useReducer, useState} from "react";
|
|
||||||
import AceEditor from "react-ace";
|
|
||||||
import {Link} from "react-router-dom";
|
|
||||||
import TabPanel from "qqq/components/misc/TabPanel";
|
import TabPanel from "qqq/components/misc/TabPanel";
|
||||||
import ScriptDocsForm from "qqq/components/scripts/ScriptDocsForm";
|
import ScriptDocsForm from "qqq/components/scripts/ScriptDocsForm";
|
||||||
import ScriptEditor, {ScriptEditorProps} from "qqq/components/scripts/ScriptEditor";
|
import ScriptEditor, {ScriptEditorProps} from "qqq/components/scripts/ScriptEditor";
|
||||||
@ -65,6 +62,9 @@ import "ace-builds/src-noconflict/mode-javascript";
|
|||||||
import "ace-builds/src-noconflict/mode-velocity";
|
import "ace-builds/src-noconflict/mode-velocity";
|
||||||
import "ace-builds/src-noconflict/mode-json";
|
import "ace-builds/src-noconflict/mode-json";
|
||||||
import "ace-builds/src-noconflict/theme-github";
|
import "ace-builds/src-noconflict/theme-github";
|
||||||
|
import React, {useReducer, useState} from "react";
|
||||||
|
import AceEditor from "react-ace";
|
||||||
|
import {Link} from "react-router-dom";
|
||||||
import "ace-builds/src-noconflict/ext-language_tools";
|
import "ace-builds/src-noconflict/ext-language_tools";
|
||||||
|
|
||||||
const qController = Client.getInstance();
|
const qController = Client.getInstance();
|
||||||
@ -97,8 +97,8 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
const [versionRecordList, setVersionRecordList] = useState(null as QRecord[]);
|
const [versionRecordList, setVersionRecordList] = useState(null as QRecord[]);
|
||||||
const [selectedVersionRecord, setSelectedVersionRecord] = useState(null as QRecord);
|
const [selectedVersionRecord, setSelectedVersionRecord] = useState(null as QRecord);
|
||||||
const [scriptLogs, setScriptLogs] = useState({} as any);
|
const [scriptLogs, setScriptLogs] = useState({} as any);
|
||||||
const [scriptTypeRecord, setScriptTypeRecord] = useState(null as QRecord)
|
const [scriptTypeRecord, setScriptTypeRecord] = useState(null as QRecord);
|
||||||
const [scriptTypeFileSchemaList, setScriptTypeFileSchemaList] = useState(null as QRecord[])
|
const [scriptTypeFileSchemaList, setScriptTypeFileSchemaList] = useState(null as QRecord[]);
|
||||||
const [availableFileNames, setAvailableFileNames] = useState([] as string[]);
|
const [availableFileNames, setAvailableFileNames] = useState([] as string[]);
|
||||||
const [selectedFileName, setSelectedFileName] = useState("");
|
const [selectedFileName, setSelectedFileName] = useState("");
|
||||||
const [currentVersionId, setCurrentVersionId] = useState(null as number);
|
const [currentVersionId, setCurrentVersionId] = useState(null as number);
|
||||||
@ -106,7 +106,7 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
const [selectedTab, setSelectedTab] = useState(0);
|
const [selectedTab, setSelectedTab] = useState(0);
|
||||||
const [editorProps, setEditorProps] = useState(null as ScriptEditorProps);
|
const [editorProps, setEditorProps] = useState(null as ScriptEditorProps);
|
||||||
const [successText, setSuccessText] = useState(null as string);
|
const [successText, setSuccessText] = useState(null as string);
|
||||||
const [failText, setFailText] = useState(null as string)
|
const [failText, setFailText] = useState(null as string);
|
||||||
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
||||||
|
|
||||||
const [loadingSelectedVersion, _] = useState(new LoadingState(forceUpdate, "loading"));
|
const [loadingSelectedVersion, _] = useState(new LoadingState(forceUpdate, "loading"));
|
||||||
@ -135,7 +135,7 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
}
|
}
|
||||||
else if (fileMode == 2) // MULTI_PRE_DEFINED
|
else if (fileMode == 2) // MULTI_PRE_DEFINED
|
||||||
{
|
{
|
||||||
const filter = new QQueryFilter([new QFilterCriteria("scriptTypeId", QCriteriaOperator.EQUALS, [scriptRecord.values.get("scriptTypeId")])], [new QFilterOrderBy("id")])
|
const filter = new QQueryFilter([new QFilterCriteria("scriptTypeId", QCriteriaOperator.EQUALS, [scriptRecord.values.get("scriptTypeId")])], [new QFilterOrderBy("id")]);
|
||||||
scriptTypeFileSchemaList = await qController.query("scriptTypeFileSchema", filter);
|
scriptTypeFileSchemaList = await qController.query("scriptTypeFileSchema", filter);
|
||||||
}
|
}
|
||||||
else // MULTI AD_HOC
|
else // MULTI AD_HOC
|
||||||
@ -147,14 +147,14 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
setScriptTypeFileSchemaList(scriptTypeFileSchemaList);
|
setScriptTypeFileSchemaList(scriptTypeFileSchemaList);
|
||||||
if (scriptTypeFileSchemaList)
|
if (scriptTypeFileSchemaList)
|
||||||
{
|
{
|
||||||
const availableFileNames = scriptTypeFileSchemaList.map((fileSchemaRecord) => fileSchemaRecord.values.get("name"))
|
const availableFileNames = scriptTypeFileSchemaList.map((fileSchemaRecord) => fileSchemaRecord.values.get("name"));
|
||||||
setAvailableFileNames(availableFileNames);
|
setAvailableFileNames(availableFileNames);
|
||||||
setSelectedFileName(availableFileNames[0])
|
setSelectedFileName(availableFileNames[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const criteria = [new QFilterCriteria("scriptId", QCriteriaOperator.EQUALS, [scriptId])];
|
const criteria = [new QFilterCriteria("scriptId", QCriteriaOperator.EQUALS, [scriptId])];
|
||||||
const orderBys = [new QFilterOrderBy("sequenceNo", false)];
|
const orderBys = [new QFilterOrderBy("sequenceNo", false)];
|
||||||
const filter = new QQueryFilter(criteria, orderBys, "AND", 0, 25);
|
const filter = new QQueryFilter(criteria, orderBys, null, "AND", 0, 25);
|
||||||
const versions = await qController.query("scriptRevision", filter);
|
const versions = await qController.query("scriptRevision", filter);
|
||||||
console.log("Fetched versions:");
|
console.log("Fetched versions:");
|
||||||
console.log(versions);
|
console.log(versions);
|
||||||
@ -253,12 +253,12 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
const handleSelectFile = (event: SelectChangeEvent) =>
|
const handleSelectFile = (event: SelectChangeEvent) =>
|
||||||
{
|
{
|
||||||
setSelectedFileName(event.target.value);
|
setSelectedFileName(event.target.value);
|
||||||
}
|
};
|
||||||
|
|
||||||
const getSelectedFileCode = (): string =>
|
const getSelectedFileCode = (): string =>
|
||||||
{
|
{
|
||||||
return (getSelectedVersionCode()[selectedFileName] ?? "");
|
return (getSelectedVersionCode()[selectedFileName] ?? "");
|
||||||
}
|
};
|
||||||
|
|
||||||
const getSelectedFileType = (): string =>
|
const getSelectedFileType = (): string =>
|
||||||
{
|
{
|
||||||
@ -272,12 +272,12 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ("javascript"); // have some default...
|
return ("javascript"); // have some default...
|
||||||
}
|
};
|
||||||
|
|
||||||
const getSelectedVersionCode = (): { [name: string]: string } =>
|
const getSelectedVersionCode = (): { [name: string]: string } =>
|
||||||
{
|
{
|
||||||
let rs: {[name: string]: string} = {}
|
let rs: { [name: string]: string } = {};
|
||||||
let files = selectedVersionRecord?.associatedRecords?.get("files")
|
let files = selectedVersionRecord?.associatedRecords?.get("files");
|
||||||
|
|
||||||
for (let j = 0; j < files?.length; j++)
|
for (let j = 0; j < files?.length; j++)
|
||||||
{
|
{
|
||||||
@ -286,7 +286,7 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (rs);
|
return (rs);
|
||||||
}
|
};
|
||||||
|
|
||||||
function getVersionsList(versionRecordList: QRecord[], selectedVersionRecord: QRecord)
|
function getVersionsList(versionRecordList: QRecord[], selectedVersionRecord: QRecord)
|
||||||
{
|
{
|
||||||
@ -348,7 +348,7 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
{
|
{
|
||||||
(async () =>
|
(async () =>
|
||||||
{
|
{
|
||||||
let filter = new QQueryFilter([new QFilterCriteria("scriptRevisionId", QCriteriaOperator.EQUALS, [scriptRevisionId])], [new QFilterOrderBy("id", false)], "AND", 0, 100);
|
let filter = new QQueryFilter([new QFilterCriteria("scriptRevisionId", QCriteriaOperator.EQUALS, [scriptRevisionId])], [new QFilterOrderBy("id", false)], null, "AND", 0, 100);
|
||||||
scriptLogs[scriptRevisionId] = await qController.query("scriptLog", filter);
|
scriptLogs[scriptRevisionId] = await qController.query("scriptLog", filter);
|
||||||
setScriptLogs(scriptLogs);
|
setScriptLogs(scriptLogs);
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
@ -368,7 +368,7 @@ export default function ScriptViewer({scriptId, associatedScriptTableName, assoc
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (<ScriptLogsView logs={logs} />);
|
return (<ScriptLogsView logs={logs} />);
|
||||||
}
|
};
|
||||||
|
|
||||||
let editButtonTooltip = "";
|
let editButtonTooltip = "";
|
||||||
let editButtonText = "Create New Version";
|
let editButtonText = "Create New Version";
|
||||||
|
@ -63,6 +63,8 @@ export default class RecordQueryView
|
|||||||
|
|
||||||
view.queryFilter = json.queryFilter as QQueryFilter;
|
view.queryFilter = json.queryFilter as QQueryFilter;
|
||||||
|
|
||||||
|
FilterUtils.stripAwayIncompleteCriteria(view.queryFilter)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// it's important that some criteria values exist as expression objects - so - do that. //
|
// it's important that some criteria values exist as expression objects - so - do that. //
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -44,11 +44,9 @@ import LinearProgress from "@mui/material/LinearProgress";
|
|||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
import Modal from "@mui/material/Modal";
|
import Modal from "@mui/material/Modal";
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
import {ColumnHeaderFilterIconButtonProps, DataGridPro, GridCallbackDetails, GridColDef, GridColumnHeaderParams, GridColumnMenuContainer, GridColumnMenuProps, GridColumnOrderChangeParams, GridColumnPinningMenuItems, GridColumnResizeParams, GridColumnsMenuItem, GridColumnVisibilityModel, GridDensity, GridEventListener, GridFilterMenuItem, GridPinnedColumns, gridPreferencePanelStateSelector, GridPreferencePanelsValue, GridRowId, GridRowParams, GridRowsProp, GridSelectionModel, GridSortItem, GridSortModel, GridState, GridToolbarColumnsButton, GridToolbarContainer, GridToolbarDensitySelector, GridToolbarExportContainer, HideGridColMenuItem, MuiEvent, SortGridMenuItems, useGridApiContext, useGridApiEventHandler, useGridApiRef, useGridSelector} from "@mui/x-data-grid-pro";
|
import {ColumnHeaderFilterIconButtonProps, DataGridPro, GridCallbackDetails, GridColDef, GridColumnHeaderParams, GridColumnMenuContainer, GridColumnMenuProps, GridColumnOrderChangeParams, GridColumnPinningMenuItems, GridColumnResizeParams, GridColumnVisibilityModel, GridDensity, GridEventListener, GridPinnedColumns, gridPreferencePanelStateSelector, GridPreferencePanelsValue, GridRowId, GridRowParams, GridRowsProp, GridSelectionModel, GridSortItem, GridSortModel, GridState, GridToolbarContainer, GridToolbarDensitySelector, HideGridColMenuItem, MuiEvent, SortGridMenuItems, useGridApiContext, useGridApiEventHandler, useGridApiRef, useGridSelector} from "@mui/x-data-grid-pro";
|
||||||
import {GridRowModel} from "@mui/x-data-grid/models/gridRows";
|
import {GridRowModel} from "@mui/x-data-grid/models/gridRows";
|
||||||
import FormData from "form-data";
|
import FormData from "form-data";
|
||||||
import React, {forwardRef, useContext, useEffect, useReducer, useRef, useState} from "react";
|
|
||||||
import {useLocation, useNavigate, useSearchParams} from "react-router-dom";
|
|
||||||
import QContext from "QContext";
|
import QContext from "QContext";
|
||||||
import colors from "qqq/assets/theme/base/colors";
|
import colors from "qqq/assets/theme/base/colors";
|
||||||
import {QCancelButton, QCreateNewButton} from "qqq/components/buttons/DefaultButtons";
|
import {QCancelButton, QCreateNewButton} from "qqq/components/buttons/DefaultButtons";
|
||||||
@ -78,6 +76,8 @@ import ProcessUtils from "qqq/utils/qqq/ProcessUtils";
|
|||||||
import {SavedViewUtils} from "qqq/utils/qqq/SavedViewUtils";
|
import {SavedViewUtils} from "qqq/utils/qqq/SavedViewUtils";
|
||||||
import TableUtils from "qqq/utils/qqq/TableUtils";
|
import TableUtils from "qqq/utils/qqq/TableUtils";
|
||||||
import ValueUtils from "qqq/utils/qqq/ValueUtils";
|
import ValueUtils from "qqq/utils/qqq/ValueUtils";
|
||||||
|
import React, {forwardRef, useContext, useEffect, useReducer, useRef, useState} from "react";
|
||||||
|
import {useLocation, useNavigate, useSearchParams} from "react-router-dom";
|
||||||
|
|
||||||
const CURRENT_SAVED_VIEW_ID_LOCAL_STORAGE_KEY_ROOT = "qqq.currentSavedViewId";
|
const CURRENT_SAVED_VIEW_ID_LOCAL_STORAGE_KEY_ROOT = "qqq.currentSavedViewId";
|
||||||
const DENSITY_LOCAL_STORAGE_KEY_ROOT = "qqq.density";
|
const DENSITY_LOCAL_STORAGE_KEY_ROOT = "qqq.density";
|
||||||
@ -112,7 +112,7 @@ const getLoadingScreen = () =>
|
|||||||
return (<BaseLayout>
|
return (<BaseLayout>
|
||||||
|
|
||||||
</BaseLayout>);
|
</BaseLayout>);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -246,7 +246,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// state of the page - e.g., have we loaded meta data? what about the initial view? or are we ready to render records. //
|
// state of the page - e.g., have we loaded meta data? what about the initial view? or are we ready to render records. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
const [pageState, setPageState] = useState("initial" as PageState)
|
const [pageState, setPageState] = useState("initial" as PageState);
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// meta-data and derived state //
|
// meta-data and derived state //
|
||||||
@ -260,8 +260,8 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
// state of the view of the query screen //
|
// state of the view of the query screen //
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
const [view, setView] = useState(defaultView)
|
const [view, setView] = useState(defaultView);
|
||||||
const [viewAsJson, setViewAsJson] = useState(JSON.stringify(defaultView))
|
const [viewAsJson, setViewAsJson] = useState(JSON.stringify(defaultView));
|
||||||
const [queryFilter, setQueryFilter] = useState(defaultView.queryFilter);
|
const [queryFilter, setQueryFilter] = useState(defaultView.queryFilter);
|
||||||
const [queryColumns, setQueryColumns] = useState(defaultView.queryColumns);
|
const [queryColumns, setQueryColumns] = useState(defaultView.queryColumns);
|
||||||
const [lastFetchedQFilterJSON, setLastFetchedQFilterJSON] = useState("");
|
const [lastFetchedQFilterJSON, setLastFetchedQFilterJSON] = useState("");
|
||||||
@ -309,7 +309,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
const [columnStatsFieldName, setColumnStatsFieldName] = useState(null as string);
|
const [columnStatsFieldName, setColumnStatsFieldName] = useState(null as string);
|
||||||
const [columnStatsField, setColumnStatsField] = useState(null as QFieldMetaData);
|
const [columnStatsField, setColumnStatsField] = useState(null as QFieldMetaData);
|
||||||
const [columnStatsFieldTableName, setColumnStatsFieldTableName] = useState(null as string)
|
const [columnStatsFieldTableName, setColumnStatsFieldTableName] = useState(null as string);
|
||||||
const [filterForColumnStats, setFilterForColumnStats] = useState(null as QQueryFilter);
|
const [filterForColumnStats, setFilterForColumnStats] = useState(null as QQueryFilter);
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
@ -353,14 +353,14 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// add a LoadingState object, in case the initial loads (of meta data and view) are slow //
|
// add a LoadingState object, in case the initial loads (of meta data and view) are slow //
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
const [pageLoadingState, _] = useState(new LoadingState(forceUpdate))
|
const [pageLoadingState, _] = useState(new LoadingState(forceUpdate));
|
||||||
|
|
||||||
if (isFirstRenderAfterChangingTables)
|
if (isFirstRenderAfterChangingTables)
|
||||||
{
|
{
|
||||||
setIsFirstRenderAfterChangingTables(false);
|
setIsFirstRenderAfterChangingTables(false);
|
||||||
|
|
||||||
console.log("This is the first render after changing tables - so - setting state based on 'defaults' from localStorage");
|
console.log("This is the first render after changing tables - so - setting state based on 'defaults' from localStorage");
|
||||||
setView(defaultView)
|
setView(defaultView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -415,7 +415,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (false);
|
return (false);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -423,7 +423,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const prepQueryFilterForBackend = (sourceFilter: QQueryFilter) =>
|
const prepQueryFilterForBackend = (sourceFilter: QQueryFilter) =>
|
||||||
{
|
{
|
||||||
const filterForBackend = new QQueryFilter([], sourceFilter.orderBys, sourceFilter.booleanOperator);
|
const filterForBackend = new QQueryFilter([], sourceFilter.orderBys, sourceFilter.subFilters, sourceFilter.booleanOperator);
|
||||||
for (let i = 0; i < sourceFilter?.criteria?.length; i++)
|
for (let i = 0; i < sourceFilter?.criteria?.length; i++)
|
||||||
{
|
{
|
||||||
const criteria = sourceFilter.criteria[i];
|
const criteria = sourceFilter.criteria[i];
|
||||||
@ -442,16 +442,26 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// else push a clone of the criteria - since it may get manipulated below (convertFilterPossibleValuesToIds) //
|
// else push a clone of the criteria - since it may get manipulated below (convertFilterPossibleValuesToIds) //
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
const [field] = FilterUtils.getField(tableMetaData, criteria.fieldName)
|
const [field] = FilterUtils.getField(tableMetaData, criteria.fieldName);
|
||||||
filterForBackend.criteria.push(new QFilterCriteria(criteria.fieldName, criteria.operator, FilterUtils.cleanseCriteriaValueForQQQ(criteria.values, field)));
|
filterForBackend.criteria.push(new QFilterCriteria(criteria.fieldName, criteria.operator, FilterUtils.cleanseCriteriaValueForQQQ(criteria.values, field)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////
|
||||||
|
// recursively prep subfilters as well //
|
||||||
|
/////////////////////////////////////////
|
||||||
|
let subFilters = [] as QQueryFilter[];
|
||||||
|
for (let j = 0; j < sourceFilter?.subFilters?.length; j++)
|
||||||
|
{
|
||||||
|
subFilters.push(prepQueryFilterForBackend(sourceFilter.subFilters[j]));
|
||||||
|
}
|
||||||
|
|
||||||
|
filterForBackend.subFilters = subFilters;
|
||||||
filterForBackend.skip = pageNumber * rowsPerPage;
|
filterForBackend.skip = pageNumber * rowsPerPage;
|
||||||
filterForBackend.limit = rowsPerPage;
|
filterForBackend.limit = rowsPerPage;
|
||||||
|
|
||||||
return filterForBackend;
|
return filterForBackend;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -475,7 +485,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
// build the export menu, for the header //
|
// build the export menu, for the header //
|
||||||
///////////////////////////////////////////
|
///////////////////////////////////////////
|
||||||
let exportMenu = <></>
|
let exportMenu = <></>;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const exportMenuItemRestProps =
|
const exportMenuItemRestProps =
|
||||||
@ -485,7 +495,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
columnsModel: columnsModel,
|
columnsModel: columnsModel,
|
||||||
columnVisibilityModel: columnVisibilityModel,
|
columnVisibilityModel: columnVisibilityModel,
|
||||||
queryFilter: prepQueryFilterForBackend(queryFilter)
|
queryFilter: prepQueryFilterForBackend(queryFilter)
|
||||||
}
|
};
|
||||||
|
|
||||||
exportMenu = (<>
|
exportMenu = (<>
|
||||||
<IconButton sx={{p: 0, fontSize: "0.75rem", mb: 1, color: colors.secondary.main, fontVariationSettings: "'wght' 100"}} onClick={openExportMenu}><Icon fontSize="small">save_alt</Icon></IconButton>
|
<IconButton sx={{p: 0, fontSize: "0.75rem", mb: 1, color: colors.secondary.main, fontVariationSettings: "'wght' 100"}} onClick={openExportMenu}><Icon fontSize="small">save_alt</Icon></IconButton>
|
||||||
@ -552,7 +562,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
<ul style={{marginLeft: "1rem"}}>
|
<ul style={{marginLeft: "1rem"}}>
|
||||||
{joinLabels.map((name) => <li key={name}>{name}</li>)}
|
{joinLabels.map((name) => <li key={name}>{name}</li>)}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -586,7 +596,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Typography>
|
</Typography>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
// Keyboard handling //
|
// Keyboard handling //
|
||||||
@ -602,12 +612,12 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
{
|
{
|
||||||
if (!e.metaKey && e.key === "n" && table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission)
|
if (!e.metaKey && e.key === "n" && table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission)
|
||||||
{
|
{
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
navigate(`${metaData?.getTablePathByName(tableName)}/create`);
|
navigate(`${metaData?.getTablePathByName(tableName)}/create`);
|
||||||
}
|
}
|
||||||
else if (!e.metaKey && e.key === "r")
|
else if (!e.metaKey && e.key === "r")
|
||||||
{
|
{
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
updateTable("'r' keyboard event");
|
updateTable("'r' keyboard event");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -620,23 +630,23 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
*/
|
*/
|
||||||
else if (!e.metaKey && e.key === "f")
|
else if (!e.metaKey && e.key === "f")
|
||||||
{
|
{
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (basicAndAdvancedQueryControlsRef?.current?.getCurrentMode() == "advanced")
|
if (basicAndAdvancedQueryControlsRef?.current?.getCurrentMode() == "advanced")
|
||||||
{
|
{
|
||||||
gridApiRef.current.showFilterPanel()
|
gridApiRef.current.showFilterPanel();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
document.addEventListener("keydown", down)
|
document.addEventListener("keydown", down);
|
||||||
return () =>
|
return () =>
|
||||||
{
|
{
|
||||||
document.removeEventListener("keydown", down)
|
document.removeEventListener("keydown", down);
|
||||||
}
|
};
|
||||||
}, [dotMenuOpen, keyboardHelpOpen, metaData, activeModalProcess])
|
}, [dotMenuOpen, keyboardHelpOpen, metaData, activeModalProcess]);
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -645,7 +655,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
const urlLooksLikeProcess = (): boolean =>
|
const urlLooksLikeProcess = (): boolean =>
|
||||||
{
|
{
|
||||||
return (pathParts[pathParts.length - 2] === tableName);
|
return (pathParts[pathParts.length - 2] === tableName);
|
||||||
}
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// monitor location changes - if our url looks like a savedView, then load that view, kinda //
|
// monitor location changes - if our url looks like a savedView, then load that view, kinda //
|
||||||
@ -701,9 +711,28 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
const doSetView = (view: RecordQueryView): void =>
|
const doSetView = (view: RecordQueryView): void =>
|
||||||
{
|
{
|
||||||
setView(view);
|
setView(view);
|
||||||
setViewAsJson(JSON.stringify(view));
|
const viewAsJSON = JSON.stringify(view);
|
||||||
localStorage.setItem(viewLocalStorageKey, JSON.stringify(view));
|
setViewAsJson(viewAsJSON);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// in case there's an incomplete criteria in the view (e.g., w/o a fieldName), //
|
||||||
|
// don't store that in local storage - we don't want that, it's messy, and it //
|
||||||
|
// has caused fails in the past. So, clone the view, and strip away such things. //
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const viewForLocalStorage: RecordQueryView = JSON.parse(viewAsJSON);
|
||||||
|
if (viewForLocalStorage?.queryFilter?.criteria?.length > 0)
|
||||||
|
{
|
||||||
|
FilterUtils.stripAwayIncompleteCriteria(viewForLocalStorage.queryFilter)
|
||||||
}
|
}
|
||||||
|
localStorage.setItem(viewLocalStorageKey, JSON.stringify(viewForLocalStorage));
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
console.log("Error storing view in local storage: " + e)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -712,10 +741,10 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
const handleColumnVisibilityChange = (columnVisibilityModel: GridColumnVisibilityModel) =>
|
const handleColumnVisibilityChange = (columnVisibilityModel: GridColumnVisibilityModel) =>
|
||||||
{
|
{
|
||||||
setColumnVisibilityModel(columnVisibilityModel);
|
setColumnVisibilityModel(columnVisibilityModel);
|
||||||
queryColumns.updateVisibility(columnVisibilityModel)
|
queryColumns.updateVisibility(columnVisibilityModel);
|
||||||
|
|
||||||
view.queryColumns = queryColumns;
|
view.queryColumns = queryColumns;
|
||||||
doSetView(view)
|
doSetView(view);
|
||||||
|
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
};
|
};
|
||||||
@ -735,7 +764,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
fieldName = `${table.name}.${field.name}`;
|
fieldName = `${table.name}.${field.name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
view.queryColumns.setIsVisible(fieldName, newValue)
|
view.queryColumns.setIsVisible(fieldName, newValue);
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// update the grid //
|
// update the grid //
|
||||||
@ -745,13 +774,13 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
// update the view (e.g., write local storage) //
|
// update the view (e.g., write local storage) //
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
doSetView(view)
|
doSetView(view);
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// ole' faithful //
|
// ole' faithful //
|
||||||
///////////////////
|
///////////////////
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -790,7 +819,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
setPinnedColumns(queryColumns.toGridPinnedColumns());
|
setPinnedColumns(queryColumns.toGridPinnedColumns());
|
||||||
setColumnVisibilityModel(queryColumns.toColumnVisibilityModel());
|
setColumnVisibilityModel(queryColumns.toColumnVisibilityModel());
|
||||||
setColumnsModel(columns);
|
setColumnsModel(columns);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -799,7 +828,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
const promptForTableVariantSelection = () =>
|
const promptForTableVariantSelection = () =>
|
||||||
{
|
{
|
||||||
setTableVariantPromptOpen(true);
|
setTableVariantPromptOpen(true);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -826,7 +855,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (rs);
|
return (rs);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1055,7 +1084,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
setRowsPerPage(size);
|
setRowsPerPage(size);
|
||||||
|
|
||||||
view.rowsPerPage = size;
|
view.rowsPerPage = size;
|
||||||
doSetView(view)
|
doSetView(view);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1064,11 +1093,11 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
const handlePinnedColumnsChange = (pinnedColumns: GridPinnedColumns) =>
|
const handlePinnedColumnsChange = (pinnedColumns: GridPinnedColumns) =>
|
||||||
{
|
{
|
||||||
setPinnedColumns(pinnedColumns);
|
setPinnedColumns(pinnedColumns);
|
||||||
queryColumns.setPinnedLeftColumns(pinnedColumns.left)
|
queryColumns.setPinnedLeftColumns(pinnedColumns.left);
|
||||||
queryColumns.setPinnedRightColumns(pinnedColumns.right)
|
queryColumns.setPinnedRightColumns(pinnedColumns.right);
|
||||||
|
|
||||||
view.queryColumns = queryColumns;
|
view.queryColumns = queryColumns;
|
||||||
doSetView(view)
|
doSetView(view);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1121,7 +1150,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
let selectedPrimaryKeys = new Set<string>();
|
let selectedPrimaryKeys = new Set<string>();
|
||||||
selectionModel.forEach((value: GridRowId, index: number) =>
|
selectionModel.forEach((value: GridRowId, index: number) =>
|
||||||
{
|
{
|
||||||
checkboxesChecked++
|
checkboxesChecked++;
|
||||||
const valueToPush = latestQueryResults[value as number].values.get(tableMetaData.primaryKeyField);
|
const valueToPush = latestQueryResults[value as number].values.get(tableMetaData.primaryKeyField);
|
||||||
selectedPrimaryKeys.add(valueToPush as string);
|
selectedPrimaryKeys.add(valueToPush as string);
|
||||||
});
|
});
|
||||||
@ -1150,7 +1179,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
queryColumns.updateColumnOrder(columnOrdering);
|
queryColumns.updateColumnOrder(columnOrdering);
|
||||||
|
|
||||||
view.queryColumns = queryColumns;
|
view.queryColumns = queryColumns;
|
||||||
doSetView(view)
|
doSetView(view);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1162,7 +1191,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
queryColumns.updateColumnWidth(params.colDef.field, params.width);
|
queryColumns.updateColumnWidth(params.colDef.field, params.width);
|
||||||
|
|
||||||
view.queryColumns = queryColumns;
|
view.queryColumns = queryColumns;
|
||||||
doSetView(view)
|
doSetView(view);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1185,7 +1214,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
{
|
{
|
||||||
const fieldName = gridSort[i].field;
|
const fieldName = gridSort[i].field;
|
||||||
const isAscending = gridSort[i].sort == "asc";
|
const isAscending = gridSort[i].sort == "asc";
|
||||||
queryFilter.orderBys.push(new QFilterOrderBy(fieldName, isAscending))
|
queryFilter.orderBys.push(new QFilterOrderBy(fieldName, isAscending));
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
@ -1209,7 +1238,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
const handleColumnHeaderClick = (params: GridColumnHeaderParams, event: MuiEvent, details: GridCallbackDetails): void =>
|
const handleColumnHeaderClick = (params: GridColumnHeaderParams, event: MuiEvent, details: GridCallbackDetails): void =>
|
||||||
{
|
{
|
||||||
event.defaultMuiPrevented = true;
|
event.defaultMuiPrevented = true;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1227,7 +1256,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
|
|
||||||
setRowsPerPage(view.rowsPerPage ?? defaultRowsPerPage);
|
setRowsPerPage(view.rowsPerPage ?? defaultRowsPerPage);
|
||||||
setMode(view.mode ?? defaultMode);
|
setMode(view.mode ?? defaultMode);
|
||||||
setQuickFilterFieldNames(view.quickFilterFieldNames ?? []) // todo not i think ?? getDefaultQuickFilterFieldNames(tableMetaData));
|
setQuickFilterFieldNames(view.quickFilterFieldNames ?? []); // todo not i think ?? getDefaultQuickFilterFieldNames(tableMetaData));
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// do this last - in case anything in the view got modified in any of those other doSet methods //
|
// do this last - in case anything in the view got modified in any of those other doSet methods //
|
||||||
@ -1240,7 +1269,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
setTimeout(() => basicAndAdvancedQueryControlsRef?.current?.ensureAllFilterCriteriaAreActiveQuickFilters(view.queryFilter, "activatedView"));
|
setTimeout(() => basicAndAdvancedQueryControlsRef?.current?.ensureAllFilterCriteriaAreActiveQuickFilters(view.queryFilter, "activatedView"));
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1287,14 +1316,14 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
if (!isFromActivateView)
|
if (!isFromActivateView)
|
||||||
{
|
{
|
||||||
view.queryFilter = queryFilter;
|
view.queryFilter = queryFilter;
|
||||||
doSetView(view)
|
doSetView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// this force-update causes a re-render that'll see the changed filter hash/json string, and make an updateTable run (if appropriate) //
|
// this force-update causes a re-render that'll see the changed filter hash/json string, and make an updateTable run (if appropriate) //
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
}
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Wrapper around setQueryColumns that also sets column models for the grid, puts
|
** Wrapper around setQueryColumns that also sets column models for the grid, puts
|
||||||
@ -1327,9 +1356,9 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
if (!isFromActivateView)
|
if (!isFromActivateView)
|
||||||
{
|
{
|
||||||
view.queryColumns = queryColumns;
|
view.queryColumns = queryColumns;
|
||||||
doSetView(view)
|
doSetView(view);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1341,7 +1370,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
setQuickFilterFieldNames([...(names ?? [])]);
|
setQuickFilterFieldNames([...(names ?? [])]);
|
||||||
|
|
||||||
view.quickFilterFieldNames = names;
|
view.quickFilterFieldNames = names;
|
||||||
doSetView(view)
|
doSetView(view);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1354,7 +1383,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
|
|
||||||
view.mode = newValue;
|
view.mode = newValue;
|
||||||
doSetView(view);
|
doSetView(view);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1372,7 +1401,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (selectedIds.length);
|
return (selectedIds.length);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1403,7 +1432,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1568,7 +1597,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
|
|
||||||
setCurrentSavedView(savedViewRecord);
|
setCurrentSavedView(savedViewRecord);
|
||||||
|
|
||||||
const viewJson = savedViewRecord.values.get("viewJson")
|
const viewJson = savedViewRecord.values.get("viewJson");
|
||||||
const newView = RecordQueryView.buildFromJSON(viewJson);
|
const newView = RecordQueryView.buildFromJSON(viewJson);
|
||||||
|
|
||||||
activateView(newView);
|
activateView(newView);
|
||||||
@ -1577,7 +1606,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
// todo can/should/does this move into the view's "identity"? //
|
// todo can/should/does this move into the view's "identity"? //
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
localStorage.setItem(currentSavedViewLocalStorageKey, `${savedViewRecord.values.get("id")}`);
|
localStorage.setItem(currentSavedViewLocalStorageKey, `${savedViewRecord.values.get("id")}`);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1587,7 +1616,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
{
|
{
|
||||||
setCurrentSavedView(null);
|
setCurrentSavedView(null);
|
||||||
localStorage.removeItem(currentSavedViewLocalStorageKey);
|
localStorage.removeItem(currentSavedViewLocalStorageKey);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1603,7 +1632,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
newDefaultView.quickFilterFieldNames = [];
|
newDefaultView.quickFilterFieldNames = [];
|
||||||
newDefaultView.mode = defaultMode;
|
newDefaultView.mode = defaultMode;
|
||||||
return newDefaultView;
|
return newDefaultView;
|
||||||
}
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** event handler for SavedViews component, to handle user selecting a view
|
** event handler for SavedViews component, to handle user selecting a view
|
||||||
@ -1638,9 +1667,9 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
// activate a new default view for the table //
|
// activate a new default view for the table //
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
activateView(buildTableDefaultView(tableMetaData))
|
activateView(buildTableDefaultView(tableMetaData));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** utility function to fetch a saved view from the backend.
|
** utility function to fetch a saved view from the backend.
|
||||||
@ -1668,7 +1697,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
// such as, making values be what they'd be in the UI (not necessarily //
|
// such as, making values be what they'd be in the UI (not necessarily //
|
||||||
// what they're like in the backend); similarly, set anything that's unset. //
|
// what they're like in the backend); similarly, set anything that's unset. //
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
const viewJson = qRecord.values.get("viewJson")
|
const viewJson = qRecord.values.get("viewJson");
|
||||||
const newView = RecordQueryView.buildFromJSON(viewJson);
|
const newView = RecordQueryView.buildFromJSON(viewJson);
|
||||||
|
|
||||||
setWarningAlert(null);
|
setWarningAlert(null);
|
||||||
@ -1689,11 +1718,11 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
newView.queryColumns = QQueryColumns.buildDefaultForTable(tableMetaData);
|
newView.queryColumns = QQueryColumns.buildDefaultForTable(tableMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
qRecord.values.set("viewJson", JSON.stringify(newView))
|
qRecord.values.set("viewJson", JSON.stringify(newView));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (qRecord);
|
return (qRecord);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1798,7 +1827,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
const plural = removedFieldCount > 1;
|
const plural = removedFieldCount > 1;
|
||||||
setWarningAlert(`${removedFieldCount} field${plural ? "s" : ""} that ${plural ? "were" : "was"} part of this view ${plural ? "are" : "is"} no longer in this table, and ${plural ? "were" : "was"} removed from this view (${[...removedFieldNames.values()].join(", ")}).`);
|
setWarningAlert(`${removedFieldCount} field${plural ? "s" : ""} that ${plural ? "were" : "was"} part of this view ${plural ? "are" : "is"} no longer in this table, and ${plural ? "were" : "was"} removed from this view (${[...removedFieldNames.values()].join(", ")}).`);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -1834,8 +1863,8 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
///////////////////////////
|
///////////////////////////
|
||||||
// open the filter panel //
|
// open the filter panel //
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
gridApiRef.current.showPreferences(GridPreferencePanelsValue.filters)
|
gridApiRef.current.showPreferences(GridPreferencePanelsValue.filters);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -2006,7 +2035,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gridApiRef.current.showPreferences(GridPreferencePanelsValue.filters)
|
gridApiRef.current.showPreferences(GridPreferencePanelsValue.filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@ -2116,7 +2145,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
// this page //
|
// this page //
|
||||||
///////////////
|
///////////////
|
||||||
programmaticallySelectSomeOrAllRows();
|
programmaticallySelectSomeOrAllRows();
|
||||||
setSelectFullFilterState("checked")
|
setSelectFullFilterState("checked");
|
||||||
}
|
}
|
||||||
else if (selectedIndex == 1)
|
else if (selectedIndex == 1)
|
||||||
{
|
{
|
||||||
@ -2124,7 +2153,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
// full query result //
|
// full query result //
|
||||||
///////////////////////
|
///////////////////////
|
||||||
programmaticallySelectSomeOrAllRows();
|
programmaticallySelectSomeOrAllRows();
|
||||||
setSelectFullFilterState("filter")
|
setSelectFullFilterState("filter");
|
||||||
}
|
}
|
||||||
else if (selectedIndex == 2)
|
else if (selectedIndex == 2)
|
||||||
{
|
{
|
||||||
@ -2138,7 +2167,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
/////////////////////
|
/////////////////////
|
||||||
// clear selection //
|
// clear selection //
|
||||||
/////////////////////
|
/////////////////////
|
||||||
setSelectFullFilterState("n/a")
|
setSelectFullFilterState("n/a");
|
||||||
setRowSelectionModel([]);
|
setRowSelectionModel([]);
|
||||||
setSelectedIds([]);
|
setSelectedIds([]);
|
||||||
}
|
}
|
||||||
@ -2166,7 +2195,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
{
|
{
|
||||||
programmaticallySelectSomeOrAllRows(value);
|
programmaticallySelectSomeOrAllRows(value);
|
||||||
setSelectionSubsetSize(value);
|
setSelectionSubsetSize(value);
|
||||||
setSelectFullFilterState("filterSubset")
|
setSelectFullFilterState("filterSubset");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2453,7 +2482,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
// so the useEffect that monitors location will see the change, and will set viewIdInLocation //
|
// so the useEffect that monitors location will see the change, and will set viewIdInLocation //
|
||||||
// so upon a re-render we'll hit this block again. //
|
// so upon a re-render we'll hit this block again. //
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
setPageState("loadedMetaData")
|
setPageState("loadedMetaData");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2487,7 +2516,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
setTimeout(() =>
|
setTimeout(() =>
|
||||||
{
|
{
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
basicAndAdvancedQueryControlsRef?.current?.ensureAllFilterCriteriaAreActiveQuickFilters(view.queryFilter, "defaultFilterLoaded")
|
basicAndAdvancedQueryControlsRef?.current?.ensureAllFilterCriteriaAreActiveQuickFilters(view.queryFilter, "defaultFilterLoaded");
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("finished preparing grid, going to page state ready");
|
console.log("finished preparing grid, going to page state ready");
|
||||||
@ -2511,11 +2540,11 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
{
|
{
|
||||||
if (pageState == "ready")
|
if (pageState == "ready")
|
||||||
{
|
{
|
||||||
pageLoadingState.setNotLoading()
|
pageLoadingState.setNotLoading();
|
||||||
|
|
||||||
if (!tableVariantPromptOpen)
|
if (!tableVariantPromptOpen)
|
||||||
{
|
{
|
||||||
updateTable("pageState is now ready")
|
updateTable("pageState is now ready");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [pageState, tableVariantPromptOpen]);
|
}, [pageState, tableVariantPromptOpen]);
|
||||||
@ -2563,7 +2592,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
let gotoVariantSubHeader = <></>;
|
let gotoVariantSubHeader = <></>;
|
||||||
if (tableMetaData?.usesVariants)
|
if (tableMetaData?.usesVariants)
|
||||||
{
|
{
|
||||||
gotoVariantSubHeader = <Box mb={2}>{getTableVariantHeader(tableVariant)}</Box>
|
gotoVariantSubHeader = <Box mb={2}>{getTableVariantHeader(tableVariant)}</Box>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -2615,7 +2644,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
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: string[] = [];
|
const viewDiffs: string[] = [];
|
||||||
SavedViewUtils.diffColumns(tableMetaData, baseView, view, viewDiffs)
|
SavedViewUtils.diffColumns(tableMetaData, baseView, view, viewDiffs);
|
||||||
|
|
||||||
if (viewDiffs.length == 0 && currentSavedView)
|
if (viewDiffs.length == 0 && currentSavedView)
|
||||||
{
|
{
|
||||||
@ -2653,7 +2682,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
color: buttonColor,
|
color: buttonColor,
|
||||||
backgroundColor: buttonBackground,
|
backgroundColor: buttonBackground,
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return (<Box order="2">
|
return (<Box order="2">
|
||||||
<FieldListMenu
|
<FieldListMenu
|
||||||
@ -2668,7 +2697,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
|
|||||||
handleToggleField={handleChangeOneColumnVisibility}
|
handleToggleField={handleChangeOneColumnVisibility}
|
||||||
/>
|
/>
|
||||||
</Box>);
|
</Box>);
|
||||||
}
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// these numbers help set the height of the grid (so page won't scroll) based on spcae above & below it //
|
// these numbers help set the height of the grid (so page won't scroll) based on spcae above & below it //
|
||||||
|
@ -46,8 +46,6 @@ import Menu from "@mui/material/Menu";
|
|||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
import Modal from "@mui/material/Modal";
|
import Modal from "@mui/material/Modal";
|
||||||
import Tooltip from "@mui/material/Tooltip/Tooltip";
|
import Tooltip from "@mui/material/Tooltip/Tooltip";
|
||||||
import React, {useContext, useEffect, useState} from "react";
|
|
||||||
import {useLocation, useNavigate, useParams} from "react-router-dom";
|
|
||||||
import QContext from "QContext";
|
import QContext from "QContext";
|
||||||
import colors from "qqq/assets/theme/base/colors";
|
import colors from "qqq/assets/theme/base/colors";
|
||||||
import AuditBody from "qqq/components/audits/AuditBody";
|
import AuditBody from "qqq/components/audits/AuditBody";
|
||||||
@ -65,6 +63,8 @@ import Client from "qqq/utils/qqq/Client";
|
|||||||
import ProcessUtils from "qqq/utils/qqq/ProcessUtils";
|
import ProcessUtils from "qqq/utils/qqq/ProcessUtils";
|
||||||
import TableUtils from "qqq/utils/qqq/TableUtils";
|
import TableUtils from "qqq/utils/qqq/TableUtils";
|
||||||
import ValueUtils from "qqq/utils/qqq/ValueUtils";
|
import ValueUtils from "qqq/utils/qqq/ValueUtils";
|
||||||
|
import React, {useContext, useEffect, useState} from "react";
|
||||||
|
import {useLocation, useNavigate, useParams} from "react-router-dom";
|
||||||
|
|
||||||
const qController = Client.getInstance();
|
const qController = Client.getInstance();
|
||||||
|
|
||||||
@ -166,50 +166,50 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
{
|
{
|
||||||
if (!e.metaKey && e.key === "n" && table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission)
|
if (!e.metaKey && e.key === "n" && table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission)
|
||||||
{
|
{
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
gotoCreate();
|
gotoCreate();
|
||||||
}
|
}
|
||||||
else if (!e.metaKey && e.key === "e" && table.capabilities.has(Capability.TABLE_UPDATE) && table.editPermission)
|
else if (!e.metaKey && e.key === "e" && table.capabilities.has(Capability.TABLE_UPDATE) && table.editPermission)
|
||||||
{
|
{
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
navigate("edit");
|
navigate("edit");
|
||||||
}
|
}
|
||||||
else if (!e.metaKey && e.key === "c" && table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission)
|
else if (!e.metaKey && e.key === "c" && table.capabilities.has(Capability.TABLE_INSERT) && table.insertPermission)
|
||||||
{
|
{
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
navigate("copy");
|
navigate("copy");
|
||||||
}
|
}
|
||||||
else if (!e.metaKey && e.key === "d" && table.capabilities.has(Capability.TABLE_DELETE) && table.deletePermission)
|
else if (!e.metaKey && e.key === "d" && table.capabilities.has(Capability.TABLE_DELETE) && table.deletePermission)
|
||||||
{
|
{
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
handleClickDeleteButton();
|
handleClickDeleteButton();
|
||||||
}
|
}
|
||||||
else if (!e.metaKey && e.key === "a" && metaData && metaData.tables.has("audit"))
|
else if (!e.metaKey && e.key === "a" && metaData && metaData.tables.has("audit"))
|
||||||
{
|
{
|
||||||
e.preventDefault()
|
e.preventDefault();
|
||||||
navigate("#audit");
|
navigate("#audit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
document.addEventListener("keydown", down)
|
document.addEventListener("keydown", down);
|
||||||
return () =>
|
return () =>
|
||||||
{
|
{
|
||||||
document.removeEventListener("keydown", down)
|
document.removeEventListener("keydown", down);
|
||||||
}
|
};
|
||||||
}, [dotMenuOpen, keyboardHelpOpen, showEditChildForm, showAudit, metaData, location])
|
}, [dotMenuOpen, keyboardHelpOpen, showEditChildForm, showAudit, metaData, location]);
|
||||||
|
|
||||||
const gotoCreate = () =>
|
const gotoCreate = () =>
|
||||||
{
|
{
|
||||||
const path = `${pathParts.slice(0, -1).join("/")}/create`;
|
const path = `${pathParts.slice(0, -1).join("/")}/create`;
|
||||||
navigate(path);
|
navigate(path);
|
||||||
}
|
};
|
||||||
|
|
||||||
const gotoEdit = () =>
|
const gotoEdit = () =>
|
||||||
{
|
{
|
||||||
const path = `${pathParts.slice(0, -1).join("/")}/${record.values.get(table.primaryKeyField)}/edit`;
|
const path = `${pathParts.slice(0, -1).join("/")}/${record.values.get(table.primaryKeyField)}/edit`;
|
||||||
navigate(path);
|
navigate(path);
|
||||||
}
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// monitor location changes - if we've clicked a link from viewing one record to viewing another, //
|
// monitor location changes - if we've clicked a link from viewing one record to viewing another, //
|
||||||
@ -349,7 +349,7 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
{
|
{
|
||||||
visibleJoinTables.add(tableForField.name);
|
visibleJoinTables.add(tableForField.name);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (visibleJoinTables);
|
return (visibleJoinTables);
|
||||||
@ -361,15 +361,15 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
const getSectionHelp = (section: QTableSection) =>
|
const getSectionHelp = (section: QTableSection) =>
|
||||||
{
|
{
|
||||||
const helpRoles = ["VIEW_SCREEN", "READ_SCREENS", "ALL_SCREENS"]
|
const helpRoles = ["VIEW_SCREEN", "READ_SCREENS", "ALL_SCREENS"];
|
||||||
const formattedHelpContent = <HelpContent helpContents={section.helpContents} roles={helpRoles} helpContentKey={`table:${tableName};section:${section.name}`} />;
|
const formattedHelpContent = <HelpContent helpContents={section.helpContents} roles={helpRoles} helpContentKey={`table:${tableName};section:${section.name}`} />;
|
||||||
|
|
||||||
return formattedHelpContent && (
|
return formattedHelpContent && (
|
||||||
<Box px={"1.5rem"} fontSize={"0.875rem"} color={colors.blueGray.main}>
|
<Box px={"1.5rem"} fontSize={"0.875rem"} color={colors.blueGray.main}>
|
||||||
{formattedHelpContent}
|
{formattedHelpContent}
|
||||||
</Box>
|
</Box>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
if (!asyncLoadInited)
|
if (!asyncLoadInited)
|
||||||
@ -401,11 +401,11 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
// load processes that the routing needs to respect //
|
// load processes that the routing needs to respect //
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
const allTableProcesses = ProcessUtils.getProcessesForTable(metaData, tableName, true) // these include hidden ones (e.g., to find the bulks)
|
const allTableProcesses = ProcessUtils.getProcessesForTable(metaData, tableName, true); // these include hidden ones (e.g., to find the bulks)
|
||||||
const runRecordScriptProcess = metaData?.processes.get("runRecordScript");
|
const runRecordScriptProcess = metaData?.processes.get("runRecordScript");
|
||||||
if (runRecordScriptProcess)
|
if (runRecordScriptProcess)
|
||||||
{
|
{
|
||||||
allTableProcesses.unshift(runRecordScriptProcess)
|
allTableProcesses.unshift(runRecordScriptProcess);
|
||||||
}
|
}
|
||||||
setAllTableProcesses(allTableProcesses);
|
setAllTableProcesses(allTableProcesses);
|
||||||
|
|
||||||
@ -522,13 +522,15 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
section.fieldNames.map((fieldName: string) =>
|
section.fieldNames.map((fieldName: string) =>
|
||||||
{
|
{
|
||||||
let [field, tableForField] = TableUtils.getFieldAndTable(tableMetaData, fieldName);
|
let [field, tableForField] = TableUtils.getFieldAndTable(tableMetaData, fieldName);
|
||||||
|
if (field != null)
|
||||||
|
{
|
||||||
let label = field.label;
|
let label = field.label;
|
||||||
|
|
||||||
const helpRoles = ["VIEW_SCREEN", "READ_SCREENS", "ALL_SCREENS"]
|
const helpRoles = ["VIEW_SCREEN", "READ_SCREENS", "ALL_SCREENS"];
|
||||||
const showHelp = helpHelpActive || hasHelpContent(field.helpContents, helpRoles);
|
const showHelp = helpHelpActive || hasHelpContent(field.helpContents, helpRoles);
|
||||||
const formattedHelpContent = <HelpContent helpContents={field.helpContents} roles={helpRoles} heading={label} helpContentKey={`table:${tableName};field:${fieldName}`} />;
|
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>
|
const labelElement = <Typography variant="button" textTransform="none" fontWeight="bold" pr={1} color="rgb(52, 71, 103)" sx={{cursor: "default"}}>{label}:</Typography>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box key={fieldName} flexDirection="row" pr={2}>
|
<Box key={fieldName} flexDirection="row" pr={2}>
|
||||||
@ -542,7 +544,8 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
</Typography>
|
</Typography>
|
||||||
</>
|
</>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</Box>
|
</Box>
|
||||||
@ -603,9 +606,9 @@ function RecordView({table, launchProcess}: Props): JSX.Element
|
|||||||
setWarningMessage(state["warning"]);
|
setWarningMessage(state["warning"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete state["createSuccess"]
|
delete state["createSuccess"];
|
||||||
delete state["updateSuccess"]
|
delete state["updateSuccess"];
|
||||||
delete state["warning"]
|
delete state["warning"];
|
||||||
|
|
||||||
window.history.replaceState(state, "");
|
window.history.replaceState(state, "");
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,14 @@ class FilterUtils
|
|||||||
|
|
||||||
criteria.values = values;
|
criteria.values = values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////
|
||||||
|
// recursively clean values in any subfilters //
|
||||||
|
////////////////////////////////////////////////
|
||||||
|
for (let j = 0; j < queryFilter?.subFilters?.length; j++)
|
||||||
|
{
|
||||||
|
await FilterUtils.cleanupValuesInFilerFromQueryString(qController, tableMetaData, queryFilter.subFilters[j]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -263,18 +271,24 @@ class FilterUtils
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public static canFilterWorkAsBasic(tableMetaData: QTableMetaData, filter: QQueryFilter): { canFilterWorkAsBasic: boolean; reasonsWhyItCannot?: string[] }
|
public static canFilterWorkAsBasic(tableMetaData: QTableMetaData, filter: QQueryFilter): { canFilterWorkAsBasic: boolean; canFilterWorkAsAdvanced: boolean, reasonsWhyItCannot?: string[] }
|
||||||
{
|
{
|
||||||
const reasonsWhyItCannot: string[] = [];
|
const reasonsWhyItCannot: string[] = [];
|
||||||
|
|
||||||
if (filter == null)
|
if (filter == null)
|
||||||
{
|
{
|
||||||
return ({canFilterWorkAsBasic: true});
|
return ({canFilterWorkAsBasic: true, canFilterWorkAsAdvanced: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.booleanOperator == "OR")
|
if (filter.booleanOperator == "OR")
|
||||||
{
|
{
|
||||||
reasonsWhyItCannot.push("Filter uses the 'OR' operator.")
|
reasonsWhyItCannot.push("Filter uses the 'OR' operator.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.subFilters?.length > 0)
|
||||||
|
{
|
||||||
|
reasonsWhyItCannot.push("Filter contains sub-filters.");
|
||||||
|
return ({canFilterWorkAsBasic: false, canFilterWorkAsAdvanced: false, reasonsWhyItCannot: reasonsWhyItCannot});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.criteria)
|
if (filter.criteria)
|
||||||
@ -309,11 +323,11 @@ class FilterUtils
|
|||||||
|
|
||||||
if (reasonsWhyItCannot.length == 0)
|
if (reasonsWhyItCannot.length == 0)
|
||||||
{
|
{
|
||||||
return ({canFilterWorkAsBasic: true});
|
return ({canFilterWorkAsBasic: true, canFilterWorkAsAdvanced: true});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ({canFilterWorkAsBasic: false, reasonsWhyItCannot: reasonsWhyItCannot});
|
return ({canFilterWorkAsBasic: false, canFilterWorkAsAdvanced: true, reasonsWhyItCannot: reasonsWhyItCannot});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +386,7 @@ class FilterUtils
|
|||||||
}
|
}
|
||||||
else if (fieldMetaData.type == QFieldType.BOOLEAN)
|
else if (fieldMetaData.type == QFieldType.BOOLEAN)
|
||||||
{
|
{
|
||||||
labels.push(value == true ? "yes" : "no")
|
labels.push(value == true ? "yes" : "no");
|
||||||
}
|
}
|
||||||
else if (fieldMetaData.type == QFieldType.DATE_TIME)
|
else if (fieldMetaData.type == QFieldType.DATE_TIME)
|
||||||
{
|
{
|
||||||
@ -450,7 +464,7 @@ class FilterUtils
|
|||||||
for (let i = 0; i < queryFilter?.orderBys?.length; i++)
|
for (let i = 0; i < queryFilter?.orderBys?.length; i++)
|
||||||
{
|
{
|
||||||
const orderBy = queryFilter.orderBys[i];
|
const orderBy = queryFilter.orderBys[i];
|
||||||
gridSortModel.push({field: orderBy.fieldName, sort: orderBy.isAscending ? "asc" : "desc"})
|
gridSortModel.push({field: orderBy.fieldName, sort: orderBy.isAscending ? "asc" : "desc"});
|
||||||
}
|
}
|
||||||
return (gridSortModel);
|
return (gridSortModel);
|
||||||
}
|
}
|
||||||
@ -497,33 +511,33 @@ class FilterUtils
|
|||||||
case QCriteriaOperator.LESS_THAN:
|
case QCriteriaOperator.LESS_THAN:
|
||||||
if (isDate || isDateTime)
|
if (isDate || isDateTime)
|
||||||
{
|
{
|
||||||
return ("is before")
|
return ("is before");
|
||||||
}
|
}
|
||||||
return ("less than");
|
return ("less than");
|
||||||
case QCriteriaOperator.LESS_THAN_OR_EQUALS:
|
case QCriteriaOperator.LESS_THAN_OR_EQUALS:
|
||||||
if (isDate)
|
if (isDate)
|
||||||
{
|
{
|
||||||
return ("is on or before")
|
return ("is on or before");
|
||||||
}
|
}
|
||||||
if (isDateTime)
|
if (isDateTime)
|
||||||
{
|
{
|
||||||
return ("is at or before")
|
return ("is at or before");
|
||||||
}
|
}
|
||||||
return ("less than or equals");
|
return ("less than or equals");
|
||||||
case QCriteriaOperator.GREATER_THAN:
|
case QCriteriaOperator.GREATER_THAN:
|
||||||
if (isDate || isDateTime)
|
if (isDate || isDateTime)
|
||||||
{
|
{
|
||||||
return ("is after")
|
return ("is after");
|
||||||
}
|
}
|
||||||
return ("greater than or equals");
|
return ("greater than or equals");
|
||||||
case QCriteriaOperator.GREATER_THAN_OR_EQUALS:
|
case QCriteriaOperator.GREATER_THAN_OR_EQUALS:
|
||||||
if (isDate)
|
if (isDate)
|
||||||
{
|
{
|
||||||
return ("is on or after")
|
return ("is on or after");
|
||||||
}
|
}
|
||||||
if (isDateTime)
|
if (isDateTime)
|
||||||
{
|
{
|
||||||
return ("is at or after")
|
return ("is at or after");
|
||||||
}
|
}
|
||||||
return ("greater than or equals");
|
return ("greater than or equals");
|
||||||
case QCriteriaOperator.IS_BLANK:
|
case QCriteriaOperator.IS_BLANK:
|
||||||
@ -539,7 +553,7 @@ class FilterUtils
|
|||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
console.log(`Error getting operator human string for ${JSON.stringify(criteria)}: ${e}`);
|
console.log(`Error getting operator human string for ${JSON.stringify(criteria)}: ${e}`);
|
||||||
return criteria?.operator
|
return criteria?.operator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,7 +581,7 @@ class FilterUtils
|
|||||||
{valuesString && <Box display="inline" p="0.125rem" pr="0.5rem" sx={{background: "#009971"}} borderRadius="0 0.5rem 0.5rem 0"> {valuesString}</Box>}
|
{valuesString && <Box display="inline" p="0.125rem" pr="0.5rem" sx={{background: "#009971"}} borderRadius="0 0.5rem 0.5rem 0"> {valuesString}</Box>}
|
||||||
|
|
||||||
</Box>
|
</Box>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -575,6 +589,29 @@ class FilterUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** after go-live of redesigin in march 2024, we had bugs where we could get a
|
||||||
|
** filter with a criteria w/ a null field name (e.g., by having an incomplete
|
||||||
|
** criteria in the Advanced filter builder - and that would sometimes break
|
||||||
|
** the screen! So, strip those away when storing or loading filters, via
|
||||||
|
** this function.
|
||||||
|
*******************************************************************************/
|
||||||
|
public static stripAwayIncompleteCriteria(filter: QQueryFilter)
|
||||||
|
{
|
||||||
|
if (filter?.criteria?.length > 0)
|
||||||
|
{
|
||||||
|
for (let i = 0; i < filter.criteria.length; i++)
|
||||||
|
{
|
||||||
|
if (!filter.criteria[i].fieldName)
|
||||||
|
{
|
||||||
|
filter.criteria.splice(i, 1);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FilterUtils;
|
export default FilterUtils;
|
||||||
|
@ -110,7 +110,7 @@ class TableUtils
|
|||||||
return ([tableMetaData.fields.get(fieldName), tableMetaData]);
|
return ([tableMetaData.fields.get(fieldName), tableMetaData]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (null);
|
return [null, null];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ class TableUtils
|
|||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
console.log(`Error getting full field label for ${fieldName} in table ${tableMetaData?.name}: ${e}`);
|
console.log(`Error getting full field label for ${fieldName} in table ${tableMetaData?.name}: ${e}`);
|
||||||
return fieldName
|
return fieldName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user