* Message list updated to be functional with new MCI/etc. (Still WIP, but working good)

This commit is contained in:
Bryan Ashby 2015-10-11 16:05:45 -06:00
parent 3038213c09
commit 6e0a4e84af
7 changed files with 83 additions and 42 deletions

View File

@ -64,10 +64,12 @@ MenuView.prototype.getItem = function(index) {
MenuView.prototype.focusNext = function() { MenuView.prototype.focusNext = function() {
// nothing @ base currently // nothing @ base currently
this.emit('index update', this.focusedItemIndex);
}; };
MenuView.prototype.focusPrevious = function() { MenuView.prototype.focusPrevious = function() {
// nothign @ base currently // nothign @ base currently
this.emit('index update', this.focusedItemIndex);
}; };
MenuView.prototype.setFocusItems = function(items) { MenuView.prototype.setFocusItems = function(items) {
@ -79,7 +81,7 @@ MenuView.prototype.setFocusItems = function(items) {
self.focusItems.push( { text : itemText } ); self.focusItems.push( { text : itemText } );
}); });
} }
} };
MenuView.prototype.setItemSpacing = function(itemSpacing) { MenuView.prototype.setItemSpacing = function(itemSpacing) {
itemSpacing = parseInt(itemSpacing); itemSpacing = parseInt(itemSpacing);

View File

@ -172,8 +172,6 @@ VerticalMenuView.prototype.setItems = function(items) {
// :TODO: Apply draw optimizaitons when only two items need drawn vs entire view! // :TODO: Apply draw optimizaitons when only two items need drawn vs entire view!
VerticalMenuView.prototype.focusNext = function() { VerticalMenuView.prototype.focusNext = function() {
VerticalMenuView.super_.prototype.focusNext.call(this);
if(this.items.length - 1 === this.focusedItemIndex) { if(this.items.length - 1 === this.focusedItemIndex) {
this.focusedItemIndex = 0; this.focusedItemIndex = 0;
@ -191,11 +189,11 @@ VerticalMenuView.prototype.focusNext = function() {
} }
this.redraw(); this.redraw();
VerticalMenuView.super_.prototype.focusNext.call(this);
}; };
VerticalMenuView.prototype.focusPrevious = function() { VerticalMenuView.prototype.focusPrevious = function() {
VerticalMenuView.super_.prototype.focusPrevious.call(this);
if(0 === this.focusedItemIndex) { if(0 === this.focusedItemIndex) {
this.focusedItemIndex = this.items.length - 1; this.focusedItemIndex = this.items.length - 1;
@ -215,6 +213,8 @@ VerticalMenuView.prototype.focusPrevious = function() {
} }
this.redraw(); this.redraw();
VerticalMenuView.super_.prototype.focusPrevious.call(this);
}; };
@ -222,7 +222,7 @@ VerticalMenuView.prototype.setFocusItems = function(items) {
VerticalMenuView.super_.prototype.setFocusItems.call(this, items); VerticalMenuView.super_.prototype.setFocusItems.call(this, items);
this.positionCacheExpired = true; this.positionCacheExpired = true;
} };
VerticalMenuView.prototype.setItemSpacing = function(itemSpacing) { VerticalMenuView.prototype.setItemSpacing = function(itemSpacing) {
VerticalMenuView.super_.prototype.setItemSpacing.call(this, itemSpacing); VerticalMenuView.super_.prototype.setItemSpacing.call(this, itemSpacing);

View File

@ -528,41 +528,39 @@
} }
} }
}, },
"messageAreaMessageList" : { messageAreaMessageList: {
"module" : "msg_list", module: msg_list
"art" : "msg_list" art: MSGLIST
"config" : { config: {
"listType" : "public" listType: public
},
"form" : {
"0" : {
"VM" : {
"mci" : {
"VM1" : {
"height" : 10,
"focus" : true,
"submit" : true,
"argName" : "message"
} }
}, form: {
"submit" : { 0: {
"*": [ mci: {
VM1: {
height: 10
focus: true
submit: true
argName: message
}
}
submit: {
*: [
{ {
"value" : { "message" : null }, value: { message: null }
"action" : "@method:selectMessage" action: @method:selectMessage
} }
] ]
}, }
"actionKeys" : [ actionKeys: [
{ {
"keys" : [ "escape", "q", "shift + q" ], keys: [ "escape", "q", "shift + q" ]
"action" : "@menu:messageArea" action: @menu:messageArea
} }
] ]
} }
} }
} }
},
messageAreaViewPost: { messageAreaViewPost: {
module: msg_area_view_fse module: msg_area_view_fse

View File

@ -10,6 +10,7 @@ var Message = require('../core/message.js');
var async = require('async'); var async = require('async');
var assert = require('assert'); var assert = require('assert');
var _ = require('lodash'); var _ = require('lodash');
var moment = require('moment');
exports.getModule = MessageListModule; exports.getModule = MessageListModule;
@ -38,9 +39,23 @@ exports.moduleInfo = {
// * Multiple LV's in sync with keyboard input // * Multiple LV's in sync with keyboard input
// * New Table LV (TV) // * New Table LV (TV)
// * // *
// VM1 - message list
// TL2 - Message area desc
// TL4 - message selected #
// TL5 - message total #
// //
// See Obv/2, Iniq, and Mystic docs // See Obv/2, Iniq, and Mystic docs
var MciCodesIds = {
MsgList : 1,
MsgAreaDesc : 2,
MsgSelNum : 4,
MsgTotal : 5,
};
function MessageListModule(options) { function MessageListModule(options) {
MenuModule.call(this, options); MenuModule.call(this, options);
@ -67,6 +82,13 @@ function MessageListModule(options) {
} }
} }
}; };
this.setViewText = function(id, text) {
var v = self.viewControllers.allViews.getView(id);
if(v) {
v.setText(text);
}
};
} }
require('util').inherits(MessageListModule, MenuModule); require('util').inherits(MessageListModule, MenuModule);
@ -83,7 +105,7 @@ MessageListModule.prototype.enter = function(client) {
MessageListModule.prototype.mciReady = function(mciData, cb) { MessageListModule.prototype.mciReady = function(mciData, cb) {
var self = this; var self = this;
var vc = self.viewControllers.msgList = new ViewController( { client : self.client } ); var vc = self.viewControllers.allViews = new ViewController( { client : self.client } );
async.series( async.series(
[ [
@ -109,17 +131,22 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
}); });
}, },
function populateList(callback) { function populateList(callback) {
var msgListView = vc.getView(1); var msgListView = vc.getView(MciCodesIds.MsgList);
var listFormat = self.menuConfig.config.listFormat || '{msgNum:>4} - {subj:>35} |{to:>15}'; var listFormat = self.menuConfig.config.listFormat || '{msgNum:>4} - {subj:>35} |{to:>15}';
var focusListFormat = self.menuConfig.config.focusListFormat; var focusListFormat = self.menuConfig.config.focusListFormat;
var msgNum = 1; var msgNum = 1;
var newMark = '*'; // :TODO: Make configurable
var dateFmt = 'ddd MMM DD'; // :TODO: Make configurable
msgListView.setItems(_.map(self.messageList, function formatMsgListEntry(mle) { msgListView.setItems(_.map(self.messageList, function formatMsgListEntry(mle) {
return listFormat.format( { return listFormat.format( {
msgNum : msgNum++, msgNum : msgNum++,
subj : mle.subject, subj : mle.subject,
to : mle.toUserName from : mle.fromUserName,
to : mle.toUserName,
ts : moment(mle.modTimestamp).format(dateFmt),
newMark : newMark, // :TODO: These should only be for actual new messages!
} ); } );
})); }));
@ -129,15 +156,29 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
return focusListFormat.format( { return focusListFormat.format( {
msgNum : msgNum++, msgNum : msgNum++,
subj : mle.subject, subj : mle.subject,
to : mle.toUserName from : mle.fromUserName,
to : mle.toUserName,
ts : moment(mle.modTimestamp).format(dateFmt),
newMark : newMark,
} ); } );
})); }));
} }
msgListView.on('index update', function indexUpdated(idx) {
self.setViewText(MciCodesIds.MsgSelNum, (idx + 1).toString());
});
msgListView.redraw(); msgListView.redraw();
callback(null); callback(null);
} },
function populateOtherMciViews(callback) {
self.setViewText(MciCodesIds.MsgAreaDesc, messageArea.getMessageAreaByName(self.messageAreaName).desc);
self.setViewText(MciCodesIds.MsgTotal, self.messageList.length.toString());
callback(null);
},
], ],
function complete(err) { function complete(err) {
if(err) { if(err) {

Binary file not shown.

Binary file not shown.

View File

@ -71,8 +71,8 @@
messageAreaMessageList: { messageAreaMessageList: {
config: { config: {
listFormat: "|00|01|37{msgNum:>4} |22|37- |00|36{subj:>35} |01{to:>17}" listFormat: "|00|01|37{msgNum:>4} |00|37- |36{subj:<29.29} {from:<20.20} {ts} {newMark}"
focusListFormat: "|00|01|42|37{msgNum:>4} |22|37- |36{subj:>35} |01{to:>17}" focusListFormat: "|00|42|30{msgNum:>4} - {subj:<29.29} {from:<20.20} {ts} {newMark}"
} }
} }