node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »

ember-crud

Ember CRUD

The Ember CRUD library includes base Routes and various mixins to help you implement CRUD (Create, Read, Update, Delete) functionality in your Ember app.

Dependencies

Configuration

  • Add one of dist/ember-crud*.js to your app
  • Add ember-i18n translations file
  • Extend from base routes and/or include mixins
  • Configure crud variable in your routes

Example Translations

Ember.I18n.translations = {
  'crud': {
    'titles': {
      'new': 'New {{model}}',
      'edit': 'Edit {{model}}',
    },
    'create': {
      'button': 'Add',
      'success': '{{model}} created successfully.',
      'error': 'Error creating {{model}}.',
    },
    'save': {
      'button': 'Save Changes',
      'success': '{{model}} saved successfully.',
      'error': 'Error saving {{model}}.',
    },
    'delete': {
      'button': 'Delete',
      'confirm': 'Are you sure you want to delete {{model}} \'{{record}}\'?',
      'success': '{{model}} deleted successfully.',
      'error': 'Error deleting {{model}}.',
    },
    'draft': {
      'button': 'Create Draft & Save',
      'success': 'Draft created for {{model}} successfully.',
      'error': 'Error creating draft for {{model}}.',
    },
    'publish': {
      'button': 'Save & Publish',
      'success': '{{model}} published successfully.',
      'error': 'Error publishing {{model}}.',
    },
    'restore': {
      'button': 'Restore',
      'success': '{{model}} restored successfully.',
      'error': 'Error restoring {{model}}.',
    },
    'cancel': {
      'button': 'Cancel',
    },
  }
}

Example Route

import BaseRoute from "ember-crud/routes/edit";

export default BaseRoute.extend({
    crud: {
      model:      'post',
      name: {
        singular: 'Post',
        plural:   'Posts',
      },
      routes: {
        index:    'posts.index',
        new:      'posts.new',
      },
    }
});

What's Included

Action Mixins

Actions you can include in your routes:

Base Routes

Base routes you can extend from.

Handles retrieval of model and includes default actions listed below:

  • list
    • setup
    • delete
    • success
    • error
  • tree
    • setup
    • delete
    • success
    • error
  • view
    • setup
  • new
    • setup
    • create
    • cancel
    • success
    • error
  • edit
    • setup
    • save
    • cancel
    • delete
    • success
    • error
  • related
    • setup
    • success
    • error

Controller Mixins

Mixins for your controllers: