diff --git a/core/menu_module.js b/core/menu_module.js index c135ed5a..a563e48a 100644 --- a/core/menu_module.js +++ b/core/menu_module.js @@ -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 { diff --git a/core/menu_util.js b/core/menu_util.js index 239922d2..d8643562 100644 --- a/core/menu_util.js +++ b/core/menu_util.js @@ -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") diff --git a/core/view_controller.js b/core/view_controller.js index 4dbed5a9..f08652e2 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -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) { diff --git a/mods/last_callers.js b/mods/last_callers.js index c6f99b16..bb7a29a9 100644 --- a/mods/last_callers.js +++ b/mods/last_callers.js @@ -25,6 +25,8 @@ exports.getModule = LastCallersModule; // :TODO: // * config.evenRowSGR (optional) +// :TODO: convert to using %XY system for finding row count + function LastCallersModule(options) { MenuModule.call(this, options); @@ -32,7 +34,13 @@ function LastCallersModule(options) { this.menuConfig = options.menuConfig; this.rows = 10; - +} + +util.inherits(LastCallersModule, MenuModule); + +LastCallersModule.prototype.enter = function(client) { + LastCallersModule.super_.prototype.enter.call(this, client); + if(_.isObject(this.menuConfig.config)) { if(_.isNumber(this.menuConfig.config.rows)) { this.rows = Math.max(1, this.menuConfig.config.rows); @@ -41,12 +49,6 @@ function LastCallersModule(options) { this.dateTimeFormat = this.menuConfig.config.dateTimeFormat; } } -} - -util.inherits(LastCallersModule, MenuModule); - -LastCallersModule.prototype.enter = function(client) { - LastCallersModule.super_.prototype.enter.call(this, client); // we need the client to init this for theming if(!_.isString(this.dateTimeFormat)) { diff --git a/mods/msg_list.js b/mods/msg_list.js index 288f15b3..fa02abe1 100644 --- a/mods/msg_list.js +++ b/mods/msg_list.js @@ -55,7 +55,7 @@ function MessageListModule(options) { selectMessage : function(formData, extraArgs) { if(1 === formData.submitId) { var modOpts = { - name : 'messageAreaViewPost', // :TODO: should come from config? + name : 'messageAreaViewPost', // :TODO: should come from config!!! extraArgs : { messageAreaName : self.messageAreaName, messageList : self.messageList, @@ -72,14 +72,13 @@ function MessageListModule(options) { require('util').inherits(MessageListModule, MenuModule); MessageListModule.prototype.enter = function(client) { + MessageListModule.super_.prototype.enter.call(this, client); if('private' === this.listType) { this.messageAreaName = Message.WellKnownAreaNames.Private; } else { this.messageAreaName = client.user.properties.message_area_name; } - - MessageListModule.super_.prototype.enter.call(this, client); }; MessageListModule.prototype.mciReady = function(mciData, cb) { @@ -112,15 +111,29 @@ MessageListModule.prototype.mciReady = function(mciData, cb) { function populateList(callback) { var msgListView = vc.getView(1); + var listFormat = self.menuConfig.config.listFormat || '{msgNum:>4} - {subj:>35} |{to:>15}'; + var focusListFormat = self.menuConfig.config.focusListFormat; + var msgNum = 1; msgListView.setItems(_.map(self.messageList, function formatMsgListEntry(mle) { - return '{msgNum:>4} - {subj:>25} {to:>15}'.format( { + return listFormat.format( { msgNum : msgNum++, subj : mle.subject, to : mle.toUserName } ); })); + if(focusListFormat) { + msgNum = 1; + msgListView.setFocusItems(_.map(self.messageList, function formatMsgListEntry(mle) { + return focusListFormat.format( { + msgNum : msgNum++, + subj : mle.subject, + to : mle.toUserName + } ); + })); + } + msgListView.redraw(); callback(null); diff --git a/mods/themes/luciano_blocktronics/theme.hjson b/mods/themes/luciano_blocktronics/theme.hjson index 47f20d05..7f421340 100644 --- a/mods/themes/luciano_blocktronics/theme.hjson +++ b/mods/themes/luciano_blocktronics/theme.hjson @@ -69,6 +69,13 @@ } } + messageAreaMessageList: { + config: { + listFormat: "|00|01|37{msgNum:>4} |22|37- |00|36{subj:>35} |01{to:>17}" + focusListFormat: "|00|01|42|37{msgNum:>4} |22|37- |36{subj:>35} |01{to:>17}" + } + } + messageAreaViewPost: { 0: { mci: {