Skip to content

Commit 05cd985

Browse files
committed
feat(forms) Internal templates, allow specification of overrides folder. Closes #80
1 parent f2c5a1d commit 05cd985

14 files changed

+137
-46
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# forms-angular
22

3+
## 0.6.0 to 0.7.0
4+
* Fixed bug with ui-router setup which meant that full routes were not parsed.
5+
* Added internal templates for lists, edit forms and report forms (previously they were in the Yeoman generator).
6+
* Internal templates can be over-ridden by specifying a templateFolder property in the routing config.
7+
### BREAKING CHANGES
8+
* To use the edit / list / report templates from a pre 0.7.0 application you must specify a templateFolder property of 'partials' when starting the routingService when configuring forms-angular
9+
310
## 0.5.1 to 0.6.0
411
* Upgrade to angular-ui-bootstrap 0.14.x, which drops support for Bootstrap 2 (but seems to work fine for the forms-angular.org website, which is BS2)
512
* Start specifying versions in npm and bower.

bower.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "forms-angular",
33
"author": "Mark Chapman <support@forms-angular.org>",
4-
"version": "0.6.0",
4+
"version": "0.7.0",
55
"homepage": "https://github.com/forms-angular/forms-angular",
66
"description": "No nonsense forms for the MEAN stack",
77
"keywords": [
@@ -18,16 +18,16 @@
1818
"dist/forms-angular.js"
1919
],
2020
"dependencies": {
21-
"angular": "1.5.0",
22-
"angular-sanitize": "1.5.0",
23-
"angular-messages": "1.5.0",
21+
"angular": "1.5.5",
22+
"angular-sanitize": "1.5.5",
23+
"angular-messages": "1.5.5",
2424
"angular-ui-bootstrap-bower": "0.14.3",
2525
"underscore": "1.8.3",
2626
"ngInfiniteScroll": "1.2.1",
2727
"angular-elastic": "2.5.1"
2828
},
2929
"devDependencies": {
30-
"angular-mocks": "1.5.0",
30+
"angular-mocks": "1.5.5",
3131
"bootstrap-3-3-5": "git://github.com/twbs/bootstrap.git#v3.3.5",
3232
"bootstrap-2-3-2": "git://github.com/twbs/bootstrap.git#v2.3.2"
3333
},

dist/forms-angular.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ declare module fng {
139139
routing: string;
140140
prefix: string;
141141
fixedRoutes?: Array<IBuiltInRoute>;
142+
templateFolder?: string;
142143
add2fngRoutes?: any;
143144
variantsForDemoWebsite?: any;
144145
variants?: any;

dist/forms-angular.js

Lines changed: 31 additions & 20 deletions
Large diffs are not rendered by default.

dist/forms-angular.min.js

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/fng-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ module fng {
160160
// prevent generated routes (which have a lot of parameters) from clashing with other routes in
161161
// the web app that have nothing to do with CRUD forms
162162
fixedRoutes?: Array<IBuiltInRoute>;
163+
templateFolder?: string; // The folder where the templates for base-list, base-edit and base-analysis live. Internal templates used by default. For pre 0.7.0 behaviour use 'partials/'
163164
add2fngRoutes?: any; // An object to add to the generated routes. One user case would be to add {authenticate: true}
164165
// so that the client authenticates for certain routes
165166

js/services/add-all.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/services/fng-routes.ts

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,58 @@ module fng.services {
1010
// fixedRoutes: [] an array in the same format as builtInRoutes that is matched before the generic routes. Can be omitted
1111
hashPrefix: '',
1212
html5Mode: false,
13-
routing: 'ngroute', // What sort of routing do we want? ngroute or uirouter
14-
prefix: '' // How do we want to prefix out routes? If not empty string then first character must be slash (which is added if not)
13+
routing: 'ngroute', // What sort of routing do we want? ngroute or uirouter
14+
prefix: '' // How do we want to prefix our routes? If not empty string then first character must be slash (which is added if not)
1515
};
1616

1717
var builtInRoutes:Array<fng.IBuiltInRoute> = [
1818
{
1919
route: '/analyse/:model/:reportSchemaName',
2020
state: 'analyse::model::report',
21-
templateUrl: 'partials/base-analysis.html'
21+
templateUrl: 'base-analysis.html'
2222
},
23-
{route: '/analyse/:model', state: 'analyse::model', templateUrl: 'partials/base-analysis.html'},
24-
{route: '/:model/:id/edit', state: 'model::edit', templateUrl: 'partials/base-edit.html'},
25-
{route: '/:model/:id/edit/:tab', state: 'model::edit::tab', templateUrl: 'partials/base-edit.html'},
26-
{route: '/:model/new', state: 'model::new', templateUrl: 'partials/base-edit.html'},
27-
{route: '/:model', state: 'model::list', templateUrl: 'partials/base-list.html'},
28-
{route: '/:model/:form/:id/edit', state: 'model::form::edit', templateUrl: 'partials/base-edit.html'}, // non default form (different fields etc)
29-
{route: '/:model/:form/:id/edit/:tab', state: 'model::form::edit::tab', templateUrl: 'partials/base-edit.html'}, // non default form (different fields etc)
30-
{route: '/:model/:form/new', state: 'model::form::new', templateUrl: 'partials/base-edit.html'}, // non default form (different fields etc)
31-
{route: '/:model/:form', state: 'model::form::list', templateUrl: 'partials/base-list.html'} // list page with links to non default form
23+
{route: '/analyse/:model', state: 'analyse::model', templateUrl: 'base-analysis.html'},
24+
{route: '/:model/:id/edit', state: 'model::edit', templateUrl: 'base-edit.html'},
25+
{route: '/:model/:id/edit/:tab', state: 'model::edit::tab', templateUrl: 'base-edit.html'},
26+
{route: '/:model/new', state: 'model::new', templateUrl: 'base-edit.html'},
27+
{route: '/:model', state: 'model::list', templateUrl: 'base-list.html'},
28+
{route: '/:model/:form/:id/edit', state: 'model::form::edit', templateUrl: 'base-edit.html'}, // non default form (different fields etc)
29+
{route: '/:model/:form/:id/edit/:tab', state: 'model::form::edit::tab', templateUrl: 'base-edit.html'}, // non default form (different fields etc)
30+
{route: '/:model/:form/new', state: 'model::form::new', templateUrl: 'base-edit.html'}, // non default form (different fields etc)
31+
{route: '/:model/:form', state: 'model::form::list', templateUrl: 'base-list.html'} // list page with links to non default form
3232
];
3333

3434
var _routeProvider, _stateProvider;
3535
var lastRoute = null;
3636
var lastObject:fng.IFngRoute = {};
3737

38+
function handleFolder(templateURL: string) : string {
39+
var retVal : string = templateURL;
40+
if (config.templateFolder) {
41+
if (config.templateFolder[config.templateFolder.length-1] !== '/') {
42+
retVal = config.templateFolder + '/' + retVal;
43+
} else {
44+
retVal = config.templateFolder + retVal;
45+
}
46+
}
47+
return retVal;
48+
}
49+
3850
function _setUpNgRoutes(routes:Array<fng.IBuiltInRoute>, prefix:string = '', additional?:any):void {
3951
prefix = prefix || '';
4052
angular.forEach(routes, function (routeSpec) {
41-
_routeProvider.when(prefix + routeSpec.route, angular.extend(routeSpec.options || {templateUrl: routeSpec.templateUrl}, additional));
53+
_routeProvider.when(prefix + routeSpec.route, angular.extend(routeSpec.options || {templateUrl: handleFolder(routeSpec.templateUrl)}, additional));
4254
});
43-
// This next bit is just for the demo website to allow demonstrating multiple frameworks - not available with other routers
55+
56+
// This next bit is just for the demo website to allow demonstrating multiple CSS frameworks - not available with other routers
4457
if (config.variantsForDemoWebsite) {
4558
angular.forEach(config.variantsForDemoWebsite, function (variant) {
4659
angular.forEach(routes, function (routeSpec) {
47-
_routeProvider.when(prefix + variant + routeSpec.route, angular.extend(routeSpec.options || {templateUrl: routeSpec.templateUrl}, additional));
60+
_routeProvider.when(prefix + variant + routeSpec.route, angular.extend(routeSpec.options || {templateUrl: handleFolder(routeSpec.templateUrl)}, additional));
4861
});
4962
});
5063
}
64+
5165
}
5266

5367
function _setUpUIRoutes(routes:Array<fng.IBuiltInRoute>, prefix:string = '', additional?:any):void {

less/forms-angular-bs-common.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ button.form-btn {
7777
max-width: 17em;
7878
}
7979

80+
8081
form {
8182
&.form-horizontal.compact {
8283
input + .help-block, select + .help-block, textarea + .help-block, .uneditable-input + .help-block,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"author": "Mark Chapman <support@forms-angular.org>",
44
"description": "A form builder that sits on top of Angular.js, Twitter Bootstrap, jQuery UI, Angular-UI, Express and Mongoose. Opinionated or what?",
55
"homepage": "http://forms-angular.org",
6-
"version": "0.6.0",
6+
"version": "0.7.0",
77
"engines": {
88
"node": ">=0.10.x",
99
"npm": ">=1.x"

server/data_form.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

template/base-analysis.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div ng-controller="AnalysisCtrl">
2+
<div class="container-fluid page-header report-header">
3+
<div ng-class="css('rowFluid')">
4+
<div class="header-lhs col-xs-7 span7">
5+
<h1>{{ reportSchema.title }}</h1>
6+
</div>
7+
<div class="header-rhs col-xs-5 span5">
8+
<form-input schema="paramSchema" name="paramForm" ng-show="paramSchema" formstyle="horizontalCompact"></form-input>
9+
</div>
10+
</div>
11+
</div>
12+
<div class="container-fluid page-body report-body">
13+
<error-display></error-display>
14+
<div class="row-fluid">
15+
<div class="gridStyle" ng-grid="gridOptions"></div>
16+
</div>
17+
</div>
18+
</div>

template/base-edit.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div ng-controller="BaseCtrl">
2+
<div ng-class="css('rowFluid')" class="page-header edit-header">
3+
<div class="header-lhs col-sm-8 span8">
4+
<h4>{{modelNameDisplay}} :
5+
<span ng-repeat="field in listSchema">{{getListData(record, field.name)}} </span>
6+
</h4>
7+
</div>
8+
<div class="header-rhs col-sm-2 span2">
9+
<div form-buttons></div>
10+
</div>
11+
</div>
12+
<div class="container-fluid page-body edit-body">
13+
<error-display></error-display>
14+
<form-input name="baseForm" schema="baseSchema()" formstyle="compact"></form-input>
15+
</div>
16+
</div>

template/base-list.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div ng-controller="BaseCtrl">
2+
<div ng-class="css('rowFluid')" class="page-header list-header">
3+
<div class="header-lhs col-sm-8 span8">
4+
<h1>{{modelNameDisplay}}</h1>
5+
</div>
6+
<div class="header-rhs col-sm-2 span2">
7+
<a ng-href="{{generateNewUrl()}}"><button id="newBtn" class="btn btn-default"><i class="icon-plus"></i> New</button></a>
8+
</div>
9+
</div>
10+
<div class="page-body list-body">
11+
<error-display></error-display>
12+
<div ng-class="css('rowFluid')" infinite-scroll="scrollTheList()">
13+
<a ng-repeat="record in recordList" ng-href="{{generateEditUrl(record)}}">
14+
<div class="list-item">
15+
<div ng-class="css('span',12/listSchema.length)" ng-repeat="field in listSchema">{{getListData(record, field.name)}} </div>
16+
</div>
17+
</a>
18+
</div>
19+
</div>
20+
</div>

0 commit comments

Comments
 (0)