page-selector.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template lang="pug">
  2. v-dialog(v-model='isShown', max-width='850px')
  3. v-card.page-selector
  4. .dialog-header.is-dark
  5. v-icon.mr-3(color='white') mdi-page-next-outline
  6. .body-1 Select Page Location
  7. v-spacer
  8. v-progress-circular(
  9. indeterminate
  10. color='white'
  11. :size='20'
  12. :width='2'
  13. v-show='searchLoading'
  14. )
  15. .d-flex(style='min-height:400px;')
  16. v-flex.grey(xs4, :class='darkMode ? `darken-4` : `lighten-3`')
  17. v-toolbar(color='grey darken-3', dark, dense, flat)
  18. .body-2 Folders
  19. //- v-spacer
  20. //- v-btn(icon): v-icon create_new_folder
  21. v-treeview(
  22. v-model='tree'
  23. :items='treeFolders'
  24. :load-children='fetchFolders'
  25. activatable
  26. open-on-click
  27. hoverable
  28. )
  29. template(slot='prepend', slot-scope='{ item, open, leaf }')
  30. v-icon mdi-{{ open ? 'folder-open' : 'folder' }}
  31. v-flex(xs8)
  32. v-toolbar(color='grey darken-2', dark, dense, flat)
  33. .body-2 Pages
  34. v-spacer
  35. v-btn(icon): v-icon mdi-forward
  36. v-btn(icon): v-icon mdi-delete
  37. v-list(dense)
  38. v-list-item
  39. v-list-item-icon: v-icon mdi-file-document-box
  40. v-list-item-title File A
  41. v-divider
  42. v-list-item
  43. v-list-item-icon: v-icon mdi-file-document-box
  44. v-list-item-title File B
  45. v-divider
  46. v-list-item
  47. v-list-item-icon: v-icon mdi-file-document-box
  48. v-list-item-title File C
  49. v-divider
  50. v-list-item
  51. v-list-item-icon: v-icon mdi-file-document-box
  52. v-list-item-title File D
  53. v-card-actions.grey.pa-2(:class='darkMode ? `darken-3-d5` : `lighten-1`')
  54. v-select(
  55. solo
  56. dark
  57. background-color='grey darken-3-d2'
  58. hide-details
  59. single-line
  60. :items='namespaces'
  61. style='flex: 0 0 100px; border-radius: 4px 0 0 4px;'
  62. v-model='currentLocale'
  63. )
  64. v-text-field(
  65. solo
  66. hide-details
  67. prefix='/'
  68. v-model='currentPath'
  69. flat
  70. clearable
  71. style='border-radius: 0 4px 4px 0;'
  72. )
  73. v-card-chin
  74. v-spacer
  75. v-btn(text, @click='close') Cancel
  76. v-btn.px-4(color='primary', @click='open')
  77. v-icon(left) mdi-check
  78. span Select
  79. </template>
  80. <script>
  81. import { get } from 'vuex-pathify'
  82. /* global siteLangs, siteConfig */
  83. export default {
  84. props: {
  85. value: {
  86. type: Boolean,
  87. default: false
  88. },
  89. path: {
  90. type: String,
  91. default: 'new-page'
  92. },
  93. locale: {
  94. type: String,
  95. default: 'en'
  96. },
  97. mode: {
  98. type: String,
  99. default: 'create'
  100. },
  101. openHandler: {
  102. type: Function,
  103. default: () => {}
  104. }
  105. },
  106. data() {
  107. return {
  108. searchLoading: false,
  109. currentLocale: siteConfig.lang,
  110. currentPath: 'new-page',
  111. tree: [],
  112. treeChildren: [],
  113. namespaces: siteLangs.length ? siteLangs.map(ns => ns.code) : [siteConfig.lang]
  114. }
  115. },
  116. computed: {
  117. darkMode: get('site/dark'),
  118. isShown: {
  119. get() { return this.value },
  120. set(val) { this.$emit('input', val) }
  121. },
  122. treeFolders() {
  123. return [
  124. {
  125. id: '/',
  126. name: '/ (root)',
  127. children: []
  128. }
  129. ]
  130. }
  131. },
  132. watch: {
  133. isShown(newValue, oldValue) {
  134. if (newValue && !oldValue) {
  135. this.currentPath = this.path
  136. this.currentLocale = this.locale
  137. }
  138. }
  139. },
  140. methods: {
  141. close() {
  142. this.isShown = false
  143. },
  144. open() {
  145. const exit = this.openHandler({
  146. locale: this.currentLocale,
  147. path: this.currentPath
  148. })
  149. if (exit !== false) {
  150. this.close()
  151. }
  152. },
  153. async fetchFolders(item) {
  154. console.info(item)
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang='scss'>
  160. .page-selector {
  161. .v-treeview-node__label {
  162. font-size: 13px;
  163. }
  164. }
  165. </style>