[HIMA-92] working on the strage behaviour

This commit is contained in:
Eraldo Hasanaj
2019-02-13 18:14:15 +01:00
parent 1a320ba8cf
commit bd3fa91183
3 changed files with 31 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { Component, OnInit, Input, ViewChild, Output, EventEmitter } from '@angular/core';
import { Process } from 'src/app/core/models/process.model';
import { Router } from '@angular/router';
import { Store, Select } from '@ngxs/store';
@@ -26,6 +26,7 @@ export class ProcessTabComponent implements OnInit {
@Input() processes: Array<Process>;
@Select(ProcessState.getProcesses) procecesses$: Observable<Process[]>;
@Select(ProcessState.getProcessCount) processCount: Observable<number>;
@Output() reload = new EventEmitter();
@ViewChild('deleteporcessdialog')
processDeleteDialogComponent: ProcessDeleteDialogComponent;
cartCount = 0;
@@ -55,7 +56,7 @@ export class ProcessTabComponent implements OnInit {
selectProcess(process: Process): void {
this.store.dispatch(new SelectProcess(process));
this.store.dispatch(new PreventProductLoad());
// this.processDeleteDialogComponent.delete();
this.reload.emit(true);
this.router.navigate([process.currentRoute]);
}

View File

@@ -10,7 +10,8 @@ import {
filter,
take,
debounceTime,
distinctUntilKeyChanged
distinctUntilKeyChanged,
find
} from 'rxjs/operators';
import { Select, Store } from '@ngxs/store';
import { ItemDTO } from 'dist/cat-service/lib/dtos';
@@ -36,7 +37,7 @@ import { procuctsMock } from 'mocks/products.mock';
animations: [staggerAnimation]
})
export class SearchResultsComponent implements OnInit {
@Select(ProcessState.getCurrentProcess) process$;
@Select(ProcessState.getProcesses) processes$: Observable<Process[]>;
currentSearch: Search;
products: Product[];
@Select(ProcessState.getProducts) products$: Observable<ItemDTO[]>;
@@ -52,6 +53,26 @@ export class SearchResultsComponent implements OnInit {
) {}
ngOnInit() {
this.store.select(ProcessState.getProcesses).subscribe(proc => {
if (!!proc) {
proc.map(
(process: Process) => {
if (process && process.selected === true && process.search) {
console.log('trigered');
// console.log(process.search);
// this.currentSearch = process.search;
// this.ds = new SearchDataSource(
// this.productService,
// process.search.query,
// this.store,
// []
// );
}
}
);
}
});
this.loadCurrentSearch();
if (!this.currentSearch) {
this.router.navigate(['dashboard']);
@@ -202,6 +223,7 @@ export class SearchDataSource extends DataSource<Product | undefined> {
);
this.dataStream.next(this.cachedData);
this.dataStreamDTO.next(this.cachedItemsDTO);
console.log(this.search);
if (page === 0) {
// dispatch immediately on first page load
this.store.dispatch(

View File

@@ -259,7 +259,7 @@ export class ProcessState {
return { ...process, users: users };
} else {
// If users found, add new breadcrumb for searched term
let currentBreadcrumbs = [...process.breadcrumbs];
const currentBreadcrumbs = [...process.breadcrumbs];
const missingBreadcrumb = currentBreadcrumbs.filter((breadcrumb: Breadcrumb) => breadcrumb.path === '/customer-search');
if (missingBreadcrumb.length === 0) {
currentBreadcrumbs.push(
@@ -271,14 +271,14 @@ export class ProcessState {
name: payload,
path: '/customer-search-result'
}
)
);
} else {
currentBreadcrumbs.push(
{
name: payload,
path: '/customer-search-result'
}
)
);
}
if (users.length > 0 && currentBreadcrumbs.length > 1) {
@@ -659,7 +659,7 @@ export class ProcessState {
console.log(indexOfCurrentBreadcrumb);
for (let x = breadcrumbs.length - 1; x >= 0; x--) {
if (indexOfCurrentBreadcrumb < x) {
ctx.dispatch(new actions.ChangeCurrentRoute(breadcrumbs[x-1].path));
ctx.dispatch(new actions.ChangeCurrentRoute(breadcrumbs[x - 1].path));
breadcrumbs.pop();
}
}