2018-09-23 04:14:01 +00:00
|
|
|
<template lang='pug'>
|
2018-09-30 03:30:20 +00:00
|
|
|
v-container(fluid, grid-list-lg)
|
2018-09-23 04:14:01 +00:00
|
|
|
v-layout(row wrap)
|
|
|
|
v-flex(xs12)
|
2018-09-30 03:30:20 +00:00
|
|
|
.admin-header
|
2019-04-07 16:37:33 +00:00
|
|
|
img.animated.fadeInUp(src='/svg/icon-triangle-arrow.svg', alt='Navigation', style='width: 80px;')
|
2018-09-30 03:30:20 +00:00
|
|
|
.admin-header-title
|
2019-04-07 16:37:33 +00:00
|
|
|
.headline.primary--text.animated.fadeInLeft {{$t('navigation.title')}}
|
|
|
|
.subheading.grey--text.animated.fadeInLeft.wait-p4s {{$t('navigation.subtitle')}}
|
2018-09-30 03:30:20 +00:00
|
|
|
v-spacer
|
2019-04-07 16:37:33 +00:00
|
|
|
v-btn.animated.fadeInDown.wait-p2s(outline, color='grey', @click='refresh', large)
|
2018-10-22 02:25:17 +00:00
|
|
|
v-icon refresh
|
2019-04-07 16:37:33 +00:00
|
|
|
v-btn.animated.fadeInDown(color='success', depressed, @click='save', large)
|
2018-09-30 03:30:20 +00:00
|
|
|
v-icon(left) check
|
|
|
|
span {{$t('common:actions.apply')}}
|
2018-09-23 04:14:01 +00:00
|
|
|
v-container.pa-0.mt-3(fluid, grid-list-lg)
|
|
|
|
v-layout(row)
|
|
|
|
v-flex(style='flex: 0 0 350px;')
|
2019-04-07 16:37:33 +00:00
|
|
|
v-card.animated.fadeInUp
|
2018-09-30 03:30:20 +00:00
|
|
|
v-list.py-2(dense, dark, :class='navTree.length < 1 ? "grey lighten-4" : "primary"')
|
|
|
|
v-list-tile(v-if='navTree.length < 1')
|
|
|
|
v-list-tile-avatar: v-icon(color='grey') explore_off
|
|
|
|
v-list-tile-content
|
|
|
|
.caption.grey--text {{$t('navigation.emptyList')}}
|
2018-09-29 19:39:09 +00:00
|
|
|
draggable(v-model='navTree')
|
2018-09-23 04:14:01 +00:00
|
|
|
template(v-for='navItem in navTree')
|
2018-09-29 19:39:09 +00:00
|
|
|
v-list-tile(
|
|
|
|
v-if='navItem.kind === "link"'
|
|
|
|
:key='navItem.id'
|
|
|
|
:class='(navItem === current) ? "blue" : ""'
|
|
|
|
@click='selectItem(navItem)'
|
|
|
|
)
|
2018-09-23 04:14:01 +00:00
|
|
|
v-list-tile-avatar: v-icon {{navItem.icon}}
|
|
|
|
v-list-tile-title {{navItem.label}}
|
2018-09-29 19:39:09 +00:00
|
|
|
.py-2.clickable(
|
|
|
|
v-else-if='navItem.kind === "divider"'
|
|
|
|
:key='navItem.id'
|
|
|
|
:class='(navItem === current) ? "blue" : ""'
|
|
|
|
@click='selectItem(navItem)'
|
|
|
|
)
|
2018-09-23 04:14:01 +00:00
|
|
|
v-divider
|
2018-09-29 19:39:09 +00:00
|
|
|
v-subheader.pl-4.clickable(
|
|
|
|
v-else-if='navItem.kind === "header"'
|
|
|
|
:key='navItem.id'
|
|
|
|
:class='(navItem === current) ? "blue" : ""'
|
|
|
|
@click='selectItem(navItem)'
|
|
|
|
) {{navItem.label}}
|
2018-09-23 04:14:01 +00:00
|
|
|
v-card-chin
|
2018-09-29 19:39:09 +00:00
|
|
|
v-menu(offset-y, bottom, min-width='200px', style='flex: 1 1;')
|
|
|
|
v-btn(slot='activator', color='primary', depressed, block)
|
2018-09-23 04:14:01 +00:00
|
|
|
v-icon(left) add
|
2018-09-29 19:39:09 +00:00
|
|
|
span {{$t('common:actions.add')}}
|
2018-09-23 04:14:01 +00:00
|
|
|
v-list
|
|
|
|
v-list-tile(@click='addItem("link")')
|
|
|
|
v-list-tile-avatar: v-icon link
|
2018-09-29 19:39:09 +00:00
|
|
|
v-list-tile-title {{$t('navigation.link')}}
|
2018-09-23 04:14:01 +00:00
|
|
|
v-list-tile(@click='addItem("header")')
|
|
|
|
v-list-tile-avatar: v-icon title
|
2018-09-29 19:39:09 +00:00
|
|
|
v-list-tile-title {{$t('navigation.header')}}
|
2018-09-23 04:14:01 +00:00
|
|
|
v-list-tile(@click='addItem("divider")')
|
|
|
|
v-list-tile-avatar: v-icon power_input
|
2018-09-29 19:39:09 +00:00
|
|
|
v-list-tile-title {{$t('navigation.divider')}}
|
2019-04-07 16:37:33 +00:00
|
|
|
v-flex.animated.fadeInUp.wait-p2s
|
2018-12-03 02:42:43 +00:00
|
|
|
v-card.wiki-form(v-if='current.kind === "link"')
|
2018-09-23 04:14:01 +00:00
|
|
|
v-toolbar(dense, color='blue', flat, dark)
|
2018-09-29 19:39:09 +00:00
|
|
|
.subheading {{$t('navigation.edit', { kind: $t('navigation.link') })}}
|
2018-09-23 04:14:01 +00:00
|
|
|
v-card-text
|
|
|
|
v-text-field(
|
|
|
|
outline
|
2018-09-29 19:39:09 +00:00
|
|
|
:label='$t("navigation.label")'
|
2018-09-23 04:14:01 +00:00
|
|
|
prepend-icon='title'
|
|
|
|
v-model='current.label'
|
|
|
|
)
|
|
|
|
v-text-field(
|
|
|
|
outline
|
2018-09-29 19:39:09 +00:00
|
|
|
:label='$t("navigation.icon")'
|
2018-09-23 04:14:01 +00:00
|
|
|
prepend-icon='casino'
|
|
|
|
v-model='current.icon'
|
2019-04-07 16:12:30 +00:00
|
|
|
hide-details
|
2018-09-23 04:14:01 +00:00
|
|
|
)
|
2019-07-13 05:45:03 +00:00
|
|
|
.caption.pt-3.pl-5 The default icon set is #[strong Material Icons]. In order to use another icon set, you must first select it in the Theme administration section.
|
|
|
|
.caption.pt-3.pl-5 #[strong Material Icons] #[em (default)]
|
|
|
|
.caption.pl-5 Refer to the #[a(href='https://material.io/tools/icons/?style=baseline', target='_blank') Material Icons Reference] for the list of all possible values.
|
|
|
|
.caption.pt-3.pl-5: strong Material Design Icons
|
|
|
|
.caption.pl-5 Refer to the #[a(href='https://cdn.materialdesignicons.com/3.7.95/', target='_blank') Material Design Icons Reference] for the list of all possible values. You must prefix all values with #[code mdi-], e.g. #[code mdi-home]
|
|
|
|
.caption.pt-3.pl-5: strong Font Awesome 5
|
|
|
|
.caption.pl-5 Refer to the #[a(href='https://fontawesome.com/icons?d=gallery&m=free', target='_blank') Font Awesome 5 Reference] for the list of all possible values. You must prefix all values with #[code fas fa-], e.g. #[code fas fa-home]
|
|
|
|
.caption.pt-3.pl-5: strong Font Awesome 4
|
|
|
|
.caption.pl-5 Refer to the #[a(href='https://fontawesome.com/v4.7.0/icons/', target='_blank') Font Awesome 4 Reference] for the list of all possible values. You must prefix all values with #[code fa fa-], e.g. #[code fa fa-home]
|
2019-04-07 16:12:30 +00:00
|
|
|
v-select.mt-4(
|
2018-09-23 04:14:01 +00:00
|
|
|
outline
|
2018-09-29 19:39:09 +00:00
|
|
|
:label='$t("navigation.targetType")'
|
2018-09-23 04:14:01 +00:00
|
|
|
prepend-icon='near_me'
|
|
|
|
:items='navTypes'
|
|
|
|
v-model='current.targetType'
|
|
|
|
)
|
|
|
|
v-text-field(
|
2018-12-03 02:42:43 +00:00
|
|
|
v-if='current.targetType === `external`'
|
2018-09-23 04:14:01 +00:00
|
|
|
outline
|
2018-09-29 19:39:09 +00:00
|
|
|
:label='$t("navigation.target")'
|
2018-09-23 04:14:01 +00:00
|
|
|
prepend-icon='near_me'
|
|
|
|
v-model='current.target'
|
|
|
|
)
|
2018-12-03 02:42:43 +00:00
|
|
|
v-btn(
|
|
|
|
v-else-if='current.targetType === "page"'
|
|
|
|
color='indigo'
|
2019-07-13 05:45:03 +00:00
|
|
|
:dark='false'
|
|
|
|
disabled
|
2019-07-02 05:48:19 +00:00
|
|
|
@click='selectPage'
|
2018-12-03 02:42:43 +00:00
|
|
|
)
|
|
|
|
v-icon(left) search
|
|
|
|
span Select Page...
|
|
|
|
v-text-field(
|
|
|
|
v-else-if='current.targetType === `search`'
|
|
|
|
outline
|
|
|
|
:label='$t("navigation.navType.searchQuery")'
|
|
|
|
prepend-icon='search'
|
|
|
|
v-model='current.target'
|
|
|
|
)
|
|
|
|
|
2018-09-23 04:14:01 +00:00
|
|
|
v-card-chin
|
|
|
|
v-spacer
|
2018-09-29 19:39:09 +00:00
|
|
|
v-btn(color='red', outline, @click='deleteItem(current)')
|
2018-09-23 04:14:01 +00:00
|
|
|
v-icon(left) delete
|
2018-09-29 19:39:09 +00:00
|
|
|
span {{$t('navigation.delete', { kind: $t('navigation.link') })}}
|
2018-09-23 04:14:01 +00:00
|
|
|
v-card(v-else-if='current.kind === "header"')
|
|
|
|
v-toolbar(dense, color='blue', flat, dark)
|
2018-09-29 19:39:09 +00:00
|
|
|
.subheading {{$t('navigation.edit', { kind: $t('navigation.header') })}}
|
2018-09-23 04:14:01 +00:00
|
|
|
v-card-text
|
|
|
|
v-text-field(
|
|
|
|
outline
|
|
|
|
background-color='grey lighten-2'
|
2018-09-29 19:39:09 +00:00
|
|
|
:label='$t("navigation.label")'
|
2018-09-23 04:14:01 +00:00
|
|
|
prepend-icon='title'
|
|
|
|
v-model='current.label'
|
|
|
|
)
|
|
|
|
v-card-chin
|
|
|
|
v-spacer
|
2018-09-29 19:39:09 +00:00
|
|
|
v-btn(color='red', outline, @click='deleteItem(current)')
|
2018-09-23 04:14:01 +00:00
|
|
|
v-icon(left) delete
|
2018-09-29 19:39:09 +00:00
|
|
|
span {{$t('navigation.delete', { kind: $t('navigation.header') })}}
|
2018-09-23 04:14:01 +00:00
|
|
|
div(v-else-if='current.kind === "divider"')
|
2018-09-29 19:39:09 +00:00
|
|
|
v-btn.mt-0(color='red', outline, @click='deleteItem(current)')
|
2018-09-23 04:14:01 +00:00
|
|
|
v-icon(left) delete
|
2018-09-29 19:39:09 +00:00
|
|
|
span {{$t('navigation.delete', { kind: $t('navigation.divider') })}}
|
2018-09-23 04:14:01 +00:00
|
|
|
v-card(v-else)
|
2018-09-30 03:30:20 +00:00
|
|
|
v-card-text.grey--text(v-if='navTree.length > 0') {{$t('navigation.noSelectionText')}}
|
|
|
|
v-card-text.grey--text(v-else) {{$t('navigation.noItemsText')}}
|
2018-09-23 04:14:01 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-09-29 19:39:09 +00:00
|
|
|
import _ from 'lodash'
|
|
|
|
import uuid from 'uuid/v4'
|
|
|
|
|
|
|
|
import treeSaveMutation from 'gql/admin/navigation/navigation-mutation-save-tree.gql'
|
|
|
|
import treeQuery from 'gql/admin/navigation/navigation-query-tree.gql'
|
|
|
|
|
2018-09-23 04:14:01 +00:00
|
|
|
import draggable from 'vuedraggable'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
draggable
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2018-09-29 19:39:09 +00:00
|
|
|
navTree: [],
|
2018-09-23 04:14:01 +00:00
|
|
|
current: {}
|
|
|
|
}
|
|
|
|
},
|
2018-09-29 19:39:09 +00:00
|
|
|
computed: {
|
|
|
|
navTypes() {
|
|
|
|
return [
|
2019-07-13 05:45:03 +00:00
|
|
|
// { text: this.$t('navigation.navType.external'), value: 'external' },
|
2018-09-29 19:39:09 +00:00
|
|
|
{ text: this.$t('navigation.navType.home'), value: 'home' },
|
2019-07-13 05:45:03 +00:00
|
|
|
{ text: 'Internal Path / External Link', value: 'external' },
|
|
|
|
// { text: this.$t('navigation.navType.page'), value: 'page' }
|
2019-07-02 05:48:19 +00:00
|
|
|
// { text: this.$t('navigation.navType.searchQuery'), value: 'search' }
|
2018-09-29 19:39:09 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2018-09-23 04:14:01 +00:00
|
|
|
methods: {
|
|
|
|
addItem(kind) {
|
|
|
|
let newItem = {
|
2018-09-29 19:39:09 +00:00
|
|
|
id: uuid(),
|
2018-09-23 04:14:01 +00:00
|
|
|
kind
|
|
|
|
}
|
|
|
|
switch (kind) {
|
|
|
|
case 'link':
|
|
|
|
newItem = {
|
|
|
|
...newItem,
|
2018-09-29 19:39:09 +00:00
|
|
|
label: this.$t('navigation.untitled', { kind: this.$t(`navigation.link`) }),
|
2018-09-23 04:14:01 +00:00
|
|
|
icon: 'chevron_right',
|
|
|
|
targetType: 'home',
|
|
|
|
target: '/'
|
|
|
|
}
|
|
|
|
break
|
|
|
|
case 'header':
|
2018-09-29 19:39:09 +00:00
|
|
|
newItem.label = this.$t('navigation.untitled', { kind: this.$t(`navigation.header`) })
|
2018-09-23 04:14:01 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
this.navTree.push(newItem)
|
|
|
|
this.current = newItem
|
|
|
|
},
|
2018-09-29 19:39:09 +00:00
|
|
|
deleteItem(item) {
|
|
|
|
this.navTree = _.pull(this.navTree, item)
|
|
|
|
this.current = {}
|
|
|
|
},
|
2018-09-23 04:14:01 +00:00
|
|
|
selectItem(item) {
|
|
|
|
this.current = item
|
2018-09-29 19:39:09 +00:00
|
|
|
},
|
2019-07-02 05:48:19 +00:00
|
|
|
selectPage() {
|
|
|
|
window.alert(`Coming soon. Use External Link for now (you can still specify internal links).`)
|
|
|
|
},
|
2018-09-29 19:39:09 +00:00
|
|
|
async save() {
|
|
|
|
this.$store.commit(`loadingStart`, 'admin-navigation-save')
|
|
|
|
try {
|
2018-10-22 02:25:17 +00:00
|
|
|
const resp = await this.$apollo.mutate({
|
2018-09-29 19:39:09 +00:00
|
|
|
mutation: treeSaveMutation,
|
|
|
|
variables: {
|
|
|
|
tree: this.navTree
|
|
|
|
}
|
|
|
|
})
|
2018-10-22 02:25:17 +00:00
|
|
|
if (_.get(resp, 'data.navigation.updateTree.responseResult.succeeded', false)) {
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: this.$t('navigation.saveSuccess'),
|
|
|
|
style: 'success',
|
|
|
|
icon: 'check'
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
throw new Error(_.get(resp, 'data.navigation.updateTree.responseResult.message', 'An unexpected error occured.'))
|
|
|
|
}
|
2018-09-29 19:39:09 +00:00
|
|
|
} catch (err) {
|
2019-01-13 03:33:30 +00:00
|
|
|
this.$store.commit('pushGraphError', err)
|
2018-09-29 19:39:09 +00:00
|
|
|
}
|
|
|
|
this.$store.commit(`loadingStop`, 'admin-navigation-save')
|
2018-10-22 02:25:17 +00:00
|
|
|
},
|
|
|
|
async refresh() {
|
|
|
|
await this.$apollo.queries.navTree.refetch()
|
|
|
|
this.current = {}
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: 'Navigation has been refreshed.',
|
|
|
|
style: 'success',
|
|
|
|
icon: 'cached'
|
|
|
|
})
|
2018-09-29 19:39:09 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
apollo: {
|
|
|
|
navTree: {
|
|
|
|
query: treeQuery,
|
|
|
|
fetchPolicy: 'network-only',
|
|
|
|
update: (data) => _.cloneDeep(data.navigation.tree),
|
|
|
|
watchLoading (isLoading) {
|
|
|
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-navigation-tree')
|
|
|
|
}
|
2018-09-23 04:14:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang='scss' scoped>
|
|
|
|
|
|
|
|
.clickable {
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background-color: rgba(mc('blue', '500'), .25);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|