attrsOption(serializer, attr) {
   var attrs = serializer.get('attrs');
   return attrs && (attrs[Ember.String.camelize(attr)] || attrs[attr]);
 }
import Ember from 'ember';
const { Component } = Ember;

export default Component.extend({
  classNames: ['flex', 'layout-row'],
  attributeBindings: ['style'],
  style: Ember.String.htmlSafe('overflow: hidden')
});
 parsePathForType: function( type ) {
   return Ember.String.capitalize( Ember.String.camelize( type ) );
 },
  function(app, property) {
    const dasherizedProperty = Ember.String.dasherize(property);

    return inspect(`model-${dasherizedProperty}`).html();
  }
Пример #5
0
 page: function(page) {
   swal(Ember.String.fmt("Page %@ is clicked.", page));
 }
 teardown: function() {
   var classifiedName = Ember.String.classify(config.modulePrefix);
   delete window[classifiedName];
   config.modulePrefix = originalModulePrefix;
   config.exportApplicationGlobal = originalExportApplicationGlobal;
 }
Пример #7
0
    options.formatSearching = function() {
      var text = self.get('typeaheadSearchingText');

      return Ember.String.htmlSafe(text);
    };
Пример #8
0
    $input.on('keydown', function(e) {
      // discard keystrokes that didn't change the actual input value
      if (e.keyCode !== 32 && e.keyCode >= 9 && e.keyCode <= 45) { return; }
      self.set('is' + Ember.String.capitalize(field) + 'Synch', false);

    }).on('change', function() {
Пример #9
0
export function translateHelper(params, hash) {
  const formatString = params[0];
  if (formatString) {
    return Ember.String.htmlSafe(translate(formatString, hash));
  }
}
Пример #10
0
export function answersAmount(params/*, hash*/) {
  var answers = params[0];
  var amount = answers.get('length');
  return Ember.String.htmlSafe('<span class="answers-amount">'+amount+'</span>');
}
Пример #11
0
// All modelNames are dasherized internally. Changing this function may
// require changes to other normalization hooks (such as typeForRoot).

/**
 This method normalizes a modelName into the format Ember Data uses
 internally.

  @method normalizeModelName
  @public
  @param {String} modelName
  @return {String} normalizedModelName
  @for DS
*/
export default function normalizeModelName(modelName) {
  return Ember.String.dasherize(modelName);
}
Пример #12
0
 keyForAttribute: function(attr) {
   return Ember.String.camelize(attr);
 },
Пример #13
0
  color: function () {
    var idString = this.get('id');
    var tagCol = this.get('colorizer').colorScheme(idString);

    return Ember.String.htmlSafe(tagCol);
  }.property('id'),
Пример #14
0
  },
  
  serializeHasMany() {
    this._super(...arguments);
    this.serializeRelationship(...arguments);
  },
  
  serializeBelongsTo() {
    this._super(...arguments);
    this.serializeRelationship(...arguments);
  },
  
  updateRecord(json, store) {
    if (json.attributes !== undefined && json.attributes.__id__ !== undefined)
    {
      json.type = Ember.String.singularize(json.type);
      
      const record = store.peekAll(json.type)
        .filterBy('currentState.stateName', "root.loaded.created.uncommitted")
        .findBy('_internalModel.' + Ember.GUID_KEY, json.attributes.__id__);

      if (record) {
        // record.unloadRecord();
        record.set('id', json.id);
        record._internalModel.flushChangedAttributes();
        record._internalModel.adapterWillCommit();
        store.didSaveRecord(record._internalModel);
        // store.push({ data: json });
      }

    }
Пример #15
0
import Ember from "ember";
import layout from "../templates/components/time-input";
import InputtableMixin from "../mixins/inputtable";

export default Ember.Component.extend(InputtableMixin, {
	layout: layout,
	dateSupport: Ember.inject.service(),
	classNameBindings: [":time-input", "dateSupport.supportsTime"],
	needsPolyfill: false,
	type: Ember.computed(function() {
		return "time";
	}).readOnly(),
	willRender() {
		this.set("needsPolyfill", !this.get(`dateSupport.${Ember.String.camelize(`Supports ${this.get("type")}`)}`));
	}
});
Пример #16
0
 singularLabel: function() {
   return Ember.String.singularize(this.get('label'));
 }.property('label'),
Пример #17
0
 htmlDescription: Ember.computed("model.longDescription", function() {
   return Ember.String.htmlSafe(this.get("model.longDescription"));
 }),
Пример #18
0
    kTrend: [
        'descending',
        'ascending',
        'building',
        'best possible technique',
        'with fewest breaths possible',
        'no breathing for first 10m',
        'no push-off',
        '3 x effort + 1 x recovery',
        // et al.
    ],

    // component lifecycle guarantees to run init() prior to didInsertElement()
    init() {
        this._super(...arguments);  // indirectly extends Ember.Object
        this.classNames = ['swim-set', 'swim-set-' + Ember.String.dasherize(this.get('setName'))];
        // must not initialise ref type property statically or else shared by all instances (sic!)
        this.widgetMap = new Map();
    },

    didInsertElement() {
            // searching DOM subtree for this component instance only
            for (let widget of this.$('select')) {  // !== null by template design
                this.widgetMap.set(widget.attributes['name'].value, widget);
            }
    },

    actions: {
        addReps() {
            // this.widgetMap.forEach(console.log, console);
            // XXX (unlikely) race condition of button click preceding didInsertElement() event?
Пример #19
0
 *    - Mixed: when using select-2 with "optionValuePath=..."
 *    - Array of Mixed: when using select-2 with "multiple=true" and
 *      "optionValuePath=..."
 *
 *  - Content: Array of Objects used to present to the user for choosing the
 *    selected values. "content" cannot be an Array of Strings, the Objects are
 *    expected to have an "id" and a property to be used as the label (by default,
 *    it is "text", but it can be overwritten via "optionLabelPath"). These
 *    properties can be computed properties or just plain JavaScript values.
 */
var Select2Component = Ember.Component.extend({
  tagName: "input",
  classNames: ["form-control"],
  classNameBindings: ["inputSize"],
  attributeBindings: ["style", "tabindex"],
  style: Ember.String.htmlSafe("display: hidden;"),
  tabindex: 0,

  // Bindings that may be overwritten in the template
  inputSize: "input-md",
  cssClass: null,
  createSearchChoice: null,
  optionIdPath: "id",
  optionValuePath: null,
  optionLabelPath: 'text',
  optionLabelSelectedPath: null,
  optionHeadlinePath: 'text',
  optionDescriptionPath: 'description',
  placeholder: null,
  multiple: false,
  allowClear: false,
Пример #20
0
export function backgroundColor(color) {
  return Ember.String.htmlSafe("background-color:" + color)
}
Пример #21
0
    options.formatAjaxError = function(jqXHR, textStatus, errorThrown) {
      var text = self.get('typeaheadErrorText');

      return Ember.String.htmlSafe(Ember.String.fmt(text, errorThrown));
    };
Пример #22
0
    let record;
    if(mirageRecord.attrs) {
      record = mirageRecord.attrs;
    }
    record['@type'] = type;
    record['@href'] = `/${type}/${mirageRecord.id}`;

    let build = mirageRecord._schema.builds.first();
    if (build) {
      record['current_build'] = build.attrs;
    }

    return record;
  },

  turnIntoV3(type, payload) {
    let response;
    if(Ember.isArray(payload)) {
      let records = payload.map( (record) => { return this._turnIntoV3Singular(type, record); } );
      let pluralized = Ember.String.pluralize(type);
      response = {};
      response['@type'] = pluralized;
      response['@href'] = `/${pluralized}`;
      response[pluralized] = records;
    } else {
      response = this._turnIntoV3Singular(type, payload);
    }
    return response;
  }
});
Пример #23
0
import Ember from 'ember';
import DS from 'ember-data';
import ApplicationSerializer from './application';

const {
    EmbeddedRecordsMixin
} = DS;

export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
    keyForAttribute(attr) {
        return Ember.String.underscore(attr);
    }
});
Пример #24
0
          }
        };

        if(Array.isArray(relationship.data)) {
          relationship.data.forEach(process);
        } else if(relationship && relationship.data) {
          process(relationship.data);
        }
      });
    }

    return { data, included };
  },

  keyForAttribute(key) {
    return Ember.String.underscore(key);
  },

  _fixReferences(payload) {
    let byHref = {}, href, records;
    if(payload['@type']) {
      // API V3 doesn't return all of the objects in a full representation
      // If an object is present in one place in the response, all of the
      // other occurences will be just references of a kind - they will just
      // include @href property.
      //
      // I don't want to identify records by href in ember-data, so here I'll
      // set an id and a @type field on all of the references.
      //
      // First we need to group all of the items in the response by href:
      traverse(payload, (item) => {
 state: computed('taskInstance.state', function() {
   return Ember.String.capitalize(this.get('taskInstance.state'));
 }),
Пример #26
0
 speciesNameMU: function() {
   return Ember.String.htmlSafe(`<em>${this.get('speciesName')}</em>`);
 }.property('speciesName').readOnly(),
 parseClassName: function (key ) {
   return Ember.String.capitalize( key );
 },
Пример #28
0
 pathForType: function(type) {
     var camelized = Ember.String.camelize(type);
     return Ember.String.pluralize(camelized);
 }
Пример #29
0
import Ember from 'ember';
import ApplicationSerializer from 'ghost-admin/serializers/application';
import EmbeddedRecordsMixin from 'ember-data/serializers/embedded-records-mixin';

export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
    attrs: {
        roles: {embedded: 'always'}
    },

    extractSingle(store, primaryType, payload) {
        let root = this.keyForAttribute(primaryType.modelName);
        let pluralizedRoot = Ember.String.pluralize(primaryType.modelName);

        payload[root] = payload[pluralizedRoot][0];
        delete payload[pluralizedRoot];

        return this._super(...arguments);
    },

    normalizeSingleResponse(store, primaryModelClass, payload) {
        let root = this.keyForAttribute(primaryModelClass.modelName);
        let pluralizedRoot = Ember.String.pluralize(primaryModelClass.modelName);

        payload[root] = payload[pluralizedRoot][0];
        delete payload[pluralizedRoot];

        return this._super(...arguments);
    }
});
 (acc, key) => Ember.assign(acc, { [Ember.String.camelize(key)]: contributor[key] }),