You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
3.9 KiB

  1. <template lang="pug">
  2. v-dialog(v-model='isShown', lazy, max-width='850px')
  3. v-card.page-selector
  4. .dialog-header.is-dark
  5. v-icon.mr-2(color='white') find_in_page
  6. span 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(xs4).grey(: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 {{ 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 forward
  36. v-btn(icon): v-icon delete
  37. v-list(dense)
  38. v-list-tile
  39. v-list-tile-avatar: v-icon insert_drive_file
  40. v-list-tile-title File A
  41. v-divider
  42. v-list-tile
  43. v-list-tile-avatar: v-icon insert_drive_file
  44. v-list-tile-title File B
  45. v-divider
  46. v-list-tile
  47. v-list-tile-avatar: v-icon insert_drive_file
  48. v-list-tile-title File C
  49. v-divider
  50. v-list-tile
  51. v-list-tile-avatar: v-icon insert_drive_file
  52. v-list-tile-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;'
  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. )
  72. v-card-chin
  73. v-spacer
  74. v-btn(outline, @click='close') Cancel
  75. v-btn(color='primary', @click='open')
  76. v-icon(left) check
  77. span Select
  78. </template>
  79. <script>
  80. import { get } from 'vuex-pathify'
  81. export default {
  82. props: {
  83. value: {
  84. type: Boolean,
  85. default: false
  86. },
  87. path: {
  88. type: String,
  89. default: 'new-page'
  90. },
  91. locale: {
  92. type: String,
  93. default: 'en'
  94. },
  95. mode: {
  96. type: String,
  97. default: 'create'
  98. },
  99. openHandler: {
  100. type: Function,
  101. default: () => {}
  102. }
  103. },
  104. data() {
  105. return {
  106. searchLoading: false,
  107. currentLocale: 'en',
  108. currentPath: 'new-page',
  109. tree: [],
  110. treeChildren: [],
  111. namespaces: ['en']
  112. }
  113. },
  114. computed: {
  115. darkMode: get('site/dark'),
  116. isShown: {
  117. get() { return this.value },
  118. set(val) { this.$emit('input', val) }
  119. },
  120. treeFolders() {
  121. return [
  122. {
  123. id: '/',
  124. name: '/ (root)',
  125. children: []
  126. }
  127. ]
  128. }
  129. },
  130. watch: {
  131. isShown(newValue, oldValue) {
  132. if (newValue && !oldValue) {
  133. this.currentPath = this.path
  134. this.currentLocale = this.locale
  135. }
  136. }
  137. },
  138. methods: {
  139. close() {
  140. this.isShown = false
  141. },
  142. open() {
  143. const exit = this.openHandler({
  144. locale: this.currentLocale,
  145. path: this.currentPath
  146. })
  147. if (exit !== false) {
  148. this.close()
  149. }
  150. },
  151. async fetchFolders(item) {
  152. console.info(item)
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang='scss'>
  158. .page-selector {
  159. .v-treeview-node__label {
  160. font-size: 13px;
  161. }
  162. }
  163. </style>