# Improved badge granting workflow

**URL:** https://meta.discourse.org/t/improved-badge-granting-workflow/58631
**Category:** Feature
**Tags:** badges, completed
**Created:** [3월 8, 2017, 12:19오후 UTC](https://meta.discourse.org/t/improved-badge-granting-workflow/58631 "2017-03-08T12:19:07Z")
**Posts on this page:** 1
**Showing post:** 16

<div class="post-metadata">

### Author: ![clapmyhands](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clapmyhands/32/69810_2.png) [@clapmyhands](https://meta.discourse.org/u/clapmyhands)
#### Post date: [4월 5, 2017, 3:51오후 UTC](https://meta.discourse.org/t/improved-badge-granting-workflow/58631/16 "2017-04-05T15:51:42Z")

</div>

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.

> [@How to render Component inside Widget?](https://meta.discourse.org/t/how-to-render-component-inside-widget/52872/2):
>
> If you have control over what you’re doing, I recommend rendering a widget within a widget rather than a component. However, in the cases where that’s not an option you can use the connect function of the decorator helper: [https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/widgets/decorator-helper.js.es6#L88-L107](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/widgets/decorator-helper.js.es6#L88-L107)

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](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 #Development somewhere but I haven’t found it yet 😅

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 😅

---

_[View the full topic](https://meta.discourse.org/t/improved-badge-granting-workflow/58631)._
