Skip to content

Commit

Permalink
Delete this commit. Demo for testing
Browse files Browse the repository at this point in the history
Demo for testing that data in various shapes doesn't get overwritten.

Next step: have tests to handle this.
  • Loading branch information
hannalaakso committed Mar 11, 2019
1 parent 83efefe commit 399dd8e
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 4 deletions.
46 changes: 42 additions & 4 deletions app/data/session-data-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
]
]
}
47 changes: 47 additions & 0 deletions docs/views/examples/pass-data/test1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "layout.html" %}

{% block pageTitle %}
Example - Passing data
{% endblock %}

{% block beforeContent %}
{% include "includes/breadcrumb_examples.html" %}
{% endblock %}

{% block content %}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">

<form action="/docs/examples/pass-data/test2" method="post" class="form">

<div class="govuk-form-group">
<h3 class="govuk-label-wrapper">
Example as used in current docs
</h3>
<input class="govuk-input" id="registration-number" name="[claimant][field1]" value="{{ data['claimant']['field1'] }}" type="text">
<h3 class="govuk-label-wrapper">
Array of objects within object
</h3>
<input class="govuk-input" id="registration-number" name="[myObject][myArrayOfObjects][0][name]" value="{{ data['myObject']['myArrayOfObjects'][0]['name'] }}" type="text">
<h3 class="govuk-label-wrapper">
Simple array within object
</h3>
<input class="govuk-input" id="registration-number" name="[myObject][mySimpleArray][0]" value="{{ data['myObject']['mySimpleArray'][0] }}" type="text">
<h3 class="govuk-label-wrapper">
Multi-level array within object
</h3>
<input class="govuk-input" id="registration-number" name="[myObject][myMultiLevelArray][0][0][0]" value="{{ data['myObject']['myMultiLevelArray'][0][0][0] }}" type="text">
<h3 class="govuk-label-wrapper">
Arrays within array
</h3>
<input class="govuk-input" id="registration-number" name="[myArray][0][0]" value="{{ data['myArray'][0][0] }}" type="text">
</div>

<button class="govuk-button">Continue</button>

</form>

</div>
</div>
{% endblock %}
42 changes: 42 additions & 0 deletions docs/views/examples/pass-data/test2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% extends "layout.html" %}

{% block pageTitle %}
Check your answers
{% endblock %}

{% block content %}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">

<h3>Example as used in current docs</h3>
{{ data['claimant']['field1'] }}
{{ data['claimant']['field2'] }}
<br>
<br>
<h3>Array of objects within object</h3>
{{ data['myObject']['myArrayOfObjects'][0]['name'] }}
{{ data['myObject']['myArrayOfObjects'][0]['address'] }}
{{ data['myObject']['myArrayOfObjects'][1]['name'] }}
<br>
<br>
<h3>Simple array within object</h3>
{{ data['myObject']['mySimpleArray'][0] }}
{{ data['myObject']['mySimpleArray'][1] }}
<br>
<br>
<h3>Multi-level array within object</h3>
{{ data['myObject']['myMultiLevelArray'][0][0][0] }}
{{ data['myObject']['myMultiLevelArray'][0][0][1] }}
{{ data['myObject']['myMultiLevelArray'][0][1] }}
<br>
<br>
<h3>Arrays within array</h3>
{{ data['myArray'][0][0] }}
{{ data['myArray'][0][1][0] }}
{{ data['myArray'][0][1][1] }}
</div>

</div>

{% endblock %}

0 comments on commit 399dd8e

Please sign in to comment.