How to use the ember-data.hasMany function in ember-data

To help you get started, we’ve selected a few ember-data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HospitalRun / hospitalrun-frontend / app / models / visit.js View on Github external
primaryBillingDiagnosis: DS.attr('string'), // AKA final diagnosis
  primaryBillingDiagnosisId: DS.attr('string'),
  reasonForVisit: DS.attr('string'),
  startDate: DS.attr('date'),
  status: DS.attr('string'),
  visitType: DS.attr(),

  // Associations
  charges: DS.hasMany('proc-charge', { async: false }),
  diagnoses: DS.hasMany('diagnosis', { async: false }),
  imaging: DS.hasMany('imaging', { async: true }),
  labs: DS.hasMany('lab', { async: true }),
  medication: DS.hasMany('medication', { async: true }),
  patient: DS.belongsTo('patient', { async: false }),
  patientNotes: DS.hasMany('patient-note', { async: true }),
  procedures: DS.hasMany('procedure', { async: true }),
  vitals: DS.hasMany('vital', { async: true }),
  reports: DS.hasMany('report', { async: true }),

  diagnosisList: computed('diagnoses.[]', function() {
    let diagnoses = get(this, 'diagnoses');
    let diagnosisList = diagnoses.map((diagnosis) => {
      return diagnosis.get('diagnosis');
    });
    return diagnosisList;
  }),

  hasAppointmentLabel: computed('hasAppointment', function() {
    let hasAppointment = get(this, 'hasAppointment');
    let i18n = get(this, 'i18n');
    if (hasAppointment === true) {
      return i18n.t('visits.labels.haveAppointment');
github aptible / dashboard.aptible.com / app / models / user.js View on Github external
createdAt: DS.attr('date'),
  superuser: DS.attr('boolean'),
  otpEnabled: DS.attr('boolean'),

  // Used when enabling 2FA. Set as an `attr` so that it's sent to the API.
  otpToken: DS.attr('string'),

  // relationships
  // REVIEW: We used to have a 'token' attribute. It's unclear where this was
  // used (if at all). Do we want to create a Ember.computed 'token' field for
  // backwards compatibility?
  memberships: DS.hasMany('membership', { async: true }),
  tokens: DS.hasMany('token', { async: true, requireReload: true }),
  roles: DS.hasMany('role', { async: true }),
  sshKeys: DS.hasMany('ssh-key', { async: true }),
  otpConfigurations: DS.hasMany('otp-configuration', { async: true }),

  currentOtpConfiguration: DS.belongsTo('otp-configuration', { async: true }),

  isRoleType(types, roles, organization) {
    Ember.assert('You must pass types to check against', !!types);
    Ember.assert('You must pass the user\'s current roles', !!roles);
    Ember.assert('You must pass an organization', !!organization);

    const organizationUrl = organization.get('data.links.self');
    return roles.filterBy('data.links.organization', organizationUrl)
                .reduce(function(prev, role) {
                  return prev || types.indexOf(role.get('type')) > -1;
                }, false);
  },

  isAccountOwner(roles, organization) {
github benoror / ember-airtable / tests / dummy / app / models / product.js View on Github external
import DS from 'ember-data';

export default DS.Model.extend({
  created: DS.attr('date'),
  name: DS.attr('string'),
  description: DS.attr('string'),
  components: DS.hasMany('component'),
  formula_readonly: DS.attr('string', { readOnly: true })
});
github 201-created / ember-data-hal-9000 / tests / dummy / app / models / owner.js View on Github external
import DS from 'ember-data';

export default DS.Model.extend({
  name: DS.attr('string'),
  team: DS.belongsTo('team', {async:true}),
  favoriteTeam: DS.belongsTo('team', {async:true}),
  amazingTeams: DS.hasMany('team', {async:true}),

  manager: DS.belongsTo('owner', {async:true, inverse: 'reports'}),
  reports: DS.hasMany('owner', {async:true, inverse: 'manager'})
});
github mapeveri / muss / static / muss / app / models / user.js View on Github external
import DS from 'ember-data';

export default DS.Model.extend({
    username: DS.attr('string'),
    email: DS.attr('string'),
    firstName: DS.attr('string'),
    password: DS.attr('string'),
    lastName: DS.attr('string'),
    userPhoto: DS.attr('string'),
    isActive: DS.attr('boolean'),
    isSuperUser: DS.attr('boolean'),
    topics: DS.hasMany('topic'),
    comments: DS.hasMany('comment'),
    registers: DS.hasMany('register'),
    moderators: DS.hasMany('forum'),
    user: DS.belongsTo('profile'),
    notifications: DS.hasMany('notification'),
});
github aptible / dashboard.aptible.com / app / models / risk-assessment.js View on Github external
import Ember from 'ember';
import DS from 'ember-data';

export default DS.Model.extend({
  status: DS.attr('string', { defaultvalue: 'draft' }),
  approvingAuthorityUserName: DS.attr('string'),
  approvingAuthorityUserEmail:DS.attr('string'),
  approvingAuthorityUrl: DS.attr('string'),
  createdByUserName: DS.attr('string'),
  createdByUserEmail:DS.attr('string'),
  createdByUrl: DS.attr('string'),
  vulnerabilities: DS.hasMany('vulnerability', {embedded: true}),
  threatEvents: DS.hasMany('threat-event', {embedded: true}),
  predisposingConditions: DS.hasMany('predisposing-condition', {embedded: true}),
  threatSources: DS.hasMany('threat-source', {embedded: true}),
  securityControls: DS.hasMany('security-control', {embedded: true}),
  mitigations: DS.hasMany('mitigation', {embedded: true}),
  createdAt: DS.attr('iso-8601-timestamp'),

  organizationProfile: DS.belongsTo('organization-profile', { async: true }),

  isDraft: Ember.computed.equal('status', 'draft'),
  isCurrent: Ember.computed.equal('status', 'current'),
  isArchived: Ember.computed.equal('status', 'archive')
});
github mapeveri / muss / static / muss / app / models / user.js View on Github external
export default DS.Model.extend({
    username: DS.attr('string'),
    email: DS.attr('string'),
    firstName: DS.attr('string'),
    password: DS.attr('string'),
    lastName: DS.attr('string'),
    userPhoto: DS.attr('string'),
    isActive: DS.attr('boolean'),
    isSuperUser: DS.attr('boolean'),
    topics: DS.hasMany('topic'),
    comments: DS.hasMany('comment'),
    registers: DS.hasMany('register'),
    moderators: DS.hasMany('forum'),
    user: DS.belongsTo('profile'),
    notifications: DS.hasMany('notification'),
});
github Flexberry / ember-flexberry-designer / addon / mixins / regenerated / models / fd-dev-stage.js View on Github external
```javascript
      _typeMapVBChanged: Ember.on('init', Ember.observer('typeMapVB', function() {
        Ember.run.once(this, '_typeMapVBCompute');
      }))
      ```
  */
  _typeMapVBCompute: function() {
    let result = (this.typeMapVBCompute && typeof this.typeMapVBCompute === 'function') ? this.typeMapVBCompute() : null;
    this.set('typeMapVB', result);
  },
  typeMapVBStr: DS.attr('string'),
  useSourceControl: DS.attr('boolean'),
  version: DS.attr('string'),
  typeDefinitions: DS.hasMany('fd-dev-type-definition', { inverse: 'stage', async: false }),
  controlTypes: DS.hasMany('fd-dev-control-type', { inverse: 'stage', async: false }),
  users: DS.hasMany('fd-user-in-stage', { inverse: 'stage', async: false }),
  moduleSettings: DS.hasMany('fd-dev-module-setting', { inverse: 'stage', async: false }),
  generations: DS.hasMany('fd-generation', { inverse: 'stage', async: false }),
  getValidations: function () {
    let parentValidations = this._super();
    let thisValidations = {
    };
    return $.extend(true, {}, parentValidations, thisValidations);
  },
  init: function () {
    this.set('validations', this.getValidations());
    this._super(...arguments);
  }
});

export let defineBaseModel = function (modelClass) {
  modelClass.reopenClass({
github ilios / frontend / app / models / offering.js View on Github external
import DS from 'ember-data';
import Ember from 'ember';
import momentFormat from 'ember-moment/computeds/format';

const { computed, RSVP } = Ember;
const { not } = computed;
const { Promise, all } = RSVP;

export default DS.Model.extend({
  room: DS.attr('string'),
  site: DS.attr('string'),
  startDate: DS.attr('date'),
  endDate: DS.attr('date'),
  updatedAt: DS.attr('date'),
  session: DS.belongsTo('session', {async: true}),
  learnerGroups: DS.hasMany('learner-group', {async: true}),
  instructorGroups: DS.hasMany('instructor-group', {async: true}),
  learners: DS.hasMany('user', {
    async: true,
    inverse: 'offerings'
  }),
  instructors: DS.hasMany('user', {
    async: true,
    inverse: 'instructedOfferings'
  }),
  //startFoo and key properties are used in creating offering blocks
  startDayOfYear: momentFormat('startDate', 'DDDD'),
  startYear: momentFormat('startDate', 'YYYY'),
  startTime: momentFormat('startDate', 'HHmm'),
  endDayOfYear: momentFormat('endDate', 'DDDD'),
  endYear: momentFormat('endDate', 'YYYY'),
  endTime: momentFormat('endDate', 'HHmm'),
github StorjOld / MetaDisk / app / models / token.js View on Github external
import DS from 'ember-data';

export default DS.Model.extend({
	token: DS.attr('string'),
	yourBandwidth: DS.attr('number', {default: 0}),
	estimatedStorage: function() {
		return this.get('yourBandwidth') / 3;
	}.property('yourBandWidth'),
	files: DS.hasMany('file', {async: true})
});