-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
7 changed files
with
167 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.tabs { | ||
background-color: black; | ||
} | ||
|
||
.tab { | ||
padding: 0.5rem; | ||
background-color: skyblue; | ||
color: black; | ||
border-bottom: none; | ||
width: 8rem; | ||
} | ||
|
||
.active-tab { | ||
background-color: white; | ||
border-bottom: none; | ||
} | ||
|
||
.tab:first-child { | ||
margin-left: 0; | ||
} | ||
|
||
.tab-container { | ||
background-color: white; | ||
} | ||
|
||
table th { | ||
background-color: black; | ||
color: white | ||
} | ||
|
||
table tr:nth-child(even) { | ||
background-color: #f2f2f2; | ||
} |
66 changes: 45 additions & 21 deletions
66
src/app/pages/reg/reg-product-list/reg-product-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,47 @@ | ||
<div class="container"> | ||
<button class="btn" (click)="newProduct()"><i class="fa fa-plus fa-lg"></i></button> | ||
<button class="btn" (click)="newProduct()"><i class="fa fa-plus fa-lg"></i></button> | ||
<button class="btn" (click)="openCart()"><i class="fa fa-shopping-cart fa-lg"></i></button> | ||
<table class="table"> | ||
<tr> | ||
<th>Product</th> | ||
<th>Price</th> | ||
<th>Cost</th> | ||
<th *ngIf="false">Category</th> | ||
<th></th> | ||
</tr> | ||
<tr *ngFor="let product of products"> | ||
<td>{{product.name}}</td> | ||
<td>{{product.price}}</td> | ||
<td>{{product.cost}}</td> | ||
<td *ngIf="false">{{product.category?.name}}</td> | ||
<td> | ||
<button class="btn" (click)="openProduct(product.id)">Edit</button> | ||
<button class="btn btn-danger" (click)="removeProduct(product.id)">Delete</button> | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
<div class="tabs"> | ||
<button class="tab" [ngClass]="{'active-tab': displayProductsTab}" (click)="setProducts()">Products</button> | ||
<button class="tab" [ngClass]="{'active-tab': !displayProductsTab}" | ||
(click)="setProductPresentations()">Details</button> | ||
</div> | ||
<div *ngIf="displayProductsTab" class="tab-container"> | ||
<table class="table"> | ||
<tr> | ||
<th>Product</th> | ||
<th>Price</th> | ||
<th>Cost</th> | ||
<th *ngIf="false">Category</th> | ||
<th></th> | ||
</tr> | ||
<tr *ngFor="let product of products"> | ||
<td>{{product.name}}</td> | ||
<td>{{product.price}}</td> | ||
<td>{{product.cost}}</td> | ||
<td *ngIf="false">{{product.category?.name}}</td> | ||
<td> | ||
<button class="btn" (click)="openProduct(product.id)">Edit</button> | ||
<button class="btn btn-danger" (click)="removeProduct(product.id)">Delete</button> | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
<div *ngIf="!displayProductsTab" class="tab-container"> | ||
<table class="table"> | ||
<tr> | ||
<th>Product</th> | ||
<th>Price</th> | ||
<th>Actions</th> | ||
</tr> | ||
<tr *ngFor="let product of productPresentations"> | ||
<td>{{product.Product.name}}</td> | ||
<td>{{product.currentPrice}}</td> | ||
<td> | ||
<button class="btn" (click)="openProduct(product.id)">Edit</button> | ||
<button class="btn btn-danger" (click)="removeProduct(product.id)">Delete</button> | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/app/services/reg/r-product-presentation.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { TestBed, inject } from '@angular/core/testing'; | ||
|
||
import { RProductPresentationService } from './r-product-presentation.service'; | ||
|
||
describe('RProductPresentationService', () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [RProductPresentationService] | ||
}); | ||
}); | ||
|
||
it('should be created', inject([RProductPresentationService], (service: RProductPresentationService) => { | ||
expect(service).toBeTruthy(); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from "@angular/common/http"; | ||
import { RConfigService } from "./r-config.service"; | ||
|
||
import { RCrudInterface } from './r-crud.interface'; | ||
import { Observable } from 'rxjs'; | ||
|
||
export interface IProductPresentation { | ||
id: string; | ||
code: string; | ||
currentPrice: number; | ||
img: string; | ||
unitOfMeasure: string; | ||
productId: string; | ||
quantity: number; | ||
} | ||
|
||
@Injectable({ | ||
providedIn: "root" | ||
}) | ||
export class RProductPresentationService implements RCrudInterface { | ||
modelUrl: string; | ||
constructor(private http: HttpClient, private configSvc: RConfigService) { | ||
this.modelUrl = this.configSvc.baseUrl + "/productPresentations"; | ||
} | ||
|
||
getAll(): Observable<any> { | ||
return this.http.get(`${this.modelUrl}`); | ||
} | ||
|
||
getById(id: string): Observable<any> { | ||
return this.http.get(`${this.modelUrl}/${id}`); | ||
} | ||
|
||
save(data: any): Observable<any> { | ||
return this.http.post(this.modelUrl, data); | ||
} | ||
|
||
update(data: any): Observable<any> { | ||
return this.http.put(`${this.modelUrl}/${data.id}`, data); | ||
} | ||
|
||
remove(productId: any): Observable<any> { | ||
return this.http.delete(`${this.modelUrl}/${productId}`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters