How to use the ember-data.attr 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 mgenev / how-to-sane / client / app / models / event.js View on Github external
import DS from 'ember-data';

export default DS.Model.extend({
    // relationships
    vendor: DS.belongsTo('vendor'),
    users: DS.hasMany('user'),

    // attributes
    title: DS.attr('string'),
    date: DS.attr('date'),
    tags: DS.attr('array')
});
github HospitalRun / hospitalrun-frontend / app / models / visit.js View on Github external
function paymentStateAcceptance(object) {
  return !Object.keys(PAYMENT_STATES)
    .some((state) => PAYMENT_STATES[state] === object.get('paymentState'));
}

export default AbstractModel.extend({
  // Attributes
  customForms: DS.attr('custom-forms'),
  dischargeInfo: DS.attr('string'),
  endDate: DS.attr('date'), // if visit type is outpatient, startDate and endDate are equal
  examiner: DS.attr('string'),
  hasAppointment: DS.attr('boolean', { defaultValue: false }),
  history: DS.attr('string'), // No longer used
  historySince: DS.attr('string'), // History of the Present Illness -- no longer used
  location: DS.attr('string'),
  notes: DS.attr('string'), // this field is being deprecated in favor of patient-note
  outPatient: DS.attr('boolean'),
  paymentState: DS.attr('string', { defaultValue: PAYMENT_STATES.PENDING }),
  primaryDiagnosis: DS.attr('string'), // No longer used -- diagnoses are stored in diagnoses hasMany relationship
  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 }),
github givanse / mvc-tree / app / models / grid-node.js View on Github external
col: Ember.computed('column', function() {
    return this.get('column.col');
  }),

  template: DS.attr('string'),

  x: DS.attr('number'),
  y: DS.attr('number'),
  x_padded: DS.attr('number'),
  y_padded: DS.attr('number'),
  rx: DS.attr('number'),
  ry: DS.attr('number'),
  cx: DS.attr('number'),
  cy: DS.attr('number'),
  width: DS.attr('number'),
  height: DS.attr('number'),

  svgenv: Ember.inject.service('svg-environment'),

  _addNodeValues: Ember.on('ready', function() {
    var svgenv = this.get('svgenv');

    if ( ! svgenv ) {
      throw new Ember.Error('svgenv has not been injected yet');
    }

    // TODO: use uppercase names for absolute values

    // x
    this.set('x', this.get('col') * svgenv.get('colW'));
    this.set('x_padded', svgenv.get('paddingL') + this.get('x'));
    this.set('cx', this.get('x') + (svgenv.get('colW') / 2));
github apache / hadoop / hadoop-yarn-project / hadoop-yarn / hadoop-yarn-ui / src / main / webapp / app / models / yarn-app-timeline.js View on Github external
*     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import DS from 'ember-data';
import Converter from 'yarn-ui/utils/converter';

export default DS.Model.extend({
  appName: DS.attr('string'),
  user: DS.attr('string'),
  queue: DS.attr('string'),
  state: DS.attr('string'),
  startTime: DS.attr('string'),
  elapsedTime: DS.attr('string'),
  finalStatus: DS.attr('string'),
  finishedTime: DS.attr('finishedTime'),
  progress: DS.attr('number'),
  diagnostics: DS.attr('string'),
  amHostHttpAddress: DS.attr('string'),
  logAggregationStatus: DS.attr('string'),
  unmanagedApplication: DS.attr('string'),
  amNodeLabelExpression: DS.attr('string'),
  applicationTags: DS.attr('string'),
  applicationType: DS.attr('string'),
  priority: DS.attr('number'),
  allocatedMB: DS.attr('number'),
  allocatedVCores: DS.attr('number'),
github Flexberry / ember-flexberry-designer / addon / mixins / regenerated / models / fd-dev-form-control.js View on Github external
import Ember from 'ember';
import DS from 'ember-data';
import { Projection } from 'ember-flexberry-data';
export let Model = Ember.Mixin.create({
  name: DS.attr('string'),
  order: DS.attr('number'),
  propertyPath: DS.attr('string'),
  settingsXml: DS.attr('string'),
  controlType: DS.belongsTo('fd-dev-control-type', { inverse: null, async: false }),
  propertyType: DS.belongsTo('fd-dev-type-definition', { inverse: null, async: false }),
  formView: DS.belongsTo('fd-dev-form-view', { inverse: 'controls', async: false }),
  getValidations: function () {
    let parentValidations = this._super();
    let thisValidations = {
      name: { presence: true },
      controlType: { presence: true },
      propertyType: { presence: true },
      formView: { presence: true }
    };
    return Ember.$.extend(true, {}, parentValidations, thisValidations);
  },
  init: function () {
github basho-labs / riak-explorer-gui / app / pods / cluster / model.js View on Github external
* Is this cluster in Dev Mode? Set in the Explorer config file.
   * Dev mode allows expensive operations like list keys, delete bucket, etc.
   * @property developmentMode
   * @type Boolean
   * @default false
   */
  developmentMode: DS.attr('boolean', {defaultValue: false}),

  /**
   * The Riak Type: either kv_oss, kv_ee, ts_oss, ts_ee, or unavailable
   * @property riakType
   * @type String
   */
  riakType: DS.attr('string', {defaultValue: 'kv_oss'}),

  riakTypeLong: DS.attr('string', {defaultValue: 'KV Open Source'}),

  /**
   * Riak Version
   * @property riakVersion
   * @type String
   */
  riakVersion: DS.attr('string'),

  /**
   * Returns a list of currently activated bucket types.
   *
   * @method activeBucketTypes
   * @return {Array}
   */
  activeBucketTypes: function() {
    return this.get('bucketTypes').filterBy('isActive');
github sedouard / gittrack / app / models / repo.js View on Github external
issues_url: DS.attr('string'),
  pulls_url: DS.attr('string'),
  milestones_url: DS.attr('string'),
  notifications_url: DS.attr('string'),
  labels_url: DS.attr('string'),
  releases_url: DS.attr('string'),
  created_at: DS.attr('string'),
  updated_at: DS.attr('string'),
  pushed_at: DS.attr('string'),
  git_url: DS.attr('string'),
  ssh_url: DS.attr('string'),
  clone_url: DS.attr('string'),
  svn_url: DS.attr('string'),
  homepage: DS.attr('string'),
  size: DS.attr('number'),
  stargazers_count: DS.attr('number'),
  watchers_count: DS.attr('number'),
  language: DS.attr('string'),
  has_issues: DS.attr('booelan'),
  has_downloads: DS.attr('booelan'),
  has_wiki: DS.attr('booelan'),
  has_pages: DS.attr('booelan'),
  forks_count: DS.attr('number'),
  mirror_url: DS.attr('string'),
  open_issues_count: DS.attr('number'),
  forks: DS.attr('number'),
  open_issues: DS.attr('number'),
  watchers: DS.attr('number'),
  default_branch: DS.attr('string'),
});
github givanse / mvc-tree / app / models / grid-node.js View on Github external
row: DS.attr('number'),

  /*
    Relationships 
  */
  column: DS.belongsTo('column', {async: true}),

  /*
    Added localy
  */

  col: Ember.computed('column', function() {
    return this.get('column.col');
  }),

  template: DS.attr('string'),

  x: DS.attr('number'),
  y: DS.attr('number'),
  x_padded: DS.attr('number'),
  y_padded: DS.attr('number'),
  rx: DS.attr('number'),
  ry: DS.attr('number'),
  cx: DS.attr('number'),
  cy: DS.attr('number'),
  width: DS.attr('number'),
  height: DS.attr('number'),

  svgenv: Ember.inject.service('svg-environment'),

  _addNodeValues: Ember.on('ready', function() {
    var svgenv = this.get('svgenv');