Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/pxweb2-api-client/src/models/Dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ClassType } from './ClassType';
import type { Dimension } from './Dimension';
import type { extension_root } from './extension_root';
import type { href } from './href';
import type { jsonstat_link } from './jsonstat_link';
import type { jsonstat_extension_link } from './jsonstat_extension_link';
import type { jsonstat_note } from './jsonstat_note';
import type { label } from './label';
import type { Role } from './Role';
Expand All @@ -29,7 +29,7 @@ export type Dataset = {
label?: label;
source?: source;
updated?: updated;
link?: jsonstat_link;
link?: jsonstat_extension_link;
/**
* Note for table
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* * SeparatorTab: Can not be combined with SeparatorSpace and SeparatorSemicolon. And only applicable for csv output format.
* * SeparatorSpace: Can not be combined with SeparatorTab and SeparatorSemicolon. And only applicable for csv output format.
* * SeparatorSemicolon: Can not be combined with SeparatorTab and SeparatorSpace. And only applicable for csv output format.
* * ExcludeZerosAndMissingValues: Can be used by all formats but only have effect on csv, html and xlsx output format.
*
*/
export enum OutputFormatParamType {
Expand All @@ -21,4 +22,5 @@ export enum OutputFormatParamType {
SEPARATOR_TAB = 'SeparatorTab',
SEPARATOR_SPACE = 'SeparatorSpace',
SEPARATOR_SEMICOLON = 'SeparatorSemicolon',
EXCLUDE_ZEROS_AND_MISSING_VALUES = 'ExcludeZerosAndMissingValues',
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,40 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { href } from './href';
import type { label } from './label';
export type jsonstat_extension_link = {
/**
* DeprecationWarning, please do not use items from describedby, use items from related instead
* @deprecated
*/
describedby?: Array<{
/**
* A extension object
*/
extension?: Record<string, string>;
}>;
related?: Array<{
extension: {
/**
* What type of information is the link to ( e.g. about-statistics, statistics-homepage, definition). Like the IANA relations, but for px.
*/
relation: string;
/**
* Non-null if the link applies to a spesific category. (Typically each contents variable has it own definition, in these cases category holds the contents variable.)
*/
category?: string | null;
/**
* Metaid that was the source when creating this Link
*/
metaid: string;
};
href: href;
label: label;
/**
* Content-Type
*/
type: string;
}>;
};

4 changes: 4 additions & 0 deletions packages/pxweb2-api-client/src/models/jsonstat_link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
/* tslint:disable */
/* eslint-disable */
import type { href } from './href';
/**
* DeprecationWarning, please do not use jsonstat-link, use jsonstat-extension-link instead
* @deprecated
*/
export type jsonstat_link = Record<string, Array<{
type?: string;
href?: href;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export function Metadata({ variablesDefinitions }: MetadataProps) {
>
<div id={`sidesheet-metadata-${variable.variableName}`}>
<Heading size="xsmall" level="4" spacing={true}>
{variable.variableName}
{
// Capitalize the first letter of the variable name
variable.variableName.charAt(0).toUpperCase() +
variable.variableName.slice(1)
}
</Heading>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { mockHTMLDialogElement } from '@pxweb2/pxweb2-ui/src/lib/util/test-utils
import { renderWithProviders } from '../../util/testing-utils';
import { AppContext, AppContextType } from '../../context/AppProvider';
import {
TableDataContext,
TableDataContextType,
} from '../../context/TableDataProvider';
VariablesContext,
VariablesContextType,
} from '../../context/VariablesProvider';

describe('TableInformation', () => {
beforeEach(() => {
Expand Down Expand Up @@ -155,43 +155,46 @@ describe('TableInformation', () => {
expect(definitionsTab).not.toBeInTheDocument();
});

it('should render Definitions tab when definitions exist', () => {
const tableDataContextValue: TableDataContextType = {
it('should render Definitions tab when variables metadata contains definitions', () => {
const variablesContextValue: VariablesContextType = {
isInitialized: true,
data: {
metadata: {
definitions: {
statisticsDefinitions: {
href: 'https://example.com/definitions',
label: 'Definitions',
},
pxTableMetadata: {
definitions: {
statisticsDefinitions: {
href: 'https://example.com/from-metadata-call',
label: 'Definitions from metadata call',
type: 'text/html',
},
},
} as unknown as TableDataContextType['data'],
fetchTableData: vi.fn(),
fetchSavedQuery: vi.fn(),
pivotToMobile: vi.fn(),
pivotToDesktop: vi.fn(),
pivot: vi.fn(),
buildTableTitle: vi.fn().mockReturnValue({
contentText: '',
firstTitlePart: '',
lastTitlePart: '',
}),
isFadingTable: false,
setIsFadingTable: vi.fn(),
} as unknown as VariablesContextType['pxTableMetadata'],
setPxTableMetadata: vi.fn(),
addSelectedValues: vi.fn(),
getSelectedValuesById: vi.fn().mockReturnValue([]),
getSelectedValuesByIdSorted: vi.fn().mockReturnValue([]),
getSelectedCodelistById: vi.fn().mockReturnValue(undefined),
getNumberOfSelectedValues: vi.fn().mockReturnValue(0),
getSelectedMatrixSize: vi.fn().mockReturnValue(1),
getUniqueIds: vi.fn().mockReturnValue([]),
syncVariablesAndValues: vi.fn(),
hasLoadedInitialSelection: false,
setHasLoadedInitialSelection: vi.fn(),
setSelectedVBValues: vi.fn(),
selectedVBValues: [],
isMatrixSizeAllowed: true,
isLoadingMetadata: false,
setIsLoadingMetadata: vi.fn(),
};

renderWithProviders(
<TableDataContext.Provider value={tableDataContextValue}>
<VariablesContext.Provider value={variablesContextValue}>
<TableInformation
isOpen={true}
selectedTab="tab-definitions"
onClose={() => {
return;
}}
/>
</TableDataContext.Provider>,
</VariablesContext.Provider>,
);

const definitionsTab = screen.getByRole('tab', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cl from 'clsx';

import classes from './TableInformation.module.scss';
import useTableData from '../../context/useTableData';
import useVariables from '../../context/useVariables';
import { ContactTab } from './Contact/ContactTab';
import { DetailsTab } from './Details/DetailsTab';
import useApp from '../../context/useApp';
Expand Down Expand Up @@ -32,7 +33,8 @@ export function TableInformation({
}: TableInformationProps) {
const { t } = useTranslation();
const [activeTab, setActiveTab] = useState(selectedTab ?? '');
const metadataOrUndefined = useTableData().data?.metadata;
const metadataOrUndefined = useTableData().data?.metadata; // metadata only for chosen values
const definitionsOrUndefined = useVariables().pxTableMetadata?.definitions; // total metadata, narrowed down to definitions
const { isMobile } = useApp();
const tabsContentRef = useRef<HTMLDivElement | null>(null);

Expand All @@ -49,7 +51,7 @@ export function TableInformation({
const tabsVariant = isMobile ? 'scrollable' : 'fixed';

const definitionsMandatoryLinkExists =
metadataOrUndefined?.definitions?.statisticsDefinitions !== undefined;
definitionsOrUndefined?.statisticsDefinitions !== undefined;

return (
<SheetComponent
Expand Down Expand Up @@ -109,7 +111,7 @@ export function TableInformation({
</TabPanel>
<TabPanel id="pnl-definitions" controlledBy="tab-definitions">
{definitionsMandatoryLinkExists && (
<DefinitionsTab definitions={metadataOrUndefined?.definitions} />
<DefinitionsTab definitions={definitionsOrUndefined} />
)}
</TabPanel>
<TabPanel id="pnl-details" controlledBy="tab-details">
Expand Down
Loading
Loading