* Fix some extraArgs stuff

* Minor updates to FSE related modules -- WIP!
This commit is contained in:
Bryan Ashby 2015-08-16 13:35:34 -06:00
parent d9b39fcaa6
commit 7990202317
5 changed files with 64 additions and 30 deletions

View File

@ -441,9 +441,9 @@ Client.prototype.gotoMenuModule = function(options, cb) {
self.detachCurrentMenuModule(); self.detachCurrentMenuModule();
var loadOptions = { var loadOptions = {
name : options.name, name : options.name,
client : self, client : self,
args : options.args extraArgs : options.extraArgs,
}; };
menuUtil.loadMenu(loadOptions, function onMenuModuleLoaded(err, modInst) { menuUtil.loadMenu(loadOptions, function onMenuModuleLoaded(err, modInst) {

View File

@ -43,7 +43,9 @@ function FullScreenEditorModule(options) {
this.editorType = config.editorType; this.editorType = config.editorType;
this.editorMode = config.editorMode; this.editorMode = config.editorMode;
this.mciData = {}; if(_.isObject(options.extraArgs)) {
this.messageAreaId = options.extraArgs.messageAreaId || Message.WellKnownAreaIds.Private;
}
// netMail/crashMail | echoMail // netMail/crashMail | echoMail
//this.messageAreaId = 'netMail' === this.editorType ? Message.WellKnownAreaIds.Private : options.messageAreaId; //this.messageAreaId = 'netMail' === this.editorType ? Message.WellKnownAreaIds.Private : options.messageAreaId;
@ -69,7 +71,7 @@ function FullScreenEditorModule(options) {
var headerValues = self.viewControllers.header.getFormData().value; var headerValues = self.viewControllers.header.getFormData().value;
var messageOpts = { var messageOpts = {
// areaId : self.messageAreaId, areaId : self.messageAreaId,
toUserName : headerValues.to, toUserName : headerValues.to,
fromUserName : headerValues.from, fromUserName : headerValues.from,
subject : headerValues.subject, subject : headerValues.subject,
@ -241,11 +243,9 @@ function FullScreenEditorModule(options) {
); );
}; };
this.mciReadyHandler = function(mciData) { this.createInitialViews = function(mciData, cb) {
var menuLoadOpts = { callingMenu : self }; var menuLoadOpts = { callingMenu : self };
console.log('mciReadyHandler...')
async.series( async.series(
[ [
@ -283,20 +283,39 @@ function FullScreenEditorModule(options) {
).loadFromMenuConfig(menuLoadOpts, function footerReady(err) { ).loadFromMenuConfig(menuLoadOpts, function footerReady(err) {
callback(err); callback(err);
}); });
},
function prepareViewStates(callback) {
var header = self.viewControllers.header;
var from = header.getView(1);
from.acceptsFocus = false;
from.setText(self.client.user.username);
var body = self.viewControllers.body.getView(1);
self.updateTextEditMode(body.getTextEditMode());
self.updateEditModePosition(body.getEditPosition());
callback(null);
},
function setInitialFocus(callback) {
self.viewControllers.body.setFocus(false);
self.viewControllers.header.switchFocus(2); // to
callback(null);
} }
], ],
function complete(err) { function complete(err) {
console.log(err) cb(err);
var bodyView = self.viewControllers.body.getView(1);
self.updateTextEditMode(bodyView.getTextEditMode());
self.updateEditModePosition(bodyView.getEditPosition());
self.viewControllers.body.setFocus(false);
self.viewControllers.header.switchFocus(1);
} }
); );
}; };
this.mciReadyHandler = function(mciData) {
self.createInitialViews(mciData, function viewsCreated(err) {
});
};
this.updateEditModePosition = function(pos) { this.updateEditModePosition = function(pos) {
if('edit' === this.editorMode) { if('edit' === this.editorMode) {
var posView = self.viewControllers.footerEdit.getView(1); var posView = self.viewControllers.footerEdit.getView(1);
@ -415,10 +434,11 @@ function FullScreenEditorModule(options) {
} }
}); });
}, },
/*
editModeMenuSave : function(formData, extraArgs) { editModeMenuSave : function(formData, extraArgs) {
var msg = self.getMessage(); var msg = self.getMessage();
console.log(msg); console.log(msg);
}, },*/
editModeMenuQuote : function(formData, extraArgs) { editModeMenuQuote : function(formData, extraArgs) {
}, },

View File

@ -102,7 +102,7 @@ function loadMenu(options, cb) {
}, },
function createModuleInstance(modData, callback) { function createModuleInstance(modData, callback) {
Log.debug( Log.debug(
{ moduleName : modData.name, args : options.args, config : modData.config, info : modData.mod.modInfo }, { moduleName : modData.name, extraArgs : options.extraArgs, config : modData.config, info : modData.mod.modInfo },
'Creating menu module instance'); 'Creating menu module instance');
try { try {
@ -110,7 +110,7 @@ function loadMenu(options, cb) {
{ {
menuName : options.name, menuName : options.name,
menuConfig : modData.config, menuConfig : modData.config,
args : options.args, extraArgs : options.extraArgs,
}); });
callback(null, moduleInstance); callback(null, moduleInstance);
} catch(e) { } catch(e) {

View File

@ -259,7 +259,12 @@
"submit" : [ "submit" : [
{ {
"value" : { "command" : "N" }, "value" : { "command" : "N" },
"action" : "@menu:messageAreaNewPost" "action" : "@menu:messageAreaNewPost",
"extraArgs" : { "messageAreaId" : 123 }
},
{
"value" : { "command" : "Q" },
"action" : "@menu:mainMenu"
} }
] ]
}, },
@ -304,7 +309,7 @@
"3" : [ "3" : [
{ {
"value" : { "subject" : null }, "value" : { "subject" : null },
"action" : "@method:fseSubmitProxy" "action" : "@method:headerSubmit"
} }
] ]
} }
@ -323,7 +328,7 @@
"*" : [ "*" : [
{ {
"value" : "message", "value" : "message",
"action" : "@method:fseSubmitProxy" "action" : "@method:editModeEscPressed"
} }
] ]
}, },
@ -359,7 +364,7 @@
"*" : [ "*" : [
{ {
"value" : { "1" : 0 }, "value" : { "1" : 0 },
"action" : "@method:fseSubmitProxy" "action" : "@method:editModeMenuSave"
}, },
{ {
"value" : { "1" : 1 }, "value" : { "1" : 1 },
@ -371,18 +376,18 @@
}, },
{ {
"value" : { "1" : 3 }, "value" : { "1" : 3 },
"action" : "@method:fseSubmitProxy" "action" : "@method:editModeMenuHelp"
}, }/*,
{ {
"value" : 1, "value" : 1,
"action" : "@method:fseSubmitProxy" "action" : "@method:editModeEscPressed"
} }*/
] ]
}, },
"actionKeys" : [ // :TODO: Need better name "actionKeys" : [ // :TODO: Need better name
{ {
"keys" : [ "escape" ], "keys" : [ "escape" ],
"action" : "@method:fseSubmitProxy" "action" : "@method:editModeEscPressed"
} }
] ]
// :TODO: something like the following for overriding keymap // :TODO: something like the following for overriding keymap

View File

@ -2,6 +2,9 @@
'use strict'; 'use strict';
var FullScreenEditorModule = require('../core/fse.js').FullScreenEditorModule; var FullScreenEditorModule = require('../core/fse.js').FullScreenEditorModule;
var Message = require('../core/message.js').Message;
var _ = require('lodash');
exports.getModule = AreaPostFSEModule; exports.getModule = AreaPostFSEModule;
@ -14,9 +17,15 @@ exports.moduleInfo = {
function AreaPostFSEModule(options) { function AreaPostFSEModule(options) {
FullScreenEditorModule.call(this, options); FullScreenEditorModule.call(this, options);
var self = this;
// we're posting, so always start with 'edit' mode // we're posting, so always start with 'edit' mode
this.editorMode = 'edit'; this.editorMode = 'edit';
this.menuMethods.editModeMenuSave = function(formData, extraArgs) {
var msg = self.getMessage();
console.log(msg);
};
} }
require('util').inherits(AreaPostFSEModule, FullScreenEditorModule); require('util').inherits(AreaPostFSEModule, FullScreenEditorModule);