add direct link from box view to items filtered by box

This commit is contained in:
j3d1 2019-12-22 22:32:15 +01:00
parent 372d773ec4
commit 90b9d63bb5
4 changed files with 24 additions and 4 deletions

View file

@ -24,11 +24,17 @@
> >
</div> </div>
</th> </th>
<th>actions</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>
<div class="btn-group">
<button class="btn btn-outline-secondary" v-for="(action, a_index) in actions" :key="a_index" @click="action.fun&&action.fun(item, action)">{{action.name}}</button>
</div>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View file

@ -64,6 +64,9 @@ const store = new Vuex.Store({
changeView({ getters }, link) { changeView({ getters }, link) {
router.push({path: `/${getters.getEventSlug}/${link.path}`}); router.push({path: `/${getters.getEventSlug}/${link.path}`});
}, },
showBoxContent({ getters }, box) {
router.push({path: `/${getters.getEventSlug}/items`, query: {box}});
},
async loadEventItems({ commit, getters }) { async loadEventItems({ commit, getters }) {
const { data } = await axios.get(`/1/${getters.getEventSlug}/items`); const { data } = await axios.get(`/1/${getters.getEventSlug}/items`);
commit('replaceLoadedItems', data); commit('replaceLoadedItems', data);

View file

@ -4,7 +4,11 @@
<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="['enlarge']" :actions="[
{name:'enlarge'},
{name:'content', fun: (item,action) => showBoxContent(item.name)},
{name:'delete'},
]"
:items="loadedBoxes" :items="loadedBoxes"
:keyName="'cid'" :keyName="'cid'"
/> />
@ -14,12 +18,14 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex'; import {mapActions, mapState} from 'vuex';
import Table from '@/components/Table'; import Table from '@/components/Table';
export default { export default {
name: 'Boxes', name: 'Boxes',
components: {Table}, components: {Table},
computed: mapState(['loadedBoxes', 'layout']), computed: mapState(['loadedBoxes', 'layout']),
methods: mapActions(['showBoxContent']),
}; };
</script> </script>

View file

@ -16,7 +16,10 @@
<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="['enlarge', 'delete']" :actions="[
{name: 'enlarge'},
{name: 'delete'}
]"
:items="loadedItems" :items="loadedItems"
:keyName="'uid'" :keyName="'uid'"
@itemActivated="openModalWith($event)" @itemActivated="openModalWith($event)"
@ -26,7 +29,9 @@
<Cards <Cards
v-if="layout === 'cards'" v-if="layout === 'cards'"
:columns="['uid', 'description', 'box']" :columns="['uid', 'description', 'box']"
:actions="['delete']" :actions="[
{name: 'delete'}
]"
:items="loadedItems" :items="loadedItems"
:keyName="'uid'" :keyName="'uid'"
v-slot="{ item }" v-slot="{ item }"