Skip to content

Commit

Permalink
Move SimpleTable into its own component
Browse files Browse the repository at this point in the history
  • Loading branch information
jolzee committed May 20, 2020
1 parent 48cc369 commit 1462b7d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 47 deletions.
50 changes: 3 additions & 47 deletions src/components/ChatTeneoResponse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,30 +132,7 @@
</v-row>
<v-row v-if="hasInlineType(extension, 'table')" no-gutters class="px-3 pt-2">
<v-col cols="12">
<v-simple-table
class="elevation-2"
:dense="extension.dense"
:fixed-header="extension.fixedHeader"
:height="extension.maxHeight ? extension.maxHeight : undefined"
>
<template v-slot:default>
<thead v-if="hasHeaders(extension)">
<tr>
<th
v-for="header in extension.headers"
:key="header + uuid"
class="text-left"
v-html="header"
></th>
</tr>
</thead>
<tbody>
<tr v-for="(row, rowIndex) in extension.rows" :key="rowIndex + uuid">
<td v-for="(column, colIndex) in row" :key="colIndex + uuid" v-html="column"></td>
</tr>
</tbody>
</template>
</v-simple-table>
<SimpleTable :extension="extension"></SimpleTable>
</v-col>
</v-row>
</span>
Expand Down Expand Up @@ -433,7 +410,8 @@ export default {
Video: () => import("@/components/Video"),
Vimeo: () => import("@/components/Vimeo"),
YouTube: () => import("@/components/YouTube"),
Form: () => import("@/components/Form")
Form: () => import("@/components/Form"),
SimpleTable: () => import("@/components/SimpleTable")
},
props: {
item: {
Expand All @@ -447,17 +425,6 @@ export default {
},
data() {
return {
simpleTable: {
name: "displaySimpleTable",
dense: false,
maxHeight: null,
fixedHeader: false,
headers: ["Account", "Balance"],
rows: [
["Current", "$1271.21"],
["Private", "$137.54"]
]
},
snackbar: false,
snackBarTimeout: 1500,
snackBarText: "Success",
Expand Down Expand Up @@ -816,17 +783,6 @@ export default {
}
},
methods: {
hasHeaders(extension) {
let hasHeaders = false;
if (extension.headers) {
extension.headers.forEach(header => {
if (header.trim() !== "") {
hasHeaders = true;
}
});
}
return hasHeaders;
},
addAccessibilityPrefix(text) {
const prefix508 = `<span class="sr-only">Chat bot said.</span>`;
if (!isHtml(text)) {
Expand Down
53 changes: 53 additions & 0 deletions src/components/SimpleTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>
<v-simple-table
class="elevation-2"
:dense="extension.dense"
:fixed-header="extension.fixedHeader"
:height="extension.maxHeight ? extension.maxHeight : undefined"
>
<template v-slot:default>
<thead v-if="hasHeaders(extension)">
<tr>
<th
v-for="header in extension.headers"
:key="header + uuid"
class="text-left"
v-html="header"
></th>
</tr>
</thead>
<tbody>
<tr v-for="(row, rowIndex) in extension.rows" :key="rowIndex + uuid">
<td v-for="(column, colIndex) in row" :key="colIndex + uuid" v-html="column"></td>
</tr>
</tbody>
</template>
</v-simple-table>
</template>

<script>
import { mapGetters } from "vuex";
export default {
name: "SimpleTable",
props: ["extension"],
data: () => ({}),
computed: {
...mapGetters(["uuid"])
},
methods: {
hasHeaders(extension) {
let hasHeaders = false;
if (extension.headers) {
extension.headers.forEach(header => {
if (header.trim() !== "") {
hasHeaders = true;
}
});
}
return hasHeaders;
},
}
};
</script>
<style>
</style>

0 comments on commit 1462b7d

Please sign in to comment.