Skip to content

Commit 33f30a5

Browse files
committed
feat(BTable): row's _showDetails prop logic was completed
1 parent 6889dbb commit 33f30a5

File tree

1 file changed

+49
-37
lines changed
  • packages/bootstrap-vue-3/src/components/BTable

1 file changed

+49
-37
lines changed

packages/bootstrap-vue-3/src/components/BTable/BTable.vue

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -63,44 +63,52 @@
6363
</tr>
6464
</thead>
6565
<tbody>
66-
<tr
67-
v-for="(tr, ind) in computedItems"
68-
:key="ind"
69-
:class="getRowClasses(tr)"
70-
@click.prevent="onRowClick(tr, ind, $event)"
71-
@dblclick.prevent="onRowDblClick(tr, ind, $event)"
72-
@mouseenter.prevent="onRowMouseEnter(tr, ind, $event)"
73-
@mouseleave.prevent="onRowMouseLeave(tr, ind, $event)"
74-
>
75-
<td
76-
v-if="addSelectableCell"
77-
class="b-table-selection-column"
78-
:class="{
79-
'b-table-sticky-column': stickySelectBoolean,
80-
}"
81-
>
82-
<slot name="selectCell">
83-
<span :class="selectedItems.has(tr) ? 'text-primary' : ''">🗹</span>
84-
</slot>
85-
</td>
86-
<td
87-
v-for="(field, index) in computedFields"
88-
:key="field.key"
89-
v-bind="field.tdAttr"
90-
:class="getFieldRowClasses(field, tr)"
66+
<template v-for="(tr, ind) in computedItems" :key="ind">
67+
<tr
68+
:class="getRowClasses(tr)"
69+
@click.prevent="onRowClick(tr, ind, $event)"
70+
@dblclick.prevent="onRowDblClick(tr, ind, $event)"
71+
@mouseenter.prevent="onRowMouseEnter(tr, ind, $event)"
72+
@mouseleave.prevent="onRowMouseLeave(tr, ind, $event)"
9173
>
92-
<slot
93-
v-if="$slots['cell(' + field.key + ')'] || $slots['cell()']"
94-
:name="$slots['cell(' + field.key + ')'] ? 'cell(' + field.key + ')' : 'cell()'"
95-
:value="tr[field.key]"
96-
:index="index"
97-
:item="tr"
98-
:field="field"
99-
:items="items"
100-
/>
101-
<template v-else>{{ tr[field.key] }}</template>
102-
</td>
103-
</tr>
74+
<td
75+
v-if="addSelectableCell"
76+
class="b-table-selection-column"
77+
:class="{
78+
'b-table-sticky-column': stickySelectBoolean,
79+
}"
80+
>
81+
<slot name="selectCell">
82+
<span :class="selectedItems.has(tr) ? 'text-primary' : ''">🗹</span>
83+
</slot>
84+
</td>
85+
<td
86+
v-for="(field, index) in computedFields"
87+
:key="field.key"
88+
v-bind="field.tdAttr"
89+
:class="getFieldRowClasses(field, tr)"
90+
>
91+
<slot
92+
v-if="$slots['cell(' + field.key + ')'] || $slots['cell()']"
93+
:name="$slots['cell(' + field.key + ')'] ? 'cell(' + field.key + ')' : 'cell()'"
94+
:value="tr[field.key]"
95+
:index="index"
96+
:item="tr"
97+
:field="field"
98+
:items="items"
99+
:toggle-details="() => toggleRowDetails(tr)"
100+
:details-showing="tr._showDetails"
101+
/>
102+
<template v-else>{{ tr[field.key] }}</template>
103+
</td>
104+
</tr>
105+
106+
<tr v-if="tr._showDetails === true && $slots['row-details']" :class="getRowClasses(tr)">
107+
<td :colspan="computedFields.length + (selectableBoolean ? 1 : 0)">
108+
<slot name="row-details" :item="tr" :toggle-details="() => toggleRowDetails(tr)" />
109+
</td>
110+
</tr>
111+
</template>
104112
</tbody>
105113
<tfoot v-if="footCloneBoolean">
106114
<tr>
@@ -368,6 +376,10 @@ const handleRowSelection = (row: TableItem, index: number, shiftClicked = false)
368376
notifySelectionEvent()
369377
}
370378
379+
const toggleRowDetails = (tr: TableItem) => {
380+
tr._showDetails = !tr._showDetails
381+
}
382+
371383
const getFieldColumnClasses = (field: TableFieldObject) => [
372384
field.class,
373385
field.thClass,

0 commit comments

Comments
 (0)