diff --git a/core/mci_view_factory.js b/core/mci_view_factory.js index eb783d41..eab2787c 100644 --- a/core/mci_view_factory.js +++ b/core/mci_view_factory.js @@ -199,5 +199,9 @@ MCIViewFactory.prototype.createFromMCI = function(mci) { break; } + if(view) { + view.mciCode = mci.code; + } + return view; }; diff --git a/core/view_controller.js b/core/view_controller.js index 71911f28..65a5a1b3 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -140,9 +140,9 @@ function ViewController(options) { }; this.createViewsFromMCI = function(mciMap, cb) { - async.each(Object.keys(mciMap), function entry(name, nextItem) { - var mci = mciMap[name]; - var view = self.mciViewFactory.createFromMCI(mci); + async.each(Object.keys(mciMap), (name, nextItem) => { + const mci = mciMap[name]; + const view = self.mciViewFactory.createFromMCI(mci); if(view) { if(false === self.noInput) { @@ -152,11 +152,11 @@ function ViewController(options) { self.addView(view); } - nextItem(null); + return nextItem(null); }, - function complete(err) { + err => { self.setViewOrder(); - cb(err); + return cb(err); }); }; @@ -426,6 +426,20 @@ ViewController.prototype.getView = function(id) { return this.views[id]; }; +ViewController.prototype.getViewsByMciCode = function(mciCode) { + if(!Array.isArray(mciCode)) { + mciCode = [ mciCode ]; + } + + const views = []; + _.each(this.views, v => { + if(mciCode.includes(v.mciCode)) { + views.push(v); + } + }); + return views; +}; + ViewController.prototype.getFocusedView = function() { return this.focusedView; };