This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/constants/pages.constant.ts

45 lines
1.3 KiB
TypeScript
Raw Normal View History

/**
* Manages the creation and retrieval of pages (route + controller)
* TODO: Convert to class/Angular service
*/
2017-01-19 22:54:00 +00:00
export default {
'_pages': {},
/**
* Create a page.
* @param pageName The name of the page.
* @param templateName The file name of the template.
* @param opt_controller Controller for the page.
* @param opt_flags Additional flags passed to route provider.
* @param opt_profiles Available profiles.
*/
2017-01-19 22:54:00 +00:00
'create': function (pageName, templateName, opt_controller, opt_flags, opt_profiles) {
var profiles = opt_profiles || ['old-layout', 'layout'];
for (var i = 0; i < profiles.length; ++i) {
this._pages[profiles[i] + ':' + pageName] = {
'name': pageName,
'controller': opt_controller,
'templateName': templateName,
'flags': opt_flags || {}
};
}
},
/**
* Retrieve a registered page.
* @param pageName The name of the page.
* @param profiles Available profiles to search.
*/
2017-01-19 22:54:00 +00:00
'get': function (pageName, profiles) {
for (var i = 0; i < profiles.length; ++i) {
var current = profiles[i];
var key = current.id + ':' + pageName;
var page = this._pages[key];
if (page) {
return [current, page];
}
}
return null;
}
};