Merge pull request #2672 from tugcekucukoglu/browser-demo

browser demo added
pull/2674/head
Tuğçe Küçükoğlu 2022-06-15 09:54:06 +03:00 committed by GitHub
commit ce13531e3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 89 additions and 2 deletions

View File

@ -438,7 +438,10 @@ export default {
imports: `<script src="https://unpkg.com/primevue@^3/dynamicdialog/dynamicdialog.min.js"><\\/script> imports: `<script src="https://unpkg.com/primevue@^3/dynamicdialog/dynamicdialog.min.js"><\\/script>
<script src="https://unpkg.com/primevue@^3/dynamicdialogservice/dynamicdialogservice.min.js"><\\/script> <script src="https://unpkg.com/primevue@^3/dynamicdialogservice/dynamicdialogservice.min.js"><\\/script>
<script src="https://unpkg.com/primevue@^3/toast/toast.min.js"><\\/script> <script src="https://unpkg.com/primevue@^3/toast/toast.min.js"><\\/script>
<script src="https://unpkg.com/primevue@^3/toastservice/toastservice.min.js"><\\/script>`, <script src="https://unpkg.com/primevue@^3/toastservice/toastservice.min.js"><\\/script>
<script src="https://unpkg.com/primevue@^3/datatable/datatable.min.js"><\\/script>
<script src="https://unpkg.com/primevue@^3/column/column.min.js"><\\/script>
<script src="./ProductService.js"><\\/script>`,
content: `<div id="app"> content: `<div id="app">
<p-button label="Show" @click="onShow"></p-button> <p-button label="Show" @click="onShow"></p-button>
<p-toast></p-toast> <p-toast></p-toast>
@ -496,6 +499,91 @@ export default {
} }
}; };
const ProductListDemo = {
template: \`<div>
<div class="flex justify-content-end mt-1 mb-3">
<p-button icon="pi pi-external-link" label="Nested Dialog" class="p-button-outlined p-button-success" @click="showInfo"></p-button>
</div>
<p-datatable :value="products" responsive-layout="scroll">
<p-column field="code" header="Code"></p-column>
<p-column field="name" header="Name"></p-column>
<p-column header="Image">
<template #body="slotProps">
<img :src="'demo/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="shadow-2 w-4rem" />
</template>
</p-column>
<p-column field="category" header="Category"></p-column>
<p-column field="quantity" header="Quantity"></p-column>
<p-column style="width:5rem">
<template #body="slotProps">
<p-button type="button" icon="pi pi-plus" class="p-button-text p-button-rounded" @click="selectProduct(slotProps.data)"></p-button>
</template>
</p-column>
</p-datatable>
</div>\`,
inject: ['dialogRef'],
data() {
return {
products: null
}
},
productService: null,
created() {
this.productService = new ProductService();
},
mounted() {
this.productService.getProductsSmall().then(data => this.products = data.slice(0,5));
},
methods: {
selectProduct(data) {
this.dialogRef.close(data);
},
showInfo() {
this.$dialog.open(InfoDemo, {
props: {
header: 'Information',
modal: true,
dismissableMask: true
},
data: {
totalProducts: this.products ? this.products.length : 0
}
});
}
},
components: {
"p-datatable": primevue.datatable,
"p-column": primevue.column,
"p-button": primevue.button
}
};
const InfoDemo = {
template: \`<div>
<p>There are <strong>{{totalProducts}}</strong> products in total in this list.</p>
<div class="flex justify-content-end">
<p-button type="button" label="Close" @click="closeDialog"></p-button>
</div>
</div>\`,
inject: ['dialogRef'],
data() {
return {
totalProducts: 0
}
},
mounted() {
this.totalProducts = this.dialogRef.data.totalProducts;
},
methods: {
closeDialog() {
this.dialogRef.close();
}
},
components: {
"p-button": primevue.button
}
};
createApp(App) createApp(App)
.use(primevue.config.default) .use(primevue.config.default)
.use(primevue.dialogservice) .use(primevue.dialogservice)

View File

@ -19,7 +19,6 @@
</template> </template>
</Column> </Column>
</DataTable> </DataTable>
</div> </div>
</template> </template>