Consolidated commit message to v22 signals
This commit is contained in:
+22
-15
@@ -1,18 +1,25 @@
|
||||
<h2>Product Group</h2>
|
||||
|
||||
<form [formGroup]="form" class="flex-col wrapped">
|
||||
<div class="row-container">
|
||||
<mat-form-field class="flex-auto">
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput #nameElement formControlName="name" (keyup.enter)="save()" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="row-container">
|
||||
<mat-checkbox formControlName="nutritional" class="flex-auto">Nutritional Information?</mat-checkbox>
|
||||
<mat-checkbox formControlName="iceCream" class="flex-auto">Ice Cream?</mat-checkbox>
|
||||
</div>
|
||||
</form>
|
||||
@if (itemResource.isLoading()) {
|
||||
<app-skeleton-loader type="card" [count]="1" />
|
||||
<app-skeleton-loader type="line" [count]="10" />
|
||||
} @else if (itemResource.error()) {
|
||||
<app-error-state [message]="'Failed to load data.'" (retryAction)="itemResource.reload()" />
|
||||
} @else {
|
||||
<form class="flex-col wrapped" [formRoot]="form">
|
||||
<div class="row-container">
|
||||
<mat-form-field class="flex-auto">
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput [formField]="form.name" (keyup.enter)="save()" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="row-container">
|
||||
<mat-checkbox [formField]="form.nutritional" class="flex-auto">Nutritional Information?</mat-checkbox>
|
||||
<mat-checkbox [formField]="form.iceCream" class="flex-auto">Ice Cream?</mat-checkbox>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="row-container">
|
||||
<button mat-raised-button (click)="save()" color="primary">Save</button>
|
||||
</div>
|
||||
<div class="row-container">
|
||||
<button mat-raised-button (click)="save()" color="primary">Save</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
+46
-46
@@ -1,67 +1,66 @@
|
||||
import { AfterViewInit, Component, ElementRef, inject, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { Component, inject, afterNextRender, linkedSignal, input, computed } from '@angular/core';
|
||||
import { form as createForm, FormField, FormRoot } from '@angular/forms/signals';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { ProductGroup } from '../../core/product-group';
|
||||
import { ErrorStateComponent } from '../../shared/error-state/error-state.component';
|
||||
import { SkeletonLoaderComponent } from '../../shared/skeleton-loader/skeleton-loader.component';
|
||||
import { ProductGroupService } from '../product-group.service';
|
||||
|
||||
export interface ProductGroupDetailFormData {
|
||||
name: string;
|
||||
nutritional: boolean;
|
||||
iceCream: boolean;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-product-group-detail',
|
||||
templateUrl: './product-group-detail.component.html',
|
||||
styleUrls: ['./product-group-detail.component.css'],
|
||||
imports: [ReactiveFormsModule, MatFormFieldModule, MatInputModule, MatCheckboxModule, MatButtonModule],
|
||||
imports: [
|
||||
FormField,
|
||||
FormRoot,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
MatCheckboxModule,
|
||||
MatButtonModule,
|
||||
SkeletonLoaderComponent,
|
||||
ErrorStateComponent,
|
||||
],
|
||||
})
|
||||
export class ProductGroupDetailComponent implements OnInit, AfterViewInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
export class ProductGroupDetailComponent {
|
||||
id = input(null, { transform: (v: string | null | undefined) => v ?? null });
|
||||
|
||||
private router = inject(Router);
|
||||
private snackBar = inject(MatSnackBar);
|
||||
private ser = inject(ProductGroupService);
|
||||
|
||||
@ViewChild('nameElement', { static: true }) nameElement!: ElementRef<HTMLInputElement>;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string | null>;
|
||||
nutritional: FormControl<boolean>;
|
||||
iceCream: FormControl<boolean>;
|
||||
}>;
|
||||
itemResource = this.ser.get(this.id);
|
||||
|
||||
item: ProductGroup = new ProductGroup();
|
||||
item = computed(() => this.itemResource.value() ?? new ProductGroup());
|
||||
|
||||
model = linkedSignal({
|
||||
source: this.item,
|
||||
computation: (itemVal): ProductGroupDetailFormData => ({
|
||||
name: itemVal.name ?? '',
|
||||
nutritional: itemVal.nutritional ?? false,
|
||||
iceCream: itemVal.iceCream ?? false,
|
||||
}),
|
||||
});
|
||||
|
||||
form = createForm(this.model);
|
||||
|
||||
constructor() {
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl<string | null>(null),
|
||||
nutritional: new FormControl<boolean>(false, { nonNullable: true }),
|
||||
iceCream: new FormControl<boolean>(false, { nonNullable: true }),
|
||||
afterNextRender(() => {
|
||||
this.form().focusBoundControl();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { item: ProductGroup };
|
||||
|
||||
this.showItem(data.item);
|
||||
});
|
||||
}
|
||||
|
||||
showItem(item: ProductGroup) {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
name: this.item.name,
|
||||
nutritional: this.item.nutritional,
|
||||
iceCream: this.item.iceCream,
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
setTimeout(() => {
|
||||
this.nameElement.nativeElement.focus();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe({
|
||||
next: () => {
|
||||
@@ -69,16 +68,17 @@ export class ProductGroupDetailComponent implements OnInit, AfterViewInit {
|
||||
this.router.navigateByUrl('/product-groups');
|
||||
},
|
||||
error: (error) => {
|
||||
this.snackBar.open(error, 'Danger');
|
||||
this.snackBar.open(error as string, 'Danger');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getItem(): ProductGroup {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name ?? '';
|
||||
this.item.nutritional = formModel.nutritional ?? false;
|
||||
this.item.iceCream = formModel.iceCream ?? false;
|
||||
return this.item;
|
||||
const formModel = this.model();
|
||||
const item = this.item();
|
||||
item.name = formModel.name ?? '';
|
||||
item.nutritional = formModel.nutritional ?? false;
|
||||
item.iceCream = formModel.iceCream ?? false;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { ProductGroup } from '../core/product-group';
|
||||
import { productGroupListResolver } from './product-group-list.resolver';
|
||||
|
||||
describe('productGroupListResolver', () => {
|
||||
const executeResolver: ResolveFn<ProductGroup[]> = (...resolverParameters) =>
|
||||
TestBed.runInInjectionContext(() => productGroupListResolver(...resolverParameters));
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(executeResolver).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { ProductGroup } from '../core/product-group';
|
||||
import { ProductGroupService } from './product-group.service';
|
||||
|
||||
export const productGroupListResolver: ResolveFn<ProductGroup[]> = () => {
|
||||
return inject(ProductGroupService).list();
|
||||
};
|
||||
@@ -1,69 +0,0 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { EventEmitter } from '@angular/core';
|
||||
import { MatPaginator, PageEvent } from '@angular/material/paginator';
|
||||
import { MatSort, Sort } from '@angular/material/sort';
|
||||
import { merge, Observable, of as observableOf } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ProductGroup } from '../../core/product-group';
|
||||
|
||||
/** Simple sort comparator for example ID/Name columns (for client-side sorting). */
|
||||
const compare = (a: string | number, b: string | number, isAsc: boolean) => (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||
export class ProductGroupListDataSource extends DataSource<ProductGroup> {
|
||||
constructor(
|
||||
public data: ProductGroup[],
|
||||
private paginator?: MatPaginator,
|
||||
private sort?: MatSort,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<ProductGroup[]> {
|
||||
const dataMutations: (EventEmitter<PageEvent> | EventEmitter<Sort>)[] = [];
|
||||
if (this.paginator) {
|
||||
dataMutations.push((this.paginator as MatPaginator).page);
|
||||
}
|
||||
if (this.sort) {
|
||||
dataMutations.push((this.sort as MatSort).sortChange);
|
||||
}
|
||||
|
||||
// Set the paginators length
|
||||
if (this.paginator) {
|
||||
this.paginator.length = this.data.length;
|
||||
}
|
||||
|
||||
return merge(observableOf(this.data), ...dataMutations).pipe(
|
||||
map(() => this.getPagedData(this.getSortedData([...this.data]))),
|
||||
);
|
||||
}
|
||||
|
||||
disconnect() {}
|
||||
|
||||
private getPagedData(data: ProductGroup[]) {
|
||||
if (this.paginator === undefined) {
|
||||
return data;
|
||||
}
|
||||
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
|
||||
return data.splice(startIndex, this.paginator.pageSize);
|
||||
}
|
||||
|
||||
private getSortedData(data: ProductGroup[]) {
|
||||
if (this.sort === undefined) {
|
||||
return data;
|
||||
}
|
||||
if (!this.sort.active || this.sort.direction === '') {
|
||||
return data;
|
||||
}
|
||||
|
||||
const sort = this.sort as MatSort;
|
||||
return data.sort((a, b) => {
|
||||
const isAsc = sort.direction === 'asc';
|
||||
switch (sort.active) {
|
||||
case 'name':
|
||||
return compare(a.name, b.name, isAsc);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+30
-24
@@ -6,30 +6,36 @@
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<mat-table #table [dataSource]="dataSource" matSort aria-label="Elements">
|
||||
<!-- 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-groups', row.id]">{{ row.name }}</a></mat-cell
|
||||
>
|
||||
</ng-container>
|
||||
@if (listResource.isLoading()) {
|
||||
<app-skeleton-loader type="table" [count]="1" />
|
||||
} @else if (listResource.error()) {
|
||||
<app-error-state [message]="'Failed to load list.'" (retryAction)="listResource.reload()" />
|
||||
} @else {
|
||||
<mat-table #table [dataSource]="dataSource()" matSort (matSortChange)="sortData($event)">
|
||||
<!-- 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-groups', row.id]">{{ row.name }}</a></mat-cell
|
||||
>
|
||||
</ng-container>
|
||||
|
||||
<!-- Is Fixture Column -->
|
||||
<ng-container matColumnDef="isFixture">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Is Fixture?</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.isFixture }}</mat-cell>
|
||||
</ng-container>
|
||||
<!-- Is Fixture Column -->
|
||||
<ng-container matColumnDef="isFixture">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Is Fixture?</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.isFixture }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
</mat-table>
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
</mat-table>
|
||||
|
||||
<mat-paginator
|
||||
#paginator
|
||||
[length]="dataSource.data.length"
|
||||
[pageIndex]="0"
|
||||
[pageSize]="50"
|
||||
[pageSizeOptions]="[25, 50, 100, 250]"
|
||||
>
|
||||
</mat-paginator>
|
||||
<mat-paginator
|
||||
(page)="handlePageEvent($event)"
|
||||
[length]="list().length"
|
||||
[pageIndex]="pageIndex()"
|
||||
[pageSize]="pageSize()"
|
||||
[pageSizeOptions]="[25, 50, 100, 250]"
|
||||
>
|
||||
</mat-paginator>
|
||||
}
|
||||
|
||||
@@ -1,36 +1,77 @@
|
||||
import { Component, inject, OnInit, ViewChild } from '@angular/core';
|
||||
import { Component, computed, inject, signal } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
|
||||
import { MatSort, MatSortModule } from '@angular/material/sort';
|
||||
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
|
||||
import { MatSortModule, Sort } from '@angular/material/sort';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { ActivatedRoute, RouterModule } from '@angular/router';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { ProductGroup } from '../../core/product-group';
|
||||
import { ProductGroupListDataSource } from './product-group-list-datasource';
|
||||
import { ErrorStateComponent } from '../../shared/error-state/error-state.component';
|
||||
import { SkeletonLoaderComponent } from '../../shared/skeleton-loader/skeleton-loader.component';
|
||||
import { ProductGroupService } from '../product-group.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-product-group-list',
|
||||
templateUrl: './product-group-list.component.html',
|
||||
styleUrls: ['./product-group-list.component.css'],
|
||||
imports: [RouterModule, MatIconModule, MatTableModule, MatSortModule, MatPaginatorModule, MatButtonModule],
|
||||
imports: [
|
||||
RouterModule,
|
||||
MatIconModule,
|
||||
MatTableModule,
|
||||
MatSortModule,
|
||||
MatPaginatorModule,
|
||||
MatButtonModule,
|
||||
SkeletonLoaderComponent,
|
||||
ErrorStateComponent,
|
||||
],
|
||||
})
|
||||
export class ProductGroupListComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
export class ProductGroupListComponent {
|
||||
private ser = inject(ProductGroupService);
|
||||
|
||||
pageSize = signal(50);
|
||||
pageIndex = signal(0);
|
||||
sortActive = signal('');
|
||||
sortDirection = signal('');
|
||||
listResource = this.ser.list();
|
||||
list = computed(() => this.listResource.value() ?? []);
|
||||
sortedList = computed(() => {
|
||||
const data = this.list();
|
||||
const active = this.sortActive();
|
||||
const direction = this.sortDirection();
|
||||
|
||||
if (!active || direction === '') {
|
||||
return data;
|
||||
}
|
||||
|
||||
return [...data].sort((a, b) => {
|
||||
const isAsc = direction === 'asc';
|
||||
switch (active) {
|
||||
case 'name':
|
||||
return compare(a.name, b.name, isAsc);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
dataSource = computed(() => {
|
||||
const data = this.sortedList();
|
||||
const pageIndex = this.pageIndex();
|
||||
const pageSize = this.pageSize();
|
||||
return data.slice(pageIndex * pageSize, (pageIndex + 1) * pageSize);
|
||||
});
|
||||
|
||||
@ViewChild(MatPaginator, { static: true }) paginator!: MatPaginator;
|
||||
@ViewChild(MatSort, { static: true }) sort!: MatSort;
|
||||
list: ProductGroup[] = [];
|
||||
dataSource: ProductGroupListDataSource = new ProductGroupListDataSource(this.list, this.paginator, this.sort);
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'isFixture'];
|
||||
handlePageEvent(e: PageEvent) {
|
||||
this.pageSize.set(e.pageSize);
|
||||
this.pageIndex.set(e.pageIndex);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: ProductGroup[] };
|
||||
|
||||
this.list = data.list;
|
||||
});
|
||||
this.dataSource = new ProductGroupListDataSource(this.list, this.paginator, this.sort);
|
||||
sortData(sort: Sort) {
|
||||
this.sortActive.set(sort.active);
|
||||
this.sortDirection.set(sort.direction);
|
||||
}
|
||||
}
|
||||
const compare = (a: string | number | boolean, b: string | number | boolean, isAsc: boolean) =>
|
||||
(a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { ProductGroup } from '../core/product-group';
|
||||
import { productGroupResolver } from './product-group.resolver';
|
||||
|
||||
describe('productGroupResolver', () => {
|
||||
const executeResolver: ResolveFn<ProductGroup> = (...resolverParameters) =>
|
||||
TestBed.runInInjectionContext(() => productGroupResolver(...resolverParameters));
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(executeResolver).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,10 +0,0 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { ProductGroup } from '../core/product-group';
|
||||
import { ProductGroupService } from './product-group.service';
|
||||
|
||||
export const productGroupResolver: ResolveFn<ProductGroup> = (route) => {
|
||||
const id = route.paramMap.get('id');
|
||||
return inject(ProductGroupService).get(id);
|
||||
};
|
||||
@@ -2,9 +2,7 @@ import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
import { ProductGroupDetailComponent } from './product-group-detail/product-group-detail.component';
|
||||
import { productGroupListResolver } from './product-group-list.resolver';
|
||||
import { ProductGroupListComponent } from './product-group-list/product-group-list.component';
|
||||
import { productGroupResolver } from './product-group.resolver';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
@@ -14,9 +12,6 @@ export const routes: Routes = [
|
||||
data: {
|
||||
permission: 'Cost Centres',
|
||||
},
|
||||
resolve: {
|
||||
list: productGroupListResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
@@ -25,9 +20,6 @@ export const routes: Routes = [
|
||||
data: {
|
||||
permission: 'Cost Centres',
|
||||
},
|
||||
resolve: {
|
||||
item: productGroupResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
@@ -36,8 +28,5 @@ export const routes: Routes = [
|
||||
data: {
|
||||
permission: 'Cost Centres',
|
||||
},
|
||||
resolve: {
|
||||
item: productGroupResolver,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { HttpClient, httpResource } from '@angular/common/http';
|
||||
import { inject, Injectable, Signal } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@@ -7,8 +7,6 @@ import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { ProductGroup } from '../core/product-group';
|
||||
|
||||
const url = '/api/product-groups';
|
||||
const serviceName = 'ProductGroupService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@@ -16,29 +14,27 @@ export class ProductGroupService {
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(id: string | null): Observable<ProductGroup> {
|
||||
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
|
||||
return this.http
|
||||
.get<ProductGroup>(getUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<ProductGroup>;
|
||||
get(id: Signal<string | null>) {
|
||||
return httpResource<ProductGroup>(() => {
|
||||
const getUrl: string = id() === null ? `${url}` : `${url}/${id()}`;
|
||||
return getUrl;
|
||||
});
|
||||
}
|
||||
|
||||
list(): Observable<ProductGroup[]> {
|
||||
return this.http
|
||||
.get<ProductGroup[]>(`${url}/list`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<ProductGroup[]>;
|
||||
list() {
|
||||
return httpResource<ProductGroup[]>(() => `${url}/list`);
|
||||
}
|
||||
|
||||
save(productGroup: ProductGroup): Observable<ProductGroup> {
|
||||
return this.http
|
||||
.post<ProductGroup>(`${url}`, productGroup)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<ProductGroup>;
|
||||
.pipe(catchError(this.log.handleError('ProductGroupService', 'save'))) as Observable<ProductGroup>;
|
||||
}
|
||||
|
||||
update(productGroup: ProductGroup): Observable<ProductGroup> {
|
||||
return this.http
|
||||
.put<ProductGroup>(`${url}/${productGroup.id}`, productGroup)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<ProductGroup>;
|
||||
.pipe(catchError(this.log.handleError('ProductGroupService', 'update'))) as Observable<ProductGroup>;
|
||||
}
|
||||
|
||||
saveOrUpdate(productGroup: ProductGroup): Observable<ProductGroup> {
|
||||
@@ -51,6 +47,6 @@ export class ProductGroupService {
|
||||
delete(id: string): Observable<ProductGroup> {
|
||||
return this.http
|
||||
.delete<ProductGroup>(`${url}/${id}`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<ProductGroup>;
|
||||
.pipe(catchError(this.log.handleError('ProductGroupService', 'delete'))) as Observable<ProductGroup>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user