Commit Graph

37 Commits

Author SHA1 Message Date
Chris Hill-Scott
88f9d156c7 Warn if a file has been sent already
We have some teams who haver a series of files they have to send each
day. It’s easy to get muddled up and accidentally send the same file
again, if you think you haven’t already sent it.

This commit blocks you from sending the same combination of template
version and filename more than once on the same day[1].

This won’t affect teams who re-use the same template to give (for
example) updates on an incident for business continuity. These teams
edit the template between each send, thereby updating the version
number of the template.

1. This is based on how the `limit_days` argument to the API works - you
can dig into the code here: 2bd4f74ad0/app/dao/jobs_dao.py (L50)
2019-02-04 14:44:54 +00:00
Chris Hill-Scott
741a8856fa Remove the word ‘printable’
Don’t think it’s necessary. Makes things consistent with the sent letter
page, which only says ‘Download as a PDF’.

This inconsistency would be more glaring now these pieces of text appear
in the same place, in adjacent steps of a journey.
2018-11-22 12:36:29 +00:00
Chris Hill-Scott
8200514461 Fix double error border 2018-11-01 14:45:12 +00:00
Chris Hill-Scott
1675e6c8d2 Show error banner for one off letter in trial mode
In trial mode you can’t send letters. But it’s still useful to be able
to build up a letter to see how it work.

Best place to put this error is before someone tries to send a letter
for real.
2018-10-31 14:25:49 +00:00
Chris Hill-Scott
ea6620083b Persist original file name when previewing row 2018-06-07 11:03:09 +01:00
Chris Hill-Scott
e74d408953 Allow users to preview all letters in trial mode
If you’re in trial mode you can’t send letters for real. But you can
still upload a spreadsheet with multiple rows, and there’s no reason why
you shouldn’t be able to explore how Notify populate the letter for each
row of the spreadsheet (since this is something we let you do when you
can send the messages for real).
2018-06-07 11:03:09 +01:00
Chris Hill-Scott
403d856fde Fix truncation message for large file
We do show the initial rows now.
2018-05-02 09:24:16 +01:00
Chris Hill-Scott
3dab34cd38 Store template ID and original file name in URL
At the moment you can’t press refresh on the check page if there’s
errors. This is because the session gets cleared when there’s errors.
This is a bad user experience.

The data that this page is relying on (from the session) is:
- template ID
- original file name

Neither of these things need to be in the session because:
- they are not secret
- the user can modify them already (by choosing a different template or
  renaming their file locally)

So this commit additionally stores them in the URL.
2018-04-04 11:30:27 +01:00
Chris Hill-Scott
e74d261ec3 Don’t store info about bad uploads in session
Because we now[1] store info about each file upload separately in the
session the session isn’t overridden every time you upload a file. This
is good because you can do multiple file uploads idempotently.

Generally we are cleaning up after ourselves because we pop anything to
do with that upload from the session. However there is an edge case: if
you never send the file then the info about the file stays in the
session in perpetuity[2]. This is generally happening when people are
uploading files that are impossible to send, ie ones that have errors.

So this commit makes two changes:

1. remove info about a file upload from the session as soon as we know
   that it contains errors
2. `POST` reuploads to the same endpoint as initial uploads because
   otherwise we need to keep info about bad uploads in the session,
   which would prevent us from doing 1.

1. https://github.com/alphagov/notifications-admin/pull/1968
2. or at least until the session is cleared by the user logging out
2018-03-29 11:56:53 +01:00
Chris Hill-Scott
f6f5faa361 Bring in refactored CSV processing
Shouldn’t be any functional changes here, just things being named more
clearly.
2018-03-08 13:30:20 +00:00
Chris Hill-Scott
a4424e999f Catch duplicate recipient columns in spreadsheets
If someone has duplicate recipient columns in their file we don’t know
which one to use. This commit adds an error message which should help
them fix the duplication.

This commit doesn’t go to the extra effort to actually show the
correct values for duplication in the preview. Don’t think it’s worth
the effort/complexity for how infrequently we’ve seen this error.

Depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/376
2018-03-02 13:18:04 +00:00
Chris Hill-Scott
9aa4a7267a Use <button> not <input>s for form submission
Both `<button type='submit'>Submit<button>` and
`<input type='submit' value='Submit'>` can be used to submit a form.

We have historically[1] used `<input>` because it’s better-supported by
IE6 in that:
- the `submit` attribute is mandatory on `<button>`, not on `<input>`
- the `innerHTML` of a button will be submitted to the server, not the
  value (as in other browsers)

Reasons to now use `<button>` instead:
- IE6/7 support is no longer a concern (especially with deprecation of
  TLS 1.0 on the way)
- Because an `<input>` element can’t have children, the pseudo-element
  hack[2] used to ensure the top edge of the button is clickable doesn’t
  work. We’re seeing this bug[3] affect real users in research.

1. We inhereted our buttons from Digital Marketplace, here is me making
   that change in their code:  8df7e2e79e (diff-b1420f7b7a25657d849edf90a70ef541)
2. 24e1906c0d (diff-ef0e4eb6f1e90b44b0c3fe39dce274a4R79)

3. https://github.com/alphagov/govuk_elements/issues/545
2018-02-01 13:53:45 +00:00
Chris Hill-Scott
072f8e0f87 Make row in URL match displayed row
Spreadsheets start at row 1 (the header row), and the values don’t start
until row 2. The row numbers in our URLs start at 0, which is a concept
that only makes sense to programmers.

It’s more predictable and consistent to make the number in the URL match
the row number displayed on the page when previewing the spreadsheet.
2018-01-15 14:45:38 +00:00
Chris Hill-Scott
ba0a010d64 Link each row in the spreadsheet
We’ve heard from some users, especially those sending letters, that
they’d like to check that a spreadsheet they’ve uploaded has populated
the template correctly.

My reckon is that seeing just one row of the spreadsheet populate the
template isn’t enough to give people confidence that everything’s
working properly.

This commit adds links to all but the currently-previewed row. Clicking
that link will populate the preview with values from that row. These
pages already exist; they were created in this PR:
https://github.com/alphagov/notifications-admin/pull/1696
2018-01-15 14:45:37 +00:00
Chris Hill-Scott
b5c114b66e Remove error handling code when no errors
`ok.html` is only used if the file has no errors. Therefore there will
never been any need to highlight which rows in the file have errors.
2018-01-15 14:45:36 +00:00
Chris Hill-Scott
a604ed60b6 Remove value of download attribute on links
We should standardise on <a download> rather than
<a download="download"> everywhere. The value of the download attribute
tells the browser what filename to use, but is overridden by the
Content-Disposition HTTP header. Since it’s not being used, we should
remove it for the sake of disambiguation.
2018-01-02 16:52:17 +00:00
Chris Hill-Scott
c6f54966bf Change tables to scroll in-page, not full screen
There were three problems with showing tables fullscreen:
- it was over-optimised for very big spreadsheets, whereas most users
  will only have a few columns in their files
- it was jarring to go from full screen and back to the normal layout
- it was a bit change for existing users, where we prefer incremental
  changes that make things better without disrupting people’s work
  (where possible)

So this commit changes the big table to scroll horizontally in the page,
not take up the full width of the page.

From the fullscreen table it keeps:
- the shimming method to keep the horizontal scrollbar at the bottom of
  the screen at all times

It introduces some more refinements to make it nicer to use:
- fixing the first column, so you always know what row you’re on
- adding shadows indicate where there is content that’s scrolled outside
  the edges of the container
2017-12-20 12:09:18 +00:00
Chris Hill-Scott
8bfb67c702 Go fullscreen for row-level errors in spreadsheets
Two bits of context:

1. As we start dealing with letters, which have more columns, it’s more
   likely that people’s spreadsheets won’t fit in our current layout.

2. We already removed the view of the template from the page that shows
   row-level errors (eg bad phone number or missing personalisation) in
   spreadsheets because you don’t need to know about the content of the
   message in order to fix the errors.

This commit goes further by removing anything that isn’t to do with
the errors, including the normal GOV.UK header and the service’s
navigation.

This means the content can go the width of the page, which means it can
be allowed to scroll horizontally without being a usability car
crash. Which means that the layout doesn’t break with a spreadsheet that
has lots of columns.
2017-12-20 12:09:18 +00:00
Chris Hill-Scott
eb395db2d6 Fix error when file has header rows but no data
Previously the error was saying ‘It needs at least one row of data, and
columns called None’.
2017-12-20 11:59:51 +00:00
Chris Hill-Scott
fa3885d47d Remove error-handling code from OK page
`ok.html` is only used when there’s a spreadsheet which doesn’t have
any errors in it.
2017-12-14 18:06:25 +00:00
Chris Hill-Scott
6995ddc8f5 Don’t list all letter address cols if some missing
If you’ve spelt ‘postcode’ wrong, or missed only ‘address_line_2’ then
it’s pretty noisy to be told that your file needs columns called address
line 1, address line 2, and postcode.

It’s better to be specific about which column you need to fix in order
to get past this error. As a principle, we’ve found it better to tell
get people to fix one error at a time, rather than overwhelm them with a
list of errors to correct – this is why we split the recipient column
errors out separately in the first place.
2017-11-10 10:10:34 +00:00
Chris Hill-Scott
4154dbba1f Only mandate mandatory address columns
If you miss ‘postcode’ from your file then you get told that you need
‘address_line_1’, ‘address_line_2’, ‘address_line_3’, etc.

This is incorrect – the only required address columns are lines 1 and 2,
plus the postcode. So this commit corrects the error message to be
factually accurate.

We had a user report this to Fajer as a bug.
2017-10-03 14:08:25 +01:00
Pete Herlihy
7a7e71ce5d Adding Using Notify to the footer links 2017-08-31 11:10:39 +01:00
Chris Hill-Scott
da70310f8e Merge pull request #1407 from alphagov/no-letters-trial-mode
Don’t let users in trial mode send letters
2017-08-24 13:58:43 +01:00
Chris Hill-Scott
5b4a4ea1b1 Remove message preview from row error page
Two reasons to remove this:

1. It’s potentially confusing because you’ll see a preview of the first
   message, but the first row might not appear in the table shown on
   screen if it doesn’t have any errors.

2. If there are row-level errors in your file then they’re not related
   to the template – it’s a distraction.
2017-08-14 15:59:09 +01:00
Chris Hill-Scott
5c872e7936 Put file name in error message
‘Your data’ sounds ambiguous and computery. Using the name of the file
is better because it’s a thing you know about.
2017-08-14 15:57:51 +01:00
Chris Hill-Scott
25e7015537 Remove stuff about test jobs on row errors page
The send yourself a test flow doesn’t reference any kind of
file/rows/table in the front end any more, and doesn’t create a CSV in
the background (except for letters). And it should validate any mistakes
before getting to the check page.

So any user doing a send yourself a test flow should never get to this
template, which means we can remove some redundant code.
2017-08-14 15:56:05 +01:00
Chris Hill-Scott
849b3737be Track errors in analytics on multiple row errors
Accidentally missed out on adding the tracking code to this particular
error message.
2017-08-14 15:55:19 +01:00
Chris Hill-Scott
4ff674158c Ensure trial mode error overrides too many rows
Telling users that they can’t send to more than 50 recipients in trial
mode doesn’t apply for letters (they can’t send to _any_ recipients).

So we should make sure that the error message about not being able to
send to any recipients always comes up instead of the 50 recipients one,
whether you’re trying to upload a file with 1 or 111 rows.
2017-08-08 11:13:48 +01:00
Chris Hill-Scott
8f40cbd2bb Don’t let users in trial mode send letters
Users in trial mode haven’t signed the MOU. This means that they haven’t
agreed to pay for any costs they incur.

Unlike text messages and emails, we don’t give you any free allowance of
letters. Sending _any_ letters will cost the user money.

Therefore we shouldn’t let users who haven’t agreed that they will pay
for the service to incur costs by sending letters.

The pattern used for this is roughly the same as other trial mode errors
that we have already, ie a red box that says you’re not allowed. Not
sure if this is exactly right because it’s not exactly an error so the
pattern might feel too heavy-handed.

Getting this in place means we can turn letters on for users in trial
mode without worrying that they’ll accidentally send real letters, which
would result in:
- us having to absorb those costs
- some awkward conversations
2017-08-08 10:10:06 +01:00
Chris Hill-Scott
f90bab8e0c Add whitespace to code for consistency
It’s harder to scan over all the different possible errors if some of
them are bunched up together with no line breaks between them.
2017-08-08 10:08:52 +01:00
Chris Hill-Scott
82233340b6 Track errors when uploading spreadsheets
Uses the new javascript event tracking stuff so that we can see what
errors people are getting when they upload spreadsheets.
2017-07-20 12:06:15 +01:00
Chris Hill-Scott
56945565ba Don’t indent column headings if no row errors
The reason to indent the first column heading is so that the number 1
lines up with the numbers of subsequent rows.

This only happens when the subsequent rows are indented because of the
red bars. This is only when there are row errors, not when there are
more general errors.
2017-07-20 12:01:59 +01:00
Chris Hill-Scott
8e947f315d Refactor check error templates to repeat less
There was a lot of repetetive wrapping code being repeated for every
conditional block in these files. Let’s wrap it around the whole
conditional bit once instead.
2017-07-20 12:00:56 +01:00
Chris Hill-Scott
94bc8191ae Remove irrelevant stuff from error check pages
If you have errors in your file then there’s stuff you’re not going to
see on the page. So this doesn’t need to be in the Jinja templates that
are only used when there are errors.

Basically the conditional stuff is moving up to the level above these
templates.
2017-07-20 11:56:37 +01:00
Chris Hill-Scott
5a9f817e52 Remove anything error-related from the OK view
If you’ve uploaded a file and everything is OK, the page that you see
doesn’t need to look at any errors (because there won’t be any).
2017-07-20 11:55:46 +01:00
Chris Hill-Scott
ddeed88210 Refactor check page into 3 separate templates
The check page is a very complex Jinja template. It needs breaking up
to make it easier to understand what’s going on.

I think there are three di
2017-07-20 11:47:04 +01:00