Skip to content

A Grails plugin for scaffolding views using Angular.js, Twitter Bootstrap and Grails (Platform Ui) Themes

Notifications You must be signed in to change notification settings

aberbenni/grails-angular-scaffolding

 
 

Repository files navigation

This is a Grails plugin that allows you to use Angular.js, Twitter Bootstrap, Grails Platform UI Theme based scaffolding. This work is derived from original Grails Angular Scaffolding Plugin by Rob Fletcher.

Usage

After installing the plugin run:

grails ng-install-templates

This will install the Angular JS scaffolding templates into your project under src/templates/scaffolding. It will also copy some common HTML template files that will be shared by all scaffolded views into web-app/ng-templates.

Static scaffolding

To generate the controller and views for a domain class run:

grails ng-generate-all _domain class name_

Dynamic scaffolding

Dynamic scaffolding is supported for the controller and views. You will not need to generate the controller and views for each domain class.

How it works

Instead of the Grails controller rendering a view for each page using a GSP the controller's index action serves up an initial framework page containing the JavaScript resources required by Angular JS. The remaining controller actions simply return JSON data.

Each 'page' in the CRUD interface for a particular domain class is accessed using a URL fragment; #/list, #/create, etc. The page content is rendered by Angular JS using an HTML template and the data to populate the page is retrieved from the controller using an AJAX call.

The HTML templates need to be generated individually for each domain class as they contain the markup needed to represent the properties of that class in a list or a form. However, the JavaScript used for the CRUD interface is the same for all domain classes.

Customizing

Templating

The deafult theme uses Twitter Bootstrap but if you like to use your theme follow the instruction in Grails Platform UI Plugin docs.

Enable optimistic locking check

By default, the JSON converter does not send the object's "version" field generated by Hibernate. Because of that, the controller does not check when concurrent modifications occur. To enable optimistic locking check, simply add the following in your Config.groovy:

grails.converters.json.domain.include.version = true

Using Grails RESTful URL mappings

By default Grails uses a non-RESTful URL scheme where the controller action representing the verb is part of the URL. In the Grails documentation there is a section on configuring RESTful URL mappings. If you want to use such a URL scheme with this plugin you will need to override the web-app/js/grails-default.js file that configures an Angular $resource service that maps to your Grails controllers.

Grails Plugins

This project makes use of these plugins:

Limitations

This is an experimental work-in-progress. See the issues list for outstanding features.

About

A Grails plugin for scaffolding views using Angular.js, Twitter Bootstrap and Grails (Platform Ui) Themes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Groovy 80.5%
  • JavaScript 19.4%
  • CSS 0.1%