diff --git a/.prettierignore b/.prettierignore index 19cf2669..f3003555 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,3 @@ node_modules/ /.yarn_home/ /dist/ -/public/ \ No newline at end of file diff --git a/public/accordion.json b/public/accordion.json index 39e06282..f3cbff86 100644 --- a/public/accordion.json +++ b/public/accordion.json @@ -1,111 +1,105 @@ { - "cleaning":{ - - }, - "maxPage":"1", - "variables":[ - { - "variableType":"COLLECTED", - "name":"NAME", - "values":{ - "PREVIOUS":null, - "COLLECTED":null, - "FORCED":null, - "EDITED":null, - "INPUTTED":null - } - } + "cleaning": {}, + "maxPage": "1", + "variables": [ + { + "variableType": "COLLECTED", + "name": "NAME", + "values": { + "PREVIOUS": null, + "COLLECTED": null, + "FORCED": null, + "EDITED": null, + "INPUTTED": null + } + } ], - "components":[ - { - "componentType":"Question", - "id":"idQuestion", - "page":"1", - "label":{ - "type":"VTL|MD", - "value":"\"Label de la Question\"" + "components": [ + { + "componentType": "Question", + "id": "idQuestion", + "page": "1", + "label": { + "type": "VTL|MD", + "value": "\"Label de la Question\"" + }, + "description": { + "type": "VTL|MD", + "value": "\"Description de la question\"" + }, + "declarations": [ + { + "declarationType": "HELP", + "id": "idQuestion-help1", + "label": { + "type": "VTL|MD", + "value": "\"Label de la déclaration en position : `BEFORE_QUESTION_TEXT`\"" + }, + "position": "BEFORE_QUESTION_TEXT" }, - "description":{ - "type":"VTL|MD", - "value":"\"Description de la question\"" - }, - "declarations":[ - { - "declarationType":"HELP", - "id":"idQuestion-help1", - "label":{ - "type":"VTL|MD", - "value":"\"Label de la déclaration en position : `BEFORE_QUESTION_TEXT`\"" - }, - "position":"BEFORE_QUESTION_TEXT" - }, - { - "declarationType":"HELP", - "id":"idQuestion-help3", - "label":{ - "type":"VTL|MD", - "value":"\"Label de la déclaration en position en position : `AFTER_QUESTION_TEXT`\"" - }, - "position":"AFTER_QUESTION_TEXT" - } - ], - "components":[ - { - "page":"1", - "componentType":"Input", - "bindingDependencies":[ - "NAME" - ], - "label":{ - "value":"\"Label du composant Input\"", - "type":"VTL|MD" - }, - "description":{ - "value":"\"Description du composant Input\"", - "type":"VTL|MD" - }, - "conditionFilter":{ - "value":"true", - "type":"VTL" - }, - "maxLength":249, - "id":"name", - "response":{ - "name":"NAME" - } - } - ] - }, - { - "componentType":"Accordion", - "items":[ - { - "label":{ - "value":"\"Pourquoi cette question ?\"", - "type":"VTL|MD" - }, - "body":{ - "value":"\"Pour en connaître plus sur vous **1984**\"", - "type":"VTL|MD" - } - } - ], - "page":"1", - "position":"bottom" - } + { + "declarationType": "HELP", + "id": "idQuestion-help3", + "label": { + "type": "VTL|MD", + "value": "\"Label de la déclaration en position en position : `AFTER_QUESTION_TEXT`\"" + }, + "position": "AFTER_QUESTION_TEXT" + } + ], + "components": [ + { + "page": "1", + "componentType": "Input", + "bindingDependencies": ["NAME"], + "label": { + "value": "\"Label du composant Input\"", + "type": "VTL|MD" + }, + "description": { + "value": "\"Description du composant Input\"", + "type": "VTL|MD" + }, + "conditionFilter": { + "value": "true", + "type": "VTL" + }, + "maxLength": 249, + "id": "name", + "response": { + "name": "NAME" + } + } + ] + }, + { + "componentType": "Accordion", + "items": [ + { + "label": { + "value": "\"Pourquoi cette question ?\"", + "type": "VTL|MD" + }, + "body": { + "value": "\"Pour en connaître plus sur vous **1984**\"", + "type": "VTL|MD" + } + } + ], + "page": "1", + "position": "bottom" + } ], - "pagination":"question", - "resizing":{ - - }, - "label":{ - "type":"VTL|MD", - "value":"Test-Dylan" + "pagination": "question", + "resizing": {}, + "label": { + "type": "VTL|MD", + "value": "Test-Dylan" }, - "lunaticModelVersion":"2.5.0", - "modele":"TESTDYLAN", - "enoCoreVersion":"2.7.1", - "generatingDate":"06-03-2024 12:46:44", - "missing":false, - "id":"lsvuvtbg" -} \ No newline at end of file + "lunaticModelVersion": "2.5.0", + "modele": "TESTDYLAN", + "enoCoreVersion": "2.7.1", + "generatingDate": "06-03-2024 12:46:44", + "missing": false, + "id": "lsvuvtbg" +} diff --git a/src/shared/metadataStore/metadataStore.ts b/src/shared/metadataStore/metadataStore.ts index ec9e3842..4f570c18 100644 --- a/src/shared/metadataStore/metadataStore.ts +++ b/src/shared/metadataStore/metadataStore.ts @@ -29,7 +29,17 @@ export const metadataStore = { return state }, updateMetadata(newState: Partial) { - state = { ...state, ...newState } + const updatedState = Object.keys(newState).reduce( + (acc, key) => { + if (newState[key as keyof MetadataStoreType] !== undefined) { + return { ...acc, [key]: newState[key as keyof MetadataStoreType] } + } + return acc + }, + { ...state } + ) + + state = updatedState emitChange() }, subscribe(listener: () => void): () => void {