From 7990202317d4e754ad628de5214848776fd048a6 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 16 Aug 2015 13:35:34 -0600 Subject: [PATCH] * Fix some extraArgs stuff * Minor updates to FSE related modules -- WIP! --- core/client.js | 6 ++--- core/fse.js | 52 +++++++++++++++++++++++++++------------ core/menu_util.js | 4 +-- mods/menu.json | 23 ++++++++++------- mods/msg_area_post_fse.js | 9 +++++++ 5 files changed, 64 insertions(+), 30 deletions(-) diff --git a/core/client.js b/core/client.js index 76c44b7a..9907862e 100644 --- a/core/client.js +++ b/core/client.js @@ -441,9 +441,9 @@ Client.prototype.gotoMenuModule = function(options, cb) { self.detachCurrentMenuModule(); var loadOptions = { - name : options.name, - client : self, - args : options.args + name : options.name, + client : self, + extraArgs : options.extraArgs, }; menuUtil.loadMenu(loadOptions, function onMenuModuleLoaded(err, modInst) { diff --git a/core/fse.js b/core/fse.js index 108b3f1f..260a71ba 100644 --- a/core/fse.js +++ b/core/fse.js @@ -43,7 +43,9 @@ function FullScreenEditorModule(options) { this.editorType = config.editorType; this.editorMode = config.editorMode; - this.mciData = {}; + if(_.isObject(options.extraArgs)) { + this.messageAreaId = options.extraArgs.messageAreaId || Message.WellKnownAreaIds.Private; + } // netMail/crashMail | echoMail //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 messageOpts = { - // areaId : self.messageAreaId, + areaId : self.messageAreaId, toUserName : headerValues.to, fromUserName : headerValues.from, subject : headerValues.subject, @@ -241,11 +243,9 @@ function FullScreenEditorModule(options) { ); }; - this.mciReadyHandler = function(mciData) { - - var menuLoadOpts = { callingMenu : self }; - - console.log('mciReadyHandler...') + this.createInitialViews = function(mciData, cb) { + + var menuLoadOpts = { callingMenu : self }; async.series( [ @@ -283,18 +283,37 @@ function FullScreenEditorModule(options) { ).loadFromMenuConfig(menuLoadOpts, function footerReady(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) { - console.log(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); + cb(err); } - ); + ); + }; + + this.mciReadyHandler = function(mciData) { + + self.createInitialViews(mciData, function viewsCreated(err) { + + }); }; this.updateEditModePosition = function(pos) { @@ -415,10 +434,11 @@ function FullScreenEditorModule(options) { } }); }, + /* editModeMenuSave : function(formData, extraArgs) { var msg = self.getMessage(); console.log(msg); - }, + },*/ editModeMenuQuote : function(formData, extraArgs) { }, diff --git a/core/menu_util.js b/core/menu_util.js index c7dcd153..27f0423e 100644 --- a/core/menu_util.js +++ b/core/menu_util.js @@ -102,7 +102,7 @@ function loadMenu(options, cb) { }, function createModuleInstance(modData, callback) { 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'); try { @@ -110,7 +110,7 @@ function loadMenu(options, cb) { { menuName : options.name, menuConfig : modData.config, - args : options.args, + extraArgs : options.extraArgs, }); callback(null, moduleInstance); } catch(e) { diff --git a/mods/menu.json b/mods/menu.json index eab40c00..427515e8 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -259,7 +259,12 @@ "submit" : [ { "value" : { "command" : "N" }, - "action" : "@menu:messageAreaNewPost" + "action" : "@menu:messageAreaNewPost", + "extraArgs" : { "messageAreaId" : 123 } + }, + { + "value" : { "command" : "Q" }, + "action" : "@menu:mainMenu" } ] }, @@ -304,7 +309,7 @@ "3" : [ { "value" : { "subject" : null }, - "action" : "@method:fseSubmitProxy" + "action" : "@method:headerSubmit" } ] } @@ -323,7 +328,7 @@ "*" : [ { "value" : "message", - "action" : "@method:fseSubmitProxy" + "action" : "@method:editModeEscPressed" } ] }, @@ -359,7 +364,7 @@ "*" : [ { "value" : { "1" : 0 }, - "action" : "@method:fseSubmitProxy" + "action" : "@method:editModeMenuSave" }, { "value" : { "1" : 1 }, @@ -371,18 +376,18 @@ }, { "value" : { "1" : 3 }, - "action" : "@method:fseSubmitProxy" - }, + "action" : "@method:editModeMenuHelp" + }/*, { "value" : 1, - "action" : "@method:fseSubmitProxy" - } + "action" : "@method:editModeEscPressed" + }*/ ] }, "actionKeys" : [ // :TODO: Need better name { "keys" : [ "escape" ], - "action" : "@method:fseSubmitProxy" + "action" : "@method:editModeEscPressed" } ] // :TODO: something like the following for overriding keymap diff --git a/mods/msg_area_post_fse.js b/mods/msg_area_post_fse.js index 0e976dab..19a3edb9 100644 --- a/mods/msg_area_post_fse.js +++ b/mods/msg_area_post_fse.js @@ -2,6 +2,9 @@ 'use strict'; var FullScreenEditorModule = require('../core/fse.js').FullScreenEditorModule; +var Message = require('../core/message.js').Message; + +var _ = require('lodash'); exports.getModule = AreaPostFSEModule; @@ -14,9 +17,15 @@ exports.moduleInfo = { function AreaPostFSEModule(options) { FullScreenEditorModule.call(this, options); + var self = this; + // we're posting, so always start with 'edit' mode this.editorMode = 'edit'; + this.menuMethods.editModeMenuSave = function(formData, extraArgs) { + var msg = self.getMessage(); + console.log(msg); + }; } require('util').inherits(AreaPostFSEModule, FullScreenEditorModule);