Skip to content

Commit

Permalink
added filterfn defintions to all date variants, and fixed linting #979
Browse files Browse the repository at this point in the history
  • Loading branch information
asuresh-code committed Oct 3, 2024
1 parent 9761bf9 commit 816706a
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 36 deletions.
2 changes: 1 addition & 1 deletion public/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* - Please do NOT serve this file on production.
*/

const PACKAGE_VERSION = '2.3.5'
const PACKAGE_VERSION = '2.4.5'
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
const activeClientIds = new Set()
Expand Down
5 changes: 3 additions & 2 deletions src/admin/units/units.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
TableCellOverFlowTipProps,
displayTableRowCountText,
formatDateTimeStrings,
getInitialColumnFilterFnState,
getPageHeightCalc,
removeSecondsFromDate,
} from '../../utils';
Expand All @@ -49,6 +48,7 @@ function Units() {
{
header: 'Value',
accessorFn: (row) => row.value,
filterFn: 'fuzzy',
id: 'value',
Cell: ({ row }) => row.original.value,
},
Expand All @@ -57,6 +57,7 @@ function Units() {
accessorFn: (row) => removeSecondsFromDate(row.modified_time),
id: 'modified_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 350,
enableGrouping: false,
Cell: ({ row }) =>
Expand All @@ -68,6 +69,7 @@ function Units() {
accessorFn: (row) => removeSecondsFromDate(row.created_time),
id: 'created_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 350,
enableGrouping: false,
enableHiding: true,
Expand All @@ -83,7 +85,6 @@ function Units() {
const { preservedState, onPreservedStatesChange } = usePreservedTableState({
initialState: {
pagination: { pageSize: 15, pageIndex: 0 },
columnFilterFns: getInitialColumnFilterFnState(columns),
},
storeInUrl: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,50 @@ exports[`Usage statuses > renders table correctly 1`] = `
class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-jk1t0h-MuiFormControl-root-MuiTextField-root"
>
<div
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-adornedEnd css-953pxc-MuiInputBase-root-MuiInput-root"
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-adornedStart MuiInputBase-adornedEnd css-953pxc-MuiInputBase-root-MuiInput-root"
>
<div
class="MuiInputAdornment-root MuiInputAdornment-positionStart MuiInputAdornment-standard MuiInputAdornment-sizeMedium css-ittuaa-MuiInputAdornment-root"
>
<span
class="notranslate"
>
</span>
<span
aria-label="Change filter mode"
class=""
data-mui-internal-clone-element="true"
>
<button
aria-label="Change filter mode"
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeSmall css-1cyhbc3-MuiButtonBase-root-MuiIconButton-root"
tabindex="0"
type="button"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-i4bv87-MuiSvgIcon-root"
data-testid="FilterListIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M10 18h4v-2h-4zM3 6v2h18V6zm3 7h12v-2H6z"
/>
</svg>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</span>
</div>
<input
aria-describedby=":r7:-helper-text"
aria-invalid="false"
aria-label="Filter by Value"
autocomplete="new-password"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-929hxt-MuiInputBase-input-MuiInput-input"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedStart MuiInputBase-inputAdornedEnd css-929hxt-MuiInputBase-input-MuiInput-input"
id=":r7:"
placeholder="Filter by Value"
title="Filter by Value"
Expand Down Expand Up @@ -433,6 +470,14 @@ exports[`Usage statuses > renders table correctly 1`] = `
</span>
</div>
</div>
<p
class="MuiFormHelperText-root MuiFormHelperText-sizeMedium css-jchqo4-MuiFormHelperText-root"
id=":r7:-helper-text"
>
<label>
Filter Mode: Fuzzy
</label>
</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -592,12 +637,12 @@ exports[`Usage statuses > renders table correctly 1`] = `
</span>
</div>
<input
aria-describedby=":rc:-helper-text"
aria-describedby=":rd:-helper-text"
aria-invalid="false"
aria-label="Min"
autocomplete="new-password"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedStart MuiInputBase-inputAdornedEnd css-929hxt-MuiInputBase-input-MuiInput-input"
id=":rc:"
id=":rd:"
inputmode="text"
placeholder="Min"
title="Min"
Expand Down Expand Up @@ -632,7 +677,7 @@ exports[`Usage statuses > renders table correctly 1`] = `
</div>
<p
class="MuiFormHelperText-root MuiFormHelperText-sizeMedium css-jchqo4-MuiFormHelperText-root"
id=":rc:-helper-text"
id=":rd:-helper-text"
>
<label>
Filter Mode: Between
Expand All @@ -650,7 +695,7 @@ exports[`Usage statuses > renders table correctly 1`] = `
aria-label="Max"
autocomplete="new-password"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-929hxt-MuiInputBase-input-MuiInput-input"
id=":rf:"
id=":rg:"
inputmode="text"
placeholder="Max"
title="Max"
Expand Down Expand Up @@ -843,12 +888,12 @@ exports[`Usage statuses > renders table correctly 1`] = `
</span>
</div>
<input
aria-describedby=":rk:-helper-text"
aria-describedby=":rl:-helper-text"
aria-invalid="false"
aria-label="Min"
autocomplete="new-password"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedStart MuiInputBase-inputAdornedEnd css-929hxt-MuiInputBase-input-MuiInput-input"
id=":rk:"
id=":rl:"
inputmode="text"
placeholder="Min"
title="Min"
Expand Down Expand Up @@ -883,7 +928,7 @@ exports[`Usage statuses > renders table correctly 1`] = `
</div>
<p
class="MuiFormHelperText-root MuiFormHelperText-sizeMedium css-jchqo4-MuiFormHelperText-root"
id=":rk:-helper-text"
id=":rl:-helper-text"
>
<label>
Filter Mode: Between
Expand All @@ -901,7 +946,7 @@ exports[`Usage statuses > renders table correctly 1`] = `
aria-label="Max"
autocomplete="new-password"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-929hxt-MuiInputBase-input-MuiInput-input"
id=":rn:"
id=":ro:"
inputmode="text"
placeholder="Max"
title="Max"
Expand Down Expand Up @@ -1322,7 +1367,7 @@ exports[`Usage statuses > renders table correctly 1`] = `
class="MuiInputBase-root MuiInput-root MuiInputBase-colorPrimary css-1mmm5cp-MuiInputBase-root-MuiInput-root-MuiSelect-root"
>
<div
aria-controls=":rp:"
aria-controls=":rq:"
aria-expanded="false"
aria-haspopup="listbox"
aria-label="Rows per page"
Expand Down
4 changes: 0 additions & 4 deletions src/admin/usageStatuses/usageStatuses.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ function UsageStatuses() {
storeInUrl: true,
});

console.log(
`INITIAL STATE ${JSON.stringify(getInitialColumnFilterFnState(columns))}`
);

const table = useMaterialReactTable({
columns: columns,
data: usageStatusData ?? [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const CatalogueCategoryTableView = (props: CatalogueCategoryTableViewProps) => {
accessorFn: (row) => removeSecondsFromDate(row.modified_time),
id: 'modified_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 567.5,
enableGrouping: false,
Cell: ({ row }) =>
Expand Down
3 changes: 2 additions & 1 deletion src/catalogue/items/catalogueItemsTable.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ const CatalogueItemsTable = (props: CatalogueItemsTableProps) => {
removeSecondsFromDate(row.catalogueItem.modified_time),
id: 'catalogueItem.modified_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 350,
enableGrouping: false,
Cell: ({ row }) =>
Expand All @@ -275,6 +276,7 @@ const CatalogueItemsTable = (props: CatalogueItemsTableProps) => {
removeSecondsFromDate(row.catalogueItem.created_time),
id: 'catalogueItem.created_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 350,
enableGrouping: false,
enableHiding: true,
Expand Down Expand Up @@ -649,7 +651,6 @@ const CatalogueItemsTable = (props: CatalogueItemsTableProps) => {
enableStickyHeader: true,
enableDensityToggle: false,
enableRowSelection: true,
enableColumnFilterModes: true,
enableHiding: !dense,
enableTopToolbar: true,
enableMultiRowSelection: !dense,
Expand Down
17 changes: 0 additions & 17 deletions src/common/preservedTableState.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ export const usePreservedTableState = (props?: UsePreservedTableStateProps) => {
getParsedState(unparsedState)
);

console.log(`PARSED STATE ${JSON.stringify(parsedState)}`);

// Update the search params only if necessary
useEffect(() => {
if (props?.storeInUrl) {
Expand Down Expand Up @@ -275,8 +273,6 @@ export const usePreservedTableState = (props?: UsePreservedTableStateProps) => {
]
);

console.log(`DEFAULT STATE ${JSON.stringify(defaultState)}`);

// Convert the state stored into the url to one that can be used
// (apply any default values here)
const state: State = useMemo(
Expand Down Expand Up @@ -541,19 +537,6 @@ export const usePreservedTableState = (props?: UsePreservedTableStateProps) => {
[defaultState.p, props?.paginationOnly, state.p, updateSearchParams]
);

console.log(
`PRESERVED STATE ${JSON.stringify({
columnFilters: state.cF,
columnFilterFns: state.cFn,
sorting: state.srt,
columnVisibility: state.cVis,
globalFilter: state.gFil,
grouping: state.g,
columnOrder: state.cO,
pagination: state.p,
})}`
);

return {
preservedState: {
columnFilters: state.cF,
Expand Down
4 changes: 4 additions & 0 deletions src/items/itemsTable.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export function ItemsTable(props: ItemTableProps) {
accessorFn: (row) => removeSecondsFromDate(row.item.modified_time),
id: 'item.modified_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 350,
Cell: ({ row }) =>
row.original.item.modified_time &&
Expand All @@ -153,6 +154,7 @@ export function ItemsTable(props: ItemTableProps) {
accessorFn: (row) => removeSecondsFromDate(row.item.created_time),
id: 'item.created_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 350,
Cell: ({ row }) =>
formatDateTimeStrings(row.original.item.created_time, true),
Expand Down Expand Up @@ -184,6 +186,7 @@ export function ItemsTable(props: ItemTableProps) {
: null,
id: 'item.warranty_end_date',
filterVariant: 'date-range',
filterFn: 'betweenInclusive',
size: 350,
Cell: ({ row }) =>
row.original.item.warranty_end_date &&
Expand All @@ -203,6 +206,7 @@ export function ItemsTable(props: ItemTableProps) {
: null,
id: 'item.delivered_date',
filterVariant: 'date-range',
filterFn: 'betweenInclusive',
size: 350,
Cell: ({ row }) =>
row.original.item.delivered_date &&
Expand Down
2 changes: 2 additions & 0 deletions src/manufacturer/manufacturer.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function ManufacturerComponent() {
accessorFn: (row) => removeSecondsFromDate(row.modified_time),
id: 'modified_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 350,
enableGrouping: false,
Cell: ({ row }) =>
Expand All @@ -91,6 +92,7 @@ function ManufacturerComponent() {
accessorFn: (row) => removeSecondsFromDate(row.created_time),
id: 'created_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 350,
enableGrouping: false,
enableHiding: true,
Expand Down
3 changes: 3 additions & 0 deletions src/systems/systemItemsTable.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export function SystemItemsTable(props: SystemItemsTableProps) {
accessorFn: (row) => removeSecondsFromDate(row.item.modified_time),
id: 'item.modified_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 350,
enableGrouping: false,
Cell: ({ row }) =>
Expand All @@ -316,6 +317,7 @@ export function SystemItemsTable(props: SystemItemsTableProps) {
accessorFn: (row) => removeSecondsFromDate(row.item.created_time),
id: 'item.created_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 350,
enableGrouping: false,
Cell: ({ row }) =>
Expand All @@ -330,6 +332,7 @@ export function SystemItemsTable(props: SystemItemsTableProps) {
: null,
id: 'item.delivered_date',
filterVariant: 'date-range',
filterFn: 'betweenInclusive',
size: 350,
Cell: ({ row }) =>
row.original.item.delivered_date &&
Expand Down
1 change: 1 addition & 0 deletions src/systems/systemsTableView.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const SystemsTableView = (props: SystemsTableViewProps) => {
accessorFn: (row) => removeSecondsFromDate(row.modified_time),
id: 'modified_time',
filterVariant: 'datetime-range',
filterFn: 'betweenInclusive',
size: 400,
enableGrouping: false,
Cell: ({ row }) =>
Expand Down
1 change: 1 addition & 0 deletions src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ export const getInitialColumnFilterFnState = (
return initialState;
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const getColumnIds = (columns: MRT_ColumnDef<any>[]): string[] => {
const columnIds = columns.reduce<string[]>((result, column) => {
if (column.id) {
Expand Down

0 comments on commit 816706a

Please sign in to comment.