|
| 1 | +{% from "importer/macros/table_view.njk" import tableView %} |
| 2 | + |
| 3 | +{# |
| 4 | + importerErrorView displays errors from the result of a mapping attempt. |
| 5 | +
|
| 6 | + These errors are grouped so that similar errors in the same column are |
| 7 | + shown together, and each side of the error there should also be a single |
| 8 | + row of non-erroring data for context where possible. |
| 9 | +
|
| 10 | + The expected error/warning structure from the API is as follows: |
| 11 | +
|
| 12 | + [ |
| 13 | + { |
| 14 | + message: "An error occurred", |
| 15 | + fields: ["A"], |
| 16 | + rows: [["A", "B", "C"]] } |
| 17 | + }, |
| 18 | + { |
| 19 | + message: "A warning is necessary", |
| 20 | + fields: ["B"], |
| 21 | + rows: [["A"]] |
| 22 | + } |
| 23 | + ] |
| 24 | +
|
| 25 | +#} |
| 26 | +{% macro importerErrorView(session, results ) %} |
| 27 | + {% set tableHeaders = importerHeaderRowDisplay(session, "source") %} |
| 28 | + |
| 29 | + <p class="govuk-body"> |
| 30 | + During import there were <strong>{{results.errorCount}}</strong> errors and <strong>{{results.warningCount}}</strong> warnings. |
| 31 | + </p> |
| 32 | + |
| 33 | + {% if results.errors.length > 0 %} |
| 34 | + <h2 class="govuk-heading-m">Errors</h2> |
| 35 | + {% for error in results.errors %} |
| 36 | + <div class="govuk-form-group govuk-form-group--error"> |
| 37 | + <h2 class="govuk-heading-m validation-error-message">{{error.message}}</h2> |
| 38 | + <p class="govuk-body">This error occurs {{error.meta.count | count_string}} in your data. The first time at row {{ error.meta.first}}:</p> |
| 39 | + |
| 40 | + {{ tableView( { |
| 41 | + caption: false, |
| 42 | + showHeaders: true, |
| 43 | + headers: tableHeaders, |
| 44 | + showRowNumbers: true, |
| 45 | + rows: error.rows, |
| 46 | + moreRowsCount: 0 |
| 47 | + } ) |
| 48 | + }} |
| 49 | + </div> |
| 50 | + {% endfor %} |
| 51 | + {% endif %} |
| 52 | + |
| 53 | + {% if results.warnings.length > 0 %} |
| 54 | + <h2 class="govuk-heading-m">Warnings</h2> |
| 55 | + {% for warning in results.warnings %} |
| 56 | + <div class="govuk-form-group govuk-form-group--error"> |
| 57 | + <h2 class="govuk-heading-m validation-error-message">{{warning.message}}</h2> |
| 58 | + <p class="govuk-body">This warning occurs {{warning.meta.count | count_string}} in your data. The first time at row {{ warning.meta.first}}:</p> |
| 59 | + |
| 60 | + |
| 61 | + {{ tableView( { |
| 62 | + caption: false, |
| 63 | + showHeaders: true, |
| 64 | + headers: tableHeaders, |
| 65 | + showRowNumbers: true, |
| 66 | + rows: warning.rows, |
| 67 | + moreRowsCount: 0 |
| 68 | + } ) |
| 69 | + }} |
| 70 | + </div> |
| 71 | + {% endfor %} |
| 72 | + {% endif %} |
| 73 | + |
| 74 | +{% endmacro %} |
| 75 | + |
| 76 | + |
0 commit comments