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

View File

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

View File

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

View File

@ -46,6 +46,11 @@ function MessageListModule(options) {
var self = this;
var config = this.menuConfig.config;
// config.listType : public | private
this.listType = config.listType || 'public';
this.messageList = [];
this.menuMethods = {
@ -80,6 +85,17 @@ function MessageListModule(options) {
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) {
var self = this;
@ -99,9 +115,13 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
vc.loadFromMenuConfig(loadOpts, 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) {
if(msgList && 0 === msgList.length) {
callback(new Error('No messages in area'));
} else {
self.messageList = msgList;
callback(err);
}
});
},
function populateList(callback) {
@ -125,6 +145,8 @@ MessageListModule.prototype.mciReady = function(mciData, cb) {
],
function complete(err) {
if(err) {
// :TODO: log this properly
self.client.gotoMenuModule( { name : self.menuConfig.fallback } );
console.log(err)
}
cb(err);