mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 20:34:26 +08:00
34 lines
904 B
JavaScript
34 lines
904 B
JavaScript
import computed from "ember-addons/ember-computed-decorators";
|
|
import { sanitize, emojiUnescape } from "discourse/lib/text";
|
|
|
|
export default Ember.Component.extend({
|
|
size: "medium",
|
|
classNameBindings: [":badge-card", "size", "badge.slug"],
|
|
|
|
@computed("badge.url", "filterUser", "username")
|
|
url(badgeUrl, filterUser, username) {
|
|
return filterUser ? `${badgeUrl}?username=${username}` : badgeUrl;
|
|
},
|
|
|
|
@computed("count", "badge.grant_count")
|
|
displayCount(count, grantCount) {
|
|
if (count == null) {
|
|
return grantCount;
|
|
}
|
|
if (count > 1) {
|
|
return count;
|
|
}
|
|
},
|
|
|
|
@computed("size")
|
|
summary(size) {
|
|
if (size === "large") {
|
|
const longDescription = this.get("badge.long_description");
|
|
if (!_.isEmpty(longDescription)) {
|
|
return emojiUnescape(sanitize(longDescription));
|
|
}
|
|
}
|
|
return sanitize(this.get("badge.description"));
|
|
}
|
|
});
|