<commit_before>import 'discourse/models/store'
import { default as computed, on } from 'ember-addons/ember-computed-decorators';
import { ajax } from 'discourse/lib/ajax';

// export default {
//   setupComponent(args, component) {
//   ajax('/natflags/flags').then((natflags) => {

//       let localised_flags = [];
//       localised_flags = natflags.flags.map (element => {
//         return {  code: element.code, 
//                   pic: element.pic, 
//                   description: I18n.t(`flags.description.${element.code}`) }});

//       component.set('natflaglist', localised_flags);
//   } )
//   }
// };

export default Ember.Component.extend({
  layoutName: 'javascripts/discourse/templates/connectors/user-custom-preferences/user-nationalflags-preferences',
  natflaglist: [],

  @on('init')
  setup() {
    console.log ('here');
    ajax({
      url:  '/natflags/flags',
      type: 'GET'
    }).then((natflags) => {

      let localised_flags = [];
      localised_flags = natflags.flags.map (element => {
        return {  code: element.code, 
                  pic: element.pic, 
                  description: I18n.t(`flags.description.${element.code}`) }});

      this.set('natflaglist', localised_flags);
    })
  },

  @computed('model.custom_fields.nationalflag_iso')
  flagsource() {
    return  (this.get('model.custom_fields.nationalflag_iso')==null) ? 'none' : this.get('model.custom_fields.nationalflag_iso')
  }
});<commit_msg>additional cleanup<commit_after>import 'discourse/models/store'
import { default as computed, on } from 'ember-addons/ember-computed-decorators';
import { ajax } from 'discourse/lib/ajax';

export default Ember.Component.extend({
  layoutName: 'javascripts/discourse/templates/connectors/user-custom-preferences/user-nationalflags-preferences',
  natflaglist: [],

  @on('init')
  setup() {

    ajax({
      url:  '/natflags/flags',
      type: 'GET'
    }).then((natflags) => {
      let localised_flags = [];
      localised_flags = natflags.flags.map (element => {
        return {  code: element.code, 
                  pic: element.pic, 
                  description: I18n.t(`flags.description.${element.code}`) }});
      this.set('natflaglist', localised_flags);
    })
  },

  @computed('model.custom_fields.nationalflag_iso')
  flagsource() {
    return  (this.get('model.custom_fields.nationalflag_iso')==null) ? 'none' : this.get('model.custom_fields.nationalflag_iso')
  }
});
{'fraction_non_alphanumeric': 0.16381418092909536, 'fraction_numerical': 0.0024449877750611247, 'mean_word_length': 3.011437908496732, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '2018232', 'n_tokens_mistral': 798, 'n_tokens_neox': 763, 'n_words': 116}