diff --git a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 index 3d5c25279ca..8a697f2de92 100644 --- a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 @@ -66,16 +66,7 @@ export default Ember.Controller.extend(CanCheckEmails, { @computed("model.user_fields.[]") userFields(userFields) { - const siteUserFields = this.site.get("user_fields"); - - if (!Ember.isEmpty(siteUserFields)) { - return siteUserFields.map(uf => { - const value = userFields ? userFields[uf.get("id").toString()] : null; - return { name: uf.get("name"), value }; - }); - } - - return []; + return this.site.collectUserFields(userFields); }, preferencesPath: fmt("model.username_lower", userPath("%@/preferences")), diff --git a/app/assets/javascripts/discourse/components/reviewable-user.js.es6 b/app/assets/javascripts/discourse/components/reviewable-user.js.es6 new file mode 100644 index 00000000000..f071ba7b336 --- /dev/null +++ b/app/assets/javascripts/discourse/components/reviewable-user.js.es6 @@ -0,0 +1,8 @@ +import { default as computed } from "ember-addons/ember-computed-decorators"; + +export default Ember.Component.extend({ + @computed("reviewable.user_fields") + userFields(fields) { + return this.site.collectUserFields(fields); + } +}); diff --git a/app/assets/javascripts/discourse/models/site.js.es6 b/app/assets/javascripts/discourse/models/site.js.es6 index 82733e89e6c..87bde462702 100644 --- a/app/assets/javascripts/discourse/models/site.js.es6 +++ b/app/assets/javascripts/discourse/models/site.js.es6 @@ -27,6 +27,21 @@ const Site = RestModel.extend({ topicCountDesc: ["topic_count:desc"], categoriesByCount: Ember.computed.sort("categories", "topicCountDesc"), + collectUserFields(fields) { + fields = fields || {}; + + let siteFields = this.get("user_fields"); + + if (!Ember.isEmpty(siteFields)) { + return siteFields.map(f => { + let value = fields ? fields[f.id.toString()] : null; + value = value || "—".htmlSafe(); + return { name: f.name, value }; + }); + } + return []; + }, + // Sort subcategories under parents @computed("categoriesByCount", "categories.[]") sortedCategories(cats) { diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-user.hbs b/app/assets/javascripts/discourse/templates/components/reviewable-user.hbs index f18b38e2acb..f55516363d5 100644 --- a/app/assets/javascripts/discourse/templates/components/reviewable-user.hbs +++ b/app/assets/javascripts/discourse/templates/components/reviewable-user.hbs @@ -1,25 +1,33 @@