From 4e2c21059a60c6069789f7d26858ecf64fb2a200 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Thu, 14 May 2015 14:56:02 -0600 Subject: [PATCH] * Distinct "menus" vs "prompts" for theme.json so conflicting names can occur * Add support for theming prompts --- core/menu_util.js | 8 ++++---- core/view_controller.js | 16 ++++++++++++---- mods/art/themes/NU-MAYA/theme.json | 8 +++++++- mods/prompt.json | 2 -- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/core/menu_util.js b/core/menu_util.js index 1a69fb4e..f8a9c17a 100644 --- a/core/menu_util.js +++ b/core/menu_util.js @@ -217,18 +217,18 @@ function applyThemeCustomization(options) { // options.name : menu/prompt name // options.configMci : menu or prompt config (menu.json / prompt.json) specific mci section // options.client : client + // options.type : menu|prompt // assert(_.isString(options.name)); + assert("menus" === options.type || "prompts" === options.type); assert(_.isObject(options.client)); - - console.log(options.configMci) if(_.isUndefined(options.configMci)) { options.configMci = {}; } - if(_.has(options.client.currentTheme, [ 'customization', 'byName', options.name ])) { - var themeConfig = options.client.currentTheme.customization.byName[options.name]; + if(_.has(options.client.currentTheme, [ 'customization', options.type, options.name ])) { + var themeConfig = options.client.currentTheme.customization[options.type][options.name]; Object.keys(themeConfig).forEach(function mciEntry(mci) { _.defaults(options.configMci[mci], themeConfig[mci]); }); diff --git a/core/view_controller.js b/core/view_controller.js index 9634fe01..8aea7935 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -397,6 +397,17 @@ ViewController.prototype.loadFromPromptConfig = function(options, cb) { callback(err); }); }, + function applyThemeCustomization(callback) { + if(_.isObject(promptConfig)) { + menuUtil.applyThemeCustomization({ + name : self.client.currentMenuModule.menuConfig.prompt, + type : "prompts", + client : self.client, + configMci : promptConfig.mci, + }); + } + callback(null); + }, function applyViewConfiguration(callback) { if(_.isObject(promptConfig.mci)) { self.applyViewConfig(promptConfig, function configApplied(err, info) { @@ -511,18 +522,15 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) { if(_.isObject(formConfig)) { menuUtil.applyThemeCustomization({ name : self.client.currentMenuModule.menuName, + type : "menus", client : self.client, configMci : formConfig.mci, }); } - //console.log(test) - callback(null); }, function applyViewConfiguration(callback) { - // - // :TODO: need to merge configs from menu -> theme (specific) -> theme (default) -> defaults if(_.isObject(formConfig)) { self.applyViewConfig(formConfig, function configApplied(err, info) { initialFocusId = info.initialFocusId; diff --git a/mods/art/themes/NU-MAYA/theme.json b/mods/art/themes/NU-MAYA/theme.json index f3f4d7b8..7594bf5c 100644 --- a/mods/art/themes/NU-MAYA/theme.json +++ b/mods/art/themes/NU-MAYA/theme.json @@ -14,7 +14,7 @@ } } }, - "byName" : { + "menus" : { "matrix" : { "VM1" : { "itemSpacing" : 1 @@ -31,6 +31,12 @@ "ET8" : { "width" : 21 }, "ET9" : { "width" : 21 }, "ET10" : { "width" : 21 } + } + }, + "prompts" : { + "userCredentials" : { + "ET1" : { "width" : 21 }, + "ET2" : { "width" : 21 } } } } diff --git a/mods/prompt.json b/mods/prompt.json index f9937e93..75fc4e78 100644 --- a/mods/prompt.json +++ b/mods/prompt.json @@ -4,14 +4,12 @@ "mci" : { "ET1" : { "argName" : "username", - "width" : 15, "maxLength" : "@config:users.usernameMax" }, "ET2" : { "submit" : true, "argName" : "password", "password" : true, - "width" : 15, "maxLength" : "@config:users.passwordMax" } }