Skip to content

Commit

Permalink
FIX: rsvp modal
Browse files Browse the repository at this point in the history
  • Loading branch information
angusmcleod committed May 13, 2024
1 parent aecec11 commit 568988f
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 60 deletions.
2 changes: 1 addition & 1 deletion app/controllers/discourse_events/rsvp_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def remove
end

def users
if rsvp_params[:usernames].none?
if rsvp_params[:usernames].present?
begin
users = User.where(username: rsvp_params[:usernames])
render_json_dump(success_json.merge(users: serialize_data(users, BasicUserSerializer)))
Expand Down
5 changes: 4 additions & 1 deletion assets/javascripts/discourse/components/event-rsvp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import Component from "@ember/component";
import { equal, gt, notEmpty } from "@ember/object/computed";
import I18n from "I18n";
import { action } from "@ember/object";
import { service } from "@ember/service";
import EventRsvp from "./modal/event-rsvp";

export default Component.extend({
classNames: "event-rsvp",
goingSaving: false,
modal: service(),

didReceiveAttrs() {
const currentUser = this.currentUser;
Expand Down Expand Up @@ -107,7 +110,7 @@ export default Component.extend({
@action
openModal() {
event?.preventDefault();
showModal("event-rsvp", {
this.modal.show(EventRsvp, {
model: {
topic: this.get("topic"),
},
Expand Down
39 changes: 39 additions & 0 deletions assets/javascripts/discourse/components/modal/event-rsvp.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<DModal
class="event-rsvp-modal"
@title={{this.title}}
@closeModal={{@closeModal}}
@flash={{this.flash}}
>
<:body>
<div class="header">
<ul class="types nav nav-pills">
<li>
<a href {{on "click" (fn this.setType 'going')}} class={{this.goingNavClass}}>
{{i18n 'event_rsvp.going.label'}}
</a>
</li>
</ul>
</div>
<div class="list">
{{#if this.loadingList}}
{{loading-spinner size='small'}}
{{else}}
<ul>
{{#each this.filteredList as |user|}}
<li>
<UserInfo @user={{user}}>
{{#if this.currentUser.staff}}
<DButton
class='btn compose-pm'
@action={{fn this.composePrivateMessage user}}
@icon="envelope"
@label='user.private_message' />
{{/if}}
</UserInfo>
</li>
{{/each}}
</ul>
{{/if}}
</div>
</:body>
</DModal>
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ import {
default as discourseComputed,
observes,
} from "discourse-common/utils/decorators";
import { getOwner } from "discourse-common/lib/get-owner";
import { getOwner } from "@ember/application";
import { ajax } from "discourse/lib/ajax";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { extractError } from "discourse/lib/ajax-error";
import Controller from "@ember/controller";
import Component from "@ember/component";
import { action } from "@ember/object";
import User from "discourse/models/user";

export default Controller.extend(ModalFunctionality, {
filter: null,
export default Component.extend({
userList: [],
type: "going",
title: I18n.t('event_rsvp.modal.title'),

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

Check failure on line 15 in assets/javascripts/discourse/components/modal/event-rsvp.js

View workflow job for this annotation

GitHub Actions / ci / linting

'I18n' is not defined

didReceiveAttrs() {
this.setUserList();
},

@observes("type", "model.topic")
setUserList() {
Expand Down Expand Up @@ -41,7 +45,7 @@ export default Controller.extend(ModalFunctionality, {
});
})
.catch((e) => {
this.flash(extractError(e), "alert-error");
this.set("flash", extractError(e));
})
.finally(() => {
this.setProperties({
Expand All @@ -55,12 +59,8 @@ export default Controller.extend(ModalFunctionality, {
return type === "going" ? "active" : "";
},

@discourseComputed("userList", "filter")
filteredList(userList, filter) {
if (filter) {
userList = userList.filter((u) => u.username.indexOf(filter) > -1);
}

@discourseComputed("userList")
filteredList(userList) {
const currentUser = this.get("currentUser");
if (currentUser) {
userList.sort((a) => {
Expand All @@ -71,7 +71,6 @@ export default Controller.extend(ModalFunctionality, {
}
});
}

return userList;
},

Expand All @@ -81,11 +80,10 @@ export default Controller.extend(ModalFunctionality, {
this.set("type", type);
},

actions: {
composePrivateMessage(user) {
const controller = getOwner(this).lookup("controller:application");
this.send("closeModal");
controller.send("composePrivateMessage", user);
},
@action
composePrivateMessage(user) {
const controller = getOwner(this).lookup("controller:application");
this.closeModal();
controller.send("composePrivateMessage", User.create(user));
},
});
36 changes: 0 additions & 36 deletions assets/javascripts/discourse/templates/modal/event-rsvp.hbs

This file was deleted.

4 changes: 2 additions & 2 deletions assets/stylesheets/common/events.scss
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ ul.events-calendar-events {
}
}

.modal-body.event-rsvp-modal {
.event-rsvp-modal {
overflow: hidden;

.header {
Expand All @@ -585,7 +585,7 @@ ul.events-calendar-events {

input {
width: 150px;
margin-bottom: -1px;
min-height: 25px;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# name: discourse-events
# about: Allows you to manage events in Discourse
# version: 0.3.0
# version: 0.3.1
# authors: Angus McLeod
# contact_emails: [email protected]
# url: https://github.com/paviliondev/discourse-events
Expand Down

0 comments on commit 568988f

Please sign in to comment.