Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b60f284
Update the project with Nx migrate latest
SjurSutterudSagen Jun 25, 2024
69a6bc4
Merge pull request #212 from PxTools/patch/update-dependencies
SjurSutterudSagen Jul 29, 2024
68d1dea
Update project dependencies with Nx Migrate (#217)
SjurSutterudSagen Jul 29, 2024
056f46f
Update chromatic-cli to latest (#218)
SjurSutterudSagen Jul 29, 2024
0419988
Migrate style-dictionary to new major version 4.0.1 (#220)
SjurSutterudSagen Jul 30, 2024
8fec2e5
Refactor scss to have nesting at the end of class (#219)
SjurSutterudSagen Jul 30, 2024
5f3100f
Update react-i18next to v15 (#221)
SjurSutterudSagen Jul 30, 2024
bcbe3bb
Feature/pxweb2 284 Time periods sometimes in the wrong order in the t…
MikaelNordberg Jul 30, 2024
e3f57c8
Add check for empty errorMsg to tableprovider
SjurSutterudSagen Jul 30, 2024
0d6f1cd
Force checks to run
SjurSutterudSagen Jul 30, 2024
23cf14c
Fix missing unique keys in variableBox component
SjurSutterudSagen Jul 30, 2024
729f028
Remove resetting the selection on lng change
SjurSutterudSagen Jul 30, 2024
07d501d
Force checks to run
SjurSutterudSagen Jul 30, 2024
09aaaba
Merge pull request #224 from PxTools/fix/PXWEB2-283-remove-resetting-…
KentMossback Jul 31, 2024
27ebc5f
Merge pull request #223 from PxTools/fix/remove-warnings-about-missin…
KentMossback Jul 31, 2024
8771438
Merge pull request #222 from PxTools/fix/add-check-for-empty-errormsg…
KentMossback Jul 31, 2024
12690d1
Updated link-location in footer and update project description in tra…
Jul 31, 2024
1661a1b
Merge branch 'feature/PXWEB2-286-Update-link-location' into feature/P…
Jul 31, 2024
7291ffd
Removed select section
Aug 1, 2024
5bef7a3
Removed empty spaces
Aug 1, 2024
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ Project leader: [Kristin Glomsås, krg@ssb.no](mailto:krg@ssb.no)

Scrum master: [Åsa Arrhén, asa.arrhen@scb.se](asa.arrhen@scb.se)


2 changes: 1 addition & 1 deletion apps/pxweb2/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
},
"footer": {
"description": "On this site you can follow as Statistics Sweden (SCB) and Statistics Norway (SSB) are building a new and more user-friendly interface for PxWeb.",
"descriptionLink": "Read more about the project on Github",
"descriptionLink": "Read more about the project",
"contact": "Contact",
"projectLeader": "Project leader",
"scrumMaster": "Scrum master",
Expand Down
2 changes: 1 addition & 1 deletion apps/pxweb2/public/locales/sv/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
},
"footer": {
"description": "På den här sidan kan du följa när Statistikmyndigheten SCB och Statistisk centralbyrå (SSB) tar fram ett nytt gränssnitt för PxWeb.",
"descriptionLink": "Läs mer om projektet på Github",
"descriptionLink": "Läs mer om projektet",
"contact": "Kontakt",
"projectLeader": "Projektledare",
"scrumMaster": "Scrummaster",
Expand Down
85 changes: 42 additions & 43 deletions apps/pxweb2/public/theme/variables.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Do not edit directly
* Generated on Wed, 19 Jun 2024 09:21:30 GMT
* Do not edit directly, this file was auto-generated.
*/

:root {
Expand All @@ -12,59 +11,59 @@
--px-border-radius-large: 16px;
--px-border-radius-xlarge: 24px;
--px-border-radius-full: 9999px;
--px-color-background-default: #ffffff;
--px-color-background-subtle: #f0f8f9;
--px-color-base-white: #ffffff;
--px-color-blue-200: #c3e6fe;
--px-color-bluegray-300: #9bc4c5;
--px-color-bluegray-700: #2f555b;
--px-color-background-default: #FFFFFF;
--px-color-background-subtle: #F0F8F9;
--px-color-base-white: #FFFFFF;
--px-color-blue-200: #C3E6FE;
--px-color-bluegray-300: #9BC4C5;
--px-color-bluegray-700: #2F555B;
--px-color-bluegray-900: #162327;
--px-color-surface-default: #ffffff;
--px-color-surface-subtle: #f0f8f9;
--px-color-surface-moderate: #dbebeb;
--px-color-surface-default: #FFFFFF;
--px-color-surface-subtle: #F0F8F9;
--px-color-surface-moderate: #DBEBEB;
--px-color-surface-inverted: #274247;
--px-color-surface-highlight: #ecfeed;
--px-color-surface-highlight: #ECFEED;
--px-color-surface-action: #274247;
--px-color-surface-action-hover: #274247;
--px-color-surface-action-active: #162327;
--px-color-surface-action-subtle-hover: #dbebeb;
--px-color-surface-action-subtle-active: #c3dcdc;
--px-color-surface-info-subtle: #d7ecfe;
--px-color-surface-info-moderate: #c3e6fe;
--px-color-surface-success-subtle: #dbf5dc;
--px-color-surface-success-moderate: #b6e8b8;
--px-color-surface-warning-subtle: #fbf1c0;
--px-color-surface-warning-moderate: #feeb9f;
--px-color-surface-error-subtle: #ffe4e0;
--px-color-surface-error-moderate: #ffcec7;
--px-color-surface-scrim: rgba(39, 66, 71, 0.5);
--px-color-surface-action-subtle-hover: #DBEBEB;
--px-color-surface-action-subtle-active: #C3DCDC;
--px-color-surface-info-subtle: #D7ECFE;
--px-color-surface-info-moderate: #C3E6FE;
--px-color-surface-success-subtle: #DBF5DC;
--px-color-surface-success-moderate: #B6E8B8;
--px-color-surface-warning-subtle: #FBF1C0;
--px-color-surface-warning-moderate: #FEEB9F;
--px-color-surface-error-subtle: #FFE4E0;
--px-color-surface-error-moderate: #FFCEC7;
--px-color-surface-scrim: #27424780;
--px-color-border-default: #162327;
--px-color-border-subtle: #c3dcdc;
--px-color-border-moderate: #62919a;
--px-color-border-divider: #62919a;
--px-color-border-divider-subtle: #c3dcdc;
--px-color-border-subtle: #C3DCDC;
--px-color-border-moderate: #62919A;
--px-color-border-divider: #62919A;
--px-color-border-divider-subtle: #C3DCDC;
--px-color-border-action: #274247;
--px-color-border-hover: #62919a;
--px-color-border-hover: #62919A;
--px-color-border-selected: #274247;
--px-color-border-info: #0179c8;
--px-color-border-success: #00824d;
--px-color-border-warning: #cb7603;
--px-color-border-error: #e23822;
--px-color-border-focus: #9272fc;
--px-color-border-focus-on-inverted: #9272fc;
--px-color-border-info: #0179C8;
--px-color-border-success: #00824D;
--px-color-border-warning: #CB7603;
--px-color-border-error: #E23822;
--px-color-border-focus: #9272FC;
--px-color-border-focus-on-inverted: #9272FC;
--px-color-text-default: #162327;
--px-color-text-subtle: #2d6975;
--px-color-text-on-inverted: #ffffff;
--px-color-text-subtle: #2D6975;
--px-color-text-on-inverted: #FFFFFF;
--px-color-text-action: #274247;
--px-color-text-on-action: #ffffff;
--px-color-text-on-action: #FFFFFF;
--px-color-text-on-action-subtle: #162327;
--px-color-icon-default: #162327;
--px-color-icon-on-inverted: #ffffff;
--px-color-icon-on-inverted: #FFFFFF;
--px-color-icon-action: #274247;
--px-color-icon-on-action: #ffffff;
--px-color-icon-on-action: #FFFFFF;
--px-color-icon-on-action-subtle: #162327;
--px-color-icon-info: #0179c8;
--px-color-icon-success: #00824d;
--px-color-icon-warning: #cb7603;
--px-color-icon-error: #e23822;
--px-color-icon-info: #0179C8;
--px-color-icon-success: #00824D;
--px-color-icon-warning: #CB7603;
--px-color-icon-error: #E23822;
}
43 changes: 27 additions & 16 deletions apps/pxweb2/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,20 @@ export function App() {
const [selectedVBValues, setSelectedVBValues] = useState<SelectedVBValues[]>(
[]
);
const [hasLoadedDefaultSelection, setHasLoadedDefaultSelection] =
useState(false);

useEffect(() => {
/**
* Updates useState hook and synchronizes variables context with the selected VB values.
*
* @param selectedVBValues - An array of selected VB values.
*/
function updateAndSyncVBValues(selectedVBValues: SelectedVBValues[]) {
setSelectedVBValues(selectedVBValues);
variables.syncVariablesAndValues(selectedVBValues);
}

useEffect(() => {
const hasSelectedMandatoryVariables = pxTableMetadata?.variables
.filter((variable) => variable.mandatory)
.every((variable) =>
Expand All @@ -238,13 +248,12 @@ export function App() {
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [i18n, selectedVBValues, tableId, variables, i18n.resolvedLanguage]);
}, [variables, i18n.resolvedLanguage]); // Should only run this useEffect when selectedVBValues are in sync with variables context

useEffect(() => {
if (!tableId) {
return;
}
TableService.getMetadataById(selectedTableId, i18n.resolvedLanguage);

if (isLoadingMetadata === false) {
setIsLoadingMetadata(true);
Expand All @@ -263,6 +272,12 @@ export function App() {
setErrorMsg('');
})
.then(() => {
if (hasLoadedDefaultSelection) {
setIsLoadingMetadata(false);

return;
}

TableService.getDefaultSelection(tableId, i18n.resolvedLanguage)
.then((selectionResponse) => {
const defaultSelection = mapTableSelectionResponse(
Expand All @@ -273,8 +288,9 @@ export function App() {
variable.selectedCodeList !== undefined
);

setSelectedVBValues(defaultSelection);
updateAndSyncVBValues(defaultSelection);
setIsLoadingMetadata(false);
setHasLoadedDefaultSelection(true);
})
.catch((error) => {
setErrorMsg('Error getting default selection: ' + tableId);
Expand All @@ -285,8 +301,6 @@ export function App() {
setPxTableMetadata(null);
});

// TODO: Fix this hook to work as intended instead of ignoring it like this
// TODO: Fix unnecessary default selection call when changing language
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tableId, i18n.resolvedLanguage]);

Expand Down Expand Up @@ -333,7 +347,7 @@ export function App() {
selectedItem
);

setSelectedVBValues(newSelectedValues);
updateAndSyncVBValues(newSelectedValues);

// TODO: This currently returns dummy data until we have the API call setup for it
const valuesForChosenCodeList: Value[] = getCodeListValues(
Expand Down Expand Up @@ -382,7 +396,7 @@ export function App() {
varId
);

setSelectedVBValues(newSelectedValues);
updateAndSyncVBValues(newSelectedValues);
}
if (allValuesSelected === 'false' || allValuesSelected === 'mixed') {
const allValuesOfVariable =
Expand All @@ -394,7 +408,7 @@ export function App() {
allValuesOfVariable
);

setSelectedVBValues(newSelectedValues);
updateAndSyncVBValues(newSelectedValues);
}
};

Expand All @@ -413,7 +427,7 @@ export function App() {
value
);

setSelectedVBValues(newSelectedValues);
updateAndSyncVBValues(newSelectedValues);
}
if (hasVariable && !hasValue) {
const newSelectedValues = addValueToVariable(
Expand All @@ -422,7 +436,7 @@ export function App() {
value
);

setSelectedVBValues(newSelectedValues);
updateAndSyncVBValues(newSelectedValues);
}
if (!hasVariable) {
const newSelectedValues = addValueToNewVariable(
Expand All @@ -431,14 +445,11 @@ export function App() {
value
);

setSelectedVBValues(newSelectedValues);
updateAndSyncVBValues(newSelectedValues);
}
};

function handleVBReset() {
if (selectedVBValues.length > 0) {
setSelectedVBValues([]);
}
if (pxTableMetaToRender !== null) {
setPxTableMetaToRender(null);
}
Expand All @@ -462,7 +473,6 @@ export function App() {

const drawerFilter = (
<div className={styles.variableBoxContainer}>
{/* TODO: I think the warning in the console about unique IDs is the variable.id below*/}
{!isLoadingMetadata &&
pxTableMetaToRender &&
pxTableMetaToRender.variables.length > 0 &&
Expand All @@ -471,6 +481,7 @@ export function App() {
variable.id && (
<VariableBox
id={variable.id}
key={variable.id + pxTableMetaToRender.id}
initialIsOpen={index === 0}
tableId={pxTableMetaToRender.id}
label={variable.label}
Expand Down
12 changes: 7 additions & 5 deletions apps/pxweb2/src/app/components/Content/Content.module.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@use '$ui/style-dictionary/dist/scss/fixed-variables.scss' as fixed;

.contentWrapper {
width: 100%;
overflow: hidden;

@media (min-width: fixed.$breakpoints-medium-min-width) {
background-color: var(--px-color-background-subtle);
}
width: 100%;
overflow: hidden;
}

.topLeftBorderRadius {
Expand All @@ -15,9 +16,6 @@
.content {
min-height: 100%;
margin: fixed.$spacing-6;
@media (min-width: fixed.$breakpoints-medium-min-width) {
padding: fixed.$spacing-12;
}

background-color: var(--px-color-background-default);
border-radius: var(--px-border-radius-xlarge);
Expand All @@ -28,4 +26,8 @@
align-items: flex-start;
gap: fixed.$spacing-10;
flex: 1 0 0;

@media (min-width: fixed.$breakpoints-medium-min-width) {
padding: fixed.$spacing-12;
}
}
2 changes: 1 addition & 1 deletion apps/pxweb2/src/app/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Footer: React.FC = () => {
<Link
inline={true}
target="_blank"
href="https://github.com/PxTools/PxWeb2"
href="https://pxtools.github.io/PxWeb2/"
>
{t('presentation_page.footer.descriptionLink')}
</Link>
Expand Down
18 changes: 12 additions & 6 deletions apps/pxweb2/src/app/context/TableDataProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { i18n } from 'i18next';
import React, { createContext, useState, useEffect, ReactNode } from 'react';
import useVariables from './useVariables';
import { Dataset, TableService, VariableSelection, VariablesSelection } from '@pxweb2/pxweb2-api-client';
import {
Dataset,
TableService,
VariableSelection,
VariablesSelection,
} from '@pxweb2/pxweb2-api-client';
import { PxTable } from '@pxweb2/pxweb2-ui';
import { mapJsonStat2Response } from '../../mappers/JsonStat2ResponseMapper';

Expand Down Expand Up @@ -29,12 +34,13 @@ const TableDataProvider: React.FC<TableDataProviderProps> = ({ children }) => {
const variables = useVariables();

useEffect(() => {
console.error('ERROR: TableDataProvider:', errorMsg);
if (errorMsg !== '') {
console.error('ERROR: TableDataProvider:', errorMsg);
}
}, [errorMsg]);

const fetchTableData = async (tableId: string, i18n: i18n) => {

const selections : Array<VariableSelection> = [];
const selections: Array<VariableSelection> = [];
const ids = variables.getUniqueIds();
ids.forEach((id) => {
const selection: VariableSelection = {
Expand All @@ -43,8 +49,8 @@ const TableDataProvider: React.FC<TableDataProviderProps> = ({ children }) => {
};
selections.push(selection);
});
const variablesSelection : VariablesSelection = {selection: selections};

const variablesSelection: VariablesSelection = { selection: selections };

const res = await TableService.getTableDataByPost(
tableId,
Expand Down
6 changes: 1 addition & 5 deletions libs/pxweb2-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

This library was generated with [Nx](https://nx.dev).

## Running unit tests
## Running unit tests

Run `nx test pxweb2-ui` to execute the unit tests via [Vitest](https://vitest.dev/).




1 change: 1 addition & 0 deletions libs/pxweb2-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@pxweb2/pxweb2-ui",
"version": "0.0.1",
"main": "./index.js",
"type": "module",
"types": "./index.d.ts",
"exports": {
".": {
Expand Down
Loading