Skip to content

Commit 36a2d4b

Browse files
committed
sidebar modifications
1 parent ec39901 commit 36a2d4b

File tree

4 files changed

+55
-19
lines changed

4 files changed

+55
-19
lines changed

src/routes/main/components/Sidebar.vue

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,78 @@
11
<template>
2-
<v-navigation-drawer dark clipped fixed app v-model="$store.state.drawer" class="secondary main-sidebar" value="false" width="220">
2+
<div @click="click()" @mouseleave="mouseleave()">
3+
<v-navigation-drawer
4+
permanent
5+
:mini-variant="$store.state.sidebarMini"
6+
dark clipped
7+
fixed
8+
app
9+
class="secondary main-sidebar"
10+
mini-variant-width="60"
11+
>
312
<v-list dense>
413
<template v-if="checkRole(item.guard)" v-for="(item) in items">
5-
<v-list-group v-model="item.model" :key="item.text" :prepend-icon="item.model ? item.icon : item['icon-alt']"
14+
<v-list-group v-model="item.model" :key="item.text" :prepend-icon="item.icon"
615
append-icon="">
716
<v-list-tile slot="activator">
817
<v-list-tile-content>
918
<v-list-tile-title>
1019
{{ $t('global.routes.' + item.text) }}
1120
</v-list-tile-title>
1221
</v-list-tile-content>
13-
</v-list-tile>
14-
<v-list-tile v-for="(child, i) in item.children" :key="i" :href="'#' + item.route + child.route">
15-
<v-list-tile-action v-if="child.icon">
16-
<v-icon>{{ child.icon }}</v-icon>
22+
<v-list-tile-action v-if="item.icon">
23+
<v-icon>{{ item.model ? 'keyboard_arrow_up' : 'keyboard_arrow_down' }}</v-icon>
1724
</v-list-tile-action>
18-
<v-list-tile-content>
19-
<v-list-tile-title>
20-
{{ $t('global.routes.' + child.text) }}
21-
</v-list-tile-title>
22-
</v-list-tile-content>
2325
</v-list-tile>
26+
<template v-if="!$store.state.sidebarMini">
27+
<v-list-tile v-for="(child, i) in item.children" :key="i" :href="'#' + item.route + child.route">
28+
<v-list-tile-action v-if="child.icon">
29+
<v-icon>{{ child.icon }}</v-icon>
30+
</v-list-tile-action>
31+
<v-list-tile-content>
32+
<v-list-tile-title>
33+
{{ $t('global.routes.' + child.text) }}
34+
</v-list-tile-title>
35+
</v-list-tile-content>
36+
</v-list-tile>
37+
</template>
2438
</v-list-group>
2539
</template>
2640
</v-list>
2741
</v-navigation-drawer>
42+
</div>
2843
</template>
2944

3045
<script>
31-
import { mapGetters } from "vuex";
46+
import { mapState, mapGetters, mapMutations } from "vuex";
3247
3348
export default {
49+
computed: {
50+
...mapState(["sidebarMini", "sidebar"]),
51+
...mapGetters("auth", ["checkRole"])
52+
},
53+
props: {
54+
source: String
55+
},
56+
methods: {
57+
...mapMutations([
58+
'toggleSidebarWidth',
59+
'setSidebarWidth'
60+
]),
61+
click() {
62+
if(this.sidebarMini) {
63+
this.setSidebarWidth(false)
64+
}
65+
},
66+
mouseleave() {
67+
this.setSidebarWidth(true)
68+
}
69+
},
3470
data: () => ({
71+
setSidebarMini: false,
3572
dialog: false,
36-
drawer: null,
3773
items: [
3874
{
39-
icon: "keyboard_arrow_up",
40-
"icon-alt": "keyboard_arrow_down",
75+
icon: "people",
4176
text: "crm.name",
4277
model: false,
4378
guard: "CRM",
@@ -90,8 +125,7 @@ export default {
90125
]
91126
},
92127
{
93-
icon: "keyboard_arrow_up",
94-
"icon-alt": "keyboard_arrow_down",
128+
icon: "person_add_disabled",
95129
text: "admin.name",
96130
model: false,
97131
guard: "ADMIN",

src/routes/main/components/Toolbar.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<template>
22
<v-toolbar clipped-left dark fixed app color="primary">
3-
<v-toolbar-side-icon @click.stop="$store.state.drawer = !$store.state.drawer"></v-toolbar-side-icon>
43
<v-toolbar-title class="title">
54
<router-link to="/home">{{$store.state.title}}</router-link>
65
</v-toolbar-title>

src/store/mutations.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ let mutations = {
1515
localStorage.setItem('locale', locale)
1616
state.locale = locale
1717
},
18+
setSidebarWidth(state, mini) {
19+
state.sidebarMini = mini
20+
},
1821
// alerts
1922
alertSuccess(state, text) {
2023
state.alert.type = 'success'

src/store/state.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let state = {
1212
secondaryTheme: 'dark',
1313
module: null,
1414
page: null,
15-
drawer: true,
15+
sidebarMini: true,
1616
activeModule: "",
1717
profileDialog: false,
1818
superuser: false,

0 commit comments

Comments
 (0)