Fix some view offsets that broke with CPR removal

* Fix Quote builder
* Fix File Browser details
* Added 'viewOffsets' ability to loadFromMenuConfig() and friends
* Add MenuModule.getCustomViewsWithFilter() -> Array[] of views
* Add ViewController.applyViewOffsets()
This commit is contained in:
Bryan Ashby 2022-08-15 22:23:14 -06:00
parent 56f03ff847
commit b48d133229
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
6 changed files with 78 additions and 18 deletions

View File

@ -345,14 +345,16 @@ exports.getModule = class FileAreaList extends MenuModule {
} }
displayArtDataPrepCallback(name, artData, viewController) { displayArtDataPrepCallback(name, artData, viewController) {
if ('details' === name) { if (name === details) {
try { try {
this.detailsInfoArea = { this.detailsInfoArea = {
top: artData.mciMap.XY2.position, top: artData.mciMap.XY2.position,
bottom: artData.mciMap.XY3.position, bottom: artData.mciMap.XY3.position,
}; };
} catch (e) { } 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, clearScreen: false,
noInput: true, noInput: true,
artDataPrep: self.displayArtDataPrepCallback.bind(self), artDataPrep: self.displayArtDataPrepCallback.bind(self),
viewOffsets: {
col: 0,
row: self.detailsInfoArea.top[0] - 1,
},
}, },
callback callback
); );

View File

@ -1299,6 +1299,10 @@ exports.FullScreenEditorModule =
callingMenu: self, callingMenu: self,
formId: formId, formId: formId,
mciMap: artData.mciMap, mciMap: artData.mciMap,
viewOffsets: {
col: 0,
row: self.header.height,
},
}; };
self.addViewController( self.addViewController(

View File

@ -663,6 +663,7 @@ exports.MenuModule = class MenuModule extends PluginModule {
callingMenu: this, callingMenu: this,
mciMap: artData.mciMap, mciMap: artData.mciMap,
formId: formId, formId: formId,
viewOffsets: options.viewOffsets,
}; };
return vc.loadFromMenuConfig(loadOpts, callback); return vc.loadFromMenuConfig(loadOpts, callback);
@ -696,17 +697,19 @@ exports.MenuModule = class MenuModule extends PluginModule {
return form && form.getView(id); return form && form.getView(id);
} }
updateCustomViewTextsWithFilter(formName, startId, fmtObj, options) { getCustomViewsWithFilter(formName, startId, options) {
options = options || {}; options = options || {};
let textView; const views = [];
let view;
let customMciId = startId; let customMciId = startId;
const config = this.menuConfig.config; const config = this.menuConfig.config;
const endId = options.endId || 99; // we'll fail to get a view before 99 const endId = options.endId || 99; // we'll fail to get a view before 99
while ( while (
customMciId <= endId && customMciId <= endId &&
(textView = this.viewControllers[formName].getView(customMciId)) (view = this.viewControllers[formName].getView(customMciId))
) { ) {
const key = `${formName}InfoFormat${customMciId}`; // e.g. "mainInfoFormat10" const key = `${formName}InfoFormat${customMciId}`; // e.g. "mainInfoFormat10"
const format = config[key]; const format = config[key];
@ -715,20 +718,35 @@ exports.MenuModule = class MenuModule extends PluginModule {
format && format &&
(!options.filter || options.filter.find(f => format.indexOf(f) > -1)) (!options.filter || options.filter.find(f => format.indexOf(f) > -1))
) { ) {
const text = stringFormat(format, fmtObj); view.key = key; // cache
views.push(view);
if (
options.appendMultiLine &&
textView instanceof MultiLineEditTextView
) {
textView.addText(text);
} else if (textView.getData() != text) {
textView.setText(text);
}
} }
++customMciId; ++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) { refreshPredefinedMciViewsByCode(formName, mciCodes) {

View File

@ -1743,7 +1743,7 @@ function FTNMessageScanTossModule() {
const totalSuccess = makeCount(finalStats.areaSuccess); const totalSuccess = makeCount(finalStats.areaSuccess);
Log.info( Log.info(
finalStats, finalStats,
`Import completed successfully with ${totalSuccess} messages` `Import completed with ${totalSuccess} new message(s)`
); );
} }

View File

@ -49,6 +49,7 @@ function View(options) {
this.position = { x: 0, y: 0 }; this.position = { x: 0, y: 0 };
this.textStyle = options.textStyle || 'normal'; this.textStyle = options.textStyle || 'normal';
this.focusTextStyle = options.focusTextStyle || this.textStyle; this.focusTextStyle = options.focusTextStyle || this.textStyle;
this.offsetsApplied = false;
if (options.id) { if (options.id) {
this.setId(options.id); this.setId(options.id);

View File

@ -150,6 +150,8 @@ function ViewController(options) {
}; };
this.createViewsFromMCI = function (mciMap, cb) { this.createViewsFromMCI = function (mciMap, cb) {
const views = [];
async.each( async.each(
Object.keys(mciMap), Object.keys(mciMap),
(name, nextItem) => { (name, nextItem) => {
@ -161,6 +163,7 @@ function ViewController(options) {
view.on('action', self.viewActionListener); view.on('action', self.viewActionListener);
} }
views.push(view);
self.addView(view); self.addView(view);
} }
@ -168,7 +171,7 @@ function ViewController(options) {
}, },
err => { err => {
self.setViewOrder(); 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) { ViewController.prototype.switchFocus = function (id) {
// //
// Perform focus switching validation now // Perform focus switching validation now
@ -759,7 +783,14 @@ ViewController.prototype.loadFromMenuConfig = function (options, cb) {
); );
}, },
function createViews(callback) { 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); callback(err);
}); });
}, },