From 52810713d3a45db424c21297aa6b9770ff37df34 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Thu, 11 Mar 2021 17:10:18 -0300 Subject: [PATCH] FEATURE: Enable contact picker on new invite modal (#12364) --- .../discourse/app/controllers/create-invite.js | 8 ++++++++ .../discourse/app/templates/modal/create-invite.hbs | 7 +++++++ app/assets/stylesheets/common/base/modal.scss | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/controllers/create-invite.js b/app/assets/javascripts/discourse/app/controllers/create-invite.js index 394ffc24ae3..4ee612ddf3e 100644 --- a/app/assets/javascripts/discourse/app/controllers/create-invite.js +++ b/app/assets/javascripts/discourse/app/controllers/create-invite.js @@ -5,6 +5,7 @@ import discourseComputed from "discourse-common/utils/decorators"; import { extractError } from "discourse/lib/ajax-error"; import { bufferedProperty } from "discourse/mixins/buffered-content"; import ModalFunctionality from "discourse/mixins/modal-functionality"; +import { getNativeContact } from "discourse/lib/pwa-utils"; import Group from "discourse/models/group"; import Invite from "discourse/models/invite"; import I18n from "I18n"; @@ -161,5 +162,12 @@ export default Controller.extend( this.save({ sendEmail }); }, + + @action + searchContact() { + getNativeContact(this.capabilities, ["email"], false).then((result) => { + this.set("buffered.email", result[0].email[0]); + }); + }, } ); diff --git a/app/assets/javascripts/discourse/app/templates/modal/create-invite.hbs b/app/assets/javascripts/discourse/app/templates/modal/create-invite.hbs index 6b5526832db..a8264f25859 100644 --- a/app/assets/javascripts/discourse/app/templates/modal/create-invite.hbs +++ b/app/assets/javascripts/discourse/app/templates/modal/create-invite.hbs @@ -44,6 +44,13 @@ value=buffered.email placeholderKey="topic.invite_reply.email_placeholder" }} + {{#if capabilities.hasContactPicker}} + {{d-button + icon="address-book" + action=(action "searchContact") + class="btn-primary open-contact-picker" + }} + {{/if}} {{/if}} diff --git a/app/assets/stylesheets/common/base/modal.scss b/app/assets/stylesheets/common/base/modal.scss index 39a1ad8ce07..d595aea87cd 100644 --- a/app/assets/stylesheets/common/base/modal.scss +++ b/app/assets/stylesheets/common/base/modal.scss @@ -856,7 +856,8 @@ input[type="text"] { width: 100%; - &.invite-link { + &.invite-link, + &#invite-email { width: 85%; } }