* Fix bug in VerticalMenuView when pressing up with low number of items

* Minor work on message list
This commit is contained in:
Bryan Ashby 2015-08-30 21:42:24 -06:00
parent 87dcb1bdda
commit e852695354
3 changed files with 40 additions and 8 deletions

View File

@ -156,9 +156,11 @@ VerticalMenuView.prototype.onKeyPress = function(ch, key) {
this.focusedItemIndex = this.items.length - 1;
this.viewWindow = {
top : this.items.length - this.maxVisibleItems,
//top : this.items.length - this.maxVisibleItems,
top : Math.max(this.items.length - this.maxVisibleItems, 0),
bottom : this.items.length - 1
};
} else {
this.focusedItemIndex--;

View File

@ -86,7 +86,8 @@
// :TODO: may want { "prompt" : { "name" : "blah", "action" : ... }}
"prompt" : "userCredentials",
"fallback" : "matrix",
"next" : "fullLoginSequenceLoginArt",
//"next" : "fullLoginSequenceLoginArt",
"next" : "messageArea",
"action" : "@systemMethod:login",
// :TODO: support alt submit method for prompts
@ -329,9 +330,26 @@
"VM" : {
"mci" : {
"VM1" : {
"height" : 10
"height" : 10,
"focus" : true,
"submit" : true,
"argName" : "message"
}
}
},
"submit" : {
"*": [
{
"value" : { "message" : null },
"action" : "@method:selectMessage"
}
]
},
"actionKeys" : [
{
"keys" : [ "escape" ],
"action" : "@menu:messageArea"
}
]
}
}
}

View File

@ -44,6 +44,17 @@ function MessageListModule(options) {
MenuModule.call(this, options);
var self = this;
this.messageList = [];
this.menuMethods = {
selectMessage : function(formData, extraArgs) {
if(1 === formData.submitId) {
var selectedMessage = self.messageList[formData.value.message];
console.log(selectedMessage)
}
}
};
}
require('util').inherits(MessageListModule, MenuModule);
@ -53,7 +64,7 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
var vc = self.viewControllers.msgList = new ViewController( { client : self.client } );
async.waterfall(
async.series(
[
function callParentMciReady(callback) {
MessageListModule.super_.prototype.mciReady.call(this, mciData, callback);
@ -68,16 +79,17 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
},
function fetchMessagesInArea(callback) {
messageArea.getMessageListForArea( { client : self.client }, self.client.user.properties.message_area_name, function msgs(err, msgList) {
callback(err, msgList);
self.messageList = msgList;
callback(err);
});
},
function populateList(msgList, callback) {
function populateList(callback) {
var msgListView = vc.getView(1);
// :TODO: {name!over5}, ...over6, over7... -> "text..." for format()
var msgNum = 1;
msgListView.setItems(_.map(msgList, function formatMsgListEntry(mle) {
msgListView.setItems(_.map(self.messageList, function formatMsgListEntry(mle) {
return '{msgNum} - {subj} {to}'.format( {
msgNum : msgNum++,
subj : mle.subject,