update listdoc
This commit is contained in:
@@ -11,10 +11,9 @@ import { ButtonModule } from 'primeng/button';
|
||||
import { Product, ProductService } from '@/src/service/product.service';
|
||||
|
||||
@Component({
|
||||
standalone:true,
|
||||
standalone: true,
|
||||
imports: [CommonModule, DataViewModule, FormsModule, SelectButtonModule, PickListModule, OrderListModule, TagModule, ButtonModule],
|
||||
template: `
|
||||
<div class="flex flex-col">
|
||||
template: ` <div class="flex flex-col">
|
||||
<div class="card">
|
||||
<div class="font-semibold text-xl">DataView</div>
|
||||
<p-dataview [value]="products" [layout]="layout">
|
||||
@@ -22,7 +21,7 @@ import { Product, ProductService } from '@/src/service/product.service';
|
||||
<div class="flex justify-end">
|
||||
<p-select-button [(ngModel)]="layout" [options]="options" [allowEmpty]="false">
|
||||
<ng-template #item let-option>
|
||||
<i class="pi " [ngClass]="{'pi-bars': option === 'list', 'pi-table': option === 'grid'}"></i>
|
||||
<i class="pi " [ngClass]="{ 'pi-bars': option === 'list', 'pi-table': option === 'grid' }"></i>
|
||||
</ng-template>
|
||||
</p-select-button>
|
||||
</div>
|
||||
@@ -31,20 +30,15 @@ import { Product, ProductService } from '@/src/service/product.service';
|
||||
<ng-template #list let-items>
|
||||
<div class="flex flex-col">
|
||||
<div *ngFor="let item of items; let i = index">
|
||||
<div class="flex flex-col sm:flex-row sm:items-center p-6 gap-4"
|
||||
[ngClass]="{ 'border-t border-surface': i !== 0 }">
|
||||
<div class="flex flex-col sm:flex-row sm:items-center p-6 gap-4" [ngClass]="{ 'border-t border-surface': i !== 0 }">
|
||||
<div class="md:w-40 relative">
|
||||
<img class="block xl:block mx-auto rounded w-full"
|
||||
src="https://primefaces.org/cdn/primevue/images/product/{{item.image}}"
|
||||
[alt]="item.name" />
|
||||
<p-tag [value]="item.inventoryStatus" [severity]="getSeverity(item)"
|
||||
class="absolute dark:!bg-surface-900" [style]="{left: '4px', top: '4px'}"></p-tag>
|
||||
<img class="block xl:block mx-auto rounded w-full" src="https://primefaces.org/cdn/primevue/images/product/{{ item.image }}" [alt]="item.name" />
|
||||
<p-tag [value]="item.inventoryStatus" [severity]="getSeverity(item)" class="absolute dark:!bg-surface-900" [style]="{ left: '4px', top: '4px' }"></p-tag>
|
||||
</div>
|
||||
<div class="flex flex-col md:flex-row justify-between md:items-center flex-1 gap-6">
|
||||
<div class="flex flex-row md:flex-col justify-between items-start gap-2">
|
||||
<div>
|
||||
<span
|
||||
class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
|
||||
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
|
||||
<div class="text-lg font-medium mt-2">{{ item.name }}</div>
|
||||
</div>
|
||||
<div class="bg-surface-100 p-1" style="border-radius: 30px">
|
||||
@@ -57,8 +51,7 @@ import { Product, ProductService } from '@/src/service/product.service';
|
||||
0px 1px 2px 0px rgba(0, 0, 0, 0.06);
|
||||
"
|
||||
>
|
||||
<span
|
||||
class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
|
||||
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
|
||||
<i class="pi pi-star-fill text-yellow-500"></i>
|
||||
</div>
|
||||
</div>
|
||||
@@ -67,9 +60,7 @@ import { Product, ProductService } from '@/src/service/product.service';
|
||||
<span class="text-xl font-semibold">$ {{ item.price }}</span>
|
||||
<div class="flex flex-row-reverse md:flex-row gap-2">
|
||||
<p-button icon="pi pi-heart" styleClass="h-full" [outlined]="true"></p-button>
|
||||
<p-button icon="pi pi-shopping-cart" label="Buy Now"
|
||||
[disabled]="item.inventoryStatus === 'OUTOFSTOCK'"
|
||||
styleClass="flex-auto md:flex-initial whitespace-nowrap"></p-button>
|
||||
<p-button icon="pi pi-shopping-cart" label="Buy Now" [disabled]="item.inventoryStatus === 'OUTOFSTOCK'" styleClass="flex-auto md:flex-initial whitespace-nowrap"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -80,25 +71,18 @@ import { Product, ProductService } from '@/src/service/product.service';
|
||||
|
||||
<ng-template #grid let-items>
|
||||
<div class="grid grid-cols-12 gap-4">
|
||||
<div *ngFor="let item of items; let i = index">
|
||||
class="col-span-12 sm:col-span-6 lg:col-span-4 p-2">
|
||||
<div
|
||||
class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded flex flex-col">
|
||||
<div *ngFor="let item of items; let i = index" class="col-span-12 sm:col-span-6 lg:col-span-4 p-2">
|
||||
<div class="p-6 border border-surface-200 dark:border-surface-700 bg-surface-0 dark:bg-surface-900 rounded flex flex-col">
|
||||
<div class="bg-surface-50 flex justify-center rounded p-6">
|
||||
<div class="relative mx-auto">
|
||||
<img class="rounded w-full"
|
||||
src="https://primefaces.org/cdn/primevue/images/product/{{item.image}}"
|
||||
[alt]="item.name" style="max-width: 300px" />
|
||||
<p-tag [value]="item.inventoryStatus" [severity]="getSeverity(item)"
|
||||
class="absolute dark:!bg-surface-900"
|
||||
[style]="{left: '4px', top: '4px'}"></p-tag>
|
||||
<img class="rounded w-full" src="https://primefaces.org/cdn/primevue/images/product/{{ item.image }}" [alt]="item.name" style="max-width: 300px" />
|
||||
<p-tag [value]="item.inventoryStatus" [severity]="getSeverity(item)" class="absolute dark:!bg-surface-900" [style]="{ left: '4px', top: '4px' }"></p-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pt-12">
|
||||
<div class="flex flex-row justify-between items-start gap-2">
|
||||
<div>
|
||||
<span
|
||||
class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
|
||||
<span class="font-medium text-surface-500 dark:text-surface-400 text-sm">{{ item.category }}</span>
|
||||
<div class="text-lg font-medium mt-1">{{ item.name }}</div>
|
||||
</div>
|
||||
<div class="bg-surface-100 p-1" style="border-radius: 30px">
|
||||
@@ -111,8 +95,7 @@ import { Product, ProductService } from '@/src/service/product.service';
|
||||
0px 1px 2px 0px rgba(0, 0, 0, 0.06);
|
||||
"
|
||||
>
|
||||
<span
|
||||
class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
|
||||
<span class="text-surface-900 font-medium text-sm">{{ item.rating }}</span>
|
||||
<i class="pi pi-star-fill text-yellow-500"></i>
|
||||
</div>
|
||||
</div>
|
||||
@@ -120,9 +103,7 @@ import { Product, ProductService } from '@/src/service/product.service';
|
||||
<div class="flex flex-col gap-6 mt-6">
|
||||
<span class="text-2xl font-semibold">$ {{ item.price }}</span>
|
||||
<div class="flex gap-2">
|
||||
<p-button icon="pi pi-shopping-cart" label="Buy Now"
|
||||
[disabled]="item.inventoryStatus === 'OUTOFSTOCK'"
|
||||
class="flex-auto whitespace-nowrap"></p-button>
|
||||
<p-button icon="pi pi-shopping-cart" label="Buy Now" [disabled]="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto whitespace-nowrap" styleClass="w-full"></p-button>
|
||||
<p-button icon="pi pi-heart" styleClass="h-full" [outlined]="true"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -160,7 +141,7 @@ import { Product, ProductService } from '@/src/service/product.service';
|
||||
</div>`,
|
||||
styles: `
|
||||
::ng-deep {
|
||||
.p-orderlist-list-container{
|
||||
.p-orderlist-list-container {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
@@ -168,7 +149,6 @@ import { Product, ProductService } from '@/src/service/product.service';
|
||||
providers: [ProductService]
|
||||
})
|
||||
export class ListDoc {
|
||||
|
||||
layout: 'list' | 'grid' = 'list';
|
||||
|
||||
options = ['list', 'grid'];
|
||||
@@ -181,10 +161,10 @@ export class ListDoc {
|
||||
|
||||
orderCities: any[] = [];
|
||||
|
||||
constructor(private productService: ProductService) { }
|
||||
constructor(private productService: ProductService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.productService.getProducts().then(data => this.products = data);
|
||||
this.productService.getProducts().then((data) => (this.products = data));
|
||||
|
||||
this.sourceCities = [
|
||||
{ name: 'San Francisco', code: 'SF' },
|
||||
@@ -193,7 +173,8 @@ export class ListDoc {
|
||||
{ name: 'Istanbul', code: 'IST' },
|
||||
{ name: 'Berlin', code: 'BRL' },
|
||||
{ name: 'Barcelona', code: 'BRC' },
|
||||
{ name: 'Rome', code: 'RM' }];
|
||||
{ name: 'Rome', code: 'RM' }
|
||||
];
|
||||
|
||||
this.targetCities = [];
|
||||
|
||||
@@ -204,11 +185,10 @@ export class ListDoc {
|
||||
{ name: 'Istanbul', code: 'IST' },
|
||||
{ name: 'Berlin', code: 'BRL' },
|
||||
{ name: 'Barcelona', code: 'BRC' },
|
||||
{ name: 'Rome', code: 'RM' }];
|
||||
|
||||
{ name: 'Rome', code: 'RM' }
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
getSeverity(product) {
|
||||
switch (product.inventoryStatus) {
|
||||
case 'INSTOCK':
|
||||
|
||||
Reference in New Issue
Block a user