import DS from 'ember-data';
import { validator, buildValidations } from 'ember-cp-validations';

const Validations = buildValidations({
  name: validator('presence', true),
});

export default DS.Model.extend(Validations, {
  name: DS.attr(),
  apiScopeIds: DS.attr(),
  permissionIds: DS.attr(),
  admins: DS.attr(),
  createdAt: DS.attr(),
  updatedAt: DS.attr(),
  creator: DS.attr(),
  updater: DS.attr(),
}).reopenClass({
  urlRoot: '/api-umbrella/v1/admin_groups',
  singlePayloadKey: 'admin_group',
  arrayPayloadKey: 'data',
});

import DS from 'ember-data';
import { validator, buildValidations } from 'ember-cp-validations';

const Validations = buildValidations({
  name: validator('presence', true),
});

export default DS.Model.extend(Validations, {
  name: DS.attr(),
  apiScopeIds: DS.attr({ defaultValue() { return [] } }),
  permissionIds: DS.attr({ defaultValue() { return [] } }),
  admins: DS.attr(),
  createdAt: DS.attr(),
  updatedAt: DS.attr(),
  creator: DS.attr(),
  updater: DS.attr(),
}).reopenClass({
  urlRoot: '/api-umbrella/v1/admin_groups',
  singlePayloadKey: 'admin_group',
  arrayPayloadKey: 'data',
});

Fix admin groups not saving selected scopes or permissions.
Fix admin groups not saving selected scopes or permissions.

These must be marked with a default value of an array for saving to work
properly.
