Commit Graph

6638 Commits

Author SHA1 Message Date
Chris Hill-Scott
b0ca82c0bd Fix beheaded test name
Tests wont run unless the function name starts with the word `test`.

Was accidentally deleted here:
de92950d8e (diff-3f993e348666469cc699ac3bf0e0cc5bR543)
2018-12-07 10:39:41 +00:00
Chris Hill-Scott
a1f78abe43 Merge pull request #2564 from alphagov/style-template-management-controls
Style template management controls
2018-12-05 17:04:13 +00:00
Chris Hill-Scott
b0f89f7fe9 Style cancel link and make it keyboard navigable
So that it looks and behaves like a normal link.
2018-12-05 16:47:45 +00:00
Chris Hill-Scott
971c64a0a9 Merge pull request #2553 from alphagov/better-live-search-team
Scope live search on team page to name and email
2018-12-05 16:46:15 +00:00
Chris Hill-Scott
eb7f421716 Remove redundant list call (sorted returns a list) 2018-12-05 16:39:23 +00:00
Chris Hill-Scott
5db1de3bbb Style the manage folder link
Right-aligned so it lines up with the right edge of the page.

Moved down so its baseline aligns with the folder title.

In a narrower column so there’s more space for the folder title.
2018-12-05 16:37:48 +00:00
Chris Hill-Scott
76e8a8f4ed Space out the buttons in the sticky footer 2018-12-05 16:37:47 +00:00
Chris Hill-Scott
224630a790 Merge pull request #2561 from alphagov/always-show-checked-search
Always show checked items in live search
2018-12-05 16:36:22 +00:00
Chris Hill-Scott
d81af78977 Merge pull request #2559 from alphagov/template-js
Template folder form smart JS
2018-12-05 16:36:12 +00:00
Katie Smith
31956999e2 Merge pull request #2562 from alphagov/allow-letters-to-be-cancelled
Allow letters to be cancelled
2018-12-05 16:07:46 +00:00
Leo Hemsted
827b58e7ac remove the unknown button in js
When you hit enter while an input in a form is in focus, your browser
finds the first button in the form, and carries out that action. So,
for non-js users, we added a hidden submit button with a value of
"unknown" to reflect that we don't know the intention of the user.

However, with JS enabled, this ambiguity doesn't exist - there's only
submit button and forms to fill in at a time, and non-visible fields
aren't even submitted at all. We can remove the unknown button,
supporting enter as submit properly. If the user is on one of the grey
button states, with no submit, it'll press the first button, and go to
the new template / move to existing folder dialog. That's fine enough.
2018-12-05 13:48:07 +00:00
Leo Hemsted
f1dffd1cb8 if state is unknown on load, then work out which action buttons to show
previously, it'd always show nothing-selected-buttons - however, if
some items were checked (due to being selected previously, and loading
with a form error message), it would be showing the wrong buttons.

Now, if the state is unknown, work out which state to show by counting
checkboxes, the same as when someone presses the cancel button.
2018-12-05 12:01:02 +00:00
Chris Hill-Scott
58a25e1e9e Merge pull request #2560 from alphagov/fix-none-email-branding-preview
Fix email branding preview for no branding
2018-12-05 11:59:48 +00:00
Chris Hill-Scott
f50ddc3322 Merge pull request #2563 from alphagov/use-normal-radios-add-template
Use normal radio field for add template choices
2018-12-05 11:59:43 +00:00
Chris Hill-Scott
d4a9fb52a5 Use normal radio field for add template choices
It doesn’t have a ‘none’ option.
2018-12-05 11:31:02 +00:00
Chris Hill-Scott
c7f34cc211 Fix email branding preview for no branding
The value that means no branding (in the form) has changed from `'None'`
to `'__NONE__'`.

This commit:
- accounts for that value
- makes sure that no branding (ie plain GOV.UK) is still displayed when
  no query argument is given
2018-12-05 11:28:10 +00:00
Chris Hill-Scott
b7e9c1a3e4 Always show checked items in live search
If you’ve searched to select an item and then you want to perform an
action on it it’s confusing when it goes away if you change your search.

It should always be clear which items you’re performing an action on.
This means that checked items should always be visible, no matter what
your search term is.
2018-12-05 11:24:16 +00:00
Katie Smith
5406efa0cc Add link to cancel letters
Added a link to cancel letters from the letter notification pages if the
letter is still able to be cancelled. Clicking on this link will show a
confirmation box, and will then cancel the letter if the user confirms.
2018-12-05 11:12:05 +00:00
Katie Smith
429a23934d Display cancelled letters show as failed
In the long term, we don't want to show cancelled letters. But for now,
this changes cancelled letters to display in the same way that letters
with a status of permanent-failure, since we are currently giving
letters that we want to cancel the status of permanent failure.
2018-12-05 11:03:59 +00:00
Katie Smith
1ee972bd04 Add endpoint for cancelling letters to NotificationApiClient 2018-12-05 11:03:59 +00:00
Leo Hemsted
17cc262ea3 preserve previous state on form error
the html now contains a `data-prev-state` attribute which contains the
previous state, taken from the `operation` value in the form data (from
the submit button). This is used to seed the `currentState` of the
templateFolderForm. If not specified (or 'unknown', because the user
hit enter last time round), then set it to nothingSelectedButtons.
2018-12-04 16:41:47 +00:00
Leo Hemsted
97f663f99e change operations to kebab-case
so that they better align with the front-end, where they'll be used in
data attributes. Also, making the kebab case is nice because it doesn't
give favouritism to either JS or python naming conventions
2018-12-04 16:41:47 +00:00
Leo Hemsted
e27540243d sticky scroll the template form 2018-12-04 16:41:47 +00:00
Leo Hemsted
05de491c0c pre-check templates/folders that were checked previously
(when rendering an error)
2018-12-04 16:41:47 +00:00
Leo Hemsted
bb50326811 remove extra add template button and cleanup of html
only remove the add template button if they have the folder service
permission (thus can see the add button at the bottom).

Also make some unnecessary functions into strings in the js, and
remove some commented out code
2018-12-04 16:41:47 +00:00
Leo Hemsted
af8de93c30 add cancel buttons to template folder flow
when cancelled, clears any data inputted into the sub-form action, and
then uses an icky hack to go back to the buttons, by changing the
state to "nothingSelectedButtons", and then pretending a checkbox was
clicked so it works out which actions to show and re-renders.
2018-12-04 16:41:47 +00:00
Leo Hemsted
9942725d35 go to forms on click of action buttons, and detatch and reattach els
the action buttons have a value that matches up with the key for the
target form in the `this.states` object - we can just set the
currentState to that and call re-render and it all Just Works™.

detatch and reattach feel better than hide/unhide, mainly because it
means when the form is posted, any data that might linger in them
definitely won't be sent in the POST.
2018-12-04 16:41:47 +00:00
Leo Hemsted
db9d4aa2cb change actions based on which checkboxes are selected
if action buttons are shown (either the nothing selected actions or the
stuff selected actions), when a checkbox is selected or deselected,
count how many checkboxes are selected. If it's zero, then show the
new template/folder buttons, if it's non-zero, then show the move
options.

Under the hood, we set the `currentState` variable, then the render fn
shows that element and hides all others.
2018-12-04 16:41:47 +00:00
Leo Hemsted
370f2527ff start js for template folder form
have a bunch of separate elements within the sticky_template_forms div
that we hide or show based on button presses and such. This commit just
sets up the class - it doesn't actually deal with button presses or
checkboxes etc yet.
2018-12-04 16:41:47 +00:00
Leo Hemsted
1a5ebb3e62 Merge pull request #2541 from alphagov/choose-new-template
Let users add new template from the choose page
2018-12-04 16:41:38 +00:00
karlchillmaid
ced35ac71c Merge pull request #2544 from alphagov/reply-to-address-content-update
Updated reply-to address content
2018-12-04 13:48:21 +00:00
Pea (Malgorzata Tyczynska)
050f768996 Merge pull request #2556 from alphagov/one_off_bug_bug
Correct argument name to mobile_number on is_current_user_the_recipient
2018-12-04 11:30:55 +00:00
Alexey Bezhan
ffa6413a13 Merge pull request #2555 from alphagov/cache-data-retention
Cache service data retention in Redis
2018-12-04 10:57:19 +00:00
Alexey Bezhan
b787ca6e5b Add Service.get_days_of_retention helper method
Data retention lookup by type is only performed to get the number
of days, so we can update the service method to return the number
or the default directly.
2018-12-03 18:04:58 +00:00
Alexey Bezhan
7a7a9ae854 Cache service data retention in Redis
Adds caching for service data retention. This removes separate API
client methods to retrieve individual data retention records by id
or type in favor of a single method that fetches and caches all
retention settings configured for the service. This makes it much
easier to invalidate cache when settings change.

Lookup by id or type is provided by helper methods in the service
model.
2018-12-03 17:57:02 +00:00
Pea Tyczynska
a21b398efd Correct argument name to mobile_number on is_current_user_the_recipient 2018-12-03 17:53:47 +00:00
Chris Hill-Scott
2fcf278a5b Use unambiguously magic value for None choices
WTForms coerces `None` as a choice to `'None'` as a string when
rendering form fields (form fields will only ever have string data
because that what the browser posts back).

But internally WTForms coerces `None` to mean an unset value, ie where
the user hasn’t selected a radio button:
283b280320/src/wtforms/utils.py (L1-L20)

We shouldn’t use `None` to mean two different things. And in fact we
can’t, because it in effect means that we’re always getting a value
for the `move_to` field, even if the user hasn’t chosen to move any
templates. Which results in some very expected behaviour.
2018-12-03 17:49:10 +00:00
Chris Hill-Scott
4c148c7c23 Look at other services only if no templates
This saves one call to the API or Redis in the common case where the
current service does have templates.

This is because `any()` evaluates all expressions before running,
whereas `or` will only evaluate the second expression if the first
returns `False`-y.
2018-12-03 17:38:38 +00:00
Chris Hill-Scott
8d0b3f47fd Set form choices as a list, not an iterator
Iterators can be exhausted, causing options to unexpectedly disappear
from the radio buttons.
2018-12-03 17:38:37 +00:00
Chris Hill-Scott
10100e51b6 Let users add new template from the choose page
Since we’re letting users add new folders directly from the choose page
it makes sense that they should also be able to add templates from
there.

This resolves the problem we saw in user research where people found it
hard to know where to go to add a new folder when they were all behind
one green button.
2018-12-03 17:38:37 +00:00
Pea (Malgorzata Tyczynska)
8aeea9929f Merge pull request #2551 from alphagov/one_off_bug
Back button on one-off message preview takes user to their flow
2018-12-03 17:12:58 +00:00
Chris Hill-Scott
fb38cd4d60 Merge pull request #2554 from alphagov/npt.gov.uk
Mark agreement signed by Neath Port Talbot County Borough Council
2018-12-03 15:41:22 +00:00
Chris Hill-Scott
cf11c1dc99 Mark agreement signed by Neath Port Talbot County Borough Council 2018-12-03 15:32:38 +00:00
Chris Hill-Scott
ba51e395f1 Fix apostrophe 2018-12-03 13:55:54 +00:00
Chris Hill-Scott
fb73fd228c Fix indentation 2018-12-03 13:55:47 +00:00
Chris Hill-Scott
4e3ddb22dc Remove go-live requirement content 2018-12-03 13:55:14 +00:00
Katie Smith
7e248e01d3 Merge pull request #2539 from alphagov/sending-content-changes
Content changes for notification pages
2018-12-03 13:36:35 +00:00
Chris Hill-Scott
8807028097 Refactor team members into the model
Follows the pattern we’re using elsewhere of having less logic in the
view methods.
2018-12-03 12:07:58 +00:00
Chris Hill-Scott
538a06c0bf Refactor filtering out accepted invites to client
None of our model or view layer code should need to know about accepted
invites. We don’t use them anywhere because once an invite is accepted
that person is now a user.

Putting this logic in the client means that:
- none of the code calling the client needs to care about accepted
  invites
- it’s easier to (if we want) update the API code to not return accepted
  invites
2018-12-03 11:06:03 +00:00
Chris Hill-Scott
29830da5e6 Scope live search on team page to name and email
It’s not useful for the search to also be picking up ‘Send messages’ or
‘Signs in with an email link’.
2018-12-03 11:05:10 +00:00