How to use the @ember-data/model.extend function in @ember-data/model

To help you get started, we’ve selected a few @ember-data/model 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 travis-ci / travis-web / app / models / job.js View on Github external
/* global Travis */

import Model, { attr, belongsTo } from '@ember-data/model';
import { observer, computed } from '@ember/object';
import { alias, and, equal, not, reads } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import { isEqual } from '@ember/utils';
import { getOwner } from '@ember/application';
import Log from 'travis/models/log';
import DurationCalculations from 'travis/mixins/duration-calculations';
import DurationAttributes from 'travis/mixins/duration-attributes';
import promiseObject from 'travis/utils/promise-object';

export default Model.extend(DurationCalculations, DurationAttributes, {
  api: service(),
  jobConfigFetcher: service(),
  features: service(),
  logId: attr(),
  queue: attr(),
  state: attr(),
  number: attr(),
  allowFailure: attr('boolean'),
  tags: attr(),
  repositoryPrivate: attr(),
  repositorySlug: attr(),
  updatedAt: attr('date'),
  _config: attr(),

  repo: belongsTo('repo'),
  build: belongsTo('build', { async: true }),
github hashicorp / vault / ui / app / models / transform / role.js View on Github external
import Model, { attr } from '@ember-data/model';
import { computed } from '@ember/object';
import { apiPath } from 'vault/macros/lazy-capabilities';
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
import attachCapabilities from 'vault/lib/attach-capabilities';

const ModelExport = Model.extend({
  // used for getting appropriate options for backend
  idPrefix: 'role/',
  // the id prefixed with `role/` so we can use it as the *secret param for the secret show route
  idForNav: computed('id', 'idPrefix', function() {
    let modelId = this.id || '';
    return `${this.idPrefix}${modelId}`;
  }),

  name: attr('string', {
    // TODO: make this required for making a transformation
    label: 'Name',
    fieldValue: 'id',
    readOnly: true,
    subText: 'The name for your role. This cannot be edited later.',
  }),
  transformations: attr('array', {
github NREL / api-umbrella / src / api-umbrella / admin-ui / app / models / api / settings.js View on Github external
// eslint-disable-next-line ember/no-observers
import EmberObject, { computed, observer } from '@ember/object';
import Model, { attr, hasMany } from '@ember-data/model';

import { A } from '@ember/array';
import compact from 'lodash-es/compact';

export default Model.extend({
  appendQueryString: attr(),
  headersString: attr(),
  httpBasicAuth: attr(),
  requireHttps: attr(),
  disableApiKey: attr(),
  apiKeyVerificationLevel: attr(),
  requiredRoles: attr(),
  requiredRolesOverride: attr(),
  allowedIps: attr(),
  allowedReferers: attr(),
  rateLimitMode: attr(),
  anonymousRateLimitBehavior: attr(),
  authenticatedRateLimitBehavior: attr(),
  passApiKeyHeader: attr(),
  passApiKeyQueryParam: attr(),
  defaultResponseHeadersString: attr(),
github NREL / api-umbrella / src / api-umbrella / admin-ui / app / models / admin-group.js View on Github external
import Model, { attr } from '@ember-data/model';
import { buildValidations, validator } from 'ember-cp-validations';

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

export default Model.extend(Validations, {
  name: attr(),
  apiScopeIds: attr({ defaultValue() { return [] } }),
  permissionIds: attr({ defaultValue() { return [] } }),
  admins: attr(),
  createdAt: attr(),
  updatedAt: attr(),
  creator: attr(),
  updater: attr(),
}).reopenClass({
  urlRoot: '/api-umbrella/v1/admin_groups',
  singlePayloadKey: 'admin_group',
  arrayPayloadKey: 'data',
});
github travis-ci / travis-web / app / models / env-var.js View on Github external
import Model, { attr, belongsTo } from '@ember-data/model';

export default Model.extend({
  name: attr('string'),
  value: attr('string'),
  'public': attr('boolean'),
  branch: attr('string'),

  repo: belongsTo('repo', { async: true })
});
github NREL / api-umbrella / src / api-umbrella / admin-ui / app / models / api / rewrite.js View on Github external
const Validations = buildValidations({
  matcherType: [
    validator('presence', true),
  ],
  httpMethod: [
    validator('presence', true),
  ],
  frontendMatcher: [
    validator('presence', true),
  ],
  backendReplacement: [
    validator('presence', true),
  ],
});

export default Model.extend(Validations, {
  sortOrder: attr('number'),
  matcherType: attr(),
  httpMethod: attr(),
  frontendMatcher: attr(),
  backendReplacement: attr(),
}).reopenClass({
  validationClass: Validations,
});
github travis-ci / travis-web / app / models / beta-migration-request.js View on Github external
import Model, { hasMany, attr } from '@ember-data/model';
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';

export default Model.extend({
  store: service(),

  ownerId: attr('number'),
  ownerName: attr('string'),
  ownerType: attr('string'),
  acceptedAt: attr('date'),
  organizations: hasMany('organization'),

  owner: computed('ownerName', 'ownerType', function () {
    const { ownerName, ownerType = '', store } = this;
    return ownerName && ownerType ? store.peekRecord(ownerType.toLowerCase(), ownerName) : null;
  })

});
github hashicorp / vault / ui / app / models / metrics / activity.js View on Github external
import Model, { attr } from '@ember-data/model';

export default Model.extend({
  total: attr('object'),
  endTime: attr('string'),
  startTime: attr('string'),
});
github travis-ci / travis-web / app / models / lead.js View on Github external
import Model, { attr } from '@ember-data/model';

export const LEAD_UTM_FIELDS = {
  SOURCE: 'utm_source',
  CAMPAIGN: 'utm_campaign',
  MEDIUM: 'utm_medium',
  TERM: 'utm_term',
  CONTENT: 'utm_content',
};

export default Model.extend({
  name: attr('string'),
  email: attr('string'),
  team_size: attr('number'),
  phone: attr('string'),
  message: attr('string'),
  referral_source: attr('string'),
  utm_fields: attr(),
});
github travis-ci / travis-web / app / models / plan.js View on Github external
import Model, { attr } from '@ember-data/model';

export default Model.extend({
  name: attr('string'),
  builds: attr(),
  price: attr(),
  annual: attr('boolean'),
  currency: attr(),
});

@ember-data/model

A basic Ember implementation of a resource presentation layer for use with @ember-data/store

MIT
Latest version published 2 months ago

Package Health Score

89 / 100
Full package analysis