mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
[HIMA-28] working on breadcrumb
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
} from '../actions/product.actions';
|
||||
import { ItemDTO } from 'dist/cat-service/lib/dtos';
|
||||
import { getCurrentProcess } from '../../utils/process.util';
|
||||
import { Search } from '../../models/search.model';
|
||||
|
||||
export class ProcessStateModel {
|
||||
processes: Process[];
|
||||
@@ -378,7 +379,10 @@ export class ProcessState {
|
||||
if (!state.processes) {
|
||||
return;
|
||||
}
|
||||
const currentProcess = getCurrentProcess(state.processes);
|
||||
const currentProcess = this.updateBreadcrumbForCurrentProcess(
|
||||
getCurrentProcess(state.processes),
|
||||
payload.query,
|
||||
'/search-results#start');
|
||||
if (
|
||||
currentProcess.search === payload &&
|
||||
currentProcess.itemsDTO &&
|
||||
@@ -577,4 +581,37 @@ export class ProcessState {
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
updateBreadcrumbForCurrentProcess(process: Process, payload: string, path: string) {
|
||||
const breadcrumbExist = process.breadcrumbs.filter(
|
||||
(breadcrumb: Breadcrumb) => breadcrumb.name === payload
|
||||
);
|
||||
if (breadcrumbExist.length > 0) {
|
||||
return process;
|
||||
}
|
||||
const updatedBreadcrumbs = process.breadcrumbs.map(
|
||||
(breadcrumb: Breadcrumb) => {
|
||||
if (breadcrumb.path === path) {
|
||||
return { name: payload, path: path };
|
||||
}
|
||||
return breadcrumb;
|
||||
}
|
||||
);
|
||||
if (updatedBreadcrumbs.length < 1) {
|
||||
return {
|
||||
...process,
|
||||
breadcrumbs: [
|
||||
...process.breadcrumbs,
|
||||
{
|
||||
name: payload,
|
||||
path: path
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
return {
|
||||
...process,
|
||||
breadcrumb: [...updatedBreadcrumbs]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user