[HIMA-87] Implemented after closing tab jump to dashboard if no other tabs are available

This commit is contained in:
Eraldo Hasanaj
2019-02-12 17:52:38 +01:00
parent 387f42ee14
commit e9d39ff1af
6 changed files with 25 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { Process } from 'src/app/core/models/process.model';
import { Router } from '@angular/router';
import { Store } from '@ngxs/store';
import { Store, Select } from '@ngxs/store';
import {
DeleteProcess,
SelectProcess,
@@ -12,6 +12,8 @@ import { Cart } from '../../core/models/cart.model';
import { AddBreadcrumb } from '../../core/store/actions/process.actions';
import { Breadcrumb } from '../../core/models/breadcrumb.model';
import { ProcessDeleteDialogComponent } from 'src/app/modules/process/process-delete-dialog/process-delete-dialog.component';
import { ProcessState } from 'src/app/core/store/state/process.state';
import { Observable } from 'rxjs';
@Component({
selector: 'app-process-tab',
@@ -21,6 +23,7 @@ import { ProcessDeleteDialogComponent } from 'src/app/modules/process/process-de
export class ProcessTabComponent implements OnInit {
@Input() process: Process;
@Input() processes: Array<Process>;
@Select(ProcessState.getProcessCount) processCount: Observable<number>;
@ViewChild('deleteporcessdialog') processDeleteDialogComponent: ProcessDeleteDialogComponent;
cartCount = 0;
@@ -28,6 +31,13 @@ export class ProcessTabComponent implements OnInit {
deleteProcess(process: Process) {
this.store.dispatch(new DeleteProcess(process));
this.processCount.subscribe(
(count: number) => {
if (count < 1) {
this.router.navigate(['/dashboard']);
}
}
);
}
openDeleteConfirmationDialog() {

View File

@@ -57,7 +57,6 @@ export class ProductCardComponent implements OnInit {
flatMap(ean => {
// TODO: remove mock data
if (ean === '3') {
console.log('ean 3');
return of('../../../assets/images/ResultBook4.png');
}
return this.catImageService.getImageUrl(ean);

View File

@@ -72,7 +72,6 @@ export class ProductDetailsComponent implements OnInit {
}
productDetailMapper(item: ItemDTO) {
console.log(item);
let fullDescription: string = null;
let ean: string = null;
let eanTag: string = null;
@@ -160,13 +159,13 @@ export class ProductDetailsComponent implements OnInit {
descriptionText(text: string) {
const container = document.getElementById('details-container');
let el = document.getElementById('details-text');
const el = document.getElementById('details-text');
el.innerHTML = text;
let wordArray = el.innerHTML.split(' ');
const wordArray = el.innerHTML.split(' ');
if (el.offsetHeight > container.offsetHeight && !this.shortenText) {
while(el.offsetHeight > container.offsetHeight) {
while (el.offsetHeight > container.offsetHeight) {
wordArray.pop();
el.innerHTML = wordArray.join(' ') + '...';
}
@@ -180,7 +179,7 @@ export class ProductDetailsComponent implements OnInit {
} else {
el.innerHTML = this.shortenText;
}
}
}
toggleMore() {
this.moreBtn = !this.moreBtn;

View File

@@ -50,6 +50,11 @@ export class ProcessState {
return state.recentArticles;
}
@Selector()
static getProcessCount(state: ProcessStateModel) {
return state.processes.length;
}
@Selector()
static getProducts(state: ProcessStateModel) {
return state.processes.find(t => t.selected === true).itemsDTO;
@@ -138,7 +143,7 @@ export class ProcessState {
const newProcessState = state.processes
.filter(p => p.id !== payload.id)
.map((process, index) => {
if (index === indexOfProcessToDelete) {
if (index === indexOfProcessToDelete - 1) {
selectedProcess = process;
}
return process;

View File

@@ -70,7 +70,6 @@ export class TextSearchComponent implements OnInit, AfterViewInit {
return;
}
this.filters$.subscribe(f => this.filters = f);
console.log(this.filters);
const search = <Search>{
query: this.searchParams,
fitlers: this.filters,

View File

@@ -2,6 +2,9 @@ import { Component, OnInit, EventEmitter, Output, Input } from '@angular/core';
import { ModalService } from 'src/app/core/services/modal.service';
import { Process } from 'src/app/core/models/process.model';
import { Router } from '@angular/router';
import { Select } from '@ngxs/store';
import { ProcessState } from 'src/app/core/store/state/process.state';
import { Observable } from 'rxjs';
@Component({
selector: 'app-process-delete-dialog',
@@ -38,7 +41,6 @@ export class ProcessDeleteDialogComponent implements OnInit {
delete() {
this.deleted.emit(this.process);
this.modalService.close(this.id);
this.router.navigate(['/dashboard']);
}
}