From 399dd8efdfc2de33dd8b3d97abdd6dd62ab9a35a Mon Sep 17 00:00:00 2001 From: Hanna Laakso Date: Mon, 11 Mar 2019 17:32:27 +0000 Subject: [PATCH] Delete this commit. Demo for testing Demo for testing that data in various shapes doesn't get overwritten. Next step: have tests to handle this. --- app/data/session-data-defaults.js | 46 +++++++++++++++++++++-- docs/views/examples/pass-data/test1.html | 47 ++++++++++++++++++++++++ docs/views/examples/pass-data/test2.html | 42 +++++++++++++++++++++ 3 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 docs/views/examples/pass-data/test1.html create mode 100644 docs/views/examples/pass-data/test2.html diff --git a/app/data/session-data-defaults.js b/app/data/session-data-defaults.js index 9e4921b0ab..3b5158abb9 100644 --- a/app/data/session-data-defaults.js +++ b/app/data/session-data-defaults.js @@ -16,9 +16,47 @@ Example usage: ============================================================================ */ - module.exports = { - - // Insert values here - + // Example as used in current docs + claimant: { + field1: 'Example 1', + field2: 'Example 2', + field3: 'Example 3' + }, + partner: { + field1: 'Example 1', + field2: 'Example 2', + field3: 'Example 3' + }, + myObject: { + // Array of objects within object + myArrayOfObjects: [ + { + name: 'test1', + address: 'test2' + }, + { + name: 'test3' + } + ], + // Simple array within object + mySimpleArray: [ + 'test4', + 'test5' + ], + // Multi-level array within object + myMultiLevelArray: [ + [ + ['test6', 'test7'], + 'test8' + ] + ] + }, + // Arrays within array + myArray: [ + [ + 'test9', + ['test10', 'test11'] + ] + ] } diff --git a/docs/views/examples/pass-data/test1.html b/docs/views/examples/pass-data/test1.html new file mode 100644 index 0000000000..ac507c3399 --- /dev/null +++ b/docs/views/examples/pass-data/test1.html @@ -0,0 +1,47 @@ +{% extends "layout.html" %} + +{% block pageTitle %} + Example - Passing data +{% endblock %} + +{% block beforeContent %} + {% include "includes/breadcrumb_examples.html" %} +{% endblock %} + +{% block content %} + +
+
+ +
+ +
+

+ Example as used in current docs +

+ +

+ Array of objects within object +

+ +

+ Simple array within object +

+ +

+ Multi-level array within object +

+ +

+ Arrays within array +

+ +
+ + + +
+ +
+
+{% endblock %} diff --git a/docs/views/examples/pass-data/test2.html b/docs/views/examples/pass-data/test2.html new file mode 100644 index 0000000000..55b407b153 --- /dev/null +++ b/docs/views/examples/pass-data/test2.html @@ -0,0 +1,42 @@ +{% extends "layout.html" %} + +{% block pageTitle %} +Check your answers +{% endblock %} + +{% block content %} + +
+
+ +

Example as used in current docs

+ {{ data['claimant']['field1'] }} + {{ data['claimant']['field2'] }} +
+
+

Array of objects within object

+ {{ data['myObject']['myArrayOfObjects'][0]['name'] }} + {{ data['myObject']['myArrayOfObjects'][0]['address'] }} + {{ data['myObject']['myArrayOfObjects'][1]['name'] }} +
+
+

Simple array within object

+ {{ data['myObject']['mySimpleArray'][0] }} + {{ data['myObject']['mySimpleArray'][1] }} +
+
+

Multi-level array within object

+ {{ data['myObject']['myMultiLevelArray'][0][0][0] }} + {{ data['myObject']['myMultiLevelArray'][0][0][1] }} + {{ data['myObject']['myMultiLevelArray'][0][1] }} +
+
+

Arrays within array

+ {{ data['myArray'][0][0] }} + {{ data['myArray'][0][1][0] }} + {{ data['myArray'][0][1][1] }} +
+ +
+ +{% endblock %}