From 2ba9085883fa2dab5cca2c3423201733632f446d Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Tue, 4 Oct 2022 10:30:54 -0500 Subject: [PATCH] Booleans on query; getProcessSummaryListItemForTableRecordLink; better location-change on entity-view; better singular/plural words in processes --- src/qqq/pages/entity-list/index.tsx | 54 ++++++++++++++++--- .../components/ViewContents/index.tsx | 7 +++ .../components/QProcessSummaryResults.tsx | 3 +- .../components/QValidationReview.tsx | 3 +- .../process-run/model/ProcessSummaryLine.tsx | 42 ++++++++++++++- src/qqq/styles/qqq-override-styles.css | 12 +++++ src/qqq/utils/QFilterUtils.ts | 13 ++++- 7 files changed, 121 insertions(+), 13 deletions(-) diff --git a/src/qqq/pages/entity-list/index.tsx b/src/qqq/pages/entity-list/index.tsx index 4ddba6e..7d98229 100644 --- a/src/qqq/pages/entity-list/index.tsx +++ b/src/qqq/pages/entity-list/index.tsx @@ -35,12 +35,13 @@ import LinearProgress from "@mui/material/LinearProgress"; import Menu from "@mui/material/Menu"; import MenuItem from "@mui/material/MenuItem"; import { - DataGridPro, + DataGridPro, getGridDateOperators, getGridNumericOperators, getGridStringOperators, GridCallbackDetails, GridColDef, GridColumnOrderChangeParams, GridColumnVisibilityModel, GridExportMenuItemProps, + GridFilterItem, GridFilterModel, GridRowId, GridRowParams, @@ -55,6 +56,7 @@ import { GridToolbarFilterButton, MuiEvent } from "@mui/x-data-grid-pro"; +import {GridFilterOperator} from "@mui/x-data-grid/models/gridFilterOperator"; import React, {useCallback, useEffect, useReducer, useRef, useState} from "react"; import {Link, useNavigate, useParams, useSearchParams} from "react-router-dom"; import DashboardLayout from "qqq/components/DashboardLayout"; @@ -216,7 +218,7 @@ function EntityList({table}: Props): JSX.Element filterModel.items.forEach((item) => { const operator = QFilterUtils.gridCriteriaOperatorToQQQ(item.operatorValue); - const values = QFilterUtils.gridCriteriaValueToQQQ(operator, item.value); + const values = QFilterUtils.gridCriteriaValueToQQQ(operator, item.value, item.operatorValue); qFilter.addCriteria(new QFilterCriteria(item.columnField, operator, values)); }); } @@ -324,6 +326,35 @@ function EntityList({table}: Props): JSX.Element delete countResults[latestQueryId]; }, [receivedCountTimestamp]); + const booleanTrueOperator: GridFilterOperator = { + label: "is yes", + value: "isTrue", + getApplyFilterFn: (filterItem: GridFilterItem, column: GridColDef) => null + }; + + const booleanFalseOperator: GridFilterOperator = { + label: "is no", + value: "isFalse", + getApplyFilterFn: (filterItem: GridFilterItem, column: GridColDef) => null + }; + + const booleanEmptyOperator: GridFilterOperator = { + label: "is empty", + value: "isEmpty", + getApplyFilterFn: (filterItem: GridFilterItem, column: GridColDef) => null + }; + + const booleanNotEmptyOperator: GridFilterOperator = { + label: "is not empty", + value: "isNotEmpty", + getApplyFilterFn: (filterItem: GridFilterItem, column: GridColDef) => null + }; + + const getCustomGridBooleanOperators = (): GridFilterOperator[] => + { + return [booleanTrueOperator, booleanFalseOperator, booleanEmptyOperator, booleanNotEmptyOperator]; + } + /////////////////////////// // display query results // /////////////////////////// @@ -380,8 +411,13 @@ function EntityList({table}: Props): JSX.Element let columnType = "string"; let columnWidth = 200; + let filterOperators: GridFilterOperator[] = getGridStringOperators(); - if (!field.possibleValueSourceName) + if (field.possibleValueSourceName) + { + filterOperators = getGridNumericOperators(); + } + else { switch (field.type) { @@ -395,18 +431,23 @@ function EntityList({table}: Props): JSX.Element columnWidth = 75; } + // @ts-ignore + filterOperators = getGridNumericOperators(); break; case QFieldType.DATE: columnType = "date"; columnWidth = 100; + filterOperators = getGridDateOperators(); break; case QFieldType.DATE_TIME: columnType = "dateTime"; columnWidth = 200; + filterOperators = getGridDateOperators(true); break; case QFieldType.BOOLEAN: - columnType = "boolean"; + columnType = "string"; // using boolean gives an odd 'no' for nulls. columnWidth = 75; + filterOperators = getCustomGridBooleanOperators(); break; default: // noop - leave as string @@ -452,6 +493,7 @@ function EntityList({table}: Props): JSX.Element headerName: field.label, width: columnWidth, renderCell: null as any, + filterOperators: filterOperators, }; if(columnsToRender[field.name]) @@ -835,7 +877,7 @@ function EntityList({table}: Props): JSX.Element records on this page are selected. @@ -845,7 +887,7 @@ function EntityList({table}: Props): JSX.Element selectFullFilterState === "filter" && (
All - {` ${totalRecords.toLocaleString()} `} + {` ${totalRecords ? totalRecords.toLocaleString() : "All"} `} records matching this query are selected.