Commit Graph

10093 Commits

Author SHA1 Message Date
Chris Hill-Scott
52c9cf3e76 Merge pull request #3538 from alphagov/start-time-hint
Make start time explicit when previewing a broadcast
2020-07-29 09:15:21 +01:00
Katie Smith
257db79710 Merge pull request #3533 from alphagov/letter-page-error-bug
Include template values when calculating letter page count
2020-07-28 08:54:35 +01:00
Chris Hill-Scott
053ed96974 Make start time explicit when previewing a broadcast
We recently introduced a form control that lets user choose when a
broadcast ends.

Based on the most recent research participant, we think:
- there is a specific misunderstanding of what this control does
- there is a general low level of understanding of what a ‘broadcast’
  means

People will try to understand what a ‘broadcast’ is by using mental
models they have for other kinds of messaging, for example text
messages.

Other kinds of messaging are one-to-one, i.e. they go from a sender to a
recipient. They are not ongoing in any way.

Emails and texts are sent at a time (and for all practicable purposes
are received at that same time). So, when we present the user with
a form that controls time, they might well assume it controls the time
when the message will be sent.

This is a feature we offer for sending messages using a spreadsheet, and
that’s where we’ve borrowed this pattern from.

We reinforce this assumption with the labelling of the form control. By
front-loading it with the word ‘When’ we are playing to the users
confirmation bias, i.e. they are interpreting the meaning of the control
in a way that confirms their prior beliefs about how messaging works.

So this commit does two things:
- re-labels the form to front-load the word ‘End’ not ‘When’
- adds text to the page explaining when the broadcast will start, so
  there’s a chance of overriding that confirmation bias

If we can get users to go through this before sending a broadcast for
real, it could help them learn what a broadcast is, and how it differs
from sending text messages.
2020-07-27 17:33:34 +01:00
Katie Smith
716977fe75 Include template values when calculating letter page count
When sending a letter we check how many pages it has and this number
then determines how many PNG images we ask template preview for. When
calculating the page count, we were getting the page count for the
template as it comes from the database (so without any placeholders
filled in). But filling in placeholders in a letter may cause the number
of pages to change, which was the cause of the 'Letter does not have a
page x' errors we were seeing from template-preview.

Now, when we calculate the letter page count during sending, we take the
placeholders that have already been filled in into account.
2020-07-27 17:22:14 +01:00
Tom Byers
0d6ef2977d Merge pull request #3465 from alphagov/add-scroll-to-reveal-method
Add scroll to reveal element method
2020-07-24 14:21:15 +01:00
karlchillmaid
d75da753e6 Merge pull request #3534 from alphagov/update-blog-link
Fix footer link to GOV.UK Notify blog
2020-07-23 17:07:21 +01:00
karlchillmaid
081d925cf6 Fix blog URL 2020-07-23 16:22:16 +01:00
Leo Hemsted
5af03607f0 Merge pull request #3532 from alphagov/broadcast-dashboard-refinements
Make live broadcasts feel more prominent on dashboard
2020-07-22 15:42:26 +01:00
Leo Hemsted
8f0c6e43c1 fix tests 2020-07-22 15:15:23 +01:00
Chris Hill-Scott
aed9bc3695 Add a ‘live broadcast’ indicator
We have a reckon that live broadcasts don’t feel prominent,
consequential or active enough on the dashboard.

This commit adds an animated component, similar to an ‘on air’ indicator
in a broadcast studio, or a ‘recording’ indicator on a video camera.

This is one option for addressing our reckon. We shouldn’t merge this
until we have a better understanding of the problem from another round
of user research.
2020-07-21 09:05:24 +01:00
Chris Hill-Scott
ad1fe752e7 Swap order of live and pending 2020-07-20 15:41:39 +01:00
Chris Hill-Scott
8e4d5c5fe4 Merge pull request #3530 from alphagov/confirm-cancel-broadcast
Add a confirmation step to cancelling a broadcast
2020-07-20 10:40:53 +01:00
Chris Hill-Scott
9958460ab3 Update tests for service permission
This commit makes the tests for the `broadcast` service permission more
robust by:
- adding coverage of endpoints that have been created since the test was
  first written
- checking that the endpoint also responds to a `post` request with a
  `403` (or `405` where it is a `get`-only endpoint)
2020-07-20 09:27:46 +01:00
Chris Hill-Scott
6704919a2d Add a confirmation step to cancelling a broadcast
It’s an irreversible action if you do click it, so it feels like an ‘Are
you sure?’ step is sensible. Follows the same pattern for deleting
templates, etc.
2020-07-20 09:27:44 +01:00
Tom Byers
e62fc846c7 Add test for scrollToRevealElement method 2020-07-17 11:57:19 +01:00
Tom Byers
413e3c4e81 Add scrollToRevealElement method to stickys API
When an element is obscured by the sticky nav,
this method allows you to scroll the page until it
is revealled.

The bulk of this code was added in: https://github.com/alphagov/notifications-admin/pull/2843
to ensure elements with focus were in view. This
moves that into a public method so, as well as
being called by the focus event handler, it can be
called directly by other code.

These changes include code that adds a
'sticky-scroll-area' class to scroll areas not
explicitly marked as such in the base HTML but
made to be a scroll area by the sticky JS.
2020-07-17 11:57:19 +01:00
Chris Hill-Scott
4f859a69a6 Merge pull request #3527 from alphagov/broadcast-end-time
Let users choose when to end a broadcast
2020-07-17 10:43:10 +01:00
Chris Hill-Scott
2d7d800c64 Merge pull request #3528 from alphagov/fix-set-broadcast-permission
Fix setting of broadcast permission
2020-07-17 10:40:26 +01:00
Chris Hill-Scott
a1f063c9aa Merge pull request #3529 from alphagov/hint-status-pending-broadcast
Make the status text of pending broadcasts grey
2020-07-17 09:36:29 +01:00
Chris Hill-Scott
b3b2097556 Make the status text of pending broadcasts grey
Only live broadcasts have their status in black text. This is to
emphasise them. Lost this in a merge conflict somewhere.
2020-07-17 08:37:19 +01:00
Tom Byers
741ab9288f Add tests for 'data-show-now-as-default' on/off 2020-07-17 08:28:59 +01:00
Tom Byers
b5360c14cc Lowercase value of 'show-now-as-default'
To match the boolean value in JavaScript.
2020-07-17 08:28:59 +01:00
Tom Byers
e45bbcf99e Fix comparison of original categories with new
These tests make sure the sub-categories shown
when a category is selected are right but the
comparison looked for a direct match between the
labels for both types.

This looks for the category label in the
sub-category label instead, ie.

'Today at' in 'Today at 1pm'.

...instead of

'Today at' === 'Today at 1pm', which will always
fail.
2020-07-17 08:28:59 +01:00
Tom Byers
909f2d4678 Fix numbering on hours in radioSelect test 2020-07-17 08:28:59 +01:00
Tom Byers
636cb6825b Fix use of querySelector in radioSelect tests 2020-07-17 08:28:58 +01:00
Chris Hill-Scott
83156bd16e Let users choose when to end a broadcast
Different emergencies will need broadcasts to last for a variable amount
of time. We give users some control over this by letting them stop a
broadcast early. But we should also let them set a maximum broadcast
time, for:
- when the duration of the danger is known
- when the broadcast has been live long enough to alert everyone who
  needs to know about it

This code re-uses the pattern for scheduling jobs, which has some
constraints that are probably OK for now:
- end time is limited to an hour
- longest duration is 3 whole days (eg if you start broadcasting Friday
  you have the choice of Saturday, Sunday and all of Monday, up to
  midnight)
2020-07-17 08:23:10 +01:00
Chris Hill-Scott
ca292037e7 Merge pull request #3522 from alphagov/broadcast-approval
Add an approval loop for broadcasts
2020-07-17 08:18:34 +01:00
Chris Hill-Scott
03b4aabf5f Add a link to reject a broadcast
If a broadcast definitely shouldn’t go out (for example because it has a
spelling mistake or is going to the wrong areas) then we should have a
way of removing it. Once it’s removed no-one else can approve it, and it
isn’t cluttering up the dashboard.

This is a link (because it’s a secondary action) and red (because it’s
destructive, in that it’s throwing away someone’s work).
2020-07-17 08:07:44 +01:00
Chris Hill-Scott
a99b40304b Add button to approve broadcast
Since new broadcasts will go into `pending-approval`, we now need a way
of approving them.

This commit adds a button to this page to start (or approve) the
broadcast. This button is wrapped in a bordered box, to emphasise that
it’s something consequential.
2020-07-17 08:07:44 +01:00
Chris Hill-Scott
5b83db9768 Don’t start broadcasts immediately
We don’t want one person going full yolo and start broadcasting without
any oversight. This commit changes the flow so that the button on the
‘preview’ page puts the broadcast into `pending-approval`, rather than
directly into `broadcasting`.
2020-07-17 08:07:43 +01:00
Chris Hill-Scott
4b1e3ec504 Refactor broadcast message model
There was a lot of duplicate code here for updating the status and other
properties of a broadcast.

This commit abstracts them into reusable methods. They’re named with an
underscore to suggest that they shouldn’t be used externally.
2020-07-17 08:07:42 +01:00
Chris Hill-Scott
73c5aa9bb7 Add page for broadcast in pending state
Since we’ll be linking to pending broadcasts from the dashboard, the
page needs to be ready to display them.

Pending broadcasts lack a few bits of information that live or previous
broadcasts have (like the start date for example). So this commit hides
the code that displays those bits of information.
2020-07-17 08:07:41 +01:00
Chris Hill-Scott
c270688fe4 Show pending broadcasts on dashboard
When we have an approval flow, `pending-approval` will be the state a
broadcast is in between being a draft and broadcasting.

This means it is the earliest stage at which a broadcast can appear on
the dashboard, so this commit adds a new section at the top of the
dashboard to display these broadcasts (since the dashboard is in a
reverse chronological order).

Rather than displaying the scheduled time, the extra information shown
is the person who drafted the broadcast, since I reckon you’ll be coming
to this page because they’ve asked you to approve their broadcast.
2020-07-17 08:07:40 +01:00
Chris Hill-Scott
e29a477eb1 Fix setting of broadcast permission
This was broken because current_service doesn’t update itself after
calling the `update` method of the API. So we thought we were changing
the permissions like this:
```
{'email', 'sms', 'letter'}
{'email', 'sms', 'letter', 'broadcast'}
{'sms', 'letter', 'broadcast'}
{'letter', 'broadcast'}
{'broadcast'}
```

But actually we were doing this:
```
{'email', 'sms', 'letter'}
{'email', 'sms', 'letter', 'broadcast'}
{'sms', 'letter'}
{'email', 'letter'}
{'email', 'sms'}
```

This commit changes the code to update the permissions like this:
```
{'email', 'sms', 'letter'}
{'broadcast'}
```

It does so by adding a new method to the service model which changes all
the permissions in one API call, and updates the tests to mock the
underlying API call, not the method on the model.
2020-07-16 19:44:20 +01:00
Chris Hill-Scott
7b00e3c5b9 Merge pull request #3523 from alphagov/broadcast-dashboard-ajax
Make the broadcast dashboard update via AJAX
2020-07-16 16:53:01 +01:00
Chris Hill-Scott
352388e92a Fix keyline width on empty dashboard tables
The styling of the empty message seems to conflict with the hard-coded
widths added by the `dashboard-table` class. So we should only add the
`dashboard-table` class when there is content we need to control the
width of.
2020-07-16 16:47:16 +01:00
Chris Hill-Scott
5229373341 Make the broadcast dashboard update via AJAX
Same technique as we use for other pages that update via AJAX.

I’ve split the page up into separate chunks because the DiffDOM library
we use finds it easier to work out what’s changed when there are fewer
elements/a shallower tree.
2020-07-16 16:47:08 +01:00
Chris Hill-Scott
414e4b5834 Merge pull request #3520 from alphagov/broadcast-user-permissions
Make user permissions make sense for services with the broadcast permission
2020-07-16 14:59:57 +01:00
Katie Smith
da1a280f7c Merge pull request #3515 from alphagov/update-usage-page-2
Update usage page to display international letters
2020-07-15 14:21:22 +01:00
Katie Smith
756a17f8db Add filter for formatting a number as currency
This is used on the usage page, but is likely to become useful in other
places now that letter rates can be greater than £1.
2020-07-15 14:09:49 +01:00
Katie Smith
355e981028 Show international letters on the usage page
The api returns letter details split by postage, so international
letters are returned with a postage of `europe` or `rest-of-world` not
`international` and these rows need to be added together when the rate
is the same before they are displayed on the usage page.

To do this, we need to replace the postage of `europe` and
`rest-of-world` with `international`. The data then needs to be sorted
by postage and rate before the letter units for rows which are
international and have the same rate are added together.
2020-07-15 14:09:49 +01:00
Katie Smith
2a6691f665 Refactor letters code for usage page
No functional changes, but this changes the letter details that are
used for the usage page from a tuple to a named tuple since this makes
it easier to understand.
2020-07-15 14:09:49 +01:00
Tom Byers
0f29b3d64c Merge pull request #3526 from alphagov/revert-3476-introduce-govuk-checkboxes
Revert "Re-introduce govuk checkboxes"
2020-07-15 14:03:04 +01:00
Tom Byers
dfcddb757e Revert "Re-introduce govuk checkboxes" 2020-07-15 13:41:34 +01:00
Tom Byers
86f70ae9fa Merge pull request #3476 from alphagov/introduce-govuk-checkboxes
Re-introduce govuk checkboxes
2020-07-15 13:14:19 +01:00
Chris Hill-Scott
cc925238c7 Merge pull request #3518 from alphagov/view-broadcast-page
Add a page to view a single broadcast
2020-07-15 11:42:45 +01:00
Chris Hill-Scott
da29d35482 Merge pull request #3524 from alphagov/no-templates-message-broadcast
Add ‘no templates’ message for broadcast services
2020-07-15 11:37:56 +01:00
Chris Hill-Scott
de333a7d83 Merge pull request #3519 from alphagov/broadcast-settings
Remove emails, text messages and letter permissions from broadcast services
2020-07-15 09:38:59 +01:00
Chris Hill-Scott
c20958ef34 Clean up test formatting
Ensures that:
- test name reflects what it now does
- only one parameter per line
- argument order in parameterize matches argument order in function
  definition
2020-07-15 09:16:06 +01:00
Chris Hill-Scott
fd05bed600 Remove references to email, text and letters in trial mode
We don’t know what trial mode for broadcast services is going to look
like, but it’s not going to involve sending emails.
2020-07-15 09:14:56 +01:00