feature: getRoute inherit extensions
This commit is contained in:
parent
8f5aed11e0
commit
03f67009ab
@ -1,12 +1,17 @@
|
|||||||
window.hubl.getRoute = (type, returnFirst = false) => {
|
window.hubl.getRoute = (type, returnFirst = false) => {
|
||||||
let availables = window.hubl.components.filter(c => c.type == type || c.uniq == type);
|
let availables = components.filter(c=>c.type==type||c.uniq==type);
|
||||||
if (availables.length > 1) {
|
availables.map(c => {
|
||||||
if (returnFirst) {
|
if(c.extensions) {
|
||||||
|
c.extensions.forEach(e => availables.push(e.type));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(availables.length > 1) {
|
||||||
|
if(returnFirst) {
|
||||||
return availables[0].route;
|
return availables[0].route;
|
||||||
} else {
|
} else {
|
||||||
console.error(`Too much components availables for route ${type}`);
|
return availables[availables.length-1].route;
|
||||||
}
|
}
|
||||||
} else if (availables.length < 1) {
|
} else if(availables.length < 1) {
|
||||||
console.error(`No component found for route ${type}`);
|
console.error(`No component found for route ${type}`);
|
||||||
} else {
|
} else {
|
||||||
return availables[0].route;
|
return availables[0].route;
|
||||||
|
Loading…
Reference in New Issue
Block a user