<commit_before>import { setting } from 'discourse/lib/computed';
import CanCheckEmails from 'discourse/mixins/can-check-emails';
import { popupAjaxError } from 'discourse/lib/ajax-error';

export default Ember.Controller.extend(CanCheckEmails, {

  allowAvatarUpload: setting('allow_uploaded_avatars'),
  allowUserLocale: setting('allow_user_locale'),
  ssoOverridesAvatar: setting('sso_overrides_avatar'),
  allowBackgrounds: setting('allow_profile_backgrounds'),
  editHistoryVisible: setting('edit_history_visible_to_public'),

  selectedCategories: function(){
    return [].concat(this.get("model.watchedCategories"),
                     this.get("model.trackedCategories"),
                     this.get("model.mutedCategories"));
  }.property("model.watchedCategories", "model.trackedCategories", "model.mutedCategories"),

  // By default we haven't saved anything
  saved: false,

  newNameInput: null,

  userFields: function() {
    let siteUserFields = this.site.get('user_fields');
    if (!Ember.isEmpty(siteUserFields)) {
      const userFields = this.get('model.user_fields');

      // Staff can edit fields that are not `editable`
      if (!this.get('currentUser.staff')) {
        siteUserFields = siteUserFields.filterProperty('editable', true);
      }
      return siteUserFields.sortBy('field_type').map(function(field) {
        const value = userFields ? userFields[field.get('id').toString()] : null;
        return Ember.Object.create({ value, field });
      });
    }
  }.property('model.user_fields.@each.value'),

  cannotDeleteAccount: Em.computed.not('can_delete_account'),
  deleteDisabled: Em.computed.or('saving', 'deleting', 'cannotDeleteAccount'),

  canEditName: setting('enable_names'),

  nameInstructions: function() {
    return I18n.t(Discourse.SiteSettings.full_name_required ? 'user.name.instructions_required' : 'user.name.instructions');
  }.property(),

  canSelectTitle: function() {
    return this.siteSettings.enable_badges && this.get('model.has_title_badges');
  }.property('model.badge_count'),<commit_msg>FIX: Fields should be ordered by position on preferences page<commit_after>import { setting } from 'discourse/lib/computed';
import CanCheckEmails from 'discourse/mixins/can-check-emails';
import { popupAjaxError } from 'discourse/lib/ajax-error';

export default Ember.Controller.extend(CanCheckEmails, {

  allowAvatarUpload: setting('allow_uploaded_avatars'),
  allowUserLocale: setting('allow_user_locale'),
  ssoOverridesAvatar: setting('sso_overrides_avatar'),
  allowBackgrounds: setting('allow_profile_backgrounds'),
  editHistoryVisible: setting('edit_history_visible_to_public'),

  selectedCategories: function(){
    return [].concat(this.get("model.watchedCategories"),
                     this.get("model.trackedCategories"),
                     this.get("model.mutedCategories"));
  }.property("model.watchedCategories", "model.trackedCategories", "model.mutedCategories"),

  // By default we haven't saved anything
  saved: false,

  newNameInput: null,

  userFields: function() {
    let siteUserFields = this.site.get('user_fields');
    if (!Ember.isEmpty(siteUserFields)) {
      const userFields = this.get('model.user_fields');

      // Staff can edit fields that are not `editable`
      if (!this.get('currentUser.staff')) {
        siteUserFields = siteUserFields.filterProperty('editable', true);
      }
      return siteUserFields.sortBy('position').map(function(field) {
        const value = userFields ? userFields[field.get('id').toString()] : null;
        return Ember.Object.create({ value, field });
      });
    }
  }.property('model.user_fields.@each.value'),

  cannotDeleteAccount: Em.computed.not('can_delete_account'),
  deleteDisabled: Em.computed.or('saving', 'deleting', 'cannotDeleteAccount'),

  canEditName: setting('enable_names'),

  nameInstructions: function() {
    return I18n.t(Discourse.SiteSettings.full_name_required ? 'user.name.instructions_required' : 'user.name.instructions');
  }.property(),

  canSelectTitle: function() {
    return this.siteSettings.enable_badges && this.get('model.has_title_badges');
  }.property('model.badge_count'),
{'fraction_non_alphanumeric': 0.13727839003354098, 'fraction_numerical': 0.0009583133684714902, 'mean_word_length': 4.6880108991825615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2013872', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1212, 'n_words': 208}