Move all controllers into page definitions and add support for layout profiles
This commit is contained in:
parent
f650479266
commit
d6d11644d8
34 changed files with 3744 additions and 3428 deletions
38
static/js/angular-route-builder.js
vendored
Normal file
38
static/js/angular-route-builder.js
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
var AngularRouteBuilder = function(routeProvider, pages, profiles, currentProfile) {
|
||||
this.routeProvider = routeProvider;
|
||||
this.pages = pages;
|
||||
this.profiles = profiles;
|
||||
|
||||
for (var i = 0; i < profiles.length; ++i) {
|
||||
var current = profiles[i];
|
||||
if (current.id == currentProfile) {
|
||||
this.profiles = this.profiles.slice(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AngularRouteBuilder.prototype.otherwise = function(options) {
|
||||
this.routeProvider.otherwise(options);
|
||||
};
|
||||
|
||||
AngularRouteBuilder.prototype.route = function(path, pagename) {
|
||||
// Lookup the page, matching our lists of profiles.
|
||||
var pair = this.pages.get(pagename, this.profiles);
|
||||
if (!pair) {
|
||||
throw Error('Unknown page: ' + pagename);
|
||||
}
|
||||
|
||||
// Create the route.
|
||||
var foundProfile = pair[0];
|
||||
var page = pair[1];
|
||||
var templateUrl = foundProfile.templatePath + page.templateName;
|
||||
|
||||
var options = jQuery.extend({}, page.flags || {});
|
||||
options['templateUrl'] = templateUrl;
|
||||
options['reloadOnSearch'] = false;
|
||||
options['controller'] = page.controller;
|
||||
|
||||
this.routeProvider.when(path, options);
|
||||
return this;
|
||||
};
|
Reference in a new issue