Merge branch 'development' of https://bitbucket.org/umwerk/instore-ma-app into development

This commit is contained in:
Eraldo Hasanaj
2019-02-13 13:10:38 +01:00
8 changed files with 67 additions and 11 deletions

View File

@@ -13,6 +13,7 @@
(inputChange)="autocomplete($event)"
placeholder="Titel, Autor, Verlag, Schlagwort, ..."
autocompletePlaceHolder="{{autocompletePlaceHolder}}"
error="{{error}}"
></app-search>
</div>
<div *ngIf="searchParams">

View File

@@ -29,6 +29,9 @@ import { Select, Store } from '@ngxs/store';
import { FilterState } from 'src/app/core/store/state/filter.state';
import { AutocompleteState } from 'src/app/core/store/state/autocomplete.state';
import { LoadAutocomplete } from 'src/app/core/store/actions/autocomplete.actions';
import { ProductService } from '../../../../core/services/product.service';
import { throttle, debounceTime, distinctUntilChanged, switchMap, map } from 'rxjs/operators';
import { ItemDTO } from 'projects/cat-service/src/lib';
@Component({
selector: 'app-text-search',
@@ -49,17 +52,25 @@ export class TextSearchComponent implements OnInit, AfterViewInit {
@Select(FilterState.getSelectedFilters) filters$: Observable<Filter[]>;
@Select(AutocompleteState.getAutocompleteResults) autocompleteResults: Observable<string>;
processes: Process[];
error = '';
@Input()
searchParams = '';
@ViewChild('searchInput') searchInput: SearchComponent;
constructor(private store: Store, private router: Router) { }
constructor(private store: Store, private router: Router, private productService: ProductService) { }
ngOnInit() {
this.loadRecentArticles();
this.searchInput.inputChange.subscribe(data => {
if (!data && this.error) {
this.error = '';
}
});
}
ngAfterViewInit() {
this.searchInput.focus();
}
@@ -69,7 +80,37 @@ export class TextSearchComponent implements OnInit, AfterViewInit {
if (!this.searchParams) {
return;
}
this.filters$.subscribe(f => this.filters = f);
this.checkIfExistAndSumbit(searchParams);
}
private checkIfExistAndSumbit(searchParams: string) {
const exists: Search = {
query: searchParams,
skip: 0,
take: 1,
fitlers: [],
firstLoad: true
}
this.productService.searchItems(exists).pipe(
map((data: ItemDTO[]) => {
return data ? data : null;
}),
debounceTime(1000),
distinctUntilChanged(),
).subscribe(data => {
if (data && data.length === 0) {
this.error = 'Ergibt keine Suchergebnisse';
} else {
this.error = '';
this.submitSearch();
}
});
}
private submitSearch() {
this.filters = this.store.selectSnapshot(FilterState.getFilters);
const search = <Search>{
query: this.searchParams,
fitlers: this.filters,
@@ -77,6 +118,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit {
skip: 0,
firstLoad: true
};
this.store.dispatch(new AllowProductLoad());
this.store.dispatch(new AddSearch(search));
this.navigateToRoute('search-results#start');
@@ -88,6 +130,7 @@ export class TextSearchComponent implements OnInit, AfterViewInit {
}
clear() {
this.error = '';
this.searchParams = null;
}

View File

@@ -7,6 +7,7 @@ import { SharedModule } from 'src/app/shared/shared.module';
import { CartReviewComponent } from './components/cart-review/cart-review.component';
import { PayMethodComponent } from './components/pay-method/pay-method.component';
import { CartConfirmationComponent } from './components/cart-confirmation/cart-confirmation.component';
import { RouterModule } from '@angular/router';
@NgModule({
declarations: [
@@ -19,6 +20,6 @@ import { CartConfirmationComponent } from './components/cart-confirmation/cart-c
PayMethodComponent,
CartConfirmationComponent
],
imports: [CommonModule, FormsModule, ReactiveFormsModule, SharedModule]
imports: [CommonModule, FormsModule, ReactiveFormsModule, SharedModule, RouterModule]
})
export class CartModule {}

View File

@@ -14,7 +14,7 @@
<div class="form-group">
<label class="placeholder form-control-placeholder" for="invoice_addrees">Rechnungsadresse</label>
<input type="text" id="invoice_addrees" class="input form-control" formControlName="invoice_addrees" required #invoicelInput>
<a class="inline-btn" >Ändern</a>
<a class="inline-btn" (click)="redirectToBilling()">Ändern</a>
</div>
<div class="line"></div>

View File

@@ -8,9 +8,6 @@
display: grid;
grid-template-rows: min-content min-content 1fr min-content;
}
.cart-title {
@@ -39,10 +36,10 @@
.cart-list {
border-radius: 5px;
box-shadow: 0px 0px 10px 0px #dce2e9;
width: 100%;
min-height: 630px;
// height: 630px;
// overflow-y: scroll;
overflow-x: hidden;
background-color: #ffffff;

View File

@@ -198,6 +198,20 @@ export class CartReviewComponent implements OnInit {
this.payMethodDialog.openDialog();
}
redirectToBilling() {
if (this.user) {
const newBread: Breadcrumb = {
name: 'Rechnungsadresse',
path: 'customer-edit/' + this.user.id + '/billing'
}
this.store.dispatch(new AddBreadcrumb(newBread));
const currentRoute = 'customer-edit/' + this.user.id + '/billing';
this.store.dispatch(new ChangeCurrentRoute(currentRoute));
this.router.navigate([currentRoute]);
}
}
private setInputData (field: string, val: string, form: FormGroup) {
form.get(field).patchValue(val);
form.get(field).disable();

View File

@@ -1,13 +1,12 @@
import { Component, OnInit } from '@angular/core';
import { ProcessState } from '../../../../core/store/state/process.state';
import { Observable, forkJoin } from 'rxjs';
import { Observable } from 'rxjs';
import { User } from '../../../../core/models/user.model';
import { Select, Store } from '@ngxs/store';
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { SetActiveUser, ChangeCurrentRoute } from '../../../../core/store/actions/process.actions';
import { Router } from '@angular/router';
import { Breadcrumb } from '../../../../core/models/breadcrumb.model';
import { switchMap } from 'rxjs/operators';
@Component({
selector: 'app-edit-customer-card',

View File

@@ -81,6 +81,7 @@
font-weight: bold;
text-align: left;
margin-left: 20px;
z-index: 100;
color: $hima-error-msg-color;
white-space: nowrap;