Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Sep 25, 2024
1 parent f8432b7 commit 95c759d
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/importer/assets/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ <h2 class="govuk-heading-l">Develop easily</h2>
<h2 class="govuk-heading-l">Get to MVP quickly</h2>
<p>Pre-built journeys accelerate prototyping and development</p>
</div>
<div class="govuk-section-break govuk-section-break--l govuk-section-break--visible" style="grid-column: span 2;"></div>
<div class="govuk-section-break govuk-section-break--l govuk-section-break--visible"
style="grid-column: span 2;"></div>
<div>
<h2 class="govuk-heading-m">Explore patterns and components</h2>
<h2 class="govuk-heading-s">Patterns</h2>
Expand All @@ -115,14 +116,14 @@ <h2 class="govuk-heading-s">Components</h2>
</div>
<div>
<h2 class="govuk-heading-m">About the Data Design Kit</h2>
<p>
The Data Design Kit is a set of components and patterns for asking users for data as a
spreadsheet. These patterns are useful when users need to provide a lot of information at once to a
service and are likely to be drawing the information from an existing source.</p>
<p>They can be used as part of the Prototype Kit and also in
production use as part of a real service. Their designs are
compatible with the GOV.UK Design System.
</p>
<p>
The Data Design Kit is a set of components and patterns for asking users for data as a
spreadsheet. These patterns are useful when users need to provide a lot of information at once to a
service and are likely to be drawing the information from an existing source.</p>
<p>They can be used as part of the Prototype Kit and also in
production use as part of a real service. Their designs are
compatible with the GOV.UK Design System.
</p>
<p>This kit is built and maintained by the team at
<a href="https://www.register-dynamics.co.uk">Register Dynamics</a>.
</p>
Expand Down Expand Up @@ -156,4 +157,4 @@ <h2 class="govuk-heading-m">About the Data Design Kit</h2>
</footer>
</body>

</html>
</html>
38 changes: 38 additions & 0 deletions lib/importer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const os = require('node:os');


const IMPORTER_SESSION_KEY = "importer.session"
const IMPORTER_FLASH_KEY = "importer.flash"
const IMPORTER_ERROR_KEY = "importer.error"

//--------------------------------------------------------------------
Expand Down Expand Up @@ -342,8 +343,45 @@ exports.Initialise = (config, router, prototypeKit) => {
redirectOnwards(request, response);
});

//--------------------------------------------------------------------
// Show the current configuration for this plugin
//--------------------------------------------------------------------
router.get("/manage-prototype/register-dynamics/importer/config", (request,response)=>{
let flash = request.session.data[IMPORTER_FLASH_KEY];
response.render(path.join(__dirname, 'templates/config.html'), {flash: flash})
delete request.session.data[IMPORTER_FLASH_KEY]
})

//--------------------------------------------------------------------
// Update the configuration for this plugin
//--------------------------------------------------------------------
router.post("/manage-prototype/register-dynamics/importer/config/steps", (request, response)=>{

request.session.data[IMPORTER_FLASH_KEY] = {
mode: "success",
title: "Configuration saved",
message: "Templates have been created in your prototype's view folder",
}


response.redirect("/manage-prototype/register-dynamics/importer/config#upload-steps")
})

router.post("/manage-prototype/register-dynamics/importer/config/fields", (request, response)=>{

request.session.data[IMPORTER_FLASH_KEY] = {
mode: "success",
title: "Configuration saved",
message: "The target fields have been saved in your configuration " +
" at {path}",
}

response.redirect("/manage-prototype/register-dynamics/importer/config#target-data")
})

};


//--------------------------------------------------------------------
// Where the user has not configured an upload path in their prototype's
// config.json, we will instead create one.
Expand Down
89 changes: 89 additions & 0 deletions lib/importer/templates/config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{% extends "layouts/main.html" %}

{% block pageTitle %} {{ serviceName }} – GOV.UK Prototype Kit {% endblock %}

{% block beforeContent %}
{{ govukBackLink({ text: "Back", href: "javascript:window.history.back()" }) }}
{% endblock %}


{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">Configure plugin</h1>

{% if flash %}
{% if flash.mode == 'error' %}
<div class="govuk-error-summary" data-module="govuk-error-summary">
<div role="alert">
<h2 class="govuk-error-summary__title">
flash.title
</h2>
<div class="govuk-error-summary__body">
<ul class="govuk-list govuk-error-summary__list">
<li>
{{ flash.message}}
</li>
</ul>
</div>
</div>
</div>
{% else %}
<div class="govuk-notification-banner govuk-notification-banner--{{flash.mode}}" role="alert"
aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
Success
</h2>
</div>
<div class="govuk-notification-banner__content">
<h3 class="govuk-notification-banner__heading">
{{ flash.title }}
</h3>
<p class="govuk-body">{{flash.message}}</p>
</div>
</div>
{% endif %}
{% endif %}

<div class="govuk-tabs" data-module="govuk-tabs">
<h2 class="govuk-tabs__title">
Contents
</h2>

<ul class="govuk-tabs__list">
<li class="govuk-tabs__list-item govuk-tabs__list-item--selected">
<a class="govuk-tabs__tab" href="#target-data">
Target data
</a>
</li>
<li class="govuk-tabs__list-item">
<a class="govuk-tabs__tab" href="#upload-steps">
Upload steps
</a>
</li>
</ul>
<div class="govuk-tabs__panel" id="target-data">
<form action="/manage-prototype/register-dynamics/importer/config/fields" method="post">
Target data

<div class="govuk-button-group">
{{ govukButton({ text: "Submit" }) }}
</div>
</form>

</div>
<div class="govuk-tabs__panel" id="upload-steps">
<form action="/manage-prototype/register-dynamics/importer/config/steps" method="post">
Upload steps

<div class="govuk-button-group">
{{ govukButton({ text: "Submit" }) }}
</div>
</form>

</div>
</div>
</div>
</div>
{% endblock %}

0 comments on commit 95c759d

Please sign in to comment.