From f6d156f51cc9e2a7f5f242302f02b7a942d41602 Mon Sep 17 00:00:00 2001 From: Juicetan Date: Tue, 7 Jan 2025 14:03:55 -0500 Subject: [PATCH 1/2] Enable test for adding new localized item with values; --- tests/objarray.spec.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/objarray.spec.js b/tests/objarray.spec.js index 4e0d932..b6100a2 100644 --- a/tests/objarray.spec.js +++ b/tests/objarray.spec.js @@ -107,7 +107,6 @@ test('Removing object', () => { expect(serverPayload?.objArray?.length).toBe(0); }); -/* test('Adding array object with new attributes', () => { let appObj = new AppObject().fromJSON(serverJSON); appObj.items.push({ @@ -117,10 +116,8 @@ test('Adding array object with new attributes', () => { }); let serverPayload = appObj.toJSON(); - console.log('wtf', JSON.stringify(serverPayload, null, 2)); expect(serverPayload?.objArray?.[1]).toBeTruthy(); expect(serverPayload?.objArray?.[1]?.localizations?.en?.header).toBe('new english header'); expect(serverPayload?.objArray?.[1]?.localizations?.en?.description).toBe('new english description'); expect(serverPayload?.objArray?.[1]?.localizations?.en?.subHeader).toBe('new english title'); -}) -*/ \ No newline at end of file +}) \ No newline at end of file From 6caf2ab84ed8d91d72679f53a2f4ea1fb087a06e Mon Sep 17 00:00:00 2001 From: Juicetan Date: Tue, 7 Jan 2025 14:05:48 -0500 Subject: [PATCH 2/2] Update handler to also cache new object attribute values; --- src/models/localizedModel.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/models/localizedModel.js b/src/models/localizedModel.js index 8b47944..c4c7d77 100644 --- a/src/models/localizedModel.js +++ b/src/models/localizedModel.js @@ -116,6 +116,9 @@ class LocalizedModel{ if(!model._strMap[`${resolvedArrKey}.${attrKey}`]){ model._strMap[`${resolvedArrKey}.${attrKey}`] = {}; } + if(newVal[attrKey]){ + model._setLocalizedValue(`${resolvedArrKey}.${attrKey}`, newVal[attrKey]); + } }); return true; }