Files
mixtape/zero.Backoffice.UI/old_app/pages/spaces/views/list.vue
T

77 lines
1.6 KiB
Vue
Raw Normal View History

2020-04-29 13:18:53 +02:00
<template>
2021-03-01 22:58:35 +01:00
<div v-if="!loading" class="space-list" :data-space="space.alias">
2020-10-07 12:37:35 +02:00
<ui-header-bar :title="space.name" :count="count" title-empty="List">
2020-10-20 15:01:34 +02:00
<ui-table-filter :attach="$refs.table" />
<ui-add-button :route="createRoute" />
2020-04-29 13:18:53 +02:00
</ui-header-bar>
<div class="ui-blank-box">
2020-10-20 15:01:34 +02:00
<ui-table ref="table" :config="listRenderer" @count="count = $event" />
2020-04-29 13:18:53 +02:00
</div>
</div>
</template>
<script>
2020-11-20 15:17:41 +01:00
import SpacesApi from 'zero/api/spaces.js';
2020-10-20 15:01:34 +02:00
import SpacesDefaultList from 'zero/renderers/lists/spaces.default.js';
2020-04-29 14:06:27 +02:00
2020-04-29 13:18:53 +02:00
export default {
2020-04-30 12:04:34 +02:00
props: [ 'space', 'config' ],
2020-04-29 14:06:27 +02:00
2020-04-29 13:18:53 +02:00
data: () => ({
2020-10-07 12:37:35 +02:00
count: 0,
2020-09-01 11:33:42 +02:00
loading: true,
2020-10-20 15:01:34 +02:00
listRenderer: null,
2020-09-01 12:20:20 +02:00
createRoute: {
name: 'space-create',
params: { alias: null }
}
2020-04-29 13:18:53 +02:00
}),
2020-04-29 14:06:27 +02:00
watch: {
2020-04-30 12:04:34 +02:00
'space': 'load'
2020-04-29 14:06:27 +02:00
},
2020-04-29 13:18:53 +02:00
created()
{
2020-04-29 14:06:27 +02:00
this.load();
2020-04-29 13:18:53 +02:00
},
methods: {
2020-04-29 14:06:27 +02:00
load()
2020-04-29 13:18:53 +02:00
{
2020-09-01 11:33:42 +02:00
this.loading = true;
2020-10-20 15:01:34 +02:00
const alias = 'spaces.' + this.space.alias;
const listRenderer = this.zero.getList(alias) || SpacesDefaultList;
2020-09-01 11:33:42 +02:00
2020-09-01 12:20:20 +02:00
this.createRoute.params.alias = this.space.alias;
2020-09-01 11:33:42 +02:00
2020-10-20 15:01:34 +02:00
listRenderer.link = item =>
{
return {
name: 'space-item',
params: { alias: this.space.alias, id: item.id }
};
2020-04-29 14:06:27 +02:00
};
2020-09-01 11:33:42 +02:00
2020-10-20 15:01:34 +02:00
listRenderer.onFetch(q => SpacesApi.getList(this.space.alias, q));
2020-09-01 12:20:20 +02:00
2020-10-20 15:01:34 +02:00
this.listRenderer = listRenderer;
2020-09-01 12:20:20 +02:00
this.loading = false;
2020-08-31 14:33:31 +02:00
},
2020-04-29 13:18:53 +02:00
2020-08-31 14:33:31 +02:00
add()
{
this.$router.push({
name: 'space-create',
params: { alias: this.space.alias }
});
}
2020-04-29 13:18:53 +02:00
}
}
</script>