* More progress on theming esp. in relation to .config menu module sections

This commit is contained in:
Bryan Ashby
2015-10-09 23:35:40 -06:00
parent a6cd6bd3b9
commit 3038213c09
6 changed files with 94 additions and 44 deletions

View File

@@ -32,6 +32,8 @@ function MenuModule(options) {
this.menuConfig.options.cls :
Config.menus.cls;
this.menuConfig.config = this.menuConfig.config || {};
this.initViewControllers();
this.initSequence = function() {
@@ -190,6 +192,13 @@ MenuModule.prototype.enter = function(client) {
this.client = client;
assert(_.isObject(client));
menuUtil.applyGeneralThemeCustomization( {
name : this.menuName,
client : this.client,
type : 'menus',
config : this.menuConfig.config,
});
if(_.isString(this.menuConfig.status)) {
this.client.currentStatus = this.menuConfig.status;
} else {

View File

@@ -21,7 +21,8 @@ exports.loadMenu = loadMenu;
exports.getFormConfigByIDAndMap = getFormConfigByIDAndMap;
exports.handleAction = handleAction;
exports.handleNext = handleNext;
exports.applyThemeCustomization = applyThemeCustomization;
exports.applyGeneralThemeCustomization = applyGeneralThemeCustomization;
exports.applyMciThemeCustomization = applyMciThemeCustomization;
function getMenuConfig(name, cb) {
var menuConfig;
@@ -255,17 +256,45 @@ function handleNext(client, nextSpec, conf) {
}
}
// :TODO: custom art needs a way to be themed -- e.g. config.art.someArtThing -- what does this mean exactly?
// :TODO: Seems better in theme.js, but that includes ViewController...which would then include theme.js
function applyThemeCustomization(options) {
// ...theme.js only brings in VC to create themed pause prompt. Perhaps that should live elsewhere
function applyGeneralThemeCustomization(options) {
//
// options.name
// options.client
// options.type
// options.config
//
assert(_.isString(options.name));
assert(_.isObject(options.client));
assert("menus" === options.type || "prompts" === options.type);
if(_.has(options.client.currentTheme, [ 'customization', options.type, options.name ])) {
var themeConfig = options.client.currentTheme.customization[options.type][options.name];
if(themeConfig.config) {
Object.keys(themeConfig.config).forEach(function confEntry(conf) {
if(options.config[conf]) {
_.defaultsDeep(options.config[conf], themeConfig.config[conf]);
} else {
options.config[conf] = themeConfig.config[conf];
}
});
}
}
}
function applyMciThemeCustomization(options) {
//
// options.name : menu/prompt name
// options.mci : menu/prompt .mci section
// options.client : client
// options.type : menu|prompt
// options.formId : (optional) form ID in cases where multiple forms may exist wanting their own customization
// options.config : menu/prompt .config section
//
// In the case of formId, the theme must include the ID as well, e.g.:
// {
@@ -283,10 +312,6 @@ function applyThemeCustomization(options) {
options.mci = {};
}
if(_.isUndefined(options.config)) {
options.config = {};
}
if(_.has(options.client.currentTheme, [ 'customization', options.type, options.name ])) {
var themeConfig = options.client.currentTheme.customization[options.type][options.name];
@@ -305,16 +330,6 @@ function applyThemeCustomization(options) {
}
});
}
if(themeConfig.config) {
Object.keys(themeConfig.config).forEach(function confEntry(conf) {
if(options.config[conf]) {
_.defaultsDeep(options.config[conf], themeConfig.config[conf]);
} else {
options.config[conf] = themeConfig.config[conf];
}
});
}
}
// :TODO: apply generic stuff, e.g. "VM" (vs "VM1")

View File

@@ -457,13 +457,13 @@ ViewController.prototype.loadFromPromptConfig = function(options, cb) {
});
},
function applyThemeCustomization(callback) {
// :TODO: apply .config customization as well
if(_.isObject(promptConfig)) {
menuUtil.applyThemeCustomization({
menuUtil.applyMciThemeCustomization({
name : promptName,
type : "prompts",
client : self.client,
mci : promptConfig.mci,
config : promptConfig.config,
mci : promptConfig.mci
});
}
callback(null);
@@ -572,20 +572,24 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) {
});
},
function applyThemeCustomization(callback) {
//if(_.isObject(formConfig)) {
formConfig = formConfig || {};
formConfig = formConfig || {};
//self.client.currentMenuModule.menuConfig.config = self.client.currentMenuModule.menuConfig.config || {};
console.log(formConfig)
//console.log('menu config.....');
//console.log(self.client.currentMenuModule.menuConfig)
menuUtil.applyThemeCustomization({
name : self.client.currentMenuModule.menuName,
type : 'menus',
client : self.client,
mci : formConfig.mci,
config : formConfig.config,
formId : formIdKey,
});
//}
menuUtil.applyMciThemeCustomization({
name : self.client.currentMenuModule.menuName,
type : 'menus',
client : self.client,
mci : formConfig.mci,
//config : self.client.currentMenuModule.menuConfig.config,
formId : formIdKey,
});
//console.log('after theme...')
//console.log(self.client.currentMenuModule.menuConfig.config)
callback(null);
},
function applyViewConfiguration(callback) {