-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add placeholder transform unit and percentage definitions (#144)
- Loading branch information
Showing
10 changed files
with
644 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
schemas/string_interpolation/transforms/format_percentage.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"$id": "https://eq.ons.gov.uk/string_interpolation/transforms/format_percentage.json", | ||
"$schema": "http://json-schema.org/draft-07/schema", | ||
"format_percentage": { | ||
"type": "object", | ||
"properties": { | ||
"transform": { | ||
"type": "string", | ||
"enum": ["format_percentage"] | ||
}, | ||
"arguments": { | ||
"type": "object", | ||
"properties": { | ||
"value": { | ||
"$ref": "https://eq.ons.gov.uk/string_interpolation/definitions.json#/placeholder_value_sources" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": ["value"] | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": ["transform", "arguments"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"$id": "https://eq.ons.gov.uk/string_interpolation/transforms/format_unit.json", | ||
"$schema": "http://json-schema.org/draft-07/schema", | ||
"format_unit": { | ||
"type": "object", | ||
"properties": { | ||
"transform": { | ||
"type": "string", | ||
"enum": ["format_unit"] | ||
}, | ||
"arguments": { | ||
"type": "object", | ||
"properties": { | ||
"value": { | ||
"$ref": "https://eq.ons.gov.uk/string_interpolation/definitions.json#/placeholder_value_sources" | ||
}, | ||
"unit_length": { | ||
"description": "The formatting length. e.g. 1h (narrow) / 1 hr (short) / 1 hour (long)", | ||
"default": "short", | ||
"type": "string", | ||
"enum": ["short", "narrow", "long"] | ||
}, | ||
"unit": { | ||
"$ref": "https://eq.ons.gov.uk/lists/units.json#/unit" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": ["value", "unit"] | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": ["transform", "arguments"] | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
tests/schemas/invalid/test_invalid_placeholder_answer_and_transform_unit_match.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
{ | ||
"mime_type": "application/json/ons/eq", | ||
"language": "en", | ||
"schema_version": "0.0.1", | ||
"data_version": "0.0.3", | ||
"survey_id": "0", | ||
"title": "Placeholder Test", | ||
"theme": "default", | ||
"description": "A questionnaire to test placeholders", | ||
"navigation": { | ||
"visible": true | ||
}, | ||
"metadata": [ | ||
{ | ||
"name": "user_id", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "period_id", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "ru_name", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "trad_as", | ||
"type": "string", | ||
"optional": true | ||
} | ||
], | ||
"questionnaire_flow": { | ||
"type": "Linear", | ||
"options": { | ||
"summary": { | ||
"collapsible": false | ||
} | ||
} | ||
}, | ||
"sections": [ | ||
{ | ||
"id": "percentage-section", | ||
"title": "Percentage Input", | ||
"groups": [ | ||
{ | ||
"id": "[percentage-group", | ||
"blocks": [ | ||
{ | ||
"type": "Question", | ||
"id": "average-distance-block", | ||
"question": { | ||
"answers": [ | ||
{ | ||
"id": "average-distance", | ||
"mandatory": false, | ||
"unit": "mile", | ||
"type": "Unit", | ||
"unit_length": "long", | ||
"label": "Average commuting distance", | ||
"default": 0 | ||
} | ||
], | ||
"id": "average-distance-question", | ||
"title": "What is the average commuting distance of an employee (in miles) ?", | ||
"type": "General" | ||
} | ||
}, | ||
{ | ||
"id": "average-distance-interstitial", | ||
"content": { | ||
"title": "Average commuting distance interstitial", | ||
"contents": [ | ||
{ | ||
"description": { | ||
"text": "The average commuting distance of an employee is <em>{answer_distance}</em>", | ||
"placeholders": [ | ||
{ | ||
"placeholder": "answer_distance", | ||
"transforms": [ | ||
{ | ||
"transform": "format_unit", | ||
"arguments": { | ||
"value": { | ||
"source": "answers", | ||
"identifier": "average-distance" | ||
}, | ||
"unit": "meter", | ||
"unit_length": "long" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"type": "Interstitial" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.