Add getViewsByMciCode()
* Store MCI code in View when created from MCI * Allow retrieval by MCI code
This commit is contained in:
parent
cb8d331415
commit
d244cd25fa
|
@ -199,5 +199,9 @@ MCIViewFactory.prototype.createFromMCI = function(mci) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(view) {
|
||||||
|
view.mciCode = mci.code;
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
};
|
};
|
||||||
|
|
|
@ -140,9 +140,9 @@ function ViewController(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.createViewsFromMCI = function(mciMap, cb) {
|
this.createViewsFromMCI = function(mciMap, cb) {
|
||||||
async.each(Object.keys(mciMap), function entry(name, nextItem) {
|
async.each(Object.keys(mciMap), (name, nextItem) => {
|
||||||
var mci = mciMap[name];
|
const mci = mciMap[name];
|
||||||
var view = self.mciViewFactory.createFromMCI(mci);
|
const view = self.mciViewFactory.createFromMCI(mci);
|
||||||
|
|
||||||
if(view) {
|
if(view) {
|
||||||
if(false === self.noInput) {
|
if(false === self.noInput) {
|
||||||
|
@ -152,11 +152,11 @@ function ViewController(options) {
|
||||||
self.addView(view);
|
self.addView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
nextItem(null);
|
return nextItem(null);
|
||||||
},
|
},
|
||||||
function complete(err) {
|
err => {
|
||||||
self.setViewOrder();
|
self.setViewOrder();
|
||||||
cb(err);
|
return cb(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -426,6 +426,20 @@ ViewController.prototype.getView = function(id) {
|
||||||
return this.views[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() {
|
ViewController.prototype.getFocusedView = function() {
|
||||||
return this.focusedView;
|
return this.focusedView;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue