Fixed source display

pull/731/head
Cagatay Civici 2020-12-01 14:41:09 +03:00
parent fcc9ee679f
commit 901eca060d
1 changed files with 98 additions and 97 deletions

View File

@ -146,113 +146,114 @@
<TabPanel header="Source">
<pre v-code>
<code><template v-pre>
&lt;Toolbar class="p-mb-4"&gt;
&lt;template #left&gt;
&lt;Button label="New" icon="pi pi-plus" class="p-button-success p-mr-2" @click="openNew" /&gt;
&lt;Button label="Delete" icon="pi pi-trash" class="p-button-danger" @click="confirmDeleteSelected" :disabled="!selectedProducts || !selectedProducts.length" /&gt;
&lt;/template&gt;
&lt;div class="card"&gt;
&lt;Toolbar class="p-mb-4"&gt;
&lt;template #left&gt;
&lt;Button label="New" icon="pi pi-plus" class="p-button-success p-mr-2" @click="openNew" /&gt;
&lt;Button label="Delete" icon="pi pi-trash" class="p-button-danger" @click="confirmDeleteSelected" :disabled="!selectedProducts || !selectedProducts.length" /&gt;
&lt;/template&gt;
&lt;template #right&gt;
&lt;FileUpload mode="basic" accept="image/*" :maxFileSize="1000000" label="Import" chooseLabel="Import" class="p-mr-2" /&gt;
&lt;Button label="Export" icon="pi pi-upload" class="p-button-help" @click="exportCSV($event)" /&gt;
&lt;/template&gt;
&lt;/Toolbar&gt;
&lt;template #right&gt;
&lt;FileUpload mode="basic" accept="image/*" :maxFileSize="1000000" label="Import" chooseLabel="Import" class="p-mr-2 p-d-inline-block" /&gt;
&lt;Button label="Export" icon="pi pi-upload" class="p-button-help" @click="exportCSV($event)" /&gt;
&lt;/template&gt;
&lt;/Toolbar&gt;
&lt;DataTable ref="dt" :value="products" v-model:selection="selectedProducts" dataKey="id"
:paginator="true" :rows="10" :filters="filters"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown" :rowsPerPageOptions="[5,10,25]"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} products"&gt;
&lt;template #header&gt;
&lt;div class="table-header"&gt;
&lt;h5 class="p-m-0"&gt;Manage Products&lt;/h5&gt;
&lt;span class="p-input-icon-left"&gt;
&lt;i class="pi pi-search" /&gt;
&lt;InputText v-model="filters['global']" placeholder="Search..." /&gt;
&lt;/span&gt;
&lt;/div&gt;
&lt;/template&gt;
&lt;DataTable ref="dt" :value="products" v-model:selection="selectedProducts" dataKey="id"
:paginator="true" :rows="10" :filters="filters"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown" :rowsPerPageOptions="[5,10,25]"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords} products"&gt;
&lt;template #header&gt;
&lt;div class="table-header"&gt;
&lt;h5 class="p-m-0"&gt;Manage Products&lt;/h5&gt;
&lt;span class="p-input-icon-left"&gt;
&lt;i class="pi pi-search" /&gt;
&lt;InputText v-model="filters['global']" placeholder="Search..." /&gt;
&lt;/span&gt;
&lt;/div&gt;
&lt;/template&gt;
&lt;Column selectionMode="multiple" headerStyle="width: 3rem" :exportable="false"&gt;&lt;/Column&gt;
&lt;Column field="code" header="Code" :sortable="true"&gt;&lt;/Column&gt;
&lt;Column field="name" header="Name" :sortable="true"&gt;&lt;/Column&gt;
&lt;Column header="Image"&gt;
&lt;Column selectionMode="multiple" headerStyle="width: 3rem" :exportable="false"&gt;&lt;/Column&gt;
&lt;Column field="code" header="Code" :sortable="true"&gt;&lt;/Column&gt;
&lt;Column field="name" header="Name" :sortable="true"&gt;&lt;/Column&gt;
&lt;Column header="Image"&gt;
&lt;template #body="slotProps"&gt;
&lt;img :src="'demo/images/product/' + slotProps.data.image" :alt="slotProps.data.image" class="product-image" /&gt;
&lt;/template&gt;
&lt;/Column&gt;
&lt;Column field="price" header="Price" :sortable="true"&gt;
&lt;template #body="slotProps"&gt;
&lt;img :src="'demo/images/product/' + slotProps.data.image" :alt="slotProps.data.image" class="product-image" /&gt;
&lt;/template&gt;
&lt;/Column&gt;
&lt;Column field="price" header="Price" :sortable="true"&gt;
&lt;template #body="slotProps"&gt;
{{formatCurrency(slotProps.data.price)}}
&lt;/template&gt;
&lt;/Column&gt;
&lt;Column field="category" header="Category" :sortable="true"&gt;&lt;/Column&gt;
&lt;Column field="rating" header="Reviews" :sortable="true"&gt;
&lt;template #body="slotProps"&gt;
&lt;Rating :modelValue="slotProps.data.rating" :readonly="true" :cancel="false" /&gt;
&lt;/template&gt;
&lt;/Column&gt;
&lt;Column field="inventoryStatus" header="Status" :sortable="true"&gt;
&lt;template #body="slotProps"&gt;
&lt;span :class="'product-badge status-' + slotProps.data.inventoryStatus.toLowerCase()"&gt;{{slotProps.data.inventoryStatus}}&lt;/span&gt;
&lt;/template&gt;
&lt;/Column&gt;
&lt;Column :exportable="false"&gt;
&lt;template #body="slotProps"&gt;
&lt;Button icon="pi pi-pencil" class="p-button-rounded p-button-success p-mr-2" @click="editProduct(slotProps.data)" /&gt;
&lt;Button icon="pi pi-trash" class="p-button-rounded p-button-warning" @click="confirmDeleteProduct(slotProps.data)" /&gt;
&lt;/template&gt;
&lt;/Column&gt;
&lt;/DataTable&gt;
{{formatCurrency(slotProps.data.price)}}
&lt;/template&gt;
&lt;/Column&gt;
&lt;Column field="category" header="Category" :sortable="true"&gt;&lt;/Column&gt;
&lt;Column field="rating" header="Reviews" :sortable="true"&gt;
&lt;template #body="slotProps"&gt;
&lt;Rating :modelValue="slotProps.data.rating" :readonly="true" :cancel="false" /&gt;
&lt;/template&gt;
&lt;/Column&gt;
&lt;Column field="inventoryStatus" header="Status" :sortable="true"&gt;
&lt;template #body="slotProps"&gt;
&lt;span :class="'product-badge status-' + slotProps.data.inventoryStatus.toLowerCase()"&gt;{{slotProps.data.inventoryStatus}}&lt;/span&gt;
&lt;/template&gt;
&lt;/Column&gt;
&lt;Column :exportable="false"&gt;
&lt;template #body="slotProps"&gt;
&lt;Button icon="pi pi-pencil" class="p-button-rounded p-button-success p-mr-2" @click="editProduct(slotProps.data)" /&gt;
&lt;Button icon="pi pi-trash" class="p-button-rounded p-button-warning" @click="confirmDeleteProduct(slotProps.data)" /&gt;
&lt;/template&gt;
&lt;/Column&gt;
&lt;/DataTable&gt;
&lt;/div&gt;
&lt;Dialog v-model:visible="productDialog" :style="{width: '450px'}" header="Product Details" :modal="true" class="p-fluid"&gt;
&lt;img :src="'demo/images/product/' + product.image" :alt="product.image" class="product-image" v-if="product.image" /&gt;
&lt;div class="p-field"&gt;
&lt;label for="name"&gt;Name&lt;/label&gt;
&lt;InputText id="name" v-model.trim="product.name" required="true" autofocus :class="{'p-invalid': submitted &amp;&amp; !product.name}" /&gt;
&lt;small class="p-invalid" v-if="submitted &amp;&amp; !product.name"&gt;Name is required.&lt;/small&gt;
&lt;/div&gt;
&lt;div class="p-field"&gt;
&lt;label for="description"&gt;Description&lt;/label&gt;
&lt;Textarea id="description" v-model="product.description" required="true" rows="3" cols="20" /&gt;
&lt;/div&gt;
&lt;img :src="'demo/images/product/' + product.image" :alt="product.image" class="product-image" v-if="product.image" /&gt;
&lt;div class="p-field"&gt;
&lt;label for="name"&gt;Name&lt;/label&gt;
&lt;InputText id="name" v-model.trim="product.name" required="true" autofocus :class="{'p-invalid': submitted &amp;&amp; !product.name}" /&gt;
&lt;small class="p-invalid" v-if="submitted &amp;&amp; !product.name"&gt;Name is required.&lt;/small&gt;
&lt;/div&gt;
&lt;div class="p-field"&gt;
&lt;label for="description"&gt;Description&lt;/label&gt;
&lt;Textarea id="description" v-model="product.description" required="true" rows="3" cols="20" /&gt;
&lt;/div&gt;
&lt;div class="p-field"&gt;
&lt;label class="p-mb-3"&gt;Category&lt;/label&gt;
&lt;div class="p-formgrid p-grid"&gt;
&lt;div class="p-field-radiobutton p-col-6"&gt;
&lt;RadioButton id="category1" name="category" value="Accessories" v-model="product.category" /&gt;
&lt;label for="category1"&gt;Accessories&lt;/label&gt;
&lt;/div&gt;
&lt;div class="p-field-radiobutton p-col-6"&gt;
&lt;RadioButton id="category2" name="category" value="Clothing" v-model="product.category" /&gt;
&lt;label for="category2"&gt;Clothing&lt;/label&gt;
&lt;/div&gt;
&lt;div class="p-field-radiobutton p-col-6"&gt;
&lt;RadioButton id="category3" name="category" value="Electronics" v-model="product.category" /&gt;
&lt;label for="category3"&gt;Electronics&lt;/label&gt;
&lt;/div&gt;
&lt;div class="p-field-radiobutton p-col-6"&gt;
&lt;RadioButton id="category4" name="category" value="Fitness" v-model="product.category" /&gt;
&lt;label for="category4"&gt;Fitness&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="p-field"&gt;
&lt;label class="p-mb-3"&gt;Category&lt;/label&gt;
&lt;div class="p-formgrid p-grid"&gt;
&lt;div class="p-field-radiobutton p-col-6"&gt;
&lt;RadioButton id="category1" name="category" value="Accessories" v-model="product.category" /&gt;
&lt;label for="category1"&gt;Accessories&lt;/label&gt;
&lt;div class="p-field p-col"&gt;
&lt;label for="price"&gt;Price&lt;/label&gt;
&lt;InputNumber id="price" v-model="product.price" mode="currency" currency="USD" locale="en-US" /&gt;
&lt;/div&gt;
&lt;div class="p-field-radiobutton p-col-6"&gt;
&lt;RadioButton id="category2" name="category" value="Clothing" v-model="product.category" /&gt;
&lt;label for="category2"&gt;Clothing&lt;/label&gt;
&lt;/div&gt;
&lt;div class="p-field-radiobutton p-col-6"&gt;
&lt;RadioButton id="category3" name="category" value="Electronics" v-model="product.category" /&gt;
&lt;label for="category3"&gt;Electronics&lt;/label&gt;
&lt;/div&gt;
&lt;div class="p-field-radiobutton p-col-6"&gt;
&lt;RadioButton id="category4" name="category" value="Fitness" v-model="product.category" /&gt;
&lt;label for="category4"&gt;Fitness&lt;/label&gt;
&lt;div class="p-field p-col"&gt;
&lt;label for="quantity"&gt;Quantity&lt;/label&gt;
&lt;InputNumber id="quantity" v-model="product.quantity" integeronly /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="p-formgrid p-grid"&gt;
&lt;div class="p-field p-col"&gt;
&lt;label for="price"&gt;Price&lt;/label&gt;
&lt;InputNumber id="price" v-model="product.price" mode="currency" currency="USD" locale="en-US" /&gt;
&lt;/div&gt;
&lt;div class="p-field p-col"&gt;
&lt;label for="quantity"&gt;Quantity&lt;/label&gt;
&lt;InputNumber id="quantity" v-model="product.quantity" integeronly /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;template #footer&gt;
&lt;Button label="Cancel" icon="pi pi-times" class="p-button-text" @click="hideDialog"/&gt;
&lt;Button label="Save" icon="pi pi-check" class="p-button-text" @click="saveProduct" /&gt;
&lt;/template&gt;
&lt;template #footer&gt;
&lt;Button label="Cancel" icon="pi pi-times" class="p-button-text" @click="hideDialog"/&gt;
&lt;Button label="Save" icon="pi pi-check" class="p-button-text" @click="saveProduct" /&gt;
&lt;/template&gt;
&lt;/Dialog&gt;
&lt;Dialog v-model:visible="deleteProductDialog" :style="{width: '450px'}" header="Confirm" :modal="true"&gt;
@ -264,9 +265,9 @@
&lt;Button label="No" icon="pi pi-times" class="p-button-text" @click="deleteProductDialog = false"/&gt;
&lt;Button label="Yes" icon="pi pi-check" class="p-button-text" @click="deleteProduct" /&gt;
&lt;/template&gt;
&lt;/Dialog&gt;
&lt;/Dialog&gt;
&lt;Dialog v-model:visible="deleteProductsDialog" :style="{width: '450px'}" header="Confirm" :modal="true"&gt;
&lt;Dialog v-model:visible="deleteProductsDialog" :style="{width: '450px'}" header="Confirm" :modal="true"&gt;
&lt;div class="confirmation-content"&gt;
&lt;i class="pi pi-exclamation-triangle p-mr-3" style="font-size: 2rem" /&gt;
&lt;span v-if="product"&gt;Are you sure you want to delete the selected products?&lt;/span&gt;