Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Update invite-user-or-group modal to Component API #477

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<DModal
@title={{i18n "discourse_post_event.invite_user_or_group.title"}}
@closeModal={{@closeModal}}
@flash={{this.flash}}
>
<:body>
<form>
<EventField>
<EmailGroupUserChooser
@value={{this.invitedNames}}
@options={{hash
fullWidthWrap=true
includeMessageableGroups=true
filterPlaceholder="composer.users_placeholder"
excludeCurrentUser=true
}}
/>
</EventField>
</form>
</:body>
<:footer>
<DButton
@type="button"
class="btn-primary"
@label="discourse_post_event.invite_user_or_group.invite"
@action={{this.invite}}
/>
</:footer>
</DModal>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import { ajax } from "discourse/lib/ajax";
import { extractError } from "discourse/lib/ajax-error";

export default class PostEventInviteUserOrGroup extends Component {
@tracked invitedNames = [];
@tracked flash = null;

@action
async invite() {
try {
await ajax(
`/discourse-post-event/events/${this.args.model.event.id}/invite.json`,
{
data: { invites: this.invitedNames },
type: "POST",
}
);
this.args.closeModal();
} catch (e) {
this.flash = extractError(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@closeModal={{@closeModal}}
class={{concat-class
(or @model.extraClass "invited")
"discourse-post-event-invitees-modal"
"post-event-invitees-modal"
}}
>
<:body>
Expand Down

This file was deleted.

This file was deleted.

5 changes: 3 additions & 2 deletions assets/javascripts/discourse/widgets/discourse-post-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { escapeExpression } from "discourse/lib/utilities";
import hbs from "discourse/widgets/hbs-compiler";
import { createWidget } from "discourse/widgets/widget";
import I18n from "I18n";
import PostEventInviteUserOrGroup from "../components/modal/post-event-invite-user-or-group";
import PostEventInvitees from "../components/modal/post-event-invitees";
import cleanTitle from "../lib/clean-title";
import { buildParams, replaceRaw } from "../lib/raw-event-helper";
Expand All @@ -25,8 +26,8 @@ export default createWidget("discourse-post-event", {

inviteUserOrGroup(postId) {
this.store.find("discourse-post-event-event", postId).then((eventModel) => {
showModal("discourse-post-event-invite-user-or-group", {
model: eventModel,
this.modal.show(PostEventInviteUserOrGroup, {
model: { event: eventModel },
});
});
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.discourse-post-event-invitees-modal {
.post-event-invitees-modal {
.modal-body {
padding: 0;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.discourse-post-event-invitees-modal {
.post-event-invitees-modal {
.modal-inner-container {
min-width: 350px;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.discourse-post-event-invitees-modal {
.post-event-invitees-modal {
.modal-inner-container {
min-width: 90vw;
}
Expand Down