ember-cli-gen

1.0.19 • Public • Published

ember-gen

Ambitiously generate application layout and CRUD views for your ember apps.

ember-gen is a addon to base your Ember application on if you want to rapidly construct common, yet powerful, CRUD views for your models.

gen modules, the fundamental elements of ember-gen, along with the components and styles included in the addon, provide a complete toolset which can be used to setup a decent web application in no time.

The most essential ember-gen features include,

  • Responsive application layout
  • Model CRUD (list,create,edit,details views)
  • Auto-generated forms with validation support (using ember-changeset-validations)
  • Authentication (using ember-simple-auth)
  • I18N (using ember-i18n)
  • TODO Authorization (using ember-can)

Installation

Prerequisites

  • An (preferably new) ember (2.8+) project.
  • A set of models the addon will use to generate views for.

To install the addon to your project run

ember install ember-cli-gen

Usage

Installing ember-gen using ember-cli automatically executes the default addon generator and sets up your project with an application template. If not, consider running

ember g ember-cli-gen

You may then edit the template located at app/templates/application.hbs in order to change the application settings (title, icon etc.)

Create a Gen module

ember-gen uses gen modules to build up your application. To create a gen module use the provided generator, it accepts a single argument which should be the name of an existing model

ember g gen <modelName>

The generator will create a file named after the provided argument in the app/gen directory. The gen module uses CRUDGen generator to build CRUD views for your model. More specifically the following things are automatically generated:

  • A menu entry to the application navigation sidebar
  • A list route/view set which lists the model records
  • Create and edit route/view sets. Form fields are automatically generated based on each field attr type.
  • Common set of object related and navigational actions and links placed along the generated views which lets you navigate around the application routes.

CRUDGen configuration

export default CRUDGen.extend({
    auth: true/false/null // require authenticated user, anonymous, or any
    appIndex: true, // by default redirect to this Generator index view
    modelName: 'myModel',

    common: {},

    list: {},
    create: {},
    edit: {},
    details: {}
})

CRUDGen objects accept a set of attributes in order to configure the generated views layout and behaviour. The following views are currently generated

  • list
  • create
  • edit
  • details

each view accepts its own configuration parameters via the corresponding attribute named after the name of the view. If you want to apply a set of configuration parameters to all the views you may use the special attribute common. Each key set to this attribute will be merged to all CRUD view configuration objects.

CRUDGen.list configuration

menu.label The text to be displayed to the menu item which links to the underlying view. This attribute is also used in page breadcrumb titles.

menu.icon The icon to be displayed to the menu item.

page.title The title of the page to be displayed when the view is currently visited.

getModel Hook which will be used by the route to resolve the route model. By default the view will return the store.findAll(modelName) result.

row.fields A list of model properties to be displayed in each list row

CRUDGen.edit and CRUDGen.create configuration

menu.label See list configuration

menu.icon See list configuration

page.title See list configuration

getModel See list configuration. Defaults to store.find(mode, params.id).

processModel Hook which allows you to modify the resolved model of getModel hook. You may use this hook to set default properties to the underlying record.

fieldsets A list of dicts.

fieldsets.[].label The fieldset label.

fieldsets.[].text The fieldset help text. Defaults to ''.

fieldsets.[].fields The list of fields to be displayed to the generated form. Deafults to all the model fields.

fieldsets.[].exclude A list of fields to be excluded from the generated form. Defaults to [].

fieldsets.[].readonly A list of fields which will appear as readonly to the form. Defaults to [].

Readme

Keywords

Package Sidebar

Install

npm i ember-cli-gen

Weekly Downloads

26

Version

1.0.19

License

MIT

Unpacked Size

575 kB

Total Files

181

Last publish

Collaborators

  • vinilios