|
63 | 63 | </tr>
|
64 | 64 | </thead>
|
65 | 65 | <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)" |
91 | 73 | >
|
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> |
104 | 112 | </tbody>
|
105 | 113 | <tfoot v-if="footCloneBoolean">
|
106 | 114 | <tr>
|
@@ -368,6 +376,10 @@ const handleRowSelection = (row: TableItem, index: number, shiftClicked = false)
|
368 | 376 | notifySelectionEvent()
|
369 | 377 | }
|
370 | 378 |
|
| 379 | +const toggleRowDetails = (tr: TableItem) => { |
| 380 | + tr._showDetails = !tr._showDetails |
| 381 | +} |
| 382 | +
|
371 | 383 | const getFieldColumnClasses = (field: TableFieldObject) => [
|
372 | 384 | field.class,
|
373 | 385 | field.thClass,
|
|
0 commit comments