feature: improve route for extensions
This commit is contained in:
parent
b7085a171e
commit
e07cafb5c8
@ -1,17 +1,21 @@
|
||||
window.hubl.getRoute = (type, returnFirst = false) => {
|
||||
let availables = window.hubl.components.filter(c=>c.type==type||c.uniq==type);
|
||||
availables.map(c => {
|
||||
if(c.extensions) {
|
||||
c.extensions.forEach(e => availables.push(e.type));
|
||||
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) {
|
||||
availables.push(e.type);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if(availables.length > 1) {
|
||||
if(returnFirst) {
|
||||
if (availables.length > 1) {
|
||||
if (returnFirst) {
|
||||
return availables[0].route;
|
||||
} else {
|
||||
return availables[availables.length-1].route;
|
||||
return availables[availables.length - 1].route;
|
||||
}
|
||||
} else if(availables.length < 1) {
|
||||
} else if (availables.length < 1) {
|
||||
console.error(`No component found for route ${type}`);
|
||||
} else {
|
||||
return availables[0].route;
|
||||
|
@ -11,19 +11,23 @@
|
||||
-
|
||||
let routes = new Set();
|
||||
const getRoute = (type, returnFirst = false) => {
|
||||
let availables = components.filter(c=>c.type==type||c.uniq==type);
|
||||
availables.map(c => {
|
||||
if(c.extensions) {
|
||||
c.extensions.forEach(e => availables.push(e.type));
|
||||
let availables = components.filter(c => c.type == type || c.uniq == type);
|
||||
components.forEach(c => {
|
||||
if (c.extensions) {
|
||||
c.extensions.forEach(e => {
|
||||
if (e.type == type || e.uniq == type) {
|
||||
availables.push(e.type);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if(availables.length > 1) {
|
||||
if(returnFirst) {
|
||||
if (availables.length > 1) {
|
||||
if (returnFirst) {
|
||||
return availables[0].route;
|
||||
} else {
|
||||
return availables[availables.length-1].route;
|
||||
return availables[availables.length - 1].route;
|
||||
}
|
||||
} else if(availables.length < 1) {
|
||||
} else if (availables.length < 1) {
|
||||
console.error(`No component found for route ${type}`);
|
||||
} else {
|
||||
return availables[0].route;
|
||||
|
Loading…
Reference in New Issue
Block a user