FIX: errors due to confusion between trustLevel and trust_level (#8149)

FIX: errors due to confusion between trustLevel and trust_level (#8149)

diff --git a/app/assets/javascripts/admin/models/admin-user.js.es6 b/app/assets/javascripts/admin/models/admin-user.js.es6
index bd830be..8a8ba62 100644
--- a/app/assets/javascripts/admin/models/admin-user.js.es6
+++ b/app/assets/javascripts/admin/models/admin-user.js.es6
@@ -243,12 +243,12 @@ const AdminUser = Discourse.User.extend({
     this.set("originalTrustLevel", this.trust_level);
   },
 
-  dirty: propertyNotEqual("originalTrustLevel", "trustLevel.id"),
+  dirty: propertyNotEqual("originalTrustLevel", "trust_level"),
 
   saveTrustLevel() {
     return ajax(`/admin/users/${this.id}/trust_level`, {
       type: "PUT",
-      data: { level: this.get("trustLevel.id") }
+      data: { level: this.trust_level }
     })
       .then(() => window.location.reload())
       .catch(e => {
@@ -266,7 +266,7 @@ const AdminUser = Discourse.User.extend({
   },
 
   restoreTrustLevel() {
-    this.set("trustLevel.id", this.originalTrustLevel);
+    this.set("trust_level", this.originalTrustLevel);
   },
 
   lockTrustLevel(locked) {
diff --git a/app/assets/javascripts/admin/templates/user-index.hbs b/app/assets/javascripts/admin/templates/user-index.hbs
index 8617ff2..6166eb1 100644
--- a/app/assets/javascripts/admin/templates/user-index.hbs
+++ b/app/assets/javascripts/admin/templates/user-index.hbs
@@ -369,8 +369,9 @@
     <div class="value">
       {{combo-box
         content=site.trustLevels
-        value=model.trustLevel.id
-        nameProperty="detailedName"}}
+        value=model.trust_level
+        nameProperty="detailedName"
+      }}
 
       {{#if model.dirty}}
         <div>

GitHub sha: aaf15944

1 Like