diff --git a/app/assets/javascripts/select-kit/addon/components/email-group-user-chooser-filter.js b/app/assets/javascripts/select-kit/addon/components/email-group-user-chooser-filter.js new file mode 100644 index 00000000000..7b301f75d0a --- /dev/null +++ b/app/assets/javascripts/select-kit/addon/components/email-group-user-chooser-filter.js @@ -0,0 +1,35 @@ +import MultiSelectFilterComponent from "select-kit/components/multi-select/multi-select-filter"; + +export default MultiSelectFilterComponent.extend({ + classNames: ["email-group-user-chooser-filter"], + + actions: { + onPaste(event) { + const data = event.originalEvent.clipboardData; + + if (!data) { + return; + } + + const recipients = []; + data + .getData("text") + .split(/[, \n]+/) + .forEach((recipient) => { + recipient = recipient.replace(/^@+/, "").trim(); + if (recipient.length > 0) { + recipients.push(recipient); + } + }); + + if (recipients.length > 0) { + event.stopPropagation(); + event.preventDefault(); + + this.selectKit.append(recipients); + + return false; + } + }, + }, +}); diff --git a/app/assets/javascripts/select-kit/addon/components/email-group-user-chooser.js b/app/assets/javascripts/select-kit/addon/components/email-group-user-chooser.js index 03a940c4fd1..f7c07e516a1 100644 --- a/app/assets/javascripts/select-kit/addon/components/email-group-user-chooser.js +++ b/app/assets/javascripts/select-kit/addon/components/email-group-user-chooser.js @@ -12,6 +12,7 @@ export default UserChooserComponent.extend({ selectKitOptions: { headerComponent: "email-group-user-chooser-header", + filterComponent: "email-group-user-chooser-filter", autoWrap: false, },