import { inject as service } from '@ember/service';
import Controller from '@ember/controller';
import { task, timeout } from 'ember-concurrency';

export default Controller.extend({
  flashMessages: service(),
  searchGroup: task(function* (term){
    yield timeout(600);
    let kindOptions = {
      'Chorus': 32,
      'Quartet': 41,
    };
    let kindModel = this.get('model.session.kind');
    let kindInt = kindOptions[kindModel];
    let groups = yield this.get('store').query('group', {
        'nomen__icontains': term,
        'status': 10,
        'page_size': 1000,
        'kind': kindInt,
      });
    return groups
  }),
  searchPerson: task(function* (term){
    yield timeout(600);
    return this.get('store').query('person', {
      'nomen__icontains': term,
      'page_size': 1000
      })
      .then((data) => data);
  }),
  actions: {
    saveEntry(entry){
      entry.save()
      .then(() => {
        this.get('flashMessages').success('Saved');
        this.transitionToRoute('dashboard.session-manager.session.entries.entry', entry);
      });
    },
    cancelEntry(){
      this.get('model').deleteRecord();
      this.transitionToRoute('dashboard.session-manager.session.entries.index');
    },
    willTransition() {
      this._super(...arguments);
      const record = this.get('model');
      record.rollbackAttributes();
    },
  },
});

import { inject as service } from '@ember/service';
import Controller from '@ember/controller';
import { task, timeout } from 'ember-concurrency';

export default Controller.extend({
  flashMessages: service(),
  searchGroup: task(function* (term){
    yield timeout(600);
    let kindOptions = {
      'Chorus': 32,
      'Quartet': 41,
    };
    let kindModel = this.get('model.session.kind');
    let kindInt = kindOptions[kindModel];
    let groups = yield this.get('store').query('group', {
        'nomen__icontains': term,
        'status__gt': 0,
        'page_size': 1000,
        'kind': kindInt,
      });
    return groups
  }),
  searchPerson: task(function* (term){
    yield timeout(600);
    return this.get('store').query('person', {
      'nomen__icontains': term,
      'page_size': 1000
      })
      .then((data) => data);
  }),
  actions: {
    saveEntry(entry){
      entry.save()
      .then(() => {
        this.get('flashMessages').success('Saved');
        this.transitionToRoute('dashboard.session-manager.session.entries.entry', entry);
      });
    },
    cancelEntry(){
      this.get('model').deleteRecord();
      this.transitionToRoute('dashboard.session-manager.session.entries.index');
    },
    willTransition() {
      this._super(...arguments);
      const record = this.get('model');
      record.rollbackAttributes();
    },
  },
});

Include exempt groups in search
Include exempt groups in search
