nx-primeng-sakai-v17/src/app/pages/app.crud.component.html

148 lines
9.2 KiB
HTML
Raw Normal View History

2021-12-21 12:57:32 +00:00
<div class="grid">
2021-12-09 14:24:42 +00:00
<div class="col-12">
<div class="card">
<p-toast></p-toast>
<p-toolbar styleClass="mb-4">
<ng-template pTemplate="left">
<button pButton pRipple label="New" icon="pi pi-plus" class="p-button-success mr-2 mb-2" (click)="openNew()"></button>
<button pButton pRipple label="Delete" icon="pi pi-trash" class="p-button-danger mb-2" (click)="deleteSelectedProducts()" [disabled]="!selectedProducts || !selectedProducts.length"></button>
</ng-template>
<ng-template pTemplate="right">
<p-fileUpload mode="basic" accept="image/*" [maxFileSize]="1000000" label="Import" chooseLabel="Import" class="mr-2 mb-2 inline-block"></p-fileUpload>
<button pButton pRipple label="Export" icon="pi pi-upload" class="p-button-help mb-2" (click)="dt.exportCSV()"></button>
</ng-template>
</p-toolbar>
2021-12-21 12:15:22 +00:00
<p-table #dt [value]="products" [columns]="cols" responsiveLayout="scroll" [rows]="10" [globalFilterFields]="['name','country.name','representative.name','status']" [rows]="10" [paginator]="true" [rowsPerPageOptions]="[10,20,30]" [showCurrentPageReport]="true" currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries" [(selection)]="selectedProducts" [rowHover]="true" dataKey="id" styleClass="p-datatable-customers" class="p-datatable-responsive">
2021-12-09 14:24:42 +00:00
<ng-template pTemplate="caption">
2021-12-21 12:57:32 +00:00
<div class="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
2021-12-09 14:24:42 +00:00
<h5 class="m-0">Manage Products</h5>
2021-12-21 12:57:32 +00:00
<span class="block mt-2 md:mt-0 p-input-icon-left">
<i class="pi pi-search"></i>
<input pInputText type="text" (input)="dt.filterGlobal($event.target.value, 'contains')" placeholder="Search..." />
</span>
2021-12-09 14:24:42 +00:00
</div>
</ng-template>
<ng-template pTemplate="header">
<tr>
<th style="width: 3rem">
<p-tableHeaderCheckbox></p-tableHeaderCheckbox>
</th>
<th pSortableColumn="code">Code <p-sortIcon field="code"></p-sortIcon></th>
<th pSortableColumn="name">Name <p-sortIcon field="name"></p-sortIcon></th>
<th>Image</th>
<th pSortableColumn="price">Price <p-sortIcon field="price"></p-sortIcon></th>
<th pSortableColumn="category">Category <p-sortIcon field="category"></p-sortIcon></th>
<th pSortableColumn="rating">Reviews <p-sortIcon field="rating"></p-sortIcon></th>
<th pSortableColumn="inventoryStatus">Status <p-sortIcon field="inventoryStatus"></p-sortIcon></th>
<th></th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-product>
<tr>
<td>
<p-tableCheckbox [value]="product"></p-tableCheckbox>
</td>
<td><span class="p-column-title">Code</span>
{{product.code}}
</td>
2021-12-21 12:57:32 +00:00
<td style="min-width:10rem;">
<span class="p-column-title">Name</span>
2021-12-09 14:24:42 +00:00
{{product.name}}
</td>
<td><span class="p-column-title">Image</span>
2021-12-15 10:53:50 +00:00
<img [src]="'assets/demo/images/product/' + product.image" [alt]="product.name" width="100" class="shadow-4" />
2021-12-09 14:24:42 +00:00
</td>
2021-12-21 12:57:32 +00:00
<td style="min-width:8rem;">
<span class="p-column-title">Price</span>
2021-12-09 14:24:42 +00:00
{{product.price | currency:'USD'}}
</td>
2021-12-21 12:57:32 +00:00
<td style="min-width:10rem;">
<span class="p-column-title">Category</span>
2021-12-09 14:24:42 +00:00
{{product.category}}
</td>
2021-12-21 12:57:32 +00:00
<td style="min-width: 10rem;"><span class="p-column-title">Reviews</span>
2021-12-09 14:24:42 +00:00
<p-rating [ngModel]="product.rating" [readonly]="true" [cancel]="false"></p-rating>
</td>
<td><span class="p-column-title">Status</span>
<span [class]="'product-badge status-' + (product.inventoryStatus ? product.inventoryStatus.toLowerCase() : '')">{{product.inventoryStatus}}</span>
</td>
<td>
<button pButton pRipple icon="pi pi-pencil" class="p-button-rounded p-button-success mr-2" (click)="editProduct(product)"></button>
<button pButton pRipple icon="pi pi-trash" class="p-button-rounded p-button-warning" (click)="deleteProduct(product)"></button>
</td>
</tr>
</ng-template>
</p-table>
</div>
2021-12-21 12:57:32 +00:00
<p-dialog [(visible)]="productDialog" [style]="{width: '450px'}" header="Product Details" [modal]="true" class="p-fluid">
2021-12-09 14:24:42 +00:00
<ng-template pTemplate="content">
2021-12-21 12:57:32 +00:00
<img [src]="'assets/demo/images/product/' + product.image" [alt]="product.image" width="150" class="mt-0 mx-auto mb-5 block shadow-2" *ngIf="product.image">
<div class="field">
2021-12-09 14:24:42 +00:00
<label for="name">Name</label>
<input type="text" pInputText id="name" [(ngModel)]="product.name" required autofocus />
<small class="ng-dirty ng-invalid" *ngIf="submitted && !product.name">Name is required.</small>
</div>
<div class="field">
2021-12-09 14:24:42 +00:00
<label for="description">Description</label>
<textarea id="description" pInputTextarea [(ngModel)]="product.description" required rows="3" cols="20"></textarea>
</div>
<div class="field">
<label for="status">Inventory Status</label>
<p-dropdown id="status" [options]="statuses" optionLabel="label" [(ngModel)]="selectedStatus" placeholder="Select a Status" >
<ng-template pTemplate="selectedItem">
<span *ngIf="selectedStatus" [class]="'product-badge status-' + selectedStatus.value.toLowerCase()">{{selectedStatus.label}}</span>
</ng-template>
<ng-template let-status pTemplate="status">
<span [class]="'product-badge status-' + status.value.toLowerCase()">{{status.label}}</span>
</ng-template>
</p-dropdown>
</div>
<div class="field">
<label>Category</label>
<div class="formgrid grid">
<div class="field-radiobutton col-6">
2021-12-09 14:24:42 +00:00
<p-radioButton id="category1" name="category" value="Accessories" [(ngModel)]="product.category"></p-radioButton>
<label for="category1">Accessories</label>
</div>
<div class="field-radiobutton col-6">
2021-12-09 14:24:42 +00:00
<p-radioButton id="category2" name="category" value="Clothing" [(ngModel)]="product.category"></p-radioButton>
<label for="category2">Clothing</label>
</div>
<div class="field-radiobutton col-6">
2021-12-09 14:24:42 +00:00
<p-radioButton id="category3" name="category" value="Electronics" [(ngModel)]="product.category"></p-radioButton>
<label for="category3">Electronics</label>
</div>
<div class="field-radiobutton col-6">
2021-12-09 14:24:42 +00:00
<p-radioButton id="category4" name="category" value="Fitness" [(ngModel)]="product.category"></p-radioButton>
<label for="category4">Fitness</label>
</div>
</div>
</div>
<div class="formgrid grid">
<div class="field col">
2021-12-09 14:24:42 +00:00
<label for="price">Price</label>
<p-inputNumber id="price" [(ngModel)]="product.price" mode="currency" currency="USD" locale="en-US"></p-inputNumber>
</div>
<div class="field col">
<label for="quantity">Quantity</label>
<p-inputNumber id="quantity" [(ngModel)]="product.quantity"></p-inputNumber>
</div>
</div>
</ng-template>
<ng-template pTemplate="footer">
<button pButton pRipple label="Cancel" icon="pi pi-times" class="p-button-text" (click)="hideDialog()"></button>
<button pButton pRipple label="Save" icon="pi pi-check" class="p-button-text" (click)="saveProduct()"></button>
</ng-template>
</p-dialog>
<p-confirmDialog [style]="{width: '350px'}"></p-confirmDialog>
</div>
</div>