From b98d69bbfa8e1953348df3697dd5e2f1588c0db3 Mon Sep 17 00:00:00 2001 From: Jordan Vidrine Date: Thu, 24 Oct 2024 17:04:45 -0500 Subject: [PATCH 1/2] UX: Change placement and position of status buttons --- .../components/discourse-post-event/index.gjs | 11 +- .../discourse-post-event/status.gjs | 166 +++++++++++------- .../common/discourse-post-event.scss | 13 +- config/locales/client.en.yml | 1 + 4 files changed, 120 insertions(+), 71 deletions(-) diff --git a/assets/javascripts/discourse/components/discourse-post-event/index.gjs b/assets/javascripts/discourse/components/discourse-post-event/index.gjs index 1c8c9e649..c2a66ffe0 100644 --- a/assets/javascripts/discourse/components/discourse-post-event/index.gjs +++ b/assets/javascripts/discourse/components/discourse-post-event/index.gjs @@ -108,12 +108,6 @@ export default class DiscoursePostEvent extends Component { /> - {{#if @event.canUpdateAttendance}} -
- -
- {{/if}} - + {{#if @event.canUpdateAttendance}} +
+ +
+ {{/if}}
{{/if}} diff --git a/assets/javascripts/discourse/components/discourse-post-event/status.gjs b/assets/javascripts/discourse/components/discourse-post-event/status.gjs index 056177769..ffcf63754 100644 --- a/assets/javascripts/discourse/components/discourse-post-event/status.gjs +++ b/assets/javascripts/discourse/components/discourse-post-event/status.gjs @@ -2,10 +2,15 @@ import Component from "@glimmer/component"; import { concat, fn, hash } from "@ember/helper"; import { action } from "@ember/object"; import { service } from "@ember/service"; +import { eq } from "truth-helpers"; import DButton from "discourse/components/d-button"; +import DropdownMenu from "discourse/components/dropdown-menu"; import PluginOutlet from "discourse/components/plugin-outlet"; import concatClass from "discourse/helpers/concat-class"; import { popupAjaxError } from "discourse/lib/ajax-error"; +import icon from "discourse-common/helpers/d-icon"; +import i18n from "discourse-common/helpers/i18n"; +import DMenu from "float-kit/components/d-menu"; export default class DiscoursePostEventStatus extends Component { @service appEvents; @@ -16,6 +21,26 @@ export default class DiscoursePostEventStatus extends Component { return this.args.event.watchingInvitee?.status; } + get inviteeButtonText() { + let status = this.args.event.watchingInvitee?.status; + return status === "going" + ? "discourse_post_event.models.invitee.status.going" + : status === "interested" + ? "discourse_post_event.models.invitee.status.interested" + : status === "not_going" + ? "discourse_post_event.models.invitee.status.not_going" + : "discourse_post_event.models.invitee.status.not_set"; + } + + get inviteButtonIcon() { + let status = this.args.event.watchingInvitee?.status; + return status === "going" + ? "check" + : status === "interested" + ? "star" + : "question"; + } + get eventButtons() { return this.siteSettings.event_participation_buttons.split("|"); } @@ -116,67 +141,86 @@ export default class DiscoursePostEventStatus extends Component { ) }} > - - {{#if this.showGoingButton}} - {{#unless @event.minimal}} - - - - {{/unless}} - {{/if}} - - {{#if this.showInterestedButton}} - - - - {{/if}} - - {{#if this.showNotGoingButton}} - {{#unless @event.minimal}} - - - - {{/unless}} - {{/if}} - + + <:trigger> + {{icon this.inviteButtonIcon}} + {{i18n + this.inviteeButtonText + }} + {{icon "angle-down"}} + + <:content> + + {{#if this.showGoingButton}} + {{#unless @event.minimal}} + + + + + + {{/unless}} + {{/if}} + + {{#if this.showInterestedButton}} + + + + + + {{/if}} + + {{#if this.showNotGoingButton}} + {{#unless @event.minimal}} + + + + + + {{/unless}} + {{/if}} + + + } diff --git a/assets/stylesheets/common/discourse-post-event.scss b/assets/stylesheets/common/discourse-post-event.scss index 4bdee323e..3b6d3d62b 100644 --- a/assets/stylesheets/common/discourse-post-event.scss +++ b/assets/stylesheets/common/discourse-post-event.scss @@ -6,6 +6,10 @@ $interested: #fb985d; .event__section { padding: 0.5em 1em; + &.event-actions svg { + padding-right: 0.25em; + } + &:not(:last-child) { border-bottom: 1px solid var(--primary-low); } @@ -70,6 +74,7 @@ $interested: #fb985d; align-items: center; padding: 0 1em; height: 75px; + border-bottom: 1px solid var(--primary-low); .more-dropdown { margin-left: auto; @@ -171,7 +176,7 @@ $interested: #fb985d; .event-actions { display: flex; - justify-content: space-between; + justify-content: end; align-items: center; height: 60px; padding: 0 1em; @@ -179,13 +184,13 @@ $interested: #fb985d; .event-status { margin: 0; - &.status-going .going-button .d-icon { + &.status-going .d-icon:not(.d-icon-angle-down) { color: var(--success); } - &.status-interested .interested-button .d-icon { + &.status-interested .d-icon:not(.d-icon-angle-down) { color: $interested; } - &.status-not_going .not-going-button .d-icon { + &.status-not_going .d-icon:not(.d-icon-angle-down) { color: var(--danger); } } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 5de542ba7..23096cf97 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -389,6 +389,7 @@ en: invitee: no_users: "No users found" status: + not_set: "RSVP" unknown: "Not interested" going: "Going" not_going: "Not Going" From c6854b1bed06fcb5681788aca5042952a62d9a7f Mon Sep 17 00:00:00 2001 From: Jordan Vidrine Date: Fri, 25 Oct 2024 16:06:26 -0500 Subject: [PATCH 2/2] UX: move invitees rendering into a DMenu --- .../components/discourse-post-event/index.gjs | 28 +++- .../discourse-post-event/invitee.gjs | 4 +- .../discourse-post-event/invitees.gjs | 123 +++++++++++------- .../common/discourse-post-event.scss | 64 ++++++++- 4 files changed, 165 insertions(+), 54 deletions(-) diff --git a/assets/javascripts/discourse/components/discourse-post-event/index.gjs b/assets/javascripts/discourse/components/discourse-post-event/index.gjs index c2a66ffe0..a55e49701 100644 --- a/assets/javascripts/discourse/components/discourse-post-event/index.gjs +++ b/assets/javascripts/discourse/components/discourse-post-event/index.gjs @@ -7,6 +7,7 @@ import concatClass from "discourse/helpers/concat-class"; import replaceEmoji from "discourse/helpers/replace-emoji"; import routeAction from "discourse/helpers/route-action"; import icon from "discourse-common/helpers/d-icon"; +import DTooltip from "float-kit/components/d-tooltip"; import Creator from "./creator"; import Dates from "./dates"; import EventStatus from "./event-status"; @@ -67,6 +68,10 @@ export default class DiscoursePostEvent extends Component { return this.currentUser && this.args.event.can_act_on_discourse_post_event; } + get eventStatsGoingInterestedCount() { + return this.args.event.stats.going + this.args.event.stats.interested; + } + diff --git a/assets/javascripts/discourse/components/discourse-post-event/invitees.gjs b/assets/javascripts/discourse/components/discourse-post-event/invitees.gjs index a3bb470b3..a5758140a 100644 --- a/assets/javascripts/discourse/components/discourse-post-event/invitees.gjs +++ b/assets/javascripts/discourse/components/discourse-post-event/invitees.gjs @@ -1,7 +1,10 @@ import Component from "@glimmer/component"; +import { tracked } from "@glimmer/tracking"; import { action } from "@ember/object"; import { service } from "@ember/service"; +import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner"; import DButton from "discourse/components/d-button"; +import icon from "discourse-common/helpers/d-icon"; import i18n from "discourse-common/helpers/i18n"; import PostEventInvitees from "../modal/post-event-invitees"; import Invitee from "./invitee"; @@ -9,6 +12,15 @@ import Invitee from "./invitee"; export default class DiscoursePostEventInvitees extends Component { @service modal; @service siteSettings; + @service discoursePostEventApi; + + @tracked isLoading = false; + @tracked inviteesList = {}; + + constructor() { + super(...arguments); + this._fetchInvitees(); + } @action showAllInvitees() { @@ -21,60 +33,79 @@ export default class DiscoursePostEventInvitees extends Component { }); } - get statsInfo() { - const stats = []; - const visibleStats = this.siteSettings.event_participation_buttons - .split("|") - .filter(Boolean); - - if (this.args.event.isPrivate) { - visibleStats.push("invited"); - } - - visibleStats.forEach((button) => { - const localeKey = button.replace(" ", "_"); - if (button === "not_going") { - button = "notGoing"; - } + async _fetchInvitees() { + try { + this.isLoading = true; - const count = this.args.event.stats[button] || 0; + const [going, interested, notGoing] = await Promise.all([ + this.discoursePostEventApi.listEventInvitees(this.args.event, { + type: "going", + }), + this.discoursePostEventApi.listEventInvitees(this.args.event, { + type: "interested", + }), + this.discoursePostEventApi.listEventInvitees(this.args.event, { + type: "not_going", + }), + ]); - const label = i18n( - `discourse_post_event.models.invitee.status.${localeKey}_count`, - { count } - ); - - stats.push({ - class: `event-status-${localeKey}`, - label, - }); - }); - - return stats; + this.inviteesList["going"] = going; + this.inviteesList["interested"] = interested; + this.inviteesList["not_going"] = notGoing; + } catch (error) { + console.error("Error fetching invitees:", error); + } finally { + this.isLoading = false; + } }