diff --git a/core/vertical_menu_view.js b/core/vertical_menu_view.js index de317972..e3222693 100644 --- a/core/vertical_menu_view.js +++ b/core/vertical_menu_view.js @@ -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--; diff --git a/mods/menu.json b/mods/menu.json index d48fde6d..859b4ab3 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -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" + } + ] } } } diff --git a/mods/msg_list.js b/mods/msg_list.js index 30c34753..31f19ff2 100644 --- a/mods/msg_list.js +++ b/mods/msg_list.js @@ -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,