Fixed HTML generation ignoring hidden property.
This commit is contained in:
parent
3a833c8396
commit
f878c679d0
@ -80,8 +80,14 @@ class Docs {
|
||||
});
|
||||
|
||||
routes.forEach(routingItem => {
|
||||
if (!routingItem.hasOwnProperty("hidden") || !routingItem["hidden"]) {
|
||||
nav.appendChild(routingItem.buildSelf());
|
||||
if (routingItem["hidden"] === false || typeof routingItem["hidden"] === "undefined") {
|
||||
const el = routingItem.buildSelf();
|
||||
|
||||
if (typeof el !== "undefined") {
|
||||
nav.appendChild(el);
|
||||
}
|
||||
} else {
|
||||
console.log(`skipped ${routingItem.name}`);
|
||||
}
|
||||
});
|
||||
|
||||
@ -214,14 +220,24 @@ class Route extends RoutingItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} force Wether to force generation or not despite the hidden property.
|
||||
* @returns {HTMLAnchorElement} The Route as an HTML link.
|
||||
*/
|
||||
buildSelf() {
|
||||
const element = document.createElement("a");
|
||||
element.href = `#${this.filepath}`;
|
||||
element.innerText = this.name;
|
||||
buildSelf(force = false) {
|
||||
if (this.hidden === false || typeof this.hidden === "undefined") {
|
||||
force = true
|
||||
}
|
||||
|
||||
return element;
|
||||
if (force) {
|
||||
const element = document.createElement("a");
|
||||
|
||||
element.href = `#${this.filepath}`;
|
||||
element.innerText = this.name;
|
||||
|
||||
return element;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -278,41 +294,40 @@ class RoutingNode extends RoutingItem {
|
||||
/**
|
||||
* @returns {HTMLUListElement} The RoutingNode as an HTML unordered list.
|
||||
*/
|
||||
buildSelf(prefix, suffix) {
|
||||
if (typeof prefix === 'undefined') {
|
||||
prefix = '';
|
||||
} else {
|
||||
prefix += '/';
|
||||
buildSelf(force = false) {
|
||||
if (this.hidden === false || typeof this.hidden === "undefined") {
|
||||
force = true
|
||||
}
|
||||
|
||||
if (typeof suffix === 'undefined') {
|
||||
suffix = '';
|
||||
if (force) {
|
||||
const element = document.createElement('section');
|
||||
element.classList.add("node", "hide");
|
||||
|
||||
|
||||
const heading = document.createElement('div');
|
||||
heading.innerText = this.name;
|
||||
heading.addEventListener('click', toggleDisplay);
|
||||
|
||||
const list = document.createElement('ul');
|
||||
// list.classList.add("hide");
|
||||
this.routes.forEach(entry => {
|
||||
const childEl = document.createElement('li');
|
||||
const el = entry.buildSelf();
|
||||
|
||||
if (typeof el !== "undefined") {
|
||||
childEl.appendChild(el);
|
||||
}
|
||||
|
||||
list.appendChild(childEl);
|
||||
});
|
||||
|
||||
element.appendChild(heading);
|
||||
element.appendChild(list);
|
||||
|
||||
return element;
|
||||
} else {
|
||||
suffix += '/';
|
||||
return;
|
||||
}
|
||||
|
||||
const element = document.createElement('section');
|
||||
element.classList.add("node","hide");
|
||||
|
||||
|
||||
const heading = document.createElement('div');
|
||||
heading.innerText = this.name;
|
||||
heading.addEventListener('click', toggleDisplay);
|
||||
|
||||
const list = document.createElement('ul');
|
||||
// list.classList.add("hide");
|
||||
this.routes.forEach(entry => {
|
||||
const childEl = document.createElement('li');
|
||||
|
||||
childEl.appendChild(entry.buildSelf());
|
||||
|
||||
list.appendChild(childEl);
|
||||
});
|
||||
|
||||
element.appendChild(heading);
|
||||
element.appendChild(list);
|
||||
|
||||
return element;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user