Templating demo
parent
d57cc67ac6
commit
68a89c7903
|
@ -9,35 +9,42 @@
|
||||||
|
|
||||||
<div class="content-section implementation">
|
<div class="content-section implementation">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<DataTable :value="cars">
|
<DataTable :value="products">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="table-header">
|
<div class="table-header">
|
||||||
List of Cars
|
Products
|
||||||
<Button icon="pi pi-refresh" />
|
<Button icon="pi pi-refresh" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column header="Image">
|
||||||
<Column field="brand" header="Brand">
|
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
<img :src="'demo/images/car/' + slotProps.data.brand + '.png'" :alt="slotProps.data.brand" width="48px"/>
|
<img :src="'demo/images/product/' + slotProps.data.image" :alt="slotProps.data.image" class="product-image" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="price" header="Price">
|
||||||
<Column headerStyle="width: 8em" bodyStyle="text-align: center">
|
|
||||||
<template #header>
|
|
||||||
<Button type="button" icon="pi pi-cog"></Button>
|
|
||||||
</template>
|
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
<Button type="button" icon="pi pi-search" class="p-button-success" style="margin-right: .5em"></Button>
|
{{formatCurrency(slotProps.data.price)}}
|
||||||
<Button type="button" icon="pi pi-pencil" class="p-button-warning"></Button>
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="category" header="Category"></Column>
|
||||||
|
<Column field="rating" header="Reviews">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<Rating :value="slotProps.data.rating" :readonly="true" :cancel="false" />
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column header="Status">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<span :class="'product-badge status-' + slotProps.data.inventoryStatus.toLowerCase()">{{slotProps.data.inventoryStatus}}</span>
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
In total there are {{cars ? cars.length : 0 }} cars.
|
In total there are {{products ? products.length : 0 }} products.
|
||||||
</template>
|
</template>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content-section documentation">
|
<div class="content-section documentation">
|
||||||
|
@ -45,54 +52,101 @@
|
||||||
<TabPanel header="Source">
|
<TabPanel header="Source">
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<DataTable :value="cars">
|
<DataTable :value="products">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div style="line-height:1.87em" class="p-clearfix">
|
<div class="table-header">
|
||||||
<Button icon="pi pi-refresh" style="float: left"/>
|
Products
|
||||||
List of Cars
|
<Button icon="pi pi-refresh" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column header="Image">
|
||||||
<Column field="brand" header="Brand">
|
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
<img :src="'demo/images/car/' + slotProps.data.brand + '.png'" :alt="slotProps.data.brand" width="48px"/>
|
<img :src="'demo/images/product/' + slotProps.data.image" :alt="slotProps.data.image" class="product-image" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="price" header="Price">
|
||||||
<Column headerStyle="width: 8em" bodyStyle="text-align: center">
|
|
||||||
<template #header>
|
|
||||||
<Button type="button" icon="pi pi-cog"></Button>
|
|
||||||
</template>
|
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
<Button type="button" icon="pi pi-search" class="p-button-success" style="margin-right: .5em"></Button>
|
{{formatCurrency(slotProps.data.price)}}
|
||||||
<Button type="button" icon="pi pi-pencil" class="p-button-warning"></Button>
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="category" header="Category"></Column>
|
||||||
|
<Column field="rating" header="Reviews">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<Rating :value="slotProps.data.rating" :readonly="true" :cancel="false" />
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column header="Status">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<span :class="'product-badge status-' + slotProps.data.inventoryStatus.toLowerCase()">{{slotProps.data.inventoryStatus}}</span>
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
In total there are {{cars ? cars.length : 0 }} cars.
|
In total there are {{products ? products.length : 0 }} products.
|
||||||
</template>
|
</template>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</template>
|
</template>
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<CodeHighlight lang="javascript">
|
<CodeHighlight lang="javascript">
|
||||||
import CarService from '../../service/CarService';
|
import ProductService from '../../service/ProductService';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
cars: null
|
products: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
carService: null,
|
productService: null,
|
||||||
created() {
|
created() {
|
||||||
this.carService = new CarService();
|
this.productService = new ProductService();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.carService.getCarsSmall().then(data => this.cars = data);
|
this.productService.getProductsSmall().then(data => this.products = data);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
formatCurrency(value) {
|
||||||
|
return value.toLocaleString('en-US', {style: 'currency', currency: 'USD'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
</CodeHighlight>
|
||||||
|
|
||||||
|
<CodeHighlight lang="css">
|
||||||
|
.table-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-badge {
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: .25em .5rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 12px;
|
||||||
|
letter-spacing: .3px;
|
||||||
|
|
||||||
|
&.status-instock {
|
||||||
|
background: #C8E6C9;
|
||||||
|
color: #256029;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-outofstock {
|
||||||
|
background: #FFCDD2;
|
||||||
|
color: #C63737;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-lowstock {
|
||||||
|
background: #FEEDAF;
|
||||||
|
color: #8A5340;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-image {
|
||||||
|
width: 100px;
|
||||||
|
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23)
|
||||||
|
}
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
@ -102,20 +156,25 @@ export default {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CarService from '../../service/CarService';
|
import ProductService from '../../service/ProductService';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
cars: null
|
products: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
carService: null,
|
productService: null,
|
||||||
created() {
|
created() {
|
||||||
this.carService = new CarService();
|
this.productService = new ProductService();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.carService.getCarsSmall().then(data => this.cars = data);
|
this.productService.getProductsSmall().then(data => this.products = data);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
formatCurrency(value) {
|
||||||
|
return value.toLocaleString('en-US', {style: 'currency', currency: 'USD'});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -126,4 +185,33 @@ export default {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.product-badge {
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: .25em .5rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 12px;
|
||||||
|
letter-spacing: .3px;
|
||||||
|
|
||||||
|
&.status-instock {
|
||||||
|
background: #C8E6C9;
|
||||||
|
color: #256029;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-outofstock {
|
||||||
|
background: #FFCDD2;
|
||||||
|
color: #C63737;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-lowstock {
|
||||||
|
background: #FEEDAF;
|
||||||
|
color: #8A5340;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-image {
|
||||||
|
width: 100px;
|
||||||
|
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23)
|
||||||
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue