* More progress on theming esp. in relation to .config menu module sections
This commit is contained in:
parent
a6cd6bd3b9
commit
3038213c09
|
@ -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 {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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: {
|
||||
|
|
Loading…
Reference in New Issue