* Menus can specify status
* WIP changes of message loading in viewer - can now do next... WIP!!!
This commit is contained in:
parent
b911db75ca
commit
1f3948d84c
|
@ -147,7 +147,7 @@ function getDefaultConfig() {
|
|||
},
|
||||
|
||||
misc : {
|
||||
idleLogoutSeconds : 60 * 3, // 3m
|
||||
idleLogoutSeconds : 60 * 6, // 6m
|
||||
},
|
||||
|
||||
logging : {
|
||||
|
|
75
core/fse.js
75
core/fse.js
|
@ -42,10 +42,17 @@ exports.moduleInfo = {
|
|||
TL9 - Hash tags
|
||||
TL10 - Message ID
|
||||
TL11 - Reply to message ID
|
||||
|
||||
Footer - Viewing
|
||||
HM1 - Menu (prev/next/etc.)
|
||||
|
||||
TL6 - Message number
|
||||
TL7 - Message total (in area)
|
||||
|
||||
|
||||
*/
|
||||
var MCICodeIds = {
|
||||
Header : {
|
||||
ViewModeHeader : {
|
||||
From : 1,
|
||||
To : 2,
|
||||
Subject : 3,
|
||||
|
@ -84,6 +91,8 @@ function FullScreenEditorModule(options) {
|
|||
this.messageNumber = options.extraArgs.messageNumber || 0;
|
||||
this.messageTotal = options.extraArgs.messageTotal || 0;
|
||||
}
|
||||
|
||||
this.isReady = false;
|
||||
|
||||
this.isEditMode = function() {
|
||||
return 'edit' === self.editorMode;
|
||||
|
@ -135,9 +144,19 @@ function FullScreenEditorModule(options) {
|
|||
};
|
||||
|
||||
this.setMessage = function(message) {
|
||||
console.log(message)
|
||||
//console.log(message)
|
||||
|
||||
self.message = message;
|
||||
|
||||
if(self.isReady) {
|
||||
self.initHeaderViewMode();
|
||||
|
||||
var bodyMessageView = self.viewControllers.body.getView(1);
|
||||
if(bodyMessageView && _.has(self, 'message.message')) {
|
||||
bodyMessageView.setText(self.message.message);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.getMessage = function() {
|
||||
|
@ -296,19 +315,22 @@ function FullScreenEditorModule(options) {
|
|||
self.setInitialFooterMode();
|
||||
|
||||
var footerName = self.getFooterName();
|
||||
console.log(footerName)
|
||||
self.redrawFooter( { footerName : footerName }, function artDisplayed(err, artData) {
|
||||
mciData[footerName] = artData;
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
function afterArtDisplayed(callback) {
|
||||
self.mciReady(mciData);
|
||||
callback(null);
|
||||
self.mciReady(mciData, callback);
|
||||
}
|
||||
],
|
||||
function complete(err) {
|
||||
if(err) {
|
||||
console.log(err)
|
||||
} else {
|
||||
self.isReady = true;
|
||||
self.finishedLoading();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -335,6 +357,8 @@ function FullScreenEditorModule(options) {
|
|||
menuLoadOpts.formId = self.getFormId('body');
|
||||
menuLoadOpts.mciMap = mciData.body.mciMap;
|
||||
|
||||
console.log('creating body.l..')
|
||||
|
||||
self.addViewController(
|
||||
'body',
|
||||
new ViewController( { client : self.client, formId : menuLoadOpts.formId } )
|
||||
|
@ -399,7 +423,7 @@ function FullScreenEditorModule(options) {
|
|||
break;
|
||||
|
||||
case 'view' :
|
||||
self.switchToBody();
|
||||
self.switchToFooter();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -412,9 +436,10 @@ function FullScreenEditorModule(options) {
|
|||
);
|
||||
};
|
||||
|
||||
this.mciReadyHandler = function(mciData) {
|
||||
this.mciReadyHandler = function(mciData, cb) {
|
||||
|
||||
self.createInitialViews(mciData, function viewsCreated(err) {
|
||||
|
||||
self.viewControllers.header.on('leave', function headerViewLeave(view) {
|
||||
|
||||
if(2 === view.id) { // "to" field
|
||||
|
@ -427,11 +452,13 @@ function FullScreenEditorModule(options) {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
cb(err);
|
||||
});
|
||||
};
|
||||
|
||||
this.updateEditModePosition = function(pos) {
|
||||
if('edit' === this.editorMode) {
|
||||
if(self.isEditMode()) {
|
||||
var posView = self.viewControllers.footerEditor.getView(1);
|
||||
if(posView) {
|
||||
self.client.term.rawWrite(ansi.savePos());
|
||||
|
@ -442,7 +469,7 @@ function FullScreenEditorModule(options) {
|
|||
};
|
||||
|
||||
this.updateTextEditMode = function(mode) {
|
||||
if('edit' === this.editorMode) {
|
||||
if(self.isEditMode()) {
|
||||
var modeView = self.viewControllers.footerEditor.getView(2);
|
||||
if(modeView) {
|
||||
self.client.term.rawWrite(ansi.savePos());
|
||||
|
@ -462,16 +489,16 @@ function FullScreenEditorModule(options) {
|
|||
}
|
||||
}
|
||||
|
||||
setHeaderText(MCICodeIds.Header.From, self.message.fromUserName);
|
||||
setHeaderText(MCICodeIds.Header.To, self.message.toUserName);
|
||||
setHeaderText(MCICodeIds.Header.Subject, self.message.subject);
|
||||
setHeaderText(MCICodeIds.Header.DateTime, moment(self.message.modTimestamp).format(self.client.currentTheme.helpers.getDateTimeFormat()));
|
||||
setHeaderText(MCICodeIds.Header.MsgNum, self.messageNumber.toString());
|
||||
setHeaderText(MCICodeIds.Header.MsgTotal, self.messageTotal.toString());
|
||||
setHeaderText(MCICodeIds.Header.ViewCount, self.message.viewCount);
|
||||
setHeaderText(MCICodeIds.Header.HashTags, 'TODO hash tags');
|
||||
setHeaderText(MCICodeIds.Header.MessageID, self.message.messageId);
|
||||
setHeaderText(MCICodeIds.Header.ReplyToMsgID, self.message.replyToMessageId);
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.From, self.message.fromUserName);
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.To, self.message.toUserName);
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.Subject, self.message.subject);
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.DateTime, moment(self.message.modTimestamp).format(self.client.currentTheme.helpers.getDateTimeFormat()));
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.MsgNum, self.messageNumber.toString());
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.MsgTotal, self.messageTotal.toString());
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.ViewCount, self.message.viewCount);
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.HashTags, 'TODO hash tags');
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.MessageID, self.message.messageId);
|
||||
setHeaderText(MCICodeIds.ViewModeHeader.ReplyToMsgID, self.message.replyToMessageId);
|
||||
};
|
||||
|
||||
this.displayHelp = function() {
|
||||
|
@ -511,6 +538,13 @@ function FullScreenEditorModule(options) {
|
|||
self.observeEditorEvents();
|
||||
};
|
||||
|
||||
this.switchToFooter = function() {
|
||||
self.viewControllers.header.setFocus(false);
|
||||
self.viewControllers.body.setFocus(false);
|
||||
|
||||
self.viewControllers[self.getFooterName()].switchFocus(1); // HM1
|
||||
};
|
||||
|
||||
|
||||
this.menuMethods = {
|
||||
// :TODO: rename to editModeHeaderSubmit
|
||||
|
@ -579,12 +613,11 @@ FullScreenEditorModule.prototype.enter = function(client) {
|
|||
FullScreenEditorModule.super_.prototype.enter.call(this, client);
|
||||
};
|
||||
|
||||
FullScreenEditorModule.prototype.mciReady = function(mciData) {
|
||||
this.mciReadyHandler(mciData);
|
||||
FullScreenEditorModule.prototype.mciReady = function(mciData, cb) {
|
||||
this.mciReadyHandler(mciData, cb);
|
||||
//this['mciReadyHandler' + _.capitalize(this.editorType)](mciData);
|
||||
};
|
||||
|
||||
FullScreenEditorModule.prototype.validateToUserName = function(un, cb) {
|
||||
cb(null); // note: to be implemented by sub classes
|
||||
};
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ function MenuModule(options) {
|
|||
this.initSequence = function() {
|
||||
var mciData = { };
|
||||
|
||||
// :TODO: This could be .series() currently
|
||||
async.waterfall(
|
||||
async.series(
|
||||
[
|
||||
function beforeDisplayArt(callback) {
|
||||
self.beforeArt();
|
||||
|
@ -139,6 +138,16 @@ function MenuModule(options) {
|
|||
menuUtil.handleAction(self.client, null, self.menuConfig);
|
||||
}
|
||||
};
|
||||
|
||||
this.setMenuStatus = function(status) {
|
||||
self.menuStatus = status;
|
||||
};
|
||||
|
||||
if(_.isString(this.menuConfig.status)) {
|
||||
self.setMenuStatus(self.menuConfig.status);
|
||||
} else {
|
||||
self.setMenuStatus('Browsing menus');
|
||||
}
|
||||
}
|
||||
|
||||
require('util').inherits(MenuModule, PluginModule);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
var msgDb = require('./database.js').dbs.message;
|
||||
var Config = require('./config.js').config;
|
||||
var Message = require('./message.js');
|
||||
|
||||
var async = require('async');
|
||||
var _ = require('lodash');
|
||||
|
@ -12,6 +13,7 @@ exports.getAvailableMessageAreas = getAvailableMessageAreas;
|
|||
exports.getMessageAreaByName = getMessageAreaByName;
|
||||
exports.changeMessageArea = changeMessageArea;
|
||||
exports.getMessageListForArea = getMessageListForArea;
|
||||
exports.gotoMsgAreaFSEModuleForMessage = gotoMsgAreaFSEModuleForMessage;
|
||||
|
||||
function getAvailableMessageAreas() {
|
||||
// example: [ { "name" : "local_music", "desc" : "Music Discussion", "groups" : ["somegroup"] }, ... ]
|
||||
|
@ -123,3 +125,31 @@ function getMessageListForArea(options, areaName, cb) {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
function gotoMsgAreaFSEModuleForMessage(options, cb) {
|
||||
// options.client
|
||||
// options.msgAreaName
|
||||
// options.messageUuid
|
||||
// options.moduleName
|
||||
// options.msgNumber
|
||||
// options.msgTotal
|
||||
|
||||
var msg = new Message();
|
||||
msg.load( { uuid : options.messageUuid, user : options.client.user }, function loaded(err) {
|
||||
if(err) {
|
||||
cb(err);
|
||||
} else {
|
||||
var modOpts = {
|
||||
name : options.moduleName,
|
||||
extraArgs : {
|
||||
message : msg,
|
||||
messageAreaName : options.msgAreaName,
|
||||
messageNumber : options.msgNumber,
|
||||
messageTotal : options.msgTotal,
|
||||
},
|
||||
};
|
||||
|
||||
options.client.gotoMenuModule(modOpts, cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -279,6 +279,10 @@
|
|||
{
|
||||
"value" : { "command" : "Q" },
|
||||
"action" : "@menu:mainMenu"
|
||||
},
|
||||
{
|
||||
"value" : 1,
|
||||
"action" : "@menu:messageArea"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -429,26 +433,33 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"3" : {
|
||||
"4" : {
|
||||
"HM" : {
|
||||
"mci" : {
|
||||
"HM1" : {
|
||||
// (P)rev/(N)ext/Post/(R)eply/(Q)uit/(?)Help
|
||||
// (#)Jump/(L)Index (msg list)/Last
|
||||
|
||||
// :TODO: Continue, Save, Discard, Clear, Quote, Help
|
||||
"items" : [ "Save", "Discard", "Quote", "Help" ]
|
||||
"items" : [ "Prev", "Next", "Reply", "Quit", "Help" ]
|
||||
}
|
||||
}/*,
|
||||
},
|
||||
"submit" : {
|
||||
"*" : [
|
||||
{
|
||||
"value" : { "1" : 0 },
|
||||
"action" : "@method:editModeMenuSave"
|
||||
"value" : { "1" : 1 },
|
||||
"action" : "@method:nextMessage"
|
||||
},
|
||||
{
|
||||
"value" : { "1" : 3 },
|
||||
"action" : "@menu:messageArea"
|
||||
}
|
||||
]
|
||||
}*/,
|
||||
"actionKeys" : [ // :TODO: Need better name
|
||||
},
|
||||
"actionKeys" : [
|
||||
{
|
||||
"keys" : [ "escape" ],
|
||||
"action" : "@method:editModeEscPressed"
|
||||
"action" : "@method:editModeEscPressed" // :TODO: fixme
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -457,6 +468,7 @@
|
|||
},
|
||||
// :TODO: messageAreaSelect (change msg areas -> call @systemMethod -> fallback to menu
|
||||
"messageAreaNewPost" : {
|
||||
"status" : "Posting message",
|
||||
"module" : "msg_area_post_fse",
|
||||
"options" : { "cls" : true },
|
||||
"fallback" : "messageArea", // :TODO: remove once default fallback is in place
|
||||
|
@ -597,34 +609,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
/*
|
||||
"messageAreaMenu" : {
|
||||
"module" : "message_area",
|
||||
"art" : "MSGAREA",
|
||||
"options" : { "cls" : true },
|
||||
"prompt" : "menuCommand",
|
||||
"config" : {
|
||||
"fseArt" : {
|
||||
"header" : "demo_fse_netmail_header.ans",
|
||||
"body" : "demo_fse_netmail_body.ans",
|
||||
"footerEdit" : "demo_fse_netmail_footer_edit.ans",
|
||||
"footerEditMenu" : "demo_fse_netmail_footer_edit_menu.ans",
|
||||
"footerView" : "demo_fse_netmail_footer_view.ans",
|
||||
"help" : "demo_fse_netmail_help.ans"
|
||||
}
|
||||
},
|
||||
"submit" : [
|
||||
{
|
||||
"value" : { "command" : "R" },
|
||||
"action" : "@method:readMessages"
|
||||
},
|
||||
{
|
||||
"value" : { "command" : "P" },
|
||||
"action" : "@method:postMessage"
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Doors
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
'use strict';
|
||||
|
||||
var FullScreenEditorModule = require('../core/fse.js').FullScreenEditorModule;
|
||||
var Message = require('../core/message.js').Message;
|
||||
var Message = require('../core/message.js');
|
||||
var messageArea = require('../core/message_area.js');
|
||||
var user = require('../core/user.js');
|
||||
|
||||
var _ = require('lodash');
|
||||
|
@ -26,6 +27,17 @@ function AreaViewFSEModule(options) {
|
|||
this.editorType = 'area';
|
||||
this.editorMode = 'view';
|
||||
|
||||
if(_.isObject(options.extraArgs)) {
|
||||
this.messageList = options.extraArgs.messageList;
|
||||
this.messageIndex = options.extraArgs.messageIndex;
|
||||
}
|
||||
|
||||
this.messageList = this.messageList || [];
|
||||
this.messageIndex = this.messageIndex || 0;
|
||||
|
||||
this.messageNumber = this.messageIndex + 1;
|
||||
this.messageTotal = this.messageList.length;
|
||||
|
||||
//assert(_.isString(options.extraArgs.messageAreaName), 'messageAreaName must be supplied!');
|
||||
//assert(options.extraArgs.messageId, 'messageId must be supplied!');
|
||||
//assert(_.isString(options.extraArgs.messageUuid), 'messageUuid must be supplied!');
|
||||
|
@ -40,7 +52,21 @@ function AreaViewFSEModule(options) {
|
|||
};
|
||||
*/
|
||||
|
||||
this.menuMethods.nextMessage = function(formData, extraArgs) {
|
||||
// :TODO: Next shouldn't even be a option if this is not the case:
|
||||
if(self.messageIndex + 1 < self.messageList.length) {
|
||||
self.messageNumber++; // :TODO: should consolidate index + number?
|
||||
self.loadMessageByUuid(self.messageList[self.messageIndex++].messageUuid);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.loadMessageByUuid = function(uuid) {
|
||||
var msg = new Message();
|
||||
msg.load( { uuid : uuid, user : self.client.user }, function loaded(err) {
|
||||
self.setMessage(msg);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
require('util').inherits(AreaViewFSEModule, FullScreenEditorModule);
|
||||
|
@ -55,5 +81,8 @@ AreaViewFSEModule.prototype.enter = function(client) {
|
|||
AreaViewFSEModule.prototype.finishedLoading = function() {
|
||||
//AreaViewFSEModule.super_.prototype.finishedLoading.call(this);
|
||||
|
||||
this.loadMessage(this.messageUuid);
|
||||
if(this.messageList.length) {
|
||||
console.log('loading from index ' + this.messageIndex)
|
||||
this.loadMessageByUuid(this.messageList[this.messageIndex].messageUuid);
|
||||
}
|
||||
};
|
|
@ -56,10 +56,28 @@ function MessageListModule(options) {
|
|||
this.menuMethods = {
|
||||
selectMessage : function(formData, extraArgs) {
|
||||
if(1 === formData.submitId) {
|
||||
/*
|
||||
extraArgs.messageAreaName
|
||||
extraArgs.messageList
|
||||
extraArgs.messageListIndex
|
||||
*/
|
||||
|
||||
var selected = self.messageList[formData.value.message];
|
||||
console.log(selected);
|
||||
|
||||
//
|
||||
//console.log(selected);
|
||||
|
||||
var modOpts = {
|
||||
name : 'messageAreaViewPost', // :TODO: should come from config?
|
||||
extraArgs : {
|
||||
messageAreaName : self.messageAreaName,
|
||||
messageList : self.messageList,
|
||||
messageListIndex : formData.value.message,
|
||||
}
|
||||
};
|
||||
|
||||
self.client.gotoMenuModule(modOpts);
|
||||
|
||||
/*
|
||||
//
|
||||
// Load full Message object
|
||||
//
|
||||
var msg = new Message();
|
||||
|
@ -83,6 +101,7 @@ function MessageListModule(options) {
|
|||
self.client.gotoMenuModule(modOpts);
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue