// -------------------------------------------------------------------------
    // Methods

    /**
     * Based on value of key, retrieve translation or usual get() value
     *
     * @function
     * @param {String} key property to retrieve
     * @returns {String}
     */
    get( key ) {
        const matches = key.match( /translate\.(.*)/ );

        return matches ?
            this.translate( matches[1] ) :
            Ember.get( this, key );
    },

    /**
     * Retrieve translated key without support for token replacement or pluralization
     *
     * @function
     * @param {String} key key to translate
     * @returns {String}
     */
    translate( key ) {
        return this.get( 'translateService' ).getKeyValue( key );
    }
});
export function filterByOrganization(params/*, hash*/) {
  const organizationUrl = Ember.get(params[1], 'data.links.self');
  return params[0].filterBy('data.links.organization', organizationUrl);
}
 itemList = items.map(function(item) {
   return Ember.get(item, descField) + '(' + this._dateFormat(Ember.get(item, dateField)) + ')';
 }.bind(this));
Example #4
0
 store._adapterRun(function() {
   var payload, data;
   var internalModel = record._internalModel;
   if (adapterPayload) {
     payload = normalizeResponseHelper(serializer, store, type, adapterPayload, Ember.get(record, "id"), operation);
     if (payload.included) {
       store.push({ data: payload.included });
     }
     data = convertResourceObject(payload.data);
   }else{
     data = adapterPayload;
   }
   store.didSaveRecord(internalModel, _normalizeSerializerPayload(internalModel.type, data));
 });
Example #5
0
File: setup.js Project: Japh/Ghost
    backRoute: Ember.computed('appController.currentRouteName', function () {
        var appController = this.get('appController'),
            currentRoute = Ember.get(appController, 'currentRouteName');

        return currentRoute === 'setup.two' ? 'setup.one' : 'setup.two';
    })
Example #6
0
function getPromise(object, property) {
  return RSVP.resolve(Ember.get(object, property));
}
Example #7
0
File: ext.js Project: eriktrom/data
    var inverseType = this.typeForRelationship(name, store);
    if (!inverseType) {
      return null;
    }

    var propertyMeta = this.metaForProperty(name);
    //If inverse is manually specified to be null, like  `comments: DS.hasMany('message', { inverse: null })`
    var options = propertyMeta.options;
    if (options.inverse === null) { return null; }

    var inverseName, inverseKind, inverse;

    //If inverse is specified manually, return the inverse
    if (options.inverse) {
      inverseName = options.inverse;
      inverse = Ember.get(inverseType, 'relationshipsByName').get(inverseName);

      assert("We found no inverse relationships by the name of '" + inverseName + "' on the '" + inverseType.modelName +
        "' model. This is most likely due to a missing attribute on your model definition.", !Ember.isNone(inverse));

      inverseKind = inverse.kind;
    } else {
      //No inverse was specified manually, we need to use a heuristic to guess one
      if (propertyMeta.type === propertyMeta.parentType.modelName) {
        warn(`Detected a reflexive relationship by the name of '${name}' without an inverse option. Look at http://emberjs.com/guides/models/defining-models/#toc_reflexive-relation for how to explicitly specify inverses.`, false, {
          id: 'ds.model.reflexive-relationship-without-inverse'
        });
      }

      var possibleRelationships = findPossibleInverses(this, inverseType);
Example #8
0
 }).catch((e) => {
   let message = Ember.getWithDefault(e, 'responseJSON.message', 'An error occured');
   Ember.get(this, 'flashMessages').danger(`Save Failed! ${message}`);
 });
  sortDirection: 'asc',
  tagName: 'select',

  /**
  * overrideable object paths for value and label paths
  */
  optionValuePath: 'content',
  optionLabelPath: 'content',
  optionGroupPath: 'content.group',

  selection: null,
  value: computedPolyfill('selection', {
    get() {
      var valuePath = this.get('_valuePath');
      var selection = this.get('selection');
      return valuePath && selection ? Ember.get(selection, valuePath) : selection;
    },
    set(key, value) {
      return value;
    }
  }),

  /*
   * Contains optgroups.
   */
  optgroups: computed('content.[]', 'groupedContent.[]', function() {
    var groupedContent = this.get('groupedContent');
    if (groupedContent) {
      return groupedContent.mapBy('label');
    } else {
      //compute option groups from content
Example #10
0
import Ember from 'ember';

export default Ember.Helper.extend({

  redux: Ember.inject.service('redux'),

  init() {
    this._super(...arguments);
    this.get('redux').subscribe(() => {
      this.recompute();
    });
  },

  compute(params) {
    let state = this.get('redux').getState();
    return Ember.get(state, params[0]);
  }
});
Example #11
0
 _replace_nan: function(item) {
     if (isNaN(Em.get(item, 'storage_volume'))) {
         console.log('Replacing NaN by 0 in storage_volume');
         Em.set(item, 'storage_volume', 0);
     }
 },
Example #12
0
 serialize: function (model) {
   return { type_id: Ember.get(model, 'name') };
 }
Example #13
0
import Ember from 'ember';
import LogService from 'ember-flexberry/services/log';
import config from '../config/environment';

let enabled = Ember.get(config, 'APP.log.enabled');
if (Ember.typeOf(enabled) === 'boolean') {
  LogService.reopen({
    enabled: enabled
  });
}

let storeErrorMessages = Ember.get(config, 'APP.log.storeErrorMessages');
if (Ember.typeOf(storeErrorMessages) === 'boolean') {
  LogService.reopen({
    storeErrorMessages: storeErrorMessages
  });
}

let storeWarnMessages = Ember.get(config, 'APP.log.storeWarnMessages');
if (Ember.typeOf(storeWarnMessages) === 'boolean') {
  LogService.reopen({
    storeWarnMessages: storeWarnMessages
  });
}

let storeLogMessages = Ember.get(config, 'APP.log.storeLogMessages');
if (Ember.typeOf(storeLogMessages) === 'boolean') {
  LogService.reopen({
    storeLogMessages: storeLogMessages
  });
}
Example #14
0
 return this.get('targetsArray').filterProperty('isIp',true).map((choice) => {
   return Ember.get(choice,'value');
 });
Example #15
0
      }).catch( (e) => {
        let message = e.responseJSON ? e.responseJSON.message : e.message;
        message = message || 'There was an unexpected error updating email';

        Ember.get(this, 'flashMessages').danger(message);
      }).finally( () => {
    this._updateDisabled();

    this.$().on('tbwchange', () => {
      if (this.get('change')) {
        this.get('change')(this.$().trumbowyg('html'));
      }
    });
  },

  _destroyTrumbowyg(){
    this.$().off('tbwchange');
    this.$().trumbowyg('destroy');
  },

  _isAttrChanged(attrs, attrName){
    return Ember.get(attrs, `newAttrs.${attrName}.value`) !== Ember.get(attrs, `oldAttrs.${attrName}.value`);
  },

  didInsertElement(){
    this._renderTrumbowyg();
  },

  didUpdateAttrs(attrs) {
    const optionsUpdated = this.get('optionNames')
      .some(optionName => this._isAttrChanged(attrs, optionName));
    const htmlUpdated = Ember.get(attrs, 'newAttrs.html.value') !== this.$().trumbowyg('html');
    const disabledUpdated = this._isAttrChanged(attrs, 'disabled');
    const placeholderUpdated = this._isAttrChanged(attrs, 'placeholder');

    if (optionsUpdated || placeholderUpdated) {
      this._destroyTrumbowyg();
Example #17
0
import Commit from '../mixins/commit-for-adapter';

//noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
export default DS.RESTAdapter.extend(BuildUrlMixin, XFind,Commit,{
  /**
   * Handle Business Error(With http code neither 200-300 nor 304)
   * 所有通过Ember-Data发起的请求,如果后端返回的HttpCode不处于200-300区间,也不是304,则会进入此钩子
   * 该钩子内部针对不同的HttpCode包装为不同的 Error并抛出.
   * @param jqXHR
   * @returns {*}
   * @param responseText
   * @param error
   */
    ajaxError(jqXHR, responseText, error) {
    if (jqXHR && jqXHR.status === 422) {
      var message = Ember.get(jqXHR, 'responseJSON.error.message');
      return new HTTPError(jqXHR.status, message);
    }

    return new HTTPError(jqXHR.status);
  },
  /**
   * Bulk Delete
   * @param store
   * @param type
   * @param snapshots
   * @returns {*}
   */
    bulkDelete(store, type, snapshots) {
    var ids = snapshots.mapBy('id');
    return this.ajax(this.buildURL(type.typeKey, ids, snapshots, 'resourceOperation', 'bulkDelete'), 'DELETE', {data: {ids: ids}});
Example #18
0
      { start: { date: new Date(2014, 2, 11), value: 72.50 }, end: { date: new Date(2014, 5, 9), value: 63.34 } },
      { start: { date: new Date(2013, 10, 21), value: 43 }, end: { date: new Date(2014, 2, 17), value: 70.50 } }
    ];
    const width = window.screen.availWidth * 0.49;
    return {
      data: data,
      width: width,
      closeValues: closeValues,
      supstanceValues: supstanceValues,
      trades: trades,
      trendlineData: trendlineData
    };
  },
  afterModel(model, transition) {
    const store = this.get('storage');
    model.currentUrl = Ember.get(transition, 'targetName');

    let i = 0;
    setInterval(() => {
      if (i > model.data.length - 1) {
        i = 0;
      }
      store.addItem({
        date: new Date(),
        open: model.data[i].open,
        high: model.data[i].high,
        low: model.data[i].low,
        close: model.data[i].close,
        volume: model.data[i].volume
      });
      i++;
Example #19
0
      }).then(() => {
        let message = `${role.get('name')} created`;

        this.transitionTo('organization.roles.index');
        Ember.get(this, 'flashMessages').success(message);
      });
import Ember from 'ember';
import ENV from '../config/environment'; 
import setupWebFont from 'ember-cli-webfontloader/initializers/ember-cli-webfontloader';
export default { 
    name: 'ember-cli-webfontloader',
    initialize() {
        const config = Ember.get(ENV, 'webFontConfig') || {};
        setupWebFont(config);
    }
};
Example #21
0
 },
 _requestType() {
   if (this.get('isNew')) {
     return 'POST';
   } else {
     return 'PUT';
   }
 },
 _commitWithAttachment(promise, adapter, serializer) {
   var operation, record, store, type, oldEmberData;
   oldEmberData = this._oldEmberData();
   store = this.store;
   record = this;
   type = record.constructor;
   operation = '';
   if (Ember.get(record, 'isNew')) {
     operation = 'createRecord';
   } else if (Ember.get(record, 'isDeleted')) {
     operation = 'deleteRecord';
   } else {
     operation = 'updateRecord';
   }
   return promise.then((function(adapterPayload) {
     if (oldEmberData) {
       var payload;
       payload = void 0;
       if (adapterPayload) {
         payload = serializer.extract(store, type, adapterPayload, Ember.get(record, "id"), operation);
       } else {
         payload = adapterPayload;
       }
Example #22
0
import Ember from 'ember';
import percyDocs from 'percy-docs';

export default Ember.Route.extend({
  model() {
    return Ember.RSVP.hash({
      navMarkdown: Ember.get(percyDocs.markdownFiles, 'nav'),
      pageMarkdown: Ember.get(percyDocs.markdownFiles, 'index'),
    });
  }
});
 getCellContent: function(row) {
   var path = this.get('contentPath');
   Ember.assert("You must either provide a contentPath or override " +
                "getCellContent in your column definition", path != null);
   return Ember.get(row, path);
 },
Example #24
0
import Ember from 'ember';

import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';

export default Ember.Route.extend(ApplicationRouteMixin,{
  actions:{
    error(error, transition) {
      alert(1);
      const flashMessages = Ember.get(this, 'flashMessages');
      if (error.errors[0].status === 401) {
        var params = transition.params['dashboard.inspection'].inspection_number;
        this.transitionTo('login');
        const message = Ember.String.htmlSafe(`Inspection with identifier <strong>${params}</strong> does not exist.`);
        flashMessages.clearMessages();
        flashMessages.success(message,{
          timeout: 10000
        });
      }
    }
  }

});
Example #25
0
 disks.forEach((disk) => {
   if ( !Ember.get(disk, 'driver') )
   {
     Ember.set(disk, 'driver', defaultDriver);
   }
 });
 _autoBrushHandler: function(e) {
   this.set('left', Ember.get(e, 'left.x'));
   this.set('right', Ember.get(e, 'right.x'));
 },
test('should own a settings model', function(assert) {
  var tSavedFilter = this.store().modelFor('savedFilter');
  var relationship = Ember.get(tSavedFilter, 'relationshipsByName').get('settings');
  assert.equal(relationship.key, 'settings', 'has a relationship with settings');
  assert.equal(relationship.kind, 'belongsTo', 'kind of relationship is hasMany');
});
Example #28
0
 user.save().then(() => {
   let message = `Email updated to ${user.get('email')}`;
   Ember.get(this, 'flashMessages').success(message);
 }).catch( (e) => {
test( 'Requires objectId as key', function( assert ) {
  assert.equal( Ember.get( serializer, 'primaryKey' ), 'objectId', 'Should be objectId.' );
});
  }),

  projectedSavings: Ember.computed('budgetSheet.income', 'total', function() {
    return this.get('budgetSheet.income') - this.get('total');
  }),

  actualSavings: Ember.computed('budgetSheet.income', 'spent', function() {
    return this.get('budgetSheet.income') - this.get('spent');
  }),

  entriesOrder: ['createdAt:desc'],
  sortedEntries: Ember.computed.sort('entries', 'entriesOrder'),

  actions: {
    addCategory(name, budgetAmount) {
      const flashMessages = Ember.get(this, 'flashMessages');

      let category = this.store.createRecord('category', {
        name: name,
        budgetAmount: budgetAmount,
        budgetSheet: this.budgetSheet
      });

      category.save().then(function() {
        flashMessages.success('Saved.');
      });
    },

    updateCategory(id, attribute, value) {
      const flashMessages = Ember.get(this, 'flashMessages');
      let category = this.store.peekRecord('category', id);