Skip to content

Commit

Permalink
feat: add phones child tables
Browse files Browse the repository at this point in the history
  • Loading branch information
sniperadmin committed Nov 16, 2021
1 parent 98887e0 commit 28307bf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/components/TheDataTable.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<v-container>
<!-- SECTION: Parent table -->
<v-data-table
:headers="computedHeaders(data).headers"
:items="computedItems(data)[0].map(o => o.data)"
Expand All @@ -13,7 +14,6 @@
}
}"
show-expand
single-expand
calculate-widths
dense
class="elevation-1"
Expand All @@ -25,6 +25,7 @@
{{ relKey }}
</v-subheader>

<!-- SECTION: Relatives -->
<v-data-table
:headers="computedHeaders(relVal.records).headers"
:items="computedItems(relVal.records)[0].map(m => m.data)"
Expand All @@ -40,16 +41,32 @@
<td :colspan="headers.length">
<template v-for="(firstVal, firstKey, firstIndex) in item.kids">
<v-subheader>
{{ relKey }}
{{ firstKey }}
</v-subheader>

<!-- SECTION: Phones -->
<v-data-table
:headers="computedHeaders(firstVal.records).headers"
:items="computedItems(firstVal.records)[0].map(m => m.data)"
:single-expand="singleExpand"
:expanded.sync="firstExpanded"
item-key="Phone ID"
@click:row="(i, s) => s.expand(!s.isExpanded)"
show-expand
hide-default-footer
class="elevation-1 mb-4"
></v-data-table>
<!-- SECTION: ./Phones -->
</template>
</td>
</template>
</v-data-table>
<!-- SECTION: ./Relatives -->
</template>
</td>
</template>
</v-data-table>
<!-- SECTION: ./Parent table -->
</v-container>
</template>

Expand Down Expand Up @@ -86,6 +103,7 @@
return {
expanded: [],
childExpanded: [],
firstExpanded: [],
singleExpand: false,
}
},
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/TheDataTable.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

exports[`TheDataTable should display parent table 1`] = `
"<v-container-stub tag=\\"div\\">
<v-data-table-stub mobilebreakpoint=\\"600\\" items=\\"[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]\\" options=\\"[object Object]\\" sortby=\\"\\" sortdesc=\\"\\" customsort=\\"[Function]\\" page=\\"1\\" itemsperpage=\\"10\\" groupby=\\"\\" groupdesc=\\"\\" customgroup=\\"[Function]\\" locale=\\"en-US\\" customfilter=\\"[Function]\\" serveritemslength=\\"-1\\" itemkey=\\"Identification number\\" value=\\"\\" expanded=\\"\\" singleexpand=\\"true\\" noresultstext=\\"$vuetify.dataIterator.noResultsText\\" nodatatext=\\"$vuetify.noDataText\\" loadingtext=\\"$vuetify.dataIterator.loadingText\\" selectablekey=\\"isSelectable\\" loaderheight=\\"4\\" headers=\\"[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]\\" showexpand=\\"true\\" dense=\\"true\\" calculatewidths=\\"true\\" expandicon=\\"$expand\\" itemclass=\\"\\" data-test=\\"parent\\" class=\\"elevation-1\\"></v-data-table-stub>
<v-data-table-stub mobilebreakpoint=\\"600\\" items=\\"[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]\\" options=\\"[object Object]\\" sortby=\\"\\" sortdesc=\\"\\" customsort=\\"[Function]\\" page=\\"1\\" itemsperpage=\\"10\\" groupby=\\"\\" groupdesc=\\"\\" customgroup=\\"[Function]\\" locale=\\"en-US\\" customfilter=\\"[Function]\\" serveritemslength=\\"-1\\" itemkey=\\"Identification number\\" value=\\"\\" expanded=\\"\\" noresultstext=\\"$vuetify.dataIterator.noResultsText\\" nodatatext=\\"$vuetify.noDataText\\" loadingtext=\\"$vuetify.dataIterator.loadingText\\" selectablekey=\\"isSelectable\\" loaderheight=\\"4\\" headers=\\"[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]\\" showexpand=\\"true\\" dense=\\"true\\" calculatewidths=\\"true\\" expandicon=\\"$expand\\" itemclass=\\"\\" data-test=\\"parent\\" class=\\"elevation-1\\"></v-data-table-stub>
</v-container-stub>"
`;

0 comments on commit 28307bf

Please sign in to comment.