FEATURE: Allow users to favorite badges (PR #12278)

Right now, we select the best 3 badges for the user to be shown in their user card. But it’s not always the ones the users are most proud of. This features provides a way for users to select up to 2 badges that will be showcased in their user badge.

:construction: :construction: Still a working progress PR (no tests!) :construction: :construction:

cc @ZogStriP


You could use toggle which is shorter


Since you changed it to a symbol on line 78, it’s best to keep it consistent here as well

      render_serialized(user_badge, DetailedUserBadgeSerializer, root: :user_badge)

alias is probably not needed for this line and next one

we prefer isFavorite for js side properties

use d-button please

use d-button please

we generally use popupAjaxError for this, or do you have a specific reason for Error?

what does it look like on mobile please?

Ah, years without using rails and I forgot how delightful it was! Thanks for pointing it out :slight_smile:

Oh whoops, I did not mean to modify that I must’ve accidentally format with auto-format on save. Thanks for picking that up!

Fair enough, I am still learning the fundamentals of Ember and I’m not sure when it is good practice to use certain things. Definitely good to get your input!

1 Like

There’s no particular reason, I just did not know it was a thing! I think I saw throw new Error somewhere else for an ajax request and I figured I’d do the same. Thanks for the pointer :grinning_face_with_smiling_eyes:

1 Like

Sounds good, thanks for the comment!

Sounds good, thanks for the comment!

That’s a fair question and I should definitely have included screenshots! Sorry about, I think I spent too much time in my last role working on a desktop-only product :sweat_smile: The screenshot below is a fullpage screenshot on a Pixel 2 width.

These lines look a bit weird. Maybe something like this

    render_serialized(user_badges, DetailedUserBadgeSerializer, 
      root: :user_badges, 
      meta: { max_favorites: MAX_FAVORITES }

Or even like this?

      root: :user_badges, 
      meta: { max_favorites: MAX_FAVORITES }

We should probably add some styling/color/emoji to differentiate “favorite” and “unfavorite”

Ember has a “less than” (called lt) helper that can do this for you :wink:

  canFavorite: lt("favoriteBadges.length", "model.meta.max_favorites"),

Ah, so I tried using that. However, it looks like Ember’s lt helper expects the second value to be constant so I couldn’t reference model.