* Varous fixes for FSE. ...WIP on separation of editorMode vs editor/menu/etc. focus

This commit is contained in:
Bryan Ashby 2015-09-04 00:02:28 -06:00
parent 42ddabd875
commit ddc806bd39
4 changed files with 56 additions and 11 deletions

View File

@ -44,6 +44,15 @@ exports.moduleInfo = {
*/ */
var MCICodeIds = {
Header : {
From : 1,
To : 2,
Subject : 3,
}
};
function FullScreenEditorModule(options) { function FullScreenEditorModule(options) {
MenuModule.call(this, options); MenuModule.call(this, options);
@ -63,11 +72,15 @@ function FullScreenEditorModule(options) {
this.editorType = config.editorType; this.editorType = config.editorType;
this.editorMode = config.editorMode; this.editorMode = config.editorMode;
console.log('editorMode=' + this.editorMode)
if(_.isObject(options.extraArgs)) { if(_.isObject(options.extraArgs)) {
this.messageAreaName = options.extraArgs.messageAreaName || Message.WellKnownAreaNames.Private; this.messageAreaName = options.extraArgs.messageAreaName || Message.WellKnownAreaNames.Private;
} }
this.isEditMode = function() { this.isEditMode = function() {
console.log(self.editorMode)
return 'edit' === self.editorMode; return 'edit' === self.editorMode;
}; };
@ -107,6 +120,7 @@ function FullScreenEditorModule(options) {
message : self.viewControllers.body.getFormData().value.message, message : self.viewControllers.body.getFormData().value.message,
}; };
console.log(msgOpts)
self.message = new Message(msgOpts); self.message = new Message(msgOpts);
}; };
@ -117,7 +131,9 @@ function FullScreenEditorModule(options) {
}; };
this.getMessage = function() { this.getMessage = function() {
console.log('getMessage')
if(self.isEditMode()) { if(self.isEditMode()) {
console.log('want build msg')
self.buildMessage(); self.buildMessage();
} }
@ -210,6 +226,8 @@ function FullScreenEditorModule(options) {
this.switchFooter = function(cb) { this.switchFooter = function(cb) {
var footerName = self.getFooterName(); var footerName = self.getFooterName();
console.log('footerName=' + footerName)
self.redrawFooter( { footerName : footerName, clear : true }, function artDisplayed(err, artData) { self.redrawFooter( { footerName : footerName, clear : true }, function artDisplayed(err, artData) {
if(err) { if(err) {
@ -369,6 +387,7 @@ function FullScreenEditorModule(options) {
switch(self.editorMode) { switch(self.editorMode) {
case 'edit' : case 'edit' :
self.editModeFocus = 'editor';
self.switchToHeader(); self.switchToHeader();
break; break;
@ -435,6 +454,7 @@ function FullScreenEditorModule(options) {
v.setText(text); v.setText(text);
} }
} }
/* TL1 - From /* TL1 - From
TL2 - To TL2 - To
TL3 - Subject TL3 - Subject
@ -447,9 +467,9 @@ function FullScreenEditorModule(options) {
TL10 - Message ID TL10 - Message ID
TL11 - Reply to message ID*/ TL11 - Reply to message ID*/
setHeaderText(1, self.message.fromUserName); setHeaderText(MCICodeIds.Header.From, self.message.fromUserName);
setHeaderText(2, self.message.toUserName); setHeaderText(MCICodeIds.Header.To, self.message.toUserName);
setHeaderText(3, self.message.subject); setHeaderText(MCICodeIds.Subject, self.message.subject);
setHeaderText(5, moment(self.message.modTimestamp).format(self.client.currentTheme.helpers.getDateTimeFormat())); setHeaderText(5, moment(self.message.modTimestamp).format(self.client.currentTheme.helpers.getDateTimeFormat()));
setHeaderText(6, '1'); // :TODO: Message number setHeaderText(6, '1'); // :TODO: Message number
@ -503,15 +523,16 @@ function FullScreenEditorModule(options) {
self.switchToBody(); self.switchToBody();
}, },
editModeEscPressed : function(formData, extraArgs) { editModeEscPressed : function(formData, extraArgs) {
self.editorMode = 'edit' === self.editorMode ? 'editMenu' : 'edit'; self.editModeFocus = 'editor' === self.editModeFocus ? 'editMenu' : 'editor';
//self.editorMode = 'edit' === self.editorMode ? 'editMenu' : 'edit';
self.switchFooter(function next(err) { self.switchFooter(function next(err) {
if(err) { if(err) {
// :TODO:... what now? // :TODO:... what now?
console.log(err) console.log(err)
} else { } else {
switch(self.editorMode) { switch(self.editModeFocus) {
case 'edit' : case 'editor' :
if(!_.isUndefined(self.viewControllers.footerEditMenu)) { if(!_.isUndefined(self.viewControllers.footerEditMenu)) {
self.viewControllers.footerEditMenu.setFocus(false); self.viewControllers.footerEditMenu.setFocus(false);
} }
@ -544,7 +565,7 @@ function FullScreenEditorModule(options) {
} }
}; };
if(_.isObject(options.extraArgs.message)) { if(_.has(options, 'extraArgs.message')) {
this.setMessage(options.extraArgs.message); this.setMessage(options.extraArgs.message);
} }
} }

View File

@ -14,6 +14,7 @@ exports.changeMessageArea = changeMessageArea;
exports.getMessageListForArea = getMessageListForArea; exports.getMessageListForArea = getMessageListForArea;
function getAvailableMessageAreas() { function getAvailableMessageAreas() {
// example: [ { "name" : "local_music", "desc" : "Music Discussion", "groups" : ["somegroup"] }, ... ]
return Config.messages.areas; return Config.messages.areas;
} }

View File

@ -323,7 +323,7 @@
"options" : { "cls" : true }, "options" : { "cls" : true },
"fallback" : "messageArea", "fallback" : "messageArea",
"config" : { "config" : {
"listType" : "private"
}, },
"form" : { "form" : {
"0" : { "0" : {
@ -469,6 +469,7 @@
"footerView" : "demo_fse_netmail_footer_view.ans", "footerView" : "demo_fse_netmail_footer_view.ans",
"help" : "demo_fse_netmail_help.ans" "help" : "demo_fse_netmail_help.ans"
}, },
"editorMode" : "edit",
"editorType" : "area" "editorType" : "area"
}, },
"form" : { "form" : {

View File

@ -46,6 +46,11 @@ function MessageListModule(options) {
var self = this; var self = this;
var config = this.menuConfig.config;
// config.listType : public | private
this.listType = config.listType || 'public';
this.messageList = []; this.messageList = [];
this.menuMethods = { this.menuMethods = {
@ -80,6 +85,17 @@ function MessageListModule(options) {
require('util').inherits(MessageListModule, MenuModule); require('util').inherits(MessageListModule, MenuModule);
MessageListModule.prototype.enter = function(client) {
if('private' === this.listType) {
this.messageAreaName = Message.WellKnownAreaNames.Private;
} else {
this.messageAreaName = client.user.properties.message_area_name;
}
MessageListModule.super_.prototype.enter.call(this, client);
};
MessageListModule.prototype.mciReady = function(mciData, cb) { MessageListModule.prototype.mciReady = function(mciData, cb) {
var self = this; var self = this;
@ -99,9 +115,13 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
vc.loadFromMenuConfig(loadOpts, callback); vc.loadFromMenuConfig(loadOpts, callback);
}, },
function fetchMessagesInArea(callback) { function fetchMessagesInArea(callback) {
messageArea.getMessageListForArea( { client : self.client }, self.client.user.properties.message_area_name, function msgs(err, msgList) { messageArea.getMessageListForArea( { client : self.client }, self.messageAreaName, function msgs(err, msgList) {
self.messageList = msgList; if(msgList && 0 === msgList.length) {
callback(err); callback(new Error('No messages in area'));
} else {
self.messageList = msgList;
callback(err);
}
}); });
}, },
function populateList(callback) { function populateList(callback) {
@ -125,6 +145,8 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
], ],
function complete(err) { function complete(err) {
if(err) { if(err) {
// :TODO: log this properly
self.client.gotoMenuModule( { name : self.menuConfig.fallback } );
console.log(err) console.log(err)
} }
cb(err); cb(err);