Coder Social home page Coder Social logo

jzinedine / grails-angular-scaffolding Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pawlorj/grails-angular-scaffolding

0.0 1.0 0.0 1.57 MB

A Grails plugin for scaffolding views using Angular.js

Home Page: http://grails-ng.cloudfoundry.com/

grails-angular-scaffolding's Introduction

This is a Grails plugin that allows you to use Angular.js based scaffolding.

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 only supported for the controller. Currently you will need to generate the views for each domain class.

To generate only the views and use a dynamically scaffolded controller run:

grails ng-generate-views _domain class name_

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

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.

Limitations

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

Demo

There is a demo of this plugin running on Cloud Foundry.

The demo application is also included under test/apps/grails-ng in this project.

Tests

There are some end-to-end tests that use Casper JS. To run the tests:

cd test/apps/grails-ng
grails run-app

Then in another terminal:

casperjs test --includes=test/casper/includes/casper-angular.coffee test/casper/specs/

grails-angular-scaffolding's People

Contributors

graemerocher avatar pawlorj avatar philixxx avatar robbugh avatar robfletcher avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.