2021-02-22 20:27:58 +00:00
|
|
|
window.hubl.getRoute = (type, returnFirst = false) => {
|
2021-05-20 14:59:49 +00:00
|
|
|
let availables = window.hubl.components.filter(c => c.type == type || c.uniq == type);
|
|
|
|
window.hubl.components.forEach(c => {
|
|
|
|
if (c.extensions) {
|
|
|
|
c.extensions.forEach(e => {
|
|
|
|
if (e.type == type || e.uniq == type) {
|
2021-05-20 15:05:06 +00:00
|
|
|
availables.push(e);
|
2021-05-20 14:59:49 +00:00
|
|
|
}
|
|
|
|
});
|
2021-05-20 14:54:00 +00:00
|
|
|
}
|
|
|
|
});
|
2021-05-20 14:59:49 +00:00
|
|
|
if (availables.length > 1) {
|
|
|
|
if (returnFirst) {
|
2021-02-22 20:27:58 +00:00
|
|
|
return availables[0].route;
|
|
|
|
} else {
|
2021-05-20 14:59:49 +00:00
|
|
|
return availables[availables.length - 1].route;
|
2021-02-22 20:27:58 +00:00
|
|
|
}
|
2021-05-20 14:59:49 +00:00
|
|
|
} else if (availables.length < 1) {
|
2021-02-22 20:27:58 +00:00
|
|
|
console.error(`No component found for route ${type}`);
|
|
|
|
} else {
|
|
|
|
return availables[0].route;
|
|
|
|
}
|
|
|
|
}
|