From 1a69ecec63d3626f0308d5acdbc32dbf0f239a14 Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Fri, 8 Nov 2024 13:48:49 +0100 Subject: [PATCH] JNG-5993 save state --- .../AccessTablePage/index.tsx.snapshot | 3 +- .../model/ActionGroupTest-ui.model | 4 +- .../components/widgets/CardsContainer.tsx.hbs | 63 +++++++++++++++++-- 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/frontend-react/src/pages/God/God/Galaxies/AccessTablePage/index.tsx.snapshot b/judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/frontend-react/src/pages/God/God/Galaxies/AccessTablePage/index.tsx.snapshot index b0314296..f0bdcd8e 100644 --- a/judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/frontend-react/src/pages/God/God/Galaxies/AccessTablePage/index.tsx.snapshot +++ b/judo-ui-react-itest/ActionGroupTest/action_group_test__god/src/test/resources/snapshots/frontend-react/src/pages/God/God/Galaxies/AccessTablePage/index.tsx.snapshot @@ -27,6 +27,7 @@ import type { JudoIdentifiable } from '~/services/data-api/common/JudoIdentifiab import { draftIdentifierPrefix } from '~/services/data-api/common/utils'; import type { ViewGalaxy, ViewGalaxyStored } from '~/services/data-api/model/ViewGalaxy'; import type { ViewGalaxyQueryCustomizer } from '~/services/data-api/rest/ViewGalaxyQueryCustomizer'; +import { X_JUDO_COUNT_RECORDS } from '~/services/data-api/rest/headers'; import type { JudoRestResponse } from '~/services/data-api/rest/requestResponse'; import { GodServiceForGalaxiesImpl } from '~/services/data-axios/GodServiceForGalaxiesImpl'; import { judoAxiosProvider } from '~/services/data-axios/JudoAxiosProvider'; @@ -195,7 +196,7 @@ export default function GodGodGalaxiesAccessTablePage() { try { setIsLoading(true); setEditMode(false); - return godServiceForGalaxiesImpl.list(undefined, queryCustomizer); + return godServiceForGalaxiesImpl.list(undefined, queryCustomizer, { [X_JUDO_COUNT_RECORDS]: 'true' }); } catch (error) { handleError(error); setLatestViewData(null); diff --git a/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model b/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model index 3491a8d0..6741371e 100644 --- a/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model +++ b/judo-ui-react-itest/ActionGroupTest/model/ActionGroupTest-ui.model @@ -3728,7 +3728,7 @@ - + @@ -5601,7 +5601,7 @@ - + diff --git a/judo-ui-react/src/main/resources/actor/src/components/widgets/CardsContainer.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/components/widgets/CardsContainer.tsx.hbs index 50c9747b..56de04ff 100644 --- a/judo-ui-react/src/main/resources/actor/src/components/widgets/CardsContainer.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/components/widgets/CardsContainer.tsx.hbs @@ -1,7 +1,14 @@ {{> fragment.header.hbs }} -import { useState, useMemo, useCallback, useEffect } from 'react'; +import { useState, useMemo, useCallback, useEffect, type ChangeEvent } from 'react'; import Box from '@mui/material/Box'; +import Button from '@mui/material/Button'; +import Grid from '@mui/material/Grid'; +import Card from '@mui/material/Card'; +import CardContent from '@mui/material/CardContent'; +import CardActions from '@mui/material/CardActions'; +import Pagination from '@mui/material/Pagination'; +import Typography from '@mui/material/Typography'; import type { GridColDef, GridEventListener, @@ -169,9 +176,9 @@ export const CardsContainer = (props: CardsContain }; const { data: res, headers } = await fetch!(processedQueryCustomizer); - if (showTotalCount) { + // if (typeof showTotalCount === 'boolean' ? showTotalCount : true) { setTotalCount(headers[X_JUDO_COUNT] ? Number(headers[X_JUDO_COUNT]) : -1); - } + // } if (res.length > rowsPerPage) { setIsNextButtonEnabled(true); @@ -199,5 +206,53 @@ export const CardsContainer = (props: CardsContain fetchData(); }, [queryCustomizer, refreshCounter]); - return ID: {uniqueId}; + const onPageChange = useCallback((event: ChangeEvent, page: number) => { + alert(page); + }, []); + + const formatValue = useCallback((value: any) => { + if (value instanceof Date) { + return new Intl.DateTimeFormat(l10nLocale, { + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + hour12: false + }).format(value); + } + if (value === undefined || value === null) { + return ''; + } + return value.toString(); + }, []); + + return + ID: {uniqueId} + + Filters + + + {data.map(d => ( + + + {columns.map((k, idx) => ( + + {formatValue(d[k.field])} + + ))} + + + + + + ))} + + + + + + + ; };