How to use the ember-inflector.pluralize function in ember-inflector

To help you get started, we’ve selected a few ember-inflector 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 TryGhost / Ghost-Admin / app / components / gh-mailchimp-settings.js View on Github external
let word = 'hour';

        // display minutes if next sync in < 1 hr
        if (hours < 1) {
            let minutes = Math.round(hours * 60);
            word = 'minute';

            if (minutes === 0) {
                minutes = 1;
            }

            hours = minutes;
        }

        if (hours !== 1) {
            word = pluralize(word);
        }

        // display hours
        return `${Math.round(hours)} ${word}`;
    }),
github cardstack / cardstack / packages / test-support / addon-test-support / test-helpers.js View on Github external
export function getSpaceForCard(type, id) {
  return getContext()
    .owner.lookup('service:store')
    .findRecord('space', `/${pluralize(type)}/${id}`);
}
github CenterForOpenScience / ember-osf-web / mirage / views / osf-resource.ts View on Github external
export function osfToManyRelationship(
    server: Server,
    parentModelName: K,
    relationshipName: string & RelationshipsFor,
    options?: Partial,
) {
    const opts: RelationshipOptions = Object.assign({
        path: `/${pluralize(underscore(parentModelName))}/:parentID/relationships/${underscore(relationshipName)}`,
        relatedModelName: relationshipName,
        defaultSortKey: '-id',
    }, options);
    const mirageParentModelName = pluralize(camelize(parentModelName));
    const actions = gatherRelationshipActions(opts);

    if (actions.includes('related')) {
        const relationshipRelatedPath = opts.path.replace('relationships/', '');
        server.get(relationshipRelatedPath, function(schema, request) {
            const data = schema[mirageParentModelName]
                .find(request.params.parentID)[relationshipName]
                .models
                .filter((m: ModelInstance) => filter(m, request))
                .map((model: ModelInstance) => this.serialize(model).data);
            return process(schema, request, this, data, { defaultSortKey: opts.defaultSortKey });
        });
github cardstack / cardstack / packages / routing / addon / services / routing.js View on Github external
routeForNew(type) {
    type = pluralize(type);
    return {
      name: 'cardstack.new-content',
      params: [['type', type]],
    };
  },
github firebase / emberfire / addon / adapters / firestore.ts View on Github external
doc._document._included = hasManyRelationships.reduce((c, e, i) => {
                c[pluralize(e.key)] = includes[i];
                return c;
            }, {});
            return Promise.all([
github pixelhandler / ember-jsonapi-resources / addon / models / resource.js View on Github external
let relation = this.get('relationships.' + related);
    if (Array.isArray(relation.data)) {
      for (let i = 0; i < relation.data.length; i++) {
        if (relation.data[i].id === id) {
          relation.data.splice(i, 1);
          this._relationRemoved(related, id);
          break;
        }
      }
      let resources = this.get(related);
      let idx = resources.mapBy('id').indexOf(id);
      if (idx > -1) {
        resources.removeAt(idx);
      }
    } else if (typeof relation === 'object') {
      if (relation.data.type === pluralize(related) && relation.data.id === id) {
        this._relationRemoved(related, id);
      }
      relation.data = null;
      this.set(`${related}.content`, null);
    }
  },
github cardstack / cardstack / packages / data / addon / services / cardstack-data.js View on Github external
async _getContentType(type) {
    if (this._contentTypeCache[type]) {
      return await this._contentTypeCache[type];
    }

    this._contentTypeCache[type] = this.get('store').findRecord('content-type', pluralize(type));
    return await this._contentTypeCache[type];
  },
github CenterForOpenScience / ember-osf-web / app / adapters / osf-adapter.ts View on Github external
pathForType(modelName: string): string {
        const underscored: string = underscore(modelName);
        return pluralize(underscored);
    }
github CenterForOpenScience / ember-osf-web / mirage / views / osf-resource.ts View on Github external
export function osfToManyRelationship(
    server: Server,
    parentModelName: K,
    relationshipName: string & RelationshipsFor,
    options?: Partial,
) {
    const opts: RelationshipOptions = Object.assign({
        path: `/${pluralize(underscore(parentModelName))}/:parentID/relationships/${underscore(relationshipName)}`,
        relatedModelName: relationshipName,
        defaultSortKey: '-id',
    }, options);
    const mirageParentModelName = pluralize(camelize(parentModelName));
    const actions = gatherRelationshipActions(opts);

    if (actions.includes('related')) {
        const relationshipRelatedPath = opts.path.replace('relationships/', '');
        server.get(relationshipRelatedPath, function(schema, request) {
            const data = schema[mirageParentModelName]
                .find(request.params.parentID)[relationshipName]
                .models
                .filter((m: ModelInstance) => filter(m, request))
                .map((model: ModelInstance) => this.serialize(model).data);
            return process(schema, request, this, data, { defaultSortKey: opts.defaultSortKey });
        });
    }

    if (actions.includes('add')) {
        server.post(opts.path, (schema: Schema, request: Request) => {
github hashicorp / levant / vendor / github.com / hashicorp / nomad / ui / app / serializers / application.js View on Github external
keyForRelationship(attr, relationshipType) {
    const key = `${singularize(attr)
      .camelize()
      .capitalize()}ID`;
    return relationshipType === 'hasMany' ? pluralize(key) : key;
  },

ember-inflector

The default blueprint for Embroider v2 addons.

MIT
Latest version published 2 months ago

Package Health Score

81 / 100
Full package analysis