Skip to content

Commit

Permalink
error on simple table style
Browse files Browse the repository at this point in the history
  • Loading branch information
ddecrulle committed Jun 14, 2024
1 parent 9b9f7c4 commit f5007c8
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 543 deletions.
32 changes: 22 additions & 10 deletions src/Loop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,34 @@ export const Loop: LunaticSlotComponents["Loop"] = props => {
console.error("Only declaration in Question are displayed");
}

const hasErrors = errors && errors.length > 0;

return (
<>
<label htmlFor={id} id={`label-${id}`}>
{label}
<span>{description}</span>
</label>
{errors?.map(error =>
error.errorMessage ? (
<Alert
severity="error"
description={error.errorMessage}
small
className={fr.cx("fr-mt-1w")}
key={error.id}
/>
) : null,
{hasErrors && (
<div role="alert">
{errors.map(error => {
if (!error.errorMessage) {
//TODO throw error
console.error(`The error : ${error} do not contains message`);
return;
}
return (
<Alert
severity="error"
description={error.errorMessage}
small
className={fr.cx("fr-mt-1w")}
key={error.id}
id={error.id}
/>
);
})}
</div>
)}
{children}
{canControlRows && (
Expand Down
16 changes: 10 additions & 6 deletions src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export const Table: LunaticSlotComponents["Table"] = props => {
const hasErrors = errors && errors.length > 0;
const errorMessageId = `${id}-messages`;
return (
<div id={id} className={fr.cx("fr-table", "fr-table--bordered")}>
<>
{hasErrors && (
<div id={errorMessageId}>
<div id={errorMessageId} role="alert">
{errors.map(error => {
if (!error.errorMessage) {
//TODO throw error
Expand All @@ -32,10 +32,14 @@ export const Table: LunaticSlotComponents["Table"] = props => {
})}
</div>
)}
<table {...(hasErrors ? { "aria-invalid": true, "aria-errormessage": errorMessageId } : {})}>
{children}
</table>
</div>
<div id={id} className={fr.cx("fr-table", "fr-table--bordered")}>
<table
{...(hasErrors ? { "aria-invalid": true, "aria-errormessage": errorMessageId } : {})}
>
{children}
</table>
</div>
</>
);
};

Expand Down
3 changes: 1 addition & 2 deletions src/stories/Orchestrator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ export const Orchestrator: (props: OrchestratorProps) => JSX.Element = ({
const { currentErrors } = compileControls();
setErrorActive({ ...errorActive, [pageTag]: currentErrors || {} });
if (!currentErrors) {
//goNextPage();
goNextPage();
}
goNextPage();
};

return (
Expand Down
27 changes: 22 additions & 5 deletions src/stories/table/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const source: LunaticSource = {
"criticality": "INFO",
"errorMessage": {
"type": "VTL|MD",
"value": '" La valeur doit être comprise entre 0 et 9999."',
"value": '"GLOBAL: La valeur de TABLEAUCLA33 doit être comprise entre 0 et 10."',
},
"typeOfControl": "FORMAT",
"control": {
Expand Down Expand Up @@ -155,13 +155,13 @@ export const source: LunaticSource = {
"criticality": "INFO",
"errorMessage": {
"type": "VTL|MD",
"value": '" La valeur doit être comprise entre 0 et 9999."',
"value": '" La valeur doit être comprise entre 0 et 10."',
},
"typeOfControl": "FORMAT",
"control": {
"type": "VTL",
"value":
"not(not(isnull(TABLEAUCLA23)) and (0>TABLEAUCLA23 or 9999<TABLEAUCLA23))",
"not(not(isnull(TABLEAUCLA23)) and (0>TABLEAUCLA23 or 10<TABLEAUCLA23))",
},
"id": "luwhnbxk-RDOP-luwh4tva-format-borne-inf-sup",
},
Expand All @@ -183,13 +183,13 @@ export const source: LunaticSource = {
"criticality": "INFO",
"errorMessage": {
"type": "VTL|MD",
"value": '" La valeur doit être comprise entre 0 et 9999."',
"value": '" La valeur doit être comprise entre 0 et 10."',
},
"typeOfControl": "FORMAT",
"control": {
"type": "VTL",
"value":
"not(not(isnull(TABLEAUCLA13)) and (0>TABLEAUCLA13 or 9999<TABLEAUCLA13))",
"not(not(isnull(TABLEAUCLA13)) and (0>TABLEAUCLA13 or 10<TABLEAUCLA13))",
},
"id": "luwhnbxk-RDOP-luwh7btb-format-borne-inf-sup",
},
Expand Down Expand Up @@ -293,6 +293,23 @@ export const source: LunaticSource = {
},
"decimals": 0,
"id": "luwhnbxk-RDOP-luwh7btb",
"controls": [
{
"criticality": "INFO",
"errorMessage": {
"type": "VTL|MD",
"value":
'"INPUTNUMBER: La valeur de TABLEAUCLA33 doit être comprise entre 0 et 10."',
},
"typeOfControl": "FORMAT",
"control": {
"type": "VTL",
"value":
"not(not(isnull(TABLEAUCLA33)) and (0>TABLEAUCLA33 or 10<TABLEAUCLA33))",
},
"id": "luwhnbxk-RDOP-luwhcilc-format-borne-inf-sup",
},
],
},
],
[
Expand Down
Loading

0 comments on commit f5007c8

Please sign in to comment.