mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 19:55:43 +00:00
UX: Use group-chooser in invite modal (#10186)
This commit is contained in:
parent
f3ff9d5625
commit
90512d723c
@ -14,6 +14,16 @@ export default Component.extend({
|
|||||||
inviteExpiresAt: moment()
|
inviteExpiresAt: moment()
|
||||||
.add(1, "month")
|
.add(1, "month")
|
||||||
.format("YYYY-MM-DD"),
|
.format("YYYY-MM-DD"),
|
||||||
|
groupIds: null,
|
||||||
|
allGroups: null,
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
Group.findAll().then(groups => {
|
||||||
|
this.set("allGroups", groups.filterBy("automatic", false));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
@ -37,10 +47,12 @@ export default Component.extend({
|
|||||||
errorMessage: I18n.t("user.invited.invite_link.error"),
|
errorMessage: I18n.t("user.invited.invite_link.error"),
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
this.set("maxRedemptionAllowed", 5);
|
this.setProperties({
|
||||||
|
maxRedemptionAllowed: 5,
|
||||||
|
groupIds: null
|
||||||
|
});
|
||||||
|
|
||||||
this.inviteModel.setProperties({
|
this.inviteModel.setProperties({
|
||||||
groupNames: null,
|
|
||||||
error: false,
|
error: false,
|
||||||
saving: false,
|
saving: false,
|
||||||
finished: false,
|
finished: false,
|
||||||
@ -54,7 +66,9 @@ export default Component.extend({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const groupNames = this.get("inviteModel.groupNames");
|
const groupNames = this.allGroups
|
||||||
|
.filter(g => this.groupIds.includes(g.id))
|
||||||
|
.map(g => g.name);
|
||||||
const maxRedemptionAllowed = this.maxRedemptionAllowed;
|
const maxRedemptionAllowed = this.maxRedemptionAllowed;
|
||||||
const inviteExpiresAt = this.inviteExpiresAt;
|
const inviteExpiresAt = this.inviteExpiresAt;
|
||||||
const userInvitedController = this.userInvitedShow;
|
const userInvitedController = this.userInvitedShow;
|
||||||
|
@ -12,6 +12,8 @@ import { getNativeContact } from "discourse/lib/pwa-utils";
|
|||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
tagName: null,
|
tagName: null,
|
||||||
|
groupIds: null,
|
||||||
|
allGroups: null,
|
||||||
|
|
||||||
inviteModel: alias("panel.model.inviteModel"),
|
inviteModel: alias("panel.model.inviteModel"),
|
||||||
userInvitedShow: alias("panel.model.userInvitedShow"),
|
userInvitedShow: alias("panel.model.userInvitedShow"),
|
||||||
@ -26,6 +28,14 @@ export default Component.extend({
|
|||||||
|
|
||||||
isAdmin: alias("currentUser.admin"),
|
isAdmin: alias("currentUser.admin"),
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
Group.findAll().then(groups => {
|
||||||
|
this.set("allGroups", groups.filterBy("automatic", false));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
@ -37,7 +47,7 @@ export default Component.extend({
|
|||||||
"emailOrUsername",
|
"emailOrUsername",
|
||||||
"invitingToTopic",
|
"invitingToTopic",
|
||||||
"isPrivateTopic",
|
"isPrivateTopic",
|
||||||
"inviteModel.groupNames.[]",
|
"groupIds",
|
||||||
"inviteModel.saving",
|
"inviteModel.saving",
|
||||||
"inviteModel.details.can_invite_to"
|
"inviteModel.details.can_invite_to"
|
||||||
)
|
)
|
||||||
@ -46,7 +56,7 @@ export default Component.extend({
|
|||||||
emailOrUsername,
|
emailOrUsername,
|
||||||
invitingToTopic,
|
invitingToTopic,
|
||||||
isPrivateTopic,
|
isPrivateTopic,
|
||||||
groupNames,
|
groupIds,
|
||||||
saving,
|
saving,
|
||||||
can_invite_to
|
can_invite_to
|
||||||
) {
|
) {
|
||||||
@ -66,7 +76,7 @@ export default Component.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// when inviting to private topic via email, group name must be specified
|
// when inviting to private topic via email, group name must be specified
|
||||||
if (isPrivateTopic && isEmpty(groupNames) && emailValid(emailTrimmed)) {
|
if (isPrivateTopic && isEmpty(groupIds) && emailValid(emailTrimmed)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +90,7 @@ export default Component.extend({
|
|||||||
"emailOrUsername",
|
"emailOrUsername",
|
||||||
"inviteModel.saving",
|
"inviteModel.saving",
|
||||||
"isPrivateTopic",
|
"isPrivateTopic",
|
||||||
"inviteModel.groupNames.[]",
|
"groupIds",
|
||||||
"hasCustomMessage"
|
"hasCustomMessage"
|
||||||
)
|
)
|
||||||
disabledCopyLink(
|
disabledCopyLink(
|
||||||
@ -88,7 +98,7 @@ export default Component.extend({
|
|||||||
emailOrUsername,
|
emailOrUsername,
|
||||||
saving,
|
saving,
|
||||||
isPrivateTopic,
|
isPrivateTopic,
|
||||||
groupNames,
|
groupIds,
|
||||||
hasCustomMessage
|
hasCustomMessage
|
||||||
) {
|
) {
|
||||||
if (hasCustomMessage) return true;
|
if (hasCustomMessage) return true;
|
||||||
@ -108,7 +118,7 @@ export default Component.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// when inviting to private topic via email, group name must be specified
|
// when inviting to private topic via email, group name must be specified
|
||||||
if (isPrivateTopic && isEmpty(groupNames) && emailValid(email)) {
|
if (isPrivateTopic && isEmpty(groupIds) && emailValid(email)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,10 +252,6 @@ export default Component.extend({
|
|||||||
return isPrivateTopic ? "required" : "optional";
|
return isPrivateTopic ? "required" : "optional";
|
||||||
},
|
},
|
||||||
|
|
||||||
groupFinder(term) {
|
|
||||||
return Group.findAll({ term, ignore_automatic: true });
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed("isPM", "emailOrUsername", "invitingExistingUserToTopic")
|
@discourseComputed("isPM", "emailOrUsername", "invitingExistingUserToTopic")
|
||||||
successMessage(isPM, emailOrUsername, invitingExistingUserToTopic) {
|
successMessage(isPM, emailOrUsername, invitingExistingUserToTopic) {
|
||||||
if (this.hasGroups) {
|
if (this.hasGroups) {
|
||||||
@ -285,11 +291,11 @@ export default Component.extend({
|
|||||||
emailOrUsername: null,
|
emailOrUsername: null,
|
||||||
hasCustomMessage: false,
|
hasCustomMessage: false,
|
||||||
customMessage: null,
|
customMessage: null,
|
||||||
invitingExistingUserToTopic: false
|
invitingExistingUserToTopic: false,
|
||||||
|
groupIds: null
|
||||||
});
|
});
|
||||||
|
|
||||||
this.inviteModel.setProperties({
|
this.inviteModel.setProperties({
|
||||||
groupNames: null,
|
|
||||||
error: false,
|
error: false,
|
||||||
saving: false,
|
saving: false,
|
||||||
finished: false,
|
finished: false,
|
||||||
@ -303,7 +309,9 @@ export default Component.extend({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const groupNames = this.get("inviteModel.groupNames");
|
const groupNames = this.allGroups
|
||||||
|
.filter(g => this.groupIds.includes(g.id))
|
||||||
|
.map(g => g.name);
|
||||||
const userInvitedController = this.userInvitedShow;
|
const userInvitedController = this.userInvitedShow;
|
||||||
|
|
||||||
const model = this.inviteModel;
|
const model = this.inviteModel;
|
||||||
|
@ -13,23 +13,23 @@
|
|||||||
<label class="instructions">
|
<label class="instructions">
|
||||||
{{i18n "topic.automatically_add_to_groups"}}
|
{{i18n "topic.automatically_add_to_groups"}}
|
||||||
</label>
|
</label>
|
||||||
{{group-selector
|
{{group-chooser
|
||||||
fullWidthWrap=true
|
content=allGroups
|
||||||
groupFinder=groupFinder
|
value=groupIds
|
||||||
groupNames=inviteModel.groupNames
|
labelProperty="name"
|
||||||
placeholderKey="topic.invite_private.group_name"}}
|
onChange=(action (mut groupIds))}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="max-redemptions-allowed">
|
<div class="max-redemptions-allowed">
|
||||||
<label class="instructions">
|
<label class="instructions">
|
||||||
{{i18n 'user.invited.invite_link.max_redemptions_allowed_label'}}
|
{{i18n "user.invited.invite_link.max_redemptions_allowed_label"}}
|
||||||
</label>
|
</label>
|
||||||
{{input type="number" value=maxRedemptionAllowed class="max-redemptions-allowed-input" min="2" max=siteSettings.invite_link_max_redemptions_limit}}
|
{{input type="number" value=maxRedemptionAllowed class="max-redemptions-allowed-input" min="2" max=siteSettings.invite_link_max_redemptions_limit}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="invite-link-expires-at">
|
<div class="invite-link-expires-at">
|
||||||
<label class="instructions">
|
<label class="instructions">
|
||||||
{{i18n 'user.invited.invite_link.expires_at'}}
|
{{i18n "user.invited.invite_link.expires_at"}}
|
||||||
</label>
|
</label>
|
||||||
{{future-date-input
|
{{future-date-input
|
||||||
includeDateTime=true
|
includeDateTime=true
|
||||||
|
@ -53,11 +53,12 @@
|
|||||||
<label class="instructions {{showGroupsClass}}">
|
<label class="instructions {{showGroupsClass}}">
|
||||||
{{i18n "topic.automatically_add_to_groups"}}
|
{{i18n "topic.automatically_add_to_groups"}}
|
||||||
</label>
|
</label>
|
||||||
{{group-selector
|
{{group-chooser
|
||||||
fullWidthWrap=true
|
content=allGroups
|
||||||
groupFinder=groupFinder
|
value=groupIds
|
||||||
groupNames=inviteModel.groupNames
|
labelProperty="name"
|
||||||
placeholderKey="topic.invite_private.group_name"}}
|
onChange=(action (mut groupIds))
|
||||||
|
}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
@ -76,6 +76,20 @@
|
|||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.invite-user-control input.email-or-username-input {
|
||||||
|
line-height: 1.75em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-access-control {
|
||||||
|
.select-kit.multi-select .choices {
|
||||||
|
padding-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-chooser {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.instructions {
|
.instructions {
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user