Improved badge granting workflow

Sorry for no news for quite some time, I was kinda busy with work and all.

So far I’ve went through the code implementing the badge granting on the current workflow.
Some thing’s I’ve encountered:

  1. The old workflow was on it’s own page /admin/users/[:user_id]/[:username]/badges which have a controller and model(connected to the user).
  2. The controller will calculate which badge can be granted (ones that haven’t been granted or can be granted multiple times)
  3. At that page you can grant multiple badge without refreshing (the controller will handle the removal of badge from grantable badge if it can only be granted once).
  4. it’s shown using the Ember component combo-box

from this, several problem that I’m facing would be:

  1. First of all, I want the widget to have the same look and feel as the old one and that requires me to connect the component to widget as shown below and I’m not sure yet on how to do that.
  1. Every time we open the grant badge widget, we have to get the badges that the user already have, get ones that we can grant, and show them. Right now I’m doing this via UserBadge.findByUsername(attrs.username) and Badge.findAll(). Instead of doing
    Badge.findAll() again and again, I can probably keep this somewhere. Any suggestion on how to get the grantableBadge in a better way?

https://meta.discourse.org/t/how-to-get-badges-for-a-user/25421/5

  1. The 2 function I mentioned above are async call and I’m not sure how to populate the widget with data after async call. There’s probably a question in #dev somewhere but I haven’t found it yet :sweat_smile:

Oh and looking at modals in a glance, it seems they have template and controller? Would I be able to use the combo-box component there and would that be a better choice instead of widget?

p.s. does onebox-ing between list in markdown breaks it? I like to onebox between list sometimes and my list starts over from 1.

p.p.s. I always feel like my reply become a long essay hope it’s not too troublesome to read :sweat_smile:

2 Likes