Commit Graph

99 Commits

Author SHA1 Message Date
Chris Hill-Scott
cdb03d1eeb Only live search on template or folder name
If you have a folder structure like this:

> FA / FB / FC

and you search for ‘FA’, it’s very noisy to see:

> FA / FB
> FA / FB / T1
> FA / FB / T2
> FA / FB / FC
> FA / FB / FC / T3
> …

It’s clearer to just show:

> FA / FB

This also has the benefit of, if you type ‘template’ (for example) you
don’t get every item any more, because it’s only looking at the name of
the thing. It used to look at the entire description, ie:

> A / B / C / Example
> Text message template

Now it only searches on the name:

> A / B / C / *Example*
> Text message template
2018-11-23 14:39:45 +00:00
Chris Hill-Scott
d7e6e6ae90 Make live search restore items to default state
At the moment live search works by either setting something to hidden
or displayed. When the search term is empty, it sets everything to
visible.

This doesn’t work with folders because some of them should be hidden by
default (the ones not at the current level).

We can account for this special case (empty search term) by removing
the `display` CSS attribute when the search term is empty. This means
that each item’s visibility will be controlled by whatever is set in the
CSS file. Using jQuery Setting a property to `''` removes it.
2018-11-23 14:35:58 +00:00
Tom Byers
eeb096aa62 Add missed .stopped method to Sticky Element 2018-11-14 16:42:52 +00:00
Tom Byers
8411598390 Remove transition if element is stuck onload
Fade-in and out for sticky elements should only be
when they move from being in-page to stuck from a
user interaction.
2018-11-14 10:25:08 +00:00
Tom Byers
c04c57b043 Fix linting errors 2018-11-08 22:47:52 +00:00
Tom Byers
412b1f1117 Add extra checks for resize and onload
Position of elements are normally checked when you
scroll but we also need it to check when the page
loads.

Re-calculate element positions if window resizes.

Adds a flag to mark if all elements have a height
which will not change as their contents have
loaded.
2018-11-08 22:45:24 +00:00
Tom Byers
fa1d669f4f Rename script to reflect what it now does 2018-11-08 22:39:39 +00:00
Tom Byers
deaa253e65 Add stop-at-bottom functionality
Detach all methods from sticky reference so they
can be attached to different objects.

Split sticky into stickAtTop and stickAtBottom and
make new versions of all methods and properties
specific to stickAtBottom.

Add CSS for stickAtBottom and call on load
2018-11-08 22:39:38 +00:00
Tom Byers
ef76d4eeb3 Record height of each sticky element
Function borrowed from stop-at-bottom JS.
2018-11-08 15:11:01 +00:00
Tom Byers
53d43073ef Refactor stick-at-top to remove top-specific code 2018-11-08 15:11:01 +00:00
Tom Byers
9e1ceb13ea Make local copy of stick-at-top JS 2018-11-08 15:11:01 +00:00
Chris Hill-Scott
666d55e82b Merge pull request #2428 from alphagov/api-key-page-neatness
Make API key page handle multiple lines of text better
2018-11-07 11:17:53 +00:00
Chris Hill-Scott
54bd321504 Make the example spreadsheet scroll horizontally
This replicates how we let large spreadsheets scroll horizontally.

Pro: this looks nicer and is more usable

Con: the code for this feels a bit fragile, especially the calling of
`.maintainWidth` twice, ie as many times as a it takes to get stuff to
render properly.
2018-11-01 15:31:14 +00:00
Chris Hill-Scott
b727a50c13 Don’t have copy API key button jump around
It’s annoying that this button moves after you click on it. It’s
happening because the API key is wrapping onto multiple lines.

This commit fixes the height of the container so that it doesn’t reflow
when it has less content in it.

Uses a bit of flexbox to vertically centre the text.
2018-10-30 13:10:19 +00:00
Tom Byers
151488fa78 Update email preview page
No longer requires the branding_type GET param.

Retains the 'govuk' default brand.
2018-08-29 16:16:15 +01:00
Tom Byers
0df88ea182 Remove branding_type from set_email_branding page
Includes updates to the controller so
branding_type is got from the email_branding model
instead of from user input.

Follows on from:

https://github.com/alphagov/notifications-admin/pull/2249
2018-08-29 11:43:35 +01:00
Chris Hill-Scott
3483490f03 Fix colour preview not loading on page load
The event was changed from `change` to `input`. The trigger was not updated accordingly.
2018-08-22 16:51:16 +01:00
Chris Hill-Scott
b10f0747ae Use input event not keyup
The `oninput` event is a more performant way to detect changes to a
textbox’s contents (compared to `onkeydown`, `onpaste`, etc).

It’s not supported in older browsers, but since this is a likely to be
used by platform admin users only that’s OK.
2018-08-22 16:31:05 +01:00
Chris Hill-Scott
6501105768 Refactor to not repeat lots of Jinja code 2018-08-22 16:31:05 +01:00
Chris Hill-Scott
b73e42650d Refactor hex colour preview Javascript
This commit improves the code that previews a hex colour when setting up
or changing an email branding.

Specifically it:
- refactors the Javascript to conform to our patterns (module pattern,
  preprocessed with Gulp)
- makes the code work when there are multiple colour previews on one
  page

It also does some visual prettifying, because I couldn’t help myself…
2018-08-22 16:31:05 +01:00
Katie Smith
979fd9bbe4 Allow service contact details to be phone number, email or url
Service contact details are needed if the upload document permission is
enabled - this used to be a link but services can now choose to use a
link, email address or phone number. The form to add or change service
contact details now gives these options and validates the data according
to the type of contact details provided.

When validating phone numbers we can't use the existing validation
because we want to allow landlines too, so there is a basic check that
the phone number is the right length and doesn't include certain
characters.
2018-08-13 10:33:39 +01:00
Chris Hill-Scott
fdf3670661 Remove basic view setting and preview 2018-08-09 17:51:34 +01:00
Chris Hill-Scott
b9b0d0870b Merge pull request #2210 from alphagov/revert-track-basic-view
Revert "Track event when someone previews basic view"
2018-08-09 09:37:54 +01:00
Chris Hill-Scott
7b1d4136bf Revert "Track event when someone previews basic view"
This reverts commit 77d96032bf.
2018-08-08 08:55:06 +01:00
Tom Byers
386105954e Add JS to embed email preview into page 2018-08-07 16:56:37 +01:00
Chris Hill-Scott
8e6efadb23 Track virtual page view when enabling basic view
So we can see what pages people go to after turning it on.
2018-08-02 15:23:52 +01:00
Chris Hill-Scott
77d96032bf Track event when someone previews basic view
We’re interested to know which services are looking at the basic view
preview (even if they’re not turning it on).

This commit logs their service IDs as events into Google Analytics.
2018-08-02 15:23:52 +01:00
Chris Hill-Scott
6452676b54 Remove show/hide behaviour from permissions form
In research we found that:
- people didn’t initially realise that the permissions expanded when the
  ‘admin’ option was selected
- not having all the options visible at once makes it hard to know what
  permissions you are (and more importantly aren’t) giving to people

This commit makes it so that:
- the options within the ‘admin’ option are always visible
- a bit of Javascript logic makes it so you can pick ‘caseworker’ and
  ‘manage service’, for example (by deselecting one when you pick the
  other)
2018-07-05 11:47:31 +01:00
Chris Hill-Scott
f4d2958d58 Allow setting of caseworking on a user
This commit changes the form that the user sees when inviting or editing
another user, if the service has the ‘caseworking’ permission set.

This will allow creating a new type of user, one who only has the
`send_messages` permission, without the `view_activity` permission.

We are doing this because we think there are a number of services with a
lot of users who don’t need to see the dashboard, or the other team
members, and that we can make a simpler interface for these users.
2018-07-05 11:47:30 +01:00
Chris Hill-Scott
784f577c4d Improve redraw performance
It’s noticeable when clicking from row to row in the spreadsheet that
the page jumps around a fair bit on load because there are a couple of
Javascript-powered components.

This commit makes sure:
- the radio select component doesn’t change height when rendering for
  the first time
- the scrollable table doesn’t show parts of the table that should be
  hidden by overflow for a fraction of second before all the JS has
  run
- the right-hand shadow on horizontally scrollable tables doesn’t fade
  in on initial page load but shows at 100% opacity immediately
2018-01-15 14:45:38 +00:00
Chris Hill-Scott
aa22568c64 Fix bug horizontal scrollbar being pushed off page
We weren’t calculating the height quite right; we were trying to
compensate for something that should have been compensated for in the
`stick-at-top-when-scrolling` code.

Add the 5px to the shim there is required because we’re adding it to the
element that the shim in replacing.
2017-12-20 15:37:34 +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
4ac90c066a Prevent doubling clicking form submissions
Have seen users complaining that they got an invitation email twice.
This is probably because they clicked the button twice even though they
think they only clicked it once.

Double form submission is a common issue on web pages, and there are a
number of different ways to prevent it. I’ve chosen to do it this way
because:
- temporarily, not permanently disabling the button means that this
  addresses the double clicking issue without breaking things if the
  user did, really want to click the button again deliberately (for
  whatever reason)
- doing it with a `data` attribute, rather than the `disabled` attribute
  means that the interaction behaviour of the button doesn’t change (
  `disabled` buttons can’t be focused, for example)
2017-09-15 14:29:56 +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
eb264f34b7 Add a little JS module to track events
Google analytics lets you send:
- pageviews
- events

Page views are used by default. But sometimes you wanna count something
which isn’t the user navigating to a new page, or you wanna track
something which isn’t just what page they were looking it. This is where
events are useful.

This commit adds a small JS module that lets us fire off an event when
the presence of an element with the right data attributes are present on
the page.
2017-07-20 12:06:15 +01:00
Chris Hill-Scott
681cea1d34 Make AJAX requests on activity page POST not GET
See parent commit for the reason we’re doing this.

Currently our AJAX requests only work as `GET` requests. So this commit
does a bit of work to make them work as `POST` requests. This is
optional behaviour, and will only happen when the element in the page
that should be updated with AJAX has the `data-form` attribute set. It
will take the form that has the corresponding `id`, serialise it, and
use that data as the body of the post request. If not form is specified
it will not do the serialisation, and submit as a `GET` request as
before.
2017-06-13 12:15:04 +01:00
Chris Hill-Scott
3106ea0e15 Make send yourself a test form stay at top of page
You might need to scroll this page quite a lot to see where a
placeholder appears in your template – especially if you have a long
email or letter.

One of the things I’m trying to stop happening so much is a lot of
scrolling back and forth. This would happen if you were scrolling down
to see the placeholder, then back up to fill in its value.

So this commit makes the textbox ‘sticky’, ie it always stays at the top
of the viewport, even when you scroll down. This lets you see the
placeholder and the textbox side by side, no matter how long the
template is.

The code to do this mostly comes from the GOV.UK Frontend Toolkit
(documented here: d9489a9870/docs/javascript.md (stick-at-top-when-scrolling)).
I had to add some extra CSS to make it look good when it overlaps the
content of the page, which the GOV.UK Frontend Toolkit implementation
doesn’t really anticipate.
2017-05-22 10:50:41 +01:00
Chris Hill-Scott
e9754e92df Add a back button to the scheduler
We’ve seen in research a user getting stuck playing with the
scheduler. They picked a day, but then didn’t want to choose one of the
options for that day. There’s no way to do this except pick a day and
then un-pick it.

What they ended up doing was clicking the grey back button, which took
them back to the previous page, making them upload their file again.

This commit adds a ‘back’ link for the scheduler. ‘Back’ seems like
sensible naming because that’s the thing that the user tried to click,
and the UI of a link matches the thing they clicked to get into this
situation.
2017-04-26 11:36:45 +01:00
Chris Hill-Scott
d731de6edf Fix the focus handling on the scheduler
This got broken when we removed the old GOV.UK Selection Buttons
javascript in a592898eff
2017-04-26 11:34:39 +01:00
Chris Hill-Scott
8d5af47620 Change class names for validation errors in html
Implements the class name changes detailed in:
https://github.com/alphagov/govuk_elements/pull/405
2017-04-10 14:54:27 +01:00
Chris Hill-Scott
a592898eff Make radio select work w/ new checkboxes/radios
The visual appearance of radio and checkbox form inputs changed in
GOV.UK Elements here:

https://github.com/alphagov/govuk_elements/pull/296

This was subsequently reimplemented with different markup and no
Javascript here:
https://github.com/alphagov/govuk_elements/pull/406

This has meant making the following changes to our app:
- changing the markup in our radio/checkbox macros to match the example
  markup given by GOV.UK Elements
- removing the previous Javascript file because it’s no longer needed to
  make the radios appear visual selected
- making the buttons on the scheduled job picker look like links,
  because the grey button style looked weird with the new radio buttons
2017-04-10 14:18:12 +01:00
Chris Hill-Scott
f3c7a167df Add find-as-you-type on the choose template page
Not everyone knows how to use `ctrl` + `f`, and it’s not scoped to
just the list of templates.

The template you want to work with is often not the first one in the
list, but ordering by created at is useful for other reasons (mainly
around first time use).

This commit adds a find as you type control which aims to give users a
quick way of getting to the template they want to work with.
2017-03-20 11:40:19 +00:00
Chris Hill-Scott
cd7cb8884c Send focus to error summary before single error
> If both sections of the page have errors and the page is submitted,
> focus moves to the mobile numbers section so screen reader users may
> not be aware of preceding errors - focus should move to a dedicated
> error summary at the top of the page.

Right now we use Javascript to focus the first error on a page (if any
errors are found). This commit adds more JS to then focus the error
summary, if there is one on the page. So this is where the focus will
rest.

It also makes some modifications to the ‘dangerous’ banner to make it
focusable, and to visually indicate that it is focused.
2017-02-14 11:51:19 +00:00
Chris Hill-Scott
103e09e3a0 Make the UI more performant by not reflowing
Fixes the height of the component until it’s loaded so that it doesn’t
causes the page to reflow while it’s rendering the buttons.

Stops the options being shown and then immediately hiding on initial
page load.
2016-10-31 09:14:05 +00:00
Chris Hill-Scott
8a01e6af36 Make it say later today
Categories before:

> Now, today, tomorrow, Friday…

Categories after:

> Now, later today, tomorrow Friday…

This reduces the ambiguity of ‘now’ vs ‘today’, and keeping the word
‘later’ suggests what this features is about.

This implementation here is a bit hacky, but it works…
2016-10-31 09:14:05 +00:00
Chris Hill-Scott
a78d9d5048 Group choices for scheduling a job by day
The options for scheduling a job by time should be grouped by day,
because a long list of 96 options is not very usable.

On the server side, this commit generates label for the next 4 days in
a friendly format (ie today/tomorrow/Sunday/Monday)

The Javascript component for choosing a time was built in a kind of
old-school jQuery way, where it manipulated the elements on the page.
The complexity of introducing groups of options was just too much for
this pattern, because it involves storing a lot of state in the DOM.

This commit completely rewrites the JS to:

- read the initial options and groups from the HTML and store them
  in the object
- use Hogan to completely re-render the UI from a series of Mustache
  templates, each of which represents a state of the UI and takes the
  inital options and groups
- filter the choices to show when the today/tomorrow/… buttons are
  clicked
2016-10-31 09:14:05 +00:00
Imdad Ahad
2a2a733a41 Fix 500s when requesting json after logged out:
* Update permissions decorator to make sure user is logged in first, else 401
* Stop further ajax json calls on failure
2016-10-21 14:24:21 +01:00
Chris Hill-Scott
f561bfe603 Show expander arrow for all browsers
The polyfill we use for details/summary only renders the arrow if the
browser doesn’t natively support the feature.

The latest versions of Firefox _do_ now support the feature (after 5
years), but for some reason they don’t draw the arrow. So this commit
forces the arrow to be polyfilled in all browsers, and hides the browser
default one, for those browsers that do render it.
2016-10-12 15:55:53 +01:00
Chris Hill-Scott
6c96b90922 Make relative timestamps update automatically
It’s weird to be on a page that says ‘2 seconds ago’ and stays stuck
there.

We don’t want to AJAX the whole page because it would get in the way of
interacting with the list of notifications.

This commit adds the venerable jQuery Timeago[1] plugin to keep the
relative times accurate and fresh.

1. http://timeago.yarp.com/
2016-09-29 09:28:13 +01:00