FIX: Display the username instead of {{username}}

FIX: Display the username instead of {{username}}

diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-item.hbs b/app/assets/javascripts/discourse/templates/components/reviewable-item.hbs
index 7204a59..80495bc 100644
--- a/app/assets/javascripts/discourse/templates/components/reviewable-item.hbs
+++ b/app/assets/javascripts/discourse/templates/components/reviewable-item.hbs
@@ -31,7 +31,7 @@
     {{else}}
       {{#component reviewableComponent reviewable=reviewable tagName=''}}
         <div class='reviewable-scores-and-history'>
-          {{reviewable-scores scores=reviewable.reviewable_scores tagName=''}}
+          {{reviewable-scores reviewable=reviewable tagName=''}}
           {{reviewable-histories histories=reviewable.reviewable_histories tagName=''}}
         </div>
       {{/component}}
diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-score.hbs b/app/assets/javascripts/discourse/templates/components/reviewable-score.hbs
index 1647ac7..7d8a72e 100644
--- a/app/assets/javascripts/discourse/templates/components/reviewable-score.hbs
+++ b/app/assets/javascripts/discourse/templates/components/reviewable-score.hbs
@@ -1,6 +1,8 @@
 <tr class='reviewable-score'>
   <td>
-    {{d-icon rs.score_type.icon}} {{rs.score_type.title}} <span class="badge-notification new-posts score">{{format-score rs.score}}</span>
+    {{d-icon rs.score_type.icon}}
+    {{title}}
+    <span class="badge-notification new-posts score">{{format-score rs.score}}</span>
   </td>
   <td class='user'>
     {{#user-link user=rs.user}}
diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-score.js.es6 b/app/assets/javascripts/discourse/templates/components/reviewable-score.js.es6
new file mode 100644
index 0000000..1a96cb9
--- /dev/null
+++ b/app/assets/javascripts/discourse/templates/components/reviewable-score.js.es6
@@ -0,0 +1,14 @@
+import computed from "ember-addons/ember-computed-decorators";
+
+export default Ember.Component.extend({
+  tagName: "",
+
+  @computed("rs.score_type.title", "reviewable.target_created_by")
+  title(title, targetCreatedBy) {
+    if (targetCreatedBy) {
+      return title.replace("{{username}}", targetCreatedBy.username);
+    }
+
+    return title;
+  }
+});
diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-scores.hbs b/app/assets/javascripts/discourse/templates/components/reviewable-scores.hbs
index 517993a..e811554 100644
--- a/app/assets/javascripts/discourse/templates/components/reviewable-scores.hbs
+++ b/app/assets/javascripts/discourse/templates/components/reviewable-scores.hbs
@@ -1,8 +1,8 @@
-{{#if scores}}
+{{#if reviewable.reviewable_scores}}
   <table class='reviewable-scores'>
     <tbody>
-    {{#each scores as |rs|}}
-      {{reviewable-score rs=rs tagName=''}}
+    {{#each reviewable.reviewable_scores as |rs|}}
+      {{reviewable-score rs=rs reviewable=reviewable}}
     {{/each}}
   </tbody>
   </table>

GitHub sha: bc949cf6

1 Like