use slot in table too

This commit is contained in:
j3d1 2019-12-24 14:40:01 +01:00
parent 52dcab03ba
commit 6290eee156
3 changed files with 18 additions and 20 deletions

View file

@ -24,16 +24,14 @@
> >
</div> </div>
</th> </th>
<th>actions</th> <th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="item in internalItems" :key="item[keyName]" @click="$emit('itemActivated', item)"> <tr v-for="item in internalItems" :key="item[keyName]" @click="$emit('itemActivated', item)">
<td v-for="(column, index) in columns" :key="index">{{ item[column] }}</td> <td v-for="(column, index) in columns" :key="index">{{ item[column] }}</td>
<td> <td>
<div class="btn-group"> <slot v-bind:item="item"/>
<button class="btn btn-outline-secondary" v-for="(action, a_index) in actions" :key="a_index" @click.stop="action.fun&&action.fun(item)" >{{action.name}}</button>
</div>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View file

@ -4,14 +4,15 @@
<div class="col-xl-8 offset-xl-2"> <div class="col-xl-8 offset-xl-2">
<Table <Table
:columns="['cid', 'name']" :columns="['cid', 'name']"
:actions="[
{name:'enlarge'},
{name:'content', fun: item => showBoxContent(item.name)},
{name:'delete'},
]"
:items="loadedBoxes" :items="loadedBoxes"
:keyName="'cid'" :keyName="'cid'"
/> v-slot="{ item }"
>
<div class="btn-group">
<button class="btn btn-outline-secondary" @click.stop="showBoxContent(item.name)" >content</button>
<button class="btn btn-outline-secondary" @click.stop="" >delete</button>
</div>
</Table>
</div> </div>
</div> </div>
</div> </div>

View file

@ -17,22 +17,21 @@
<div class="col-xl-8 offset-xl-2"> <div class="col-xl-8 offset-xl-2">
<Table <Table
:columns="['uid', 'description', 'box']" :columns="['uid', 'description', 'box']"
:actions="[
{name: 'enlarge', fun: item => openEditingModalWith(item)},
{name: 'delete',fun: item => deleteItem(item)}
]"
:items="loadedItems" :items="loadedItems"
:keyName="'uid'" :keyName="'uid'"
v-slot="{ item }"
@itemActivated="openLightboxModalWith($event)" @itemActivated="openLightboxModalWith($event)"
/> >
<div class="btn-group">
<button class="btn btn-outline-secondary" @click.stop="openEditingModalWith(item)" >edit</button>
<button class="btn btn-outline-secondary" @click.stop="deleteItem(item)" >delete</button>
</div>
</Table>
</div> </div>
</div> </div>
<Cards <Cards
v-if="layout === 'cards'" v-if="layout === 'cards'"
:columns="['uid', 'description', 'box']" :columns="['uid', 'description', 'box']"
:actions="[
{name: 'delete'}
]"
:items="loadedItems" :items="loadedItems"
:keyName="'uid'" :keyName="'uid'"
v-slot="{ item }" v-slot="{ item }"
@ -48,10 +47,10 @@
<div class="row mx-auto mt-2"> <div class="row mx-auto mt-2">
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-outline-secondary" @click.stop="openEditingModalWith(item)"> <button class="btn btn-outline-secondary" @click.stop="openEditingModalWith(item)">
Edit edit
</button> </button>
<button class="btn btn-outline-secondary" @click.stop="deleteItem(item)"> <button class="btn btn-outline-secondary" @click.stop="deleteItem(item)">
Delete delete
</button> </button>
</div> </div>
</div> </div>