Commit 9aee7186 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos
Browse files

Merge branch 'milestone-fix-collapse-search' into 'milestone-logbook-search-settings'

fix search result in collapsed events

See merge request !523
parents 4aeedb65 da26127c
Pipeline #48272 passed with stage
in 5 minutes and 7 seconds
...@@ -16,14 +16,18 @@ function collapse(items) { ...@@ -16,14 +16,18 @@ function collapse(items) {
const collapsed = []; const collapsed = [];
for (let i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
const event = items[i]; const event = items[i];
if (event.category) {
if (event.category && !isEventSearchedResult(event)) {
if ( if (
event.category.toLowerCase() === EVENT_CATEGORY_COMMANDLINE && event.category.toLowerCase() === EVENT_CATEGORY_COMMANDLINE &&
!event.previousVersionEvent !event.previousVersionEvent
) { ) {
const lastEvent = collapsed[collapsed.length - 1]; const lastEvent = collapsed[collapsed.length - 1];
if (lastEvent && lastEvent.category) { if (lastEvent && lastEvent.category) {
if (lastEvent.category.toLowerCase() === EVENT_CATEGORY_COMMANDLINE) { if (
lastEvent.category.toLowerCase() === EVENT_CATEGORY_COMMANDLINE &&
!isEventSearchedResult(lastEvent)
) {
if (!lastEvent.events) { if (!lastEvent.events) {
lastEvent.events = [event]; lastEvent.events = [event];
} else { } else {
...@@ -41,6 +45,12 @@ function collapse(items) { ...@@ -41,6 +45,12 @@ function collapse(items) {
return collapsed; return collapsed;
} }
function isEventSearchedResult(event) {
const { hash } = window.location;
const id = hash ? hash.replace('#', '') : undefined;
return id && id === event._id;
}
/** Returns the list of items to be displayed in the table: events + days */ /** Returns the list of items to be displayed in the table: events + days */
function getItems(events, automaticCollapsing) { function getItems(events, automaticCollapsing) {
const eventsCopy = cloneDeep(events); const eventsCopy = cloneDeep(events);
...@@ -86,11 +96,14 @@ function EventList(props) { ...@@ -86,11 +96,14 @@ function EventList(props) {
return <UserMessage type="info" message="No log found." />; return <UserMessage type="info" message="No log found." />;
} }
const collapseEvents =
search && search.length > 0 ? false : automaticCollapsing;
return ( return (
<> <>
<Table responsive style={{ border: 0 }}> <Table responsive style={{ border: 0 }}>
<tbody> <tbody>
{getItems(events, automaticCollapsing).map((event, index) => { {getItems(events, collapseEvents).map((event, index) => {
if (event.type === 'date') { if (event.type === 'date') {
return ( return (
<tr <tr
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment