Skip to content

Commit a1528ed

Browse files
authored
chore: Add crud table body slot (baserow#5428)
1 parent b8559a5 commit a1528ed

1 file changed

Lines changed: 40 additions & 28 deletions

File tree

web-frontend/modules/core/components/crudTable/CrudTable.vue

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -77,36 +77,47 @@
7777
</tr>
7878
</thead>
7979
<tbody>
80-
<tr
81-
v-for="row in rows"
82-
:key="'row-' + row.id"
83-
class="data-table__table-row"
80+
<slot
81+
name="rows"
82+
:rows="rows"
83+
:columns="columns"
84+
:update-row="updateRow"
85+
:delete-row="deleteRow"
86+
:refresh="refresh"
8487
>
85-
<td
86-
v-for="col in columns"
87-
:key="'col-' + col.key"
88-
class="data-table__table-cell"
89-
:class="{
90-
'data-table__table-cell--sticky-left': col.stickyLeft,
91-
'data-table__table-cell--sticky-right': col.stickyRight,
92-
[`data-table__table-cell--${col.key}`]: true,
93-
}"
94-
@contextmenu="$emit('row-context', { col, row, event: $event })"
88+
<tr
89+
v-for="row in rows"
90+
:key="'row-' + row.id"
91+
class="data-table__table-row"
9592
>
96-
<div class="data-table__table-cell-content">
97-
<component
98-
:is="col.cellComponent"
99-
:row="row"
100-
:column="col"
101-
v-on="$attrs"
102-
@row-context="(payload) => $emit('row-context', payload)"
103-
@row-update="updateRow"
104-
@row-delete="deleteRow"
105-
@refresh="refresh"
106-
/>
107-
</div>
108-
</td>
109-
</tr>
93+
<td
94+
v-for="col in columns"
95+
:key="'col-' + col.key"
96+
class="data-table__table-cell"
97+
:class="{
98+
'data-table__table-cell--sticky-left': col.stickyLeft,
99+
'data-table__table-cell--sticky-right': col.stickyRight,
100+
[`data-table__table-cell--${col.key}`]: true,
101+
}"
102+
@contextmenu="
103+
$emit('row-context', { col, row, event: $event })
104+
"
105+
>
106+
<div class="data-table__table-cell-content">
107+
<component
108+
:is="col.cellComponent"
109+
:row="row"
110+
:column="col"
111+
v-on="$attrs"
112+
@row-context="(payload) => $emit('row-context', payload)"
113+
@row-update="updateRow"
114+
@row-delete="deleteRow"
115+
@refresh="refresh"
116+
/>
117+
</div>
118+
</td>
119+
</tr>
120+
</slot>
110121
</tbody>
111122
</table>
112123
</div>
@@ -145,6 +156,7 @@ import isObject from 'lodash/isObject'
145156
* Two slot props are provided `updateRow` and `deleteRow` which are functions
146157
* called when your menu has changed the row state which trigger the CrudTable
147158
* to rerender the rows with the new data.
159+
* #rows: Can optionally replace the rows in the table.
148160
*/
149161
export default {
150162
name: 'CrudTable',

0 commit comments

Comments
 (0)