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
-2
@@ -1,7 +1,7 @@
|
||||
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
||||
|
||||
import {ProductGroupService} from '../product-group.service';
|
||||
import {ProductGroup} from '../product-group';
|
||||
import {ProductGroup} from '../../core/product-group';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ToasterService} from '../../core/toaster.service';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
@@ -57,7 +57,7 @@ export class ProductGroupDetailComponent implements OnInit, AfterViewInit {
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/ProductGroups');
|
||||
this.router.navigateByUrl('/product-groups');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {ProductGroup} from './product-group';
|
||||
import {ProductGroup} from '../core/product-group';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {ProductGroupService} from './product-group.service';
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {merge, Observable, of as observableOf} from 'rxjs';
|
||||
import {ProductGroup} from '../product-group';
|
||||
import {ProductGroup} from '../../core/product-group';
|
||||
|
||||
export class ProductGroupListDataSource extends DataSource<ProductGroup> {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Product Groups</mat-card-title>
|
||||
<a mat-button [routerLink]="['/ProductGroup']">
|
||||
<a mat-button [routerLink]="['/product-groups', 'new']">
|
||||
<mat-icon>add_box</mat-icon>
|
||||
Add
|
||||
</a>
|
||||
@@ -12,7 +12,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]="['/ProductGroup', row.id]">{{row.name}}</a></mat-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="['/product-groups', row.id]">{{row.name}}</a></mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Is Fixture Column -->
|
||||
|
||||
@@ -2,7 +2,7 @@ import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import {ProductGroupListDataSource} from './product-group-list-datasource';
|
||||
import {ProductGroup} from '../product-group';
|
||||
import {ProductGroup} from '../../core/product-group';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {ProductGroupService} from './product-group.service';
|
||||
import {ProductGroup} from './product-group';
|
||||
import {ProductGroup} from '../core/product-group';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
|
||||
@Injectable({
|
||||
|
||||
@@ -9,7 +9,7 @@ import {AuthGuard} from '../auth/auth-guard.service';
|
||||
|
||||
const productGroupRoutes: Routes = [
|
||||
{
|
||||
path: 'ProductGroups',
|
||||
path: '',
|
||||
component: ProductGroupListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
@@ -20,7 +20,7 @@ const productGroupRoutes: Routes = [
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'ProductGroup',
|
||||
path: 'new',
|
||||
component: ProductGroupDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
@@ -31,7 +31,7 @@ const productGroupRoutes: Routes = [
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'ProductGroup/:id',
|
||||
path: ':id',
|
||||
component: ProductGroupDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
|
||||
@@ -3,12 +3,12 @@ import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
||||
import {ErrorLoggerService} from '../core/error-logger.service';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {ProductGroup} from './product-group';
|
||||
import {ProductGroup} from '../core/product-group';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
const url = '/api/ProductGroup';
|
||||
const url = '/api/product-groups';
|
||||
const serviceName = 'ProductGroupService';
|
||||
|
||||
@Injectable({
|
||||
@@ -19,7 +19,7 @@ export class ProductGroupService {
|
||||
}
|
||||
|
||||
get(id: string): Observable<ProductGroup> {
|
||||
const getUrl: string = (id === null) ? url : `${url}/${id}`;
|
||||
const getUrl: string = (id === null) ? `${url}/new` : `${url}/${id}`;
|
||||
return <Observable<ProductGroup>>this.http.get<ProductGroup>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
@@ -35,7 +35,7 @@ export class ProductGroupService {
|
||||
}
|
||||
|
||||
save(productGroup: ProductGroup): Observable<ProductGroup> {
|
||||
return <Observable<ProductGroup>>this.http.post<ProductGroup>(url, productGroup, httpOptions)
|
||||
return <Observable<ProductGroup>>this.http.post<ProductGroup>(`${url}/new`, productGroup, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export class ProductGroup {
|
||||
id: string;
|
||||
name: string;
|
||||
isFixture: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user