diff --git a/core/file_area_list.js b/core/file_area_list.js index 77b079ff..49235a9d 100644 --- a/core/file_area_list.js +++ b/core/file_area_list.js @@ -345,14 +345,16 @@ exports.getModule = class FileAreaList extends MenuModule { } displayArtDataPrepCallback(name, artData, viewController) { - if ('details' === name) { + if (name === details) { try { this.detailsInfoArea = { top: artData.mciMap.XY2.position, bottom: artData.mciMap.XY3.position, }; } catch (e) { - throw Errors.DoesNotExist('Missing XY2 and XY3 position indicators!'); + throw Errors.DoesNotExist( + 'File listing details %XY2 and/or %XY3 MCI position indicators!' + ); } } } @@ -734,6 +736,10 @@ exports.getModule = class FileAreaList extends MenuModule { clearScreen: false, noInput: true, artDataPrep: self.displayArtDataPrepCallback.bind(self), + viewOffsets: { + col: 0, + row: self.detailsInfoArea.top[0] - 1, + }, }, callback ); diff --git a/core/fse.js b/core/fse.js index b5997ca5..c5413989 100644 --- a/core/fse.js +++ b/core/fse.js @@ -1299,6 +1299,10 @@ exports.FullScreenEditorModule = callingMenu: self, formId: formId, mciMap: artData.mciMap, + viewOffsets: { + col: 0, + row: self.header.height, + }, }; self.addViewController( diff --git a/core/menu_module.js b/core/menu_module.js index eb98ef29..ddcce17f 100644 --- a/core/menu_module.js +++ b/core/menu_module.js @@ -663,6 +663,7 @@ exports.MenuModule = class MenuModule extends PluginModule { callingMenu: this, mciMap: artData.mciMap, formId: formId, + viewOffsets: options.viewOffsets, }; return vc.loadFromMenuConfig(loadOpts, callback); @@ -696,17 +697,19 @@ exports.MenuModule = class MenuModule extends PluginModule { return form && form.getView(id); } - updateCustomViewTextsWithFilter(formName, startId, fmtObj, options) { + getCustomViewsWithFilter(formName, startId, options) { options = options || {}; - let textView; + const views = []; + + let view; let customMciId = startId; const config = this.menuConfig.config; const endId = options.endId || 99; // we'll fail to get a view before 99 while ( customMciId <= endId && - (textView = this.viewControllers[formName].getView(customMciId)) + (view = this.viewControllers[formName].getView(customMciId)) ) { const key = `${formName}InfoFormat${customMciId}`; // e.g. "mainInfoFormat10" const format = config[key]; @@ -715,20 +718,35 @@ exports.MenuModule = class MenuModule extends PluginModule { format && (!options.filter || options.filter.find(f => format.indexOf(f) > -1)) ) { - const text = stringFormat(format, fmtObj); - - if ( - options.appendMultiLine && - textView instanceof MultiLineEditTextView - ) { - textView.addText(text); - } else if (textView.getData() != text) { - textView.setText(text); - } + view.key = key; // cache + views.push(view); } ++customMciId; } + + return views; + } + + updateCustomViewTextsWithFilter(formName, startId, fmtObj, options) { + options = options || {}; + const views = this.getCustomViewsWithFilter(formName, startId, options); + const config = this.menuConfig.config; + + views.forEach(view => { + const format = config[view.key]; + const text = stringFormat(format, fmtObj); + + if (options.appendMultiLine && view instanceof MultiLineEditTextView) { + view.addText(text); + } else { + if (view.getData() != text) { + view.setText(text); + } else { + view.redraw(); + } + } + }); } refreshPredefinedMciViewsByCode(formName, mciCodes) { diff --git a/core/scanner_tossers/ftn_bso.js b/core/scanner_tossers/ftn_bso.js index f1593c5e..c4bc7878 100644 --- a/core/scanner_tossers/ftn_bso.js +++ b/core/scanner_tossers/ftn_bso.js @@ -1743,7 +1743,7 @@ function FTNMessageScanTossModule() { const totalSuccess = makeCount(finalStats.areaSuccess); Log.info( finalStats, - `Import completed successfully with ${totalSuccess} messages` + `Import completed with ${totalSuccess} new message(s)` ); } diff --git a/core/view.js b/core/view.js index 5063322a..f568a09a 100644 --- a/core/view.js +++ b/core/view.js @@ -49,6 +49,7 @@ function View(options) { this.position = { x: 0, y: 0 }; this.textStyle = options.textStyle || 'normal'; this.focusTextStyle = options.focusTextStyle || this.textStyle; + this.offsetsApplied = false; if (options.id) { this.setId(options.id); diff --git a/core/view_controller.js b/core/view_controller.js index 2c252764..6a0597e7 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -150,6 +150,8 @@ function ViewController(options) { }; this.createViewsFromMCI = function (mciMap, cb) { + const views = []; + async.each( Object.keys(mciMap), (name, nextItem) => { @@ -161,6 +163,7 @@ function ViewController(options) { view.on('action', self.viewActionListener); } + views.push(view); self.addView(view); } @@ -168,7 +171,7 @@ function ViewController(options) { }, err => { self.setViewOrder(); - return cb(err); + return cb(err, views); } ); }; @@ -491,6 +494,27 @@ ViewController.prototype.resetInitialFocus = function () { } }; +ViewController.prototype.applyViewOffsets = function ( + views, + offsetCol, + offsetRow, + force = false +) { + if (!Array.isArray(views)) { + views = [views]; + } + + views.forEach(view => { + if (force || !view.offsetsApplied) { + view.offsetsApplied = true; + view.setPosition({ + col: view.position.col + offsetCol, + row: view.position.row + offsetRow, + }); + } + }); +}; + ViewController.prototype.switchFocus = function (id) { // // Perform focus switching validation now @@ -759,7 +783,14 @@ ViewController.prototype.loadFromMenuConfig = function (options, cb) { ); }, function createViews(callback) { - self.createViewsFromMCI(options.mciMap, function viewsCreated(err) { + self.createViewsFromMCI(options.mciMap, (err, views) => { + if (!err && _.isObject(options.viewOffsets)) { + self.applyViewOffsets( + views, + options.viewOffsets.col, + options.viewOffsets.row + ); + } callback(err); }); },