From 5549ff5512f6a922615832299882716826a0de95 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Tue, 7 Feb 2017 22:15:34 -0700 Subject: [PATCH] * Help pages * No results for criteria page * noHistory can be passed to gotoMenu() --- core/menu_stack.js | 5 ++++- mods/file_area_list.js | 38 ++++++++++++++++++++++++++++++++------ mods/file_base_search.js | 11 ++++++----- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/core/menu_stack.js b/core/menu_stack.js index f524ce75..f4b29460 100644 --- a/core/menu_stack.js +++ b/core/menu_stack.js @@ -99,6 +99,7 @@ module.exports = class MenuStack { if(!cb && _.isFunction(options)) { cb = options; + options = {}; } const self = this; @@ -134,7 +135,9 @@ module.exports = class MenuStack { currentModuleInfo.instance.leave(); - if(modInst.menuConfig.options.menuFlags.includes('noHistory')) { + const menuFlags = (options && Array.isArray(options.menuFlags)) ? options.menuFlags : modInst.menuConfig.options.menuFlags; + + if(menuFlags.includes('noHistory')) { this.pop().instance.leave(); // leave & remove current } } diff --git a/mods/file_area_list.js b/mods/file_area_list.js index 2f590a1f..7a36f21b 100644 --- a/mods/file_area_list.js +++ b/mods/file_area_list.js @@ -124,6 +124,9 @@ exports.getModule = class FileAreaList extends MenuModule { }, showWebDownloadLink : (formData, extraArgs, cb) => { return this.fetchAndDisplayWebDownloadLink(cb); + }, + displayHelp : (formData, extraArgs, cb) => { + return this.displayHelpPage(cb); } }; } @@ -180,7 +183,12 @@ exports.getModule = class FileAreaList extends MenuModule { return self.beforeArt(callback); }, function display(callback) { - return self.displayBrowsePage(false, callback); + return self.displayBrowsePage(false, err => { + if(err && 'NORESULTS' === err.reasonCode) { + self.gotoMenu(self.menuConfig.config.noResultsMenu || 'fileBaseListEntriesNoResults'); + } + return callback(err); + }); } ], () => { @@ -334,16 +342,22 @@ exports.getModule = class FileAreaList extends MenuModule { async.series( [ - function prepArtAndViewController(callback) { - return self.displayArtAndPrepViewController('browse', { clearScreen : clearScreen }, callback); - }, function fetchEntryData(callback) { if(self.fileList) { return callback(null); } return self.loadFileIds(false, callback); // false=do not force }, - function loadCurrentFileInfo(callback) { + function checkEmptyResults(callback) { + if(0 === self.fileList.length) { + return callback(Errors.General('No results for criteria', 'NORESULTS')); + } + return callback(null); + }, + function prepArtAndViewController(callback) { + return self.displayArtAndPrepViewController('browse', { clearScreen : clearScreen }, callback); + }, + function loadCurrentFileInfo(callback) { self.currentFileEntry = new FileEntry(); self.currentFileEntry.load( self.fileList[ self.fileListPosition ], err => { @@ -381,7 +395,7 @@ exports.getModule = class FileAreaList extends MenuModule { } } ], - err => { + err => { if(cb) { return cb(err); } @@ -428,6 +442,18 @@ exports.getModule = class FileAreaList extends MenuModule { } ); } + + displayHelpPage(cb) { + this.displayAsset( + this.menuConfig.config.art.help, + { clearScreen : true }, + () => { + this.client.waitForKeyPress( () => { + return this.displayBrowsePage(true, cb); + }); + } + ); + } fetchAndDisplayWebDownloadLink(cb) { const self = this; diff --git a/mods/file_base_search.js b/mods/file_base_search.js index 87c127cd..e984e1a4 100644 --- a/mods/file_base_search.js +++ b/mods/file_base_search.js @@ -58,9 +58,9 @@ exports.getModule = class FileBaseSearch extends MenuModule { self.availAreas = [ { name : '-ALL-' } ].concat(getSortedAvailableFileAreas(self.client) || []); const areasView = vc.getView(MciViewIds.search.area); - if(areasView) { - areasView.setItems( self.availAreas.map( a => a.name ) ); - } + areasView.setItems( self.availAreas.map( a => a.name ) ); + areasView.redraw(); + vc.switchFocus(MciViewIds.search.searchTerms); return callback(null); } @@ -110,8 +110,9 @@ exports.getModule = class FileBaseSearch extends MenuModule { const menuOpts = { extraArgs : { - filterCriteria : filterCriteria, - } + filterCriteria : filterCriteria, + }, + menuFlags : [ 'noHistory' ], }; return this.gotoMenu(this.menuConfig.config.fileBaseListEntriesMenu || 'fileBaseListEntries', menuOpts, cb);