wikijs-fork/client/components/common/page-selector.vue

171 lines
4.1 KiB
Vue
Raw Normal View History

2018-09-30 22:19:28 +00:00
<template lang="pug">
2019-07-29 04:50:03 +00:00
v-dialog(v-model='isShown', max-width='850px')
2018-11-12 05:51:34 +00:00
v-card.page-selector
.dialog-header.is-dark
2019-08-03 04:48:55 +00:00
v-icon.mr-3(color='white') mdi-page-next-outline
2018-09-30 22:19:28 +00:00
span Select Page Location
v-spacer
v-progress-circular(
indeterminate
color='white'
:size='20'
:width='2'
v-show='searchLoading'
)
2019-06-22 03:39:04 +00:00
//- .d-flex(style='min-height:400px;')
//- v-flex(xs4).grey(:class='darkMode ? `darken-4` : `lighten-3`')
//- v-toolbar(color='grey darken-3', dark, dense, flat)
//- .body-2 Folders
//- v-spacer
//- v-btn(icon): v-icon create_new_folder
//- v-treeview(
//- v-model='tree'
//- :items='treeFolders'
//- :load-children='fetchFolders'
//- activatable
//- open-on-click
//- hoverable
//- )
//- template(slot='prepend', slot-scope='{ item, open, leaf }')
//- v-icon {{ open ? 'folder_open' : 'folder' }}
//- v-flex(xs8)
//- v-toolbar(color='grey darken-2', dark, dense, flat)
//- .body-2 Pages
//- v-spacer
//- v-btn(icon): v-icon forward
//- v-btn(icon): v-icon delete
//- v-list(dense)
2019-07-29 04:50:03 +00:00
//- v-list-item
//- v-list-item-avatar: v-icon insert_drive_file
//- v-list-item-title File A
2019-06-22 03:39:04 +00:00
//- v-divider
2019-07-29 04:50:03 +00:00
//- v-list-item
//- v-list-item-avatar: v-icon insert_drive_file
//- v-list-item-title File B
2019-06-22 03:39:04 +00:00
//- v-divider
2019-07-29 04:50:03 +00:00
//- v-list-item
//- v-list-item-avatar: v-icon insert_drive_file
//- v-list-item-title File C
2019-06-22 03:39:04 +00:00
//- v-divider
2019-07-29 04:50:03 +00:00
//- v-list-item
//- v-list-item-avatar: v-icon insert_drive_file
//- v-list-item-title File D
v-card-actions.grey.pa-2(:class='darkMode ? `darken-3-d5` : `lighten-1`')
v-select(
solo
dark
background-color='grey darken-3-d2'
hide-details
single-line
:items='namespaces'
style='flex: 0 0 100px;'
v-model='currentLocale'
)
2018-09-30 22:19:28 +00:00
v-text-field(
solo
hide-details
prefix='/'
v-model='currentPath'
2018-10-01 02:18:40 +00:00
flat
clearable
2018-09-30 22:19:28 +00:00
)
v-card-chin
v-spacer
2019-08-03 04:48:55 +00:00
v-btn(text, @click='close') Cancel
v-btn.px-4(color='primary', @click='open')
v-icon(left) mdi-check
2018-09-30 22:19:28 +00:00
span Select
</template>
<script>
2018-12-02 04:03:14 +00:00
import { get } from 'vuex-pathify'
2019-06-22 03:39:04 +00:00
/* global siteLangs, siteConfig */
2018-09-30 22:19:28 +00:00
export default {
props: {
value: {
type: Boolean,
default: false
2018-11-12 05:51:34 +00:00
},
path: {
type: String,
default: 'new-page'
},
locale: {
type: String,
default: 'en'
},
2018-11-12 05:51:34 +00:00
mode: {
type: String,
default: 'create'
},
openHandler: {
type: Function,
default: () => {}
2018-09-30 22:19:28 +00:00
}
},
data() {
return {
2018-11-12 05:51:34 +00:00
searchLoading: false,
currentLocale: siteConfig.lang,
currentPath: 'new-page',
2018-11-12 05:51:34 +00:00
tree: [],
treeChildren: [],
2019-06-22 03:39:04 +00:00
namespaces: siteLangs.length ? siteLangs.map(ns => ns.code) : [siteConfig.lang]
2018-09-30 22:19:28 +00:00
}
},
computed: {
2018-12-02 04:03:14 +00:00
darkMode: get('site/dark'),
2018-09-30 22:19:28 +00:00
isShown: {
get() { return this.value },
set(val) { this.$emit('input', val) }
2018-11-12 05:51:34 +00:00
},
treeFolders() {
return [
{
id: '/',
name: '/ (root)',
children: []
}
]
2018-09-30 22:19:28 +00:00
}
},
watch: {
isShown(newValue, oldValue) {
if (newValue && !oldValue) {
this.currentPath = this.path
this.currentLocale = this.locale
}
}
},
2018-09-30 22:19:28 +00:00
methods: {
close() {
this.isShown = false
2018-11-12 05:51:34 +00:00
},
open() {
const exit = this.openHandler({
locale: this.currentLocale,
path: this.currentPath
})
if (exit !== false) {
this.close()
2018-11-12 05:51:34 +00:00
}
},
async fetchFolders(item) {
console.info(item)
2018-09-30 22:19:28 +00:00
}
}
}
</script>
2018-11-12 05:51:34 +00:00
<style lang='scss'>
.page-selector {
.v-treeview-node__label {
font-size: 13px;
}
}
</style>