Feature: Lazy loading
Lazy loaded everything TODO: The cash flow module when clicking on sub-links, it reloads the whole page, it needs to be diagnosed and fixed, this problem also exists in the other modules TODO: Rename folders and modules such as account to accounts to match the url
This commit is contained in:
@ -2,8 +2,8 @@ import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/
|
||||
import {ToasterService} from '../../core/toaster.service';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ProductService} from '../product.service';
|
||||
import {Product} from '../product';
|
||||
import {ProductGroup} from '../../product-group/product-group';
|
||||
import {Product} from '../../core/product';
|
||||
import {ProductGroup} from '../../core/product-group';
|
||||
import {ConfirmDialogComponent} from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
@ -84,7 +84,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/Products');
|
||||
this.router.navigateByUrl('/products');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
@ -97,7 +97,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/Products');
|
||||
this.router.navigateByUrl('/products');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
|
||||
import {Product} from './product';
|
||||
import {Product} from '../core/product';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {ProductService} from './product.service';
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import {map, tap} from 'rxjs/operators';
|
||||
import {merge, Observable, of as observableOf} from 'rxjs';
|
||||
import {Product} from '../product';
|
||||
import {Product} from '../../core/product';
|
||||
|
||||
|
||||
export class ProductListDataSource extends DataSource<Product> {
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<button mat-button mat-icon-button *ngIf="dataSource.data.length" (click)="exportCsv()">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</button>
|
||||
<a mat-button [routerLink]="['/Product']">
|
||||
<a mat-button [routerLink]="['/products', 'new']">
|
||||
<mat-icon>add_box</mat-icon>
|
||||
Add
|
||||
</a>
|
||||
@ -23,7 +23,7 @@
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="['/Product', row.id]">{{row.name}} ({{showExtended ?
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="['/products', row.id]">{{row.name}} ({{showExtended ?
|
||||
row.fraction + ' ' + row.fractionUnits + ' = 1 ':''}}{{row.units}})</a></mat-cell>
|
||||
</ng-container>
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import {ProductListDataSource} from './product-list-datasource';
|
||||
import {Product} from '../product';
|
||||
import {Product} from '../../core/product';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {debounceTime, distinctUntilChanged, startWith} from 'rxjs/operators';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {ProductService} from './product.service';
|
||||
import {Product} from './product';
|
||||
import {Product} from '../core/product';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
|
||||
@Injectable({
|
||||
|
||||
@ -9,11 +9,10 @@ import {ProductListComponent} from './product-list/product-list.component';
|
||||
|
||||
import {AuthGuard} from '../auth/auth-guard.service';
|
||||
import {ProductGroupListResolver} from '../product-group/product-group-list-resolver.service';
|
||||
import {AccountListResolver} from '../account/account-list-resolver.service';
|
||||
|
||||
const productRoutes: Routes = [
|
||||
{
|
||||
path: 'Products',
|
||||
path: '',
|
||||
component: ProductListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
@ -24,7 +23,7 @@ const productRoutes: Routes = [
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'Product',
|
||||
path: 'new',
|
||||
component: ProductDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
@ -36,7 +35,7 @@ const productRoutes: Routes = [
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'Product/:id',
|
||||
path: ':id',
|
||||
component: ProductDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
|
||||
@ -2,14 +2,14 @@ import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
||||
import {Product} from './product';
|
||||
import {Product} from '../core/product';
|
||||
import {ErrorLoggerService} from '../core/error-logger.service';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/api/Product';
|
||||
const url = '/api/products';
|
||||
const serviceName = 'ProductService';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@ -19,7 +19,7 @@ export class ProductService {
|
||||
}
|
||||
|
||||
get(id: string): Observable<Product> {
|
||||
const getUrl: string = (id === null) ? url : `${url}/${id}`;
|
||||
const getUrl: string = (id === null) ? `${url}/new` : `${url}/${id}`;
|
||||
return <Observable<Product>>this.http.get<Product>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
@ -35,7 +35,7 @@ export class ProductService {
|
||||
}
|
||||
|
||||
save(product: Product): Observable<Product> {
|
||||
return <Observable<Product>>this.http.post<Product>(url, product, httpOptions)
|
||||
return <Observable<Product>>this.http.post<Product>(`${url}/new`, product, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
import {Account} from '../account/account';
|
||||
import {ProductGroup} from '../product-group/product-group';
|
||||
|
||||
export class Product {
|
||||
id: string;
|
||||
code: number;
|
||||
name: string;
|
||||
units: string;
|
||||
fraction: number;
|
||||
fractionUnits: string;
|
||||
productYield: number;
|
||||
price: number;
|
||||
salePrice: number;
|
||||
isActive: boolean;
|
||||
isFixture: boolean;
|
||||
isPurchased: boolean;
|
||||
isSold: boolean;
|
||||
productGroup: ProductGroup;
|
||||
account: Account;
|
||||
}
|
||||
Reference in New Issue
Block a user