-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: Update Event Invitees modal to new Component API (#476)
- Upgrade modal to new component based API - Remove redundant event status in RSVPed modal # Before <img width="593" alt="Screenshot 2023-11-09 at 12 28 03 PM" src="https://github.com/discourse/discourse-calendar/assets/50783505/c860c5b5-10b0-4b09-b25b-56bf5d6262e8"> # After <img width="334" alt="Screenshot 2023-11-09 at 1 12 58 PM" src="https://github.com/discourse/discourse-calendar/assets/50783505/9a2132ae-179c-455c-8dda-65a060416c3c">
- Loading branch information
1 parent
7e9b77a
commit 6566915
Showing
9 changed files
with
144 additions
and
157 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
assets/javascripts/discourse/components/modal/post-event-invitees.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<DModal | ||
@title={{this.title}} | ||
@closeModal={{@closeModal}} | ||
class={{concat-class | ||
(or @model.extraClass "invited") | ||
"discourse-post-event-invitees-modal" | ||
}} | ||
> | ||
<:body> | ||
<Input | ||
@value={{this.filter}} | ||
{{on "input" this.onFilterChanged}} | ||
class="filter" | ||
placeholder={{i18n | ||
"discourse_post_event.invitees_modal.filter_placeholder" | ||
}} | ||
/> | ||
<ToggleInvitees @viewType={{this.type}} @toggle={{this.toggleType}} /> | ||
<ConditionalLoadingSpinner @condition={{this.isLoading}}> | ||
{{#if this.invitees}} | ||
<ul class="invitees"> | ||
{{#each this.invitees as |invitee|}} | ||
<li class="invitee"> | ||
{{render-invitee invitee}} | ||
{{#if @model.event.can_act_on_discourse_post_event}} | ||
<DButton | ||
@icon="trash-alt" | ||
@action={{fn this.removeInvitee invitee}} | ||
/> | ||
{{/if}} | ||
</li> | ||
{{/each}} | ||
</ul> | ||
{{else}} | ||
<p class="no-users"> | ||
{{i18n "discourse_post_event.models.invitee.no_users"}} | ||
</p> | ||
{{/if}} | ||
</ConditionalLoadingSpinner> | ||
</:body> | ||
</DModal> |
63 changes: 63 additions & 0 deletions
63
assets/javascripts/discourse/components/modal/post-event-invitees.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import Component from "@glimmer/component"; | ||
import { tracked } from "@glimmer/tracking"; | ||
import { action } from "@ember/object"; | ||
import { inject as service } from "@ember/service"; | ||
import { debounce } from "discourse-common/utils/decorators"; | ||
import I18n from "discourse-i18n"; | ||
|
||
export default class PostEventInvitees extends Component { | ||
@service store; | ||
|
||
@tracked invitees; | ||
@tracked filter; | ||
@tracked isLoading = false; | ||
@tracked type = "going"; | ||
|
||
constructor() { | ||
super(...arguments); | ||
this._fetchInvitees(); | ||
} | ||
|
||
get title() { | ||
return I18n.t( | ||
`discourse_post_event.invitees_modal.${ | ||
this.args.model.title || "title_invited" | ||
}` | ||
); | ||
} | ||
|
||
@action | ||
toggleType(type) { | ||
this.type = type; | ||
this._fetchInvitees(this.filter); | ||
} | ||
|
||
@debounce(250) | ||
onFilterChanged() { | ||
this._fetchInvitees(this.filter); | ||
} | ||
|
||
@action | ||
async removeInvitee(invitee) { | ||
await invitee.destroyRecord(); | ||
this._fetchInvitees(); | ||
} | ||
|
||
async _fetchInvitees(filter) { | ||
try { | ||
this.isLoading = true; | ||
const invitees = await this.store.findAll( | ||
"discourse-post-event-invitee", | ||
{ | ||
filter, | ||
post_id: this.args.model.event.id, | ||
type: this.type, | ||
} | ||
); | ||
|
||
this.invitees = invitees; | ||
} finally { | ||
this.isLoading = false; | ||
} | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
assets/javascripts/discourse/components/toggle-invitees-modal.hbs
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
assets/javascripts/discourse/components/toggle-invitees-modal.js
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
assets/javascripts/discourse/components/toggle-invitees.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<div class="invitees-type-filter"> | ||
<DButton | ||
@label="discourse_post_event.models.invitee.status.going" | ||
class={{concat-class | ||
"btn toggle-going" | ||
(if (eq @viewType "going") "btn-danger" "btn-default") | ||
}} | ||
@action={{fn @toggle "going"}} | ||
/> | ||
|
||
<DButton | ||
@label="discourse_post_event.models.invitee.status.interested" | ||
class={{concat-class | ||
"btn toggle-interested" | ||
(if (eq @viewType "interested") "btn-danger" "btn-default") | ||
}} | ||
@action={{fn @toggle "interested"}} | ||
/> | ||
|
||
<DButton | ||
@label="discourse_post_event.models.invitee.status.not_going" | ||
class={{concat-class | ||
"btn toggle-not-going" | ||
(if (eq @viewType "not_going") "btn-danger" "btn-default") | ||
}} | ||
@action={{fn @toggle "not_going"}} | ||
/> | ||
</div> |
49 changes: 0 additions & 49 deletions
49
assets/javascripts/discourse/controllers/discourse-post-event-invitees.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
assets/javascripts/discourse/templates/modal/discourse-post-event-invitees.hbs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters