diff --git a/quasar_site/src/ViewModel.js b/quasar_site/src/ViewModel.js index 331e8644..a0d5eb77 100644 --- a/quasar_site/src/ViewModel.js +++ b/quasar_site/src/ViewModel.js @@ -16,7 +16,6 @@ let _searchInstance = null; let _selectedPath = ""; let _lastFound = null; let _pathMap = {}; -let _maxVersion = null; let updateTree = (path, children) => (obj) => { if (obj.path === path) { @@ -152,9 +151,6 @@ const ViewModel = { _viewmodel = null; _searchInstance = null; }, - setMaxVersion(v) { - _maxVersion = v; - }, getTree() { if (_viewmodel) return _viewmodel; let viewmodel = null; @@ -162,16 +158,6 @@ const ViewModel = { // console.log('creating viewodel') const namespaceDict = {}; ApiInfo.forEach((type) => { - if ( - _maxVersion && - type.since && - this.sinceIsGreater(type.since, _maxVersion) - ) { - // console.log( - // `not including ${type.name} because ${type.since} is newer than ${_maxVersion}` - // ); - return; - } let summary = ""; if (type.summary) summary = type.summary; if (type.dataType === DataTypes.NAMESPACE) { @@ -249,13 +235,6 @@ const ViewModel = { let found = null; if (_lastFound && this.itemPath(_lastFound) === path) { - if ( - _maxVersion && - _lastFound.since && - this.sinceIsGreater(_lastFound.since, _maxVersion) - ) { - return; - } return _lastFound; } @@ -265,14 +244,6 @@ const ViewModel = { }); _lastFound = found; - if ( - found && - _maxVersion && - found.since && - this.sinceIsGreater(found.since, _maxVersion) - ) { - return; - } return found; }, setSelectedItem(item, updateRoute = true) { @@ -496,17 +467,6 @@ const ViewModel = { getSearchList() { const items = []; ApiInfo.forEach((entry) => { - // skip namespaces - if ( - _maxVersion && - entry.since && - this.sinceIsGreater(entry.since, _maxVersion) - ) { - // console.log( - // `not including ${entry.name} because ${entry.since} is newer than ${_maxVersion}` - // ); - return; - } if (entry.dataType === "namespace") return; const dataTypeUrl = (entry.namespace + "." + entry.name).toLowerCase(); const typename = entry.namespace + "." + entry.name; @@ -521,18 +481,14 @@ const ViewModel = { items.push(node); if (entry.properties) { entry.properties.forEach((prop) => { - if ( - _maxVersion && - prop.since && - this.sinceIsGreater(prop.since, _maxVersion) - ) { - return; - } const chunks = prop.signature.split(" "); node = { typename: typename, member: chunks[chunks.length - 1] }; if (items[items.length - 1].member === node.member) return; node.type = "property"; - node.url = dataTypeUrl + "/" + node.member.toLowerCase(); + node.url = `${dataTypeUrl}/${node.member.toLowerCase()}#${this.signatureAnchorRef( + prop.signature + )}`; + node.since = entry.since; node.keywords = dataTypeUrl.replaceAll(".", " ") + " " + node.member.toLowerCase(); if (prop.summary) node.summary = prop.summary; @@ -541,19 +497,14 @@ const ViewModel = { } if (entry.methods) { entry.methods.forEach((method) => { - if ( - _maxVersion && - method.since && - this.sinceIsGreater(method.since, _maxVersion) - ) { - return; - } let chunks = method.signature.split("("); chunks = chunks[0].split(" "); node = { typename: typename, member: chunks[chunks.length - 1] }; - if (items[items.length - 1].member === node.member) return; node.type = "method"; - node.url = dataTypeUrl + "/" + node.member.toLowerCase(); + node.url = `${dataTypeUrl}/${node.member.toLowerCase()}#${this.signatureAnchorRef( + method.signature + )}`; + node.since = method.since; node.keywords = dataTypeUrl.replaceAll(".", " ") + " " + node.member.toLowerCase(); if (method.summary) node.summary = method.summary; @@ -562,18 +513,14 @@ const ViewModel = { } if (entry.events) { entry.events.forEach((event) => { - if ( - _maxVersion && - event.since && - this.sinceIsGreater(event.since, _maxVersion) - ) { - return; - } const chunks = event.signature.split(" "); node = { typename: typename, member: chunks[chunks.length - 1] }; if (items[items.length - 1].member === node.member) return; node.type = "event"; - node.url = dataTypeUrl + "/" + node.member.toLowerCase(); + node.url = `${dataTypeUrl}/${node.member.toLowerCase()}#${this.signatureAnchorRef( + event.signature + )}`; + node.since = event.since; node.keywords = dataTypeUrl.replaceAll(".", " ") + " " + node.member.toLowerCase(); if (event.summary) node.summary = event.summary; @@ -582,18 +529,14 @@ const ViewModel = { } if (entry.operators) { entry.operators.forEach((operator) => { - if ( - _maxVersion && - operator.since && - this.sinceIsGreater(operator.since, _maxVersion) - ) { - return; - } const chunks = operator.signature.split(" "); node = { typename: typename, member: chunks[chunks.length - 1] }; if (items[items.length - 1].member === node.member) return; node.type = "operator"; - node.url = dataTypeUrl + "/" + node.member.toLowerCase(); + node.url = `${dataTypeUrl}/${node.member.toLowerCase()}#${this.signatureAnchorRef( + operator.signature + )}`; + node.since = operator.since; node.keywords = dataTypeUrl.replaceAll(".", " ") + " " + node.member.toLowerCase(); if (operator.summary) node.summary = operator.summary; @@ -602,19 +545,14 @@ const ViewModel = { } if (entry.fields) { entry.fields.forEach((field) => { - //TODO: review - if ( - _maxVersion && - field.since && - this.sinceIsGreater(field.since, _maxVersion) - ) { - return; - } const chunks = field.signature.split(" "); node = { typename: typename, member: chunks[chunks.length - 1] }; if (items[items.length - 1].member === node.member) return; node.type = "field"; - node.url = dataTypeUrl + "/" + node.member.toLowerCase(); + node.url = `${dataTypeUrl}/${node.member.toLowerCase()}#${this.signatureAnchorRef( + field.signature + )}`; + node.since = field.since; node.keywords = dataTypeUrl.replaceAll(".", " ") + " " + node.member.toLowerCase(); if (field.summary) node.summary = field.summary; @@ -631,14 +569,6 @@ const ViewModel = { if (node[memberType]) { for (let i = 0; i < members.length; i++) { - if ( - _maxVersion && - members[i].since && - this.sinceIsGreater(members[i].since, _maxVersion) - ) { - // console.log(`not including ${members[i]}`); - return; - } members[i].parent = node.namespace + "." + node.name; members[i].namespace = node.namespace; const url = this.memberUrl(memberType, members[i]); diff --git a/quasar_site/src/layouts/MainLayout.vue b/quasar_site/src/layouts/MainLayout.vue index ddb89903..ae90e1b4 100644 --- a/quasar_site/src/layouts/MainLayout.vue +++ b/quasar_site/src/layouts/MainLayout.vue @@ -85,8 +85,7 @@ export default { }, data() { const mostRecent = ViewModel.mostRecentSince(); - ViewModel.setMaxVersion(mostRecent); - const vm = ViewModel.getTree(mostRecent); + const vm = ViewModel.getTree(); const $q = useQuasar(); return { leftDrawerOpen: false, @@ -120,14 +119,7 @@ export default { methods: { onChangeVersionFilter (item) { this.filterVersion = item; - if (this.$route.query["version"] != item){ - ViewModel.resetTree(); - ViewModel.setMaxVersion(item); - this.api = ViewModel.getTree(); - this.$router.push({ query: { version: item } }).then( () =>{ - window.location.reload(); // - }) - } + this.$router.push({ query: { ...this.$route.query, version: item } }) }, filterTocByVersion (node, filter) { if(node.since){ diff --git a/quasar_site/src/pages/DataType.vue b/quasar_site/src/pages/DataType.vue index 43a1de11..a9bec1d3 100644 --- a/quasar_site/src/pages/DataType.vue +++ b/quasar_site/src/pages/DataType.vue @@ -30,49 +30,48 @@ :to="(baseUrl + 'references/' + namespace + '.' + name).toLowerCase()">references

-
- - - - -

{{ splitSignature(ViewModel.memberName(member, section.type))[0] }}{{ - splitSignature(ViewModel.memberName(member, section.type))[1] }}

  - - - From {{ member.parent }} - - - - Protected Member - - - - Virtual Member - - - - Static Member - - - - {{member.obsolete && "Obsolete"}}{{member.obsolete && member.deprecated && " | "}}{{member.deprecated && "Deprecated"}} - -
- - -
- {{ line }} -
-
-
+
+ + + +

{{ splitSignature(ViewModel.memberName(member, section.type))[0] }}{{ + splitSignature(ViewModel.memberName(member, section.type))[1] }}

  + + + From {{ member.parent }} + + + + Protected Member + + + + Virtual Member + + + + Static Member + + + + {{member.obsolete && "Obsolete"}}{{member.obsolete && member.deprecated && " | "}}{{member.deprecated && "Deprecated"}} + +
+ + +
+ {{ line }} +
+
+
@@ -114,7 +113,8 @@ export default { return { ViewModel, ExpandedSections: { - } + }, + filterVersion: "" } }, mixins: [ @@ -162,9 +162,9 @@ export default { if (item.dataType !== 'namespace') { const constructors = ViewModel.getMembers(item, "constructors", true) - if (constructors.length > 0) { + if (constructors && constructors.length > 0) { rc.push(Object.freeze({ - title: 'Constructors (' + constructors.length + ')', + title: 'Constructors', items: Object.freeze(constructors), expanded: expandedType ?'constructors' == expandedType : true, //expand everything if no hash type: 'constructors' @@ -178,7 +178,7 @@ export default { } } values = values.filter(v => v != null) - if (values.length > 0) { + if (values && values.length > 0) { rc.push(Object.freeze({ title: 'Values', items: Object.freeze(values), @@ -196,7 +196,7 @@ export default { const properties = ViewModel.getMembers(item, "properties", true) if (properties && properties.length > 0) { rc.push(Object.freeze({ - title: 'Properties (' + properties.length + ')', + title: 'Properties', items: Object.freeze(properties), expanded: expandedType ?'properties' == expandedType : true, //expand everything if no hash type: 'properties' @@ -207,7 +207,7 @@ export default { const methods = ViewModel.getMembers(item, "methods", true) if (methods && methods.length > 0) { rc.push(Object.freeze({ - title: 'Methods (' + methods.length + ')', + title: 'Methods', items: Object.freeze(methods), expanded: expandedType ?'methods' == expandedType : true, //expand everything if no hash type: 'methods' @@ -218,7 +218,7 @@ export default { const operators = ViewModel.getMembers(item, "operators", true) if (operators && operators.length > 0) { rc.push(Object.freeze({ - title: 'Operators (' + operators.length + ')', + title: 'Operators', items: Object.freeze(operators), expanded: expandedType ?'operators' == expandedType : true, //expand everything if no hash type: 'operators' @@ -229,7 +229,7 @@ export default { const fields = ViewModel.getMembers(item, "fields", true) if (fields && fields.length > 0) { rc.push(Object.freeze({ - title: 'fields (' + fields.length + ')', + title: 'Fields', items: Object.freeze(fields), expanded: expandedType ?'fields' == expandedType : true, //expand everything if no hash type: 'fields' @@ -240,7 +240,7 @@ export default { const events = ViewModel.getMembers(item, "events", true) if (events && events.length > 0) { rc.push(Object.freeze({ - title: 'Events (' + events.length + ')', + title: 'Events', items: Object.freeze(events), expanded: expandedType ?'events' == expandedType : true, //expand everything if no hash type: 'events' @@ -300,6 +300,8 @@ export default { } }, mounted() { + this.filterVersion = this.$route.query.version; + if (this.$route.params && this.$route.params.datatype) { const selectedItem = decodeURI(this.$route.fullPath.substring(this.baseUrl.length)) ViewModel.setSelectedItem(selectedItem) @@ -317,6 +319,9 @@ export default { watch: { '$route'(to, from) { // react to route changes... + // console.log("route changfe:", to) + this.filterVersion = to.query.version; + const selectedItem = to.fullPath.substring(this.baseUrl.length) ViewModel.setSelectedItem(selectedItem) @@ -334,6 +339,12 @@ export default { } }, methods: { + filterByVersion (node) { + if(node.since && this.filterVersion){ + return !ViewModel.sinceIsGreater(node.since, this.filterVersion) + } + return true + }, // takes an element object scrollToElement (el, padding) { console.log("scrolling to:", el) diff --git a/quasar_site/src/pages/SearchPage.vue b/quasar_site/src/pages/SearchPage.vue index cdb99947..eeeba340 100644 --- a/quasar_site/src/pages/SearchPage.vue +++ b/quasar_site/src/pages/SearchPage.vue @@ -2,7 +2,7 @@