<commit_before>FLOW.deviceGroupControl = Ember.ArrayController.create({
  content: null,

  populate: function() {
    var unassigned;
    this.set('content', FLOW.store.find(FLOW.DeviceGroup));
    unassigned = FLOW.store.createRecord(FLOW.DeviceGroup, {
      code: 'all unassigned devices',
      keyId: '-1'
    });
  }
});

FLOW.deviceControl = Ember.ArrayController.create({
  sortProperties: null,
  sortAscending: true,
  selected: null,
  content: null,

  populate: function() {
    this.set('content', FLOW.store.findQuery(FLOW.Device, {}));
    this.set('sortProperties', ['lastPositionDate']);
    this.set('sortAscending', false);
  },

  allAreSelected: function(key, value) {
    if(arguments.length === 2) {
      this.setEach('isSelected', value);
      return value;
    } else {
      return !this.get('isEmpty') && this.everyProperty('isSelected', true);
    }
  }.property('@each.isSelected'),

  atLeastOneSelected: function() {
    return this.filterProperty('isSelected', true).get('length');
  }.property('@each.isSelected'),

  // fired from tableColumnView.sort
  getSortInfo: function() {
    this.set('sortProperties', FLOW.tableColumnControl.get('sortProperties'));
    this.set('sortAscending', FLOW.tableColumnControl.get('sortAscending'));
  }
});


FLOW.devicesInGroupControl = Ember.ArrayController.create({
  content: null,
  sortProperties: ['phoneNumber'],
  sortAscending: true,
  setDevicesInGroup: function() {
    var deviceGroupId;
    if(FLOW.selectedControl.get('selectedDeviceGroup') && FLOW.selectedControl.selectedDeviceGroup.get('keyId') !== null) {
      deviceGroupId = FLOW.selectedControl.selectedDeviceGroup.get('keyId');
      if(deviceGroupId == -1) {
        this.set('content', FLOW.store.filter(FLOW.Device, function(item) {
          return(Ember.none(item.get('deviceGroup')));
        }));
      } else {
        this.set('content', FLOW.store.filter(FLOW.Device, function(item) {
          return(parseInt(item.get('deviceGroup'), 10) == deviceGroupId);
        }));
      }
    }
  }.observes('FLOW.selectedControl.selectedDeviceGroup')
});


FLOW.surveyAssignmentControl = Ember.ArrayController.create({
  sortProperties: null,
  sortAscending: true,
  content: null,

  populate: function() {
    this.set('content', FLOW.store.find(FLOW.SurveyAssignment));
    this.set('sortProperties', ['name']);
    this.set('sortAscending', true);<commit_msg>implement unassigned devices display<commit_after>FLOW.deviceGroupControl = Ember.ArrayController.create({
  content: null,

  populate: function() {
    var unassigned;

    unassigned = FLOW.store.filter(FLOW.DeviceGroup, function(item) {
      return item.get('keyId') == 1;
    });
    if(unassigned.toArray().length === 0) {
      unassigned = FLOW.store.createRecord(FLOW.DeviceGroup, {
        code: 'all unassigned devices',
        keyId: 1
      });
      unassigned.get('stateManager').send('becameClean');
    }
    this.set('content', FLOW.store.find(FLOW.DeviceGroup));
  }
});

FLOW.deviceControl = Ember.ArrayController.create({
  sortProperties: null,
  sortAscending: true,
  selected: null,
  content: null,

  populate: function() {
    this.set('content', FLOW.store.findQuery(FLOW.Device, {}));
    this.set('sortProperties', ['lastPositionDate']);
    this.set('sortAscending', false);
  },

  allAreSelected: function(key, value) {
    if(arguments.length === 2) {
      this.setEach('isSelected', value);
      return value;
    } else {
      return !this.get('isEmpty') && this.everyProperty('isSelected', true);
    }
  }.property('@each.isSelected'),

  atLeastOneSelected: function() {
    return this.filterProperty('isSelected', true).get('length');
  }.property('@each.isSelected'),

  // fired from tableColumnView.sort
  getSortInfo: function() {
    this.set('sortProperties', FLOW.tableColumnControl.get('sortProperties'));
    this.set('sortAscending', FLOW.tableColumnControl.get('sortAscending'));
  }
});


FLOW.devicesInGroupControl = Ember.ArrayController.create({
  content: null,
  sortProperties: ['phoneNumber'],
  sortAscending: true,
  setDevicesInGroup: function() {
    var deviceGroupId;
    if(FLOW.selectedControl.get('selectedDeviceGroup') && FLOW.selectedControl.selectedDeviceGroup.get('keyId') !== null) {
      deviceGroupId = FLOW.selectedControl.selectedDeviceGroup.get('keyId');

      if(deviceGroupId == 1) {
        this.set('content', FLOW.store.filter(FLOW.Device, function(item) {
          return(Ember.empty(item.get('deviceGroup')));
        }));
      } else {
        this.set('content', FLOW.store.filter(FLOW.Device, function(item) {
          return(parseInt(item.get('deviceGroup'), 10) == deviceGroupId);
        }));
      }
    }
  }.observes('FLOW.selectedControl.selectedDeviceGroup')
});


FLOW.surveyAssignmentControl = Ember.ArrayController.create({
  sortProperties: null,
  sortAscending: true,
  content: null,

  populate: function() {
    this.set('content', FLOW.store.find(FLOW.SurveyAssignment));
    this.set('sortProperties', ['name']);
    this.set('sortAscending', true);
{'fraction_non_alphanumeric': 0.16014164863269723, 'fraction_numerical': 0.0023608105449537675, 'mean_word_length': 4.0436507936507935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4665454', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1585, 'n_words': 237}