Commit Graph

63 Commits

Author SHA1 Message Date
Steve Howell d48fb1d776 pills: Use insertText for copy/paste. 2018-03-31 09:32:52 -07:00
Steve Howell fb3293a24a node tests: Add tests for input_pill.js.
This gets us coverage on most of the core "data" code, but it
doesn't get deep into the key handlers.
2018-03-07 15:53:11 -08:00
Steve Howell f0d101edf5 pills: Streamline input pills (for user groups).
The main point of this change is to streamline the core
code for input pills, and we use also modify user groups.

The main change to input_pill.js is that you now
configure a function called `create_item_from_text`, and
that can return an arbitrary object, and it just needs
a field called `display_value`.

Other changes:
    * You now call `input.create(opts)` to create the
      widget.
    * There is no longer a cache, because we can
      write smarter code in typeahead `source` functions
      that exclude ids up front.
    * There is no value/optinalKey complexity, because
      the calling code can supply arbitrary objects and
      do their own external data management on the pill
      items.
    * We eliminate `prependPill`.
    * We eliminate `data`, `keys`, and `values`, and just
      have `items`.
2018-03-07 15:53:11 -08:00
Brock Whittaker 4d54515455 input-pill: Add copy override functionality for input pills.
When a pill is selected and you press copy, it will by default return
the value, but it can be overridden with the `onCopyReturn` function.
2018-02-20 14:18:11 -08:00
Brock Whittaker bee0fa4001 input-pill: Disable input of commas with invalid pills.
A user should not be able to start forming a new pill if the previous
pill is invalid.
2018-02-20 14:11:51 -08:00
Brock Whittaker 4cd25fb861 input-pill: Add multiple pill support with pasting.
This allows for pasting in comma separated lists that will validate
pills on paste, along with creating an API for inserting many pills.

This now allows in the `input_pill.pill.append` a comma separated list
that will then call the `insertManyPills` method that will break up the
input and then call `append`.
2018-02-20 14:11:47 -08:00
Brock Whittaker 8ea39d2609 input-pill: Wrap "values" in IIFE.
The function should execute initially and return a function, not
be a function that when executed returns another function. This
fixes an existing bug.
2017-12-20 08:53:27 -05:00
Brock Whittaker 511f2f3db4 input-pill: Add "onPillRemove" callback.
This will now allow a callback to be triggered when a pill is
removed from the set.
2017-12-20 08:53:27 -05:00
Brock Whittaker 5ae4b8d3f3 input-pill: Add clean up functions.
This adds functions to remove pills and reset the state.
2017-11-10 14:14:03 -08:00
Brock Whittaker 5a0bba2afc input-pill: Add validation callback for pills.
This adds a validator that when calling `reject` will reject a pill
from being added.
2017-11-10 14:14:03 -08:00
Brock Whittaker 5d0aae283f input-pill: Add key/value caching.
Some of the calls in our codebase will call for the `.keys()` method a
lot, so this caches the results and returns them rather than mapping
the array if it knows the state to be the same as before.
2017-11-10 14:14:03 -08:00
Brock Whittaker 93141cbe39 input-pill: Have all clicks directly on container focus input.
If a user clicks on the pill container and not directly on a pill
or on an "x" inside of a pill, it should be presumed they are
trying to input new text. This effectively makes the whole non-pill
section an input bar.
2017-11-10 14:14:03 -08:00
Brock Whittaker 7b00736fa2 input-pill: Add "input_pill" class and documentation. 2017-11-10 14:14:03 -08:00