mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 13:48:12 +00:00
[Notebook] Search includes sections/pages with no initial entries (#3777)
This commit is contained in:
@ -404,18 +404,16 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const output = [];
|
const output = [];
|
||||||
|
const sections = this.internalDomainObject.configuration.sections;
|
||||||
const entries = this.internalDomainObject.configuration.entries;
|
const entries = this.internalDomainObject.configuration.entries;
|
||||||
const sectionKeys = Object.keys(entries);
|
|
||||||
const searchTextLower = this.search.toLowerCase();
|
const searchTextLower = this.search.toLowerCase();
|
||||||
const originalSearchText = this.search;
|
const originalSearchText = this.search;
|
||||||
let sectionTrackPageHit;
|
let sectionTrackPageHit;
|
||||||
let pageTrackEntryHit;
|
let pageTrackEntryHit;
|
||||||
let sectionTrackEntryHit;
|
let sectionTrackEntryHit;
|
||||||
|
|
||||||
sectionKeys.forEach(sectionKey => {
|
sections.forEach(section => {
|
||||||
const pages = entries[sectionKey];
|
const pages = section.pages;
|
||||||
const pageKeys = Object.keys(pages);
|
|
||||||
const section = this.getSection(sectionKey);
|
|
||||||
let resultMetadata = {
|
let resultMetadata = {
|
||||||
originalSearchText,
|
originalSearchText,
|
||||||
sectionHit: section.name && section.name.toLowerCase().includes(searchTextLower)
|
sectionHit: section.name && section.name.toLowerCase().includes(searchTextLower)
|
||||||
@ -423,9 +421,7 @@ export default {
|
|||||||
sectionTrackPageHit = false;
|
sectionTrackPageHit = false;
|
||||||
sectionTrackEntryHit = false;
|
sectionTrackEntryHit = false;
|
||||||
|
|
||||||
pageKeys.forEach(pageKey => {
|
pages.forEach(page => {
|
||||||
const pageEntries = entries[sectionKey][pageKey];
|
|
||||||
const page = this.getPage(section, pageKey);
|
|
||||||
resultMetadata.pageHit = page.name && page.name.toLowerCase().includes(searchTextLower);
|
resultMetadata.pageHit = page.name && page.name.toLowerCase().includes(searchTextLower);
|
||||||
pageTrackEntryHit = false;
|
pageTrackEntryHit = false;
|
||||||
|
|
||||||
@ -433,23 +429,29 @@ export default {
|
|||||||
sectionTrackPageHit = true;
|
sectionTrackPageHit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pageEntries.forEach(entry => {
|
// check for no entries first
|
||||||
const entryHit = entry.text && entry.text.toLowerCase().includes(searchTextLower);
|
if (entries[section.id]) {
|
||||||
|
const pageEntries = entries[section.id][page.id];
|
||||||
|
|
||||||
// any entry hit goes in, it's the most unique of the hits
|
pageEntries.forEach(entry => {
|
||||||
if (entryHit) {
|
const entryHit = entry.text && entry.text.toLowerCase().includes(searchTextLower);
|
||||||
resultMetadata.entryHit = entryHit;
|
|
||||||
pageTrackEntryHit = true;
|
// any entry hit goes in, it's the most unique of the hits
|
||||||
sectionTrackEntryHit = true;
|
if (entryHit) {
|
||||||
|
resultMetadata.entryHit = entryHit;
|
||||||
|
pageTrackEntryHit = true;
|
||||||
|
sectionTrackEntryHit = true;
|
||||||
|
|
||||||
|
output.push(objectCopy({
|
||||||
|
metadata: resultMetadata,
|
||||||
|
section,
|
||||||
|
page,
|
||||||
|
entry
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
output.push(objectCopy({
|
|
||||||
metadata: resultMetadata,
|
|
||||||
section,
|
|
||||||
page,
|
|
||||||
entry
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// all entries checked, now in pages,
|
// all entries checked, now in pages,
|
||||||
// if page hit, but not in results, need to add
|
// if page hit, but not in results, need to add
|
||||||
if (resultMetadata.pageHit && !pageTrackEntryHit) {
|
if (resultMetadata.pageHit && !pageTrackEntryHit) {
|
||||||
@ -463,6 +465,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// all pages checked, now in sections,
|
// all pages checked, now in sections,
|
||||||
// if section hit, but not in results, need to add and default page
|
// if section hit, but not in results, need to add and default page
|
||||||
if (resultMetadata.sectionHit && !sectionTrackPageHit && !sectionTrackEntryHit) {
|
if (resultMetadata.sectionHit && !sectionTrackPageHit && !sectionTrackEntryHit) {
|
||||||
@ -472,7 +475,7 @@ export default {
|
|||||||
output.push(objectCopy({
|
output.push(objectCopy({
|
||||||
metadata: resultMetadata,
|
metadata: resultMetadata,
|
||||||
section,
|
section,
|
||||||
page: this.getPage(section, pageKeys[0])
|
page: pages[0]
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +195,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
overflow-y: auto;
|
||||||
|
|
||||||
> * + * {
|
> * + * {
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
|
Reference in New Issue
Block a user