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

245 lines
5.0 KiB
Vue
Raw Normal View History

2020-04-10 15:47:29 +02:00
<template>
<div class="spaces">
2020-08-20 15:11:41 +02:00
<div class="app-tree spaces-tree" v-resizable="resizable">
2020-08-31 14:33:31 +02:00
<ui-header-bar title="@space.list" />
2020-09-01 12:26:09 +02:00
<div class="spaces-tree-items">
2021-12-23 14:39:00 +01:00
<ui-link :to="{ name: 'space', params: { alias: item.alias } }" v-for="item in spaces" :key="item.alias" class="spaces-tree-item" :class="{ 'has-line': item.lineBelow }">
2021-01-17 20:04:43 +01:00
<ui-icon class="spaces-tree-item-icon" :symbol="item.icon" />
2020-09-01 12:26:09 +02:00
<span class="spaces-tree-item-text">
<span v-localize="item.name"></span>
<span class="-minor" v-if="item.description" v-localize="item.description"></span>
</span>
2021-12-23 14:39:00 +01:00
</ui-link>
2020-04-29 13:18:53 +02:00
</div>
<div class="spaces-tree-resizable ui-resizable"></div>
2020-04-10 15:47:29 +02:00
</div>
2020-04-29 13:18:53 +02:00
2020-12-13 18:17:55 +01:00
<component class="spaces-main" v-if="!isOverview && loaded && component" ref="comp" :is="component" :space="space" :config="spaceConfig"></component>
2020-04-10 15:47:29 +02:00
</div>
</template>
<script>
2020-11-01 22:20:29 +01:00
import SpaceEditor from 'zero/pages/spaces/views/editor.vue';
import SpaceList from 'zero/pages/spaces/views/list.vue';
import SpaceCustom from 'zero/pages/spaces/views/custom.vue';
2020-11-20 15:17:41 +01:00
import SpacesApi from 'zero/api/spaces.js';
2020-04-10 15:47:29 +02:00
2020-04-29 13:18:53 +02:00
export default {
2020-04-10 15:47:29 +02:00
data: () => ({
spaces: [],
loaded: false,
component: null,
space: null,
spaceConfig: {},
2020-04-29 13:18:53 +02:00
resizable: {
axis: 'x',
min: 260,
max: 520,
save: 'spaces-tree',
2020-04-29 13:18:53 +02:00
handle: '.ui-resizable'
}
2020-04-10 15:47:29 +02:00
}),
2020-04-29 13:18:53 +02:00
computed: {
isOverview()
{
return !this.$route.params.alias;
2020-04-29 13:18:53 +02:00
}
},
watch: {
'$route': 'loadSpace'
},
2020-04-10 15:47:29 +02:00
created()
{
2020-04-30 12:04:34 +02:00
SpacesApi.getAll().then(response =>
2020-04-29 13:18:53 +02:00
{
this.spaces = response;
this.loadSpace();
2020-04-29 13:18:53 +02:00
});
2020-04-10 15:47:29 +02:00
},
2020-05-04 14:13:03 +02:00
beforeRouteLeave(to, from, next)
{
if (this.$refs.comp && this.$refs.comp.beforeRouteLeave)
{
this.$refs.comp.beforeRouteLeave(to, from, next);
}
else
{
next();
}
},
beforeRouteUpdate(to, from, next)
{
if (this.$refs.comp && this.$refs.comp.beforeRouteLeave)
{
this.$refs.comp.beforeRouteLeave(to, from, next);
}
else
{
next();
}
},
2020-04-10 15:47:29 +02:00
methods: {
loadSpace()
{
this.loaded = false;
2020-10-20 15:01:34 +02:00
this.$nextTick(() =>
{
if (this.isOverview)
{
const space = this.spaces[0];
if (space)
{
this.$router.replace({
name: 'space',
params: { alias: space.alias }
});
}
else
{
this.space = null;
this.component = null;
this.loaded = true;
}
2020-10-20 15:01:34 +02:00
return;
}
2020-10-20 15:01:34 +02:00
this.space = this.spaces.find(space => space.alias === this.$route.params.alias);
2020-10-20 15:01:34 +02:00
if (this.space.view === 'editor' || this.$route.params.id || this.$route.meta.create)
{
this.component = SpaceEditor;
}
else if (this.space.view === 'list')
{
this.component = SpaceList;
}
else
{
throw "Not implemented. Custom space view";
}
this.loaded = true;
});
2020-04-10 15:47:29 +02:00
}
}
}
2020-04-29 13:18:53 +02:00
</script>
<style lang="scss">
.spaces
2020-04-29 13:18:53 +02:00
{
display: grid;
grid-template-columns: auto 1fr;
gap: 2px;
2020-04-29 13:18:53 +02:00
justify-content: stretch;
height: 100vh;
}
2020-12-13 18:17:55 +01:00
.spaces-main
{
min-height: 100vh;
overflow-y: auto;
}
.spaces-overview
2020-04-29 13:18:53 +02:00
{
padding: 95px 0 0 60px;
}
2020-08-20 15:11:41 +02:00
.spaces-tree-items
{
margin-top: -13px;
}
2020-04-29 13:18:53 +02:00
.spaces-tree-item
2020-04-29 13:18:53 +02:00
{
display: grid;
2021-01-06 12:03:21 +01:00
grid-template-columns: 32px 1fr auto;
2020-09-01 12:26:09 +02:00
gap: 6px;
height: 100%;
2020-04-29 13:18:53 +02:00
align-items: center;
position: relative;
2020-09-01 12:26:09 +02:00
padding: 15px var(--padding);
font-size: var(--font-size);
color: var(--color-text);
2020-04-29 13:18:53 +02:00
transition: color 0.2s ease;
&:hover > .spaces-tree-item-actions
2020-04-29 13:18:53 +02:00
{
transition-delay: 0.2s;
opacity: 1;
}
2020-08-20 15:11:41 +02:00
&.is-active
{
background: var(--color-tree-selected);
2020-04-29 13:18:53 +02:00
font-weight: bold;
2020-04-30 15:46:50 +02:00
.spaces-tree-item-text span
{
font-weight: 400;
}
2020-09-05 17:35:47 +02:00
.spaces-tree-item-text span:first-child
{
font-weight: 700;
}
2020-04-29 13:18:53 +02:00
}
2021-01-06 12:03:21 +01:00
/*&.is-active:before
{
2021-01-06 12:03:21 +01:00
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 3px;
display: inline-block;
background: var(--color-tree-selected-line);
}*/
&:hover .spaces-tree-item-icon
{
color: var(--color-text);
}
&.is-active .spaces-tree-item-icon
{
color: var(--color-primary);
}
2020-04-29 13:18:53 +02:00
}
.spaces-tree-item-text
2020-04-29 13:18:53 +02:00
{
display: flex;
flex-direction: column;
2020-09-01 12:26:09 +02:00
.-minor
2020-04-29 13:18:53 +02:00
{
color: var(--color-text-dim);
2020-05-03 15:43:26 +02:00
margin-top: 3px;
2020-04-29 13:18:53 +02:00
}
}
.spaces-tree-item-icon
2020-04-29 13:18:53 +02:00
{
font-size: 18px;
line-height: 1;
font-weight: 400;
position: relative;
top: -2px;
color: var(--color-text-dim);
2020-04-29 13:18:53 +02:00
transition: color 0.2s ease;
}
</style>