compose: Add pills for typing in PM recipients.

@brockwhittaker wrote the original prototype for having
pills in the recipient box when users compose PMs (either
1:1 or huddle).  The prototype was test deloyed on our
main realm for several weeks.

This commit includes all the original CSS and HTML from
the prototype.

After some things changed with the codebase after the initial
test deployment, I made the following changes:

    * In prior commits I refactored out a module called
      `user_pill.js` that implemented some common functions
      against a more streamlined version of `input_pill.js`,
      and this commit largely integrates with that.

    * I made changes in a prior commit to handle Zephyr
      semantics (emails don't get validated) and tested
      this commit with zephyr.

    * I fixed a reload bug by extracting code out to
      `compose_pm_pill.js` and re-ordering some
      calls to `initialize`.

There are still two flaws related to un-pill-ified text in the
input:

    * We could be more aggressive about trying to pill-ify
      emails when you blur or tab away.

    * We only look at the pills when you send the message,
      instead of complaining about the un-pill-ified text.
      (Some folks may consider that a feature, but it's
      probably surprising to others.)
This commit is contained in:
Steve Howell
2018-03-06 09:07:55 -05:00
committed by Tim Abbott
parent 1aba722e63
commit 3a1bf04a56
19 changed files with 275 additions and 148 deletions

View File

@@ -567,8 +567,8 @@ function validate_stream_message() {
// The function checks whether the recipients are users of the realm or cross realm users (bots
// for now)
function validate_private_message() {
if (compose_state.recipient() === "") {
compose_error(i18n.t("Please specify at least one recipient"), $("#private_message_recipient"));
if (compose_state.recipient().length === 0) {
compose_error(i18n.t("Please specify at least one valid recipient"), $("#private_message_recipient"));
return false;
} else if (page_params.realm_is_zephyr_mirror_realm) {
// For Zephyr mirroring realms, the frontend doesn't know which users exist