Allow editing of product version with the right permission.
This commit is contained in:
@ -17,11 +17,11 @@ const serviceName = 'ProductService';
|
||||
export class ProductService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
get(id: string | null): Observable<Product> {
|
||||
get(id: string | null): Observable<Product[]> {
|
||||
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
|
||||
return this.http
|
||||
.get<Product>(getUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<Product>;
|
||||
.get<Product[]>(getUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<Product[]>;
|
||||
}
|
||||
|
||||
list(): Observable<Product[]> {
|
||||
@ -48,16 +48,16 @@ export class ProductService {
|
||||
>;
|
||||
}
|
||||
|
||||
save(product: Product): Observable<Product> {
|
||||
save(product: Product): Observable<void> {
|
||||
return this.http
|
||||
.post<Product>(`${url}`, product, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<Product>;
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save'))) as Observable<void>;
|
||||
}
|
||||
|
||||
update(product: Product): Observable<Product> {
|
||||
update(product: Product): Observable<void> {
|
||||
return this.http
|
||||
.put<Product>(`${url}/${product.id}`, product, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<Product>;
|
||||
.put<Product>(`${url}/${product.versionId}`, product, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<void>;
|
||||
}
|
||||
|
||||
updateSortOrder(list: Product[]): Observable<Product[]> {
|
||||
@ -68,17 +68,17 @@ export class ProductService {
|
||||
>;
|
||||
}
|
||||
|
||||
saveOrUpdate(product: Product): Observable<Product> {
|
||||
if (!product.id) {
|
||||
saveOrUpdate(product: Product): Observable<void> {
|
||||
if (!product.versionId) {
|
||||
return this.save(product);
|
||||
}
|
||||
return this.update(product);
|
||||
}
|
||||
|
||||
delete(id: string): Observable<Product> {
|
||||
delete(id: string): Observable<void> {
|
||||
return this.http
|
||||
.delete<Product>(`${url}/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<Product>;
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<void>;
|
||||
}
|
||||
|
||||
balance(id: string, date: string): Observable<number> {
|
||||
|
||||
Reference in New Issue
Block a user