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.

170 lines
4.1 KiB

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