Skip to content

Commit

Permalink
Mkarimi/filter toc (#131)
Browse files Browse the repository at this point in the history
* Filter toc with search text

* Filter TOC by version
  • Loading branch information
karimi authored Jun 4, 2024
1 parent ff1e85c commit f319c4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions quasar_site/src/ViewModel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { version } from "core-js";
import ApiInfo from "./api_info.json";

const DataTypes = {
Expand Down Expand Up @@ -78,6 +77,7 @@ const ViewModel = {
header: "secondary",
deprecated: x.deprecated,
obsolete: x.obsolete,
since: x.since,
children:
overloads.length > 1
? overloads.map((o) => {
Expand All @@ -86,6 +86,7 @@ const ViewModel = {
this.memberName(o, childType.toLowerCase())
)[1],
path: `${o.path}#${this.signatureAnchorRef(o.signature)}`,
since: o.since,
};
})
: [],
Expand Down Expand Up @@ -244,7 +245,6 @@ const ViewModel = {
if (!path) {
return;
}
// console.log("finding:", path);
path = path.toLowerCase();
let found = null;

Expand All @@ -266,6 +266,7 @@ const ViewModel = {
_lastFound = found;

if (
found &&
_maxVersion &&
found.since &&
this.sinceIsGreater(found.since, _maxVersion)
Expand Down
9 changes: 7 additions & 2 deletions quasar_site/src/layouts/MainLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</q-header>
<q-drawer v-model="leftDrawerOpen" behavior="desktop" show-if-above bordered id="myDrawer" :width="drawerWidth"
@mouseover="() => shouldAutoScroll = false" @mouseout="() => shouldAutoScroll = true">
<q-tree no-transition ref=myTree :nodes="api" accordion dense node-key="path" selected-color="accent"
<q-tree no-transition ref=myTree :nodes="api" accordion dense node-key="path" selected-color="accent" :filter="filterVersion" :filter-method="filterTocByVersion"
v-model:selected="selectedNode" v-model:expanded="expanded" :duration="200" @lazy-load="onLazyLoad">
<template v-slot:default-header="prop" >
<div class="row items-center">
Expand Down Expand Up @@ -129,6 +129,12 @@ export default {
})
}
},
filterTocByVersion (node, filter) {
if(node.since){
return !ViewModel.sinceIsGreater(node.since, filter)
}
return true
},
resizeDrawer(ev) {
const drawerEl = document.getElementById("myDrawer");
const drawerParent = drawerEl.parentElement;
Expand All @@ -148,7 +154,6 @@ export default {
},
onChangeSelectedItem(item, updateRoute) {
const newSelectedNode = ViewModel.itemPath(item);
console.log("onchangeselecteditem");
if (newSelectedNode !== this.selectedNode) {
this.routePushEnabled = updateRoute;
this.selectedNode = newSelectedNode;
Expand Down

0 comments on commit f319c4f

Please sign in to comment.