From 549fba6b34e2c10cebb9f855c50ca18e7587d32e Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 18 Oct 2015 21:24:13 -0600 Subject: [PATCH] * Code cleanup + comments * Fix message area access in NUA path --- core/message_area.js | 2 +- mods/apply.js | 3 + mods/menu.hjson | 2 +- mods/msg_list.js | 95 ++++++++------------ mods/themes/luciano_blocktronics/theme.hjson | 5 +- mods/user_list.js | 17 ++-- 6 files changed, 56 insertions(+), 68 deletions(-) diff --git a/core/message_area.js b/core/message_area.js index 9a460c67..90f5f4f0 100644 --- a/core/message_area.js +++ b/core/message_area.js @@ -53,7 +53,7 @@ function getDefaultMessageArea() { function getMessageAreaByName(areaName) { areaName = areaName.toLowerCase(); - var availAreas = getAvailableMessageAreas(); + var availAreas = getAvailableMessageAreas( { includePrivate : true } ); var index = _.findIndex(availAreas, function pred(an) { return an.name == areaName; }); diff --git a/mods/apply.js b/mods/apply.js index a8361bc9..de6cdbf5 100644 --- a/mods/apply.js +++ b/mods/apply.js @@ -97,6 +97,9 @@ function submitApplication(callingMenu, formData, extraArgs) { account_created : new Date().toISOString(), message_area_name : getDefaultMessageArea().name, + + term_height : client.term.termHeight, + term_width : client.term.termWidth, // :TODO: This is set in User.create() -- proabbly don't need it here: //account_status : Config.users.requireActivation ? user.User.AccountStatus.inactive : user.User.AccountStatus.active, diff --git a/mods/menu.hjson b/mods/menu.hjson index f64e7fdc..cd6e8d8d 100644 --- a/mods/menu.hjson +++ b/mods/menu.hjson @@ -491,7 +491,7 @@ } actionKeys: [ { - keys: [ "escape" ] + keys: [ "escape", "q", "shift + q" ] action: @systemMethod:fallbackMenu } ] diff --git a/mods/msg_list.js b/mods/msg_list.js index 6f42b029..086072e3 100644 --- a/mods/msg_list.js +++ b/mods/msg_list.js @@ -12,6 +12,24 @@ var assert = require('assert'); var _ = require('lodash'); var moment = require('moment'); +/* + Available listFormat/focusListFormat members (VM1): + + msgNum : Message number + to : To username/handle + from : From username/handle + subj : Subject + ts : Message mod timestamp (format with config.dateTimeFormat) + newIndicator : New mark/indicator (config.newIndicator) + + MCI codes: + + VM1 : Message list + TL2 : Message area description + TL4 : Message selected # + TL5 : Total messages in area +*/ + exports.getModule = MessageListModule; exports.moduleInfo = { @@ -20,34 +38,6 @@ exports.moduleInfo = { author : 'NuSkooler', }; -// -// :TODO: -// * Avail data: -// To - {to} -// From - {from} -// Subject -// Date -// Status (New/Read) -// Message Num (Area) -// Message Total (Area) -// Message Area desc - {areaDesc} / %TL2 -// Message Area Name - {areaName} -// -// Ideas -// * Module config can define custom formats for items & focused items (inc. Pipe Codes) -// * Single list view with advanced formatting (would need textOverflow stuff), advanced formatting... -// * Multiple LV's in sync with keyboard input -// * New Table LV (TV) -// * - -// VM1 - message list -// TL2 - Message area desc - -// TL4 - message selected # -// TL5 - message total # -// -// See Obv/2, Iniq, and Mystic docs - var MciCodesIds = { MsgList : 1, MsgAreaDesc : 2, @@ -134,36 +124,32 @@ MessageListModule.prototype.mciReady = function(mciData, cb) { var msgListView = vc.getView(MciCodesIds.MsgList); // :TODO: fix default format - var listFormat = self.menuConfig.config.listFormat || '{msgNum:>4} - {subj:>35} |{to:>15}'; + var listFormat = self.menuConfig.config.listFormat || '{msgNum} - {subj} |{to}'; var focusListFormat = self.menuConfig.config.focusListFormat || listFormat; // :TODO: default change color here + var dateTimeFormat = self.menuConfig.config.dateTimeFormat || 'ddd MMM DDD'; + var newIndicator = self.menuConfig.config.newIndicator || '*'; var msgNum = 1; - var newMark = '*'; // :TODO: Make configurable - var dateFmt = 'ddd MMM DD'; // :TODO: Make configurable + + function getMsgFmtObj(mle) { + return { + msgNum : msgNum++, + subj : mle.subject, + from : mle.fromUserName, + to : mle.toUserName, + ts : moment(mle.modTimestamp).format(dateTimeFormat), + newIndicator : newIndicator, // :TODO: These should only be for actual new messages! + } + } + msgListView.setItems(_.map(self.messageList, function formatMsgListEntry(mle) { - return listFormat.format( { - msgNum : msgNum++, - subj : mle.subject, - from : mle.fromUserName, - to : mle.toUserName, - ts : moment(mle.modTimestamp).format(dateFmt), - newMark : newMark, // :TODO: These should only be for actual new messages! - } ); + return listFormat.format(getMsgFmtObj(mle)); })); - if(focusListFormat) { - msgNum = 1; - msgListView.setFocusItems(_.map(self.messageList, function formatMsgListEntry(mle) { - return focusListFormat.format( { - msgNum : msgNum++, - subj : mle.subject, - from : mle.fromUserName, - to : mle.toUserName, - ts : moment(mle.modTimestamp).format(dateFmt), - newMark : newMark, - } ); - })); - } + msgNum = 1; + msgListView.setFocusItems(_.map(self.messageList, function formatMsgListEntry(mle) { + return focusListFormat.format(getMsgFmtObj(mle)); + }); msgListView.on('index update', function indexUpdated(idx) { self.setViewText(MciCodesIds.MsgSelNum, (idx + 1).toString()); @@ -184,10 +170,7 @@ MessageListModule.prototype.mciReady = function(mciData, cb) { ], function complete(err) { if(err) { - // :TODO: log this properly - // :TODO: use fallbackMenuModule() here - self.client.gotoMenuModule( { name : self.menuConfig.fallback } ); - console.log(err) + self.client.log.error( { error : err.toString() }, 'Error loading message list'); } cb(err); } diff --git a/mods/themes/luciano_blocktronics/theme.hjson b/mods/themes/luciano_blocktronics/theme.hjson index ecde3903..06b212c0 100644 --- a/mods/themes/luciano_blocktronics/theme.hjson +++ b/mods/themes/luciano_blocktronics/theme.hjson @@ -105,8 +105,8 @@ mainMenuUserList: { config: { - listFormat: "|00|01|36{userName:<17.17}{affils:<21.21}{note:<21.21}{lastLoginTs}" - focusListFormat: "|00|42|30{userName:<17.17}{affils:<21.21}{note:<21.21}{lastLoginTs}" + listFormat: "|00|01|36{userName:<17.17}{affils:<21.21}{note:<19.19}{lastLoginTs}" + focusListFormat: "|00|42|30{userName:<17.17}{affils:<21.21}{note:<19.19}{lastLoginTs}" dateTimeFormat: MMM Do h:mma } mci: { @@ -118,6 +118,7 @@ config: { listFormat: "|00|01|37{msgNum:>4} |00|37- |36{subj:<29.29} {from:<20.20} {ts} |01|31{newMark}" focusListFormat: "|00|42|30{msgNum:>4} - {subj:<29.29} {from:<20.20} {ts} {newMark}" + dateTimeFormat: ddd MMM DDD } mci: { VM1: { diff --git a/mods/user_list.js b/mods/user_list.js index 53216313..7cb6a687 100644 --- a/mods/user_list.js +++ b/mods/user_list.js @@ -12,14 +12,15 @@ var assert = require('assert'); var _ = require('lodash'); /* - Available listFormat object members: - userId - userName - lastLoginTs - status - location - affiliation - note + Available listFormat/focusListFormat object members: + + userId : User ID + userName : User name/handle + lastLoginTs : Last login timestamp + status : Status: active | inactive + location : Location + affiliation : Affils + note : User note */ exports.moduleInfo = {