page-selector.vue 3.87 KB
Newer Older
1 2
<template lang="pug">
  v-dialog(v-model='isShown', lazy, max-width='850px')
Nicolas Giard's avatar
Nicolas Giard committed
3
    v-card.page-selector
4 5
      .dialog-header.is-dark
        v-icon.mr-2(color='white') find_in_page
6 7 8 9 10 11 12 13 14 15
        span Select Page Location
        v-spacer
        v-progress-circular(
          indeterminate
          color='white'
          :size='20'
          :width='2'
          v-show='searchLoading'
          )
      .d-flex(style='min-height:400px;')
16
        v-flex(xs4).grey(:class='darkMode ? `darken-4` : `lighten-3`')
Nicolas Giard's avatar
Nicolas Giard committed
17 18
          v-toolbar(color='grey darken-3', dark, dense, flat)
            .body-2 Folders
19
            v-spacer
Nicolas Giard's avatar
Nicolas Giard committed
20 21 22 23 24 25 26 27 28 29 30
            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' }}
31
        v-flex(xs8)
Nicolas Giard's avatar
Nicolas Giard committed
32 33
          v-toolbar(color='grey darken-2', dark, dense, flat)
            .body-2 Pages
34
            v-spacer
Nicolas Giard's avatar
Nicolas Giard committed
35 36
            v-btn(icon): v-icon forward
            v-btn(icon): v-icon delete
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
          v-list(dense)
            v-list-tile
              v-list-tile-avatar: v-icon insert_drive_file
              v-list-tile-title File A
            v-divider
            v-list-tile
              v-list-tile-avatar: v-icon insert_drive_file
              v-list-tile-title File B
            v-divider
            v-list-tile
              v-list-tile-avatar: v-icon insert_drive_file
              v-list-tile-title File C
            v-divider
            v-list-tile
              v-list-tile-avatar: v-icon insert_drive_file
              v-list-tile-title File D
53 54 55 56 57 58 59 60 61 62 63
      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'
          )
64 65 66
        v-text-field(
          solo
          hide-details
67 68
          prefix='/'
          v-model='currentPath'
69 70
          flat
          clearable
71 72 73 74
        )
      v-card-chin
        v-spacer
        v-btn(outline, @click='close') Cancel
Nicolas Giard's avatar
Nicolas Giard committed
75
        v-btn(color='primary', @click='open')
76 77 78 79 80
          v-icon(left) check
          span Select
</template>

<script>
81 82
import { get } from 'vuex-pathify'

83 84 85 86 87
export default {
  props: {
    value: {
      type: Boolean,
      default: false
Nicolas Giard's avatar
Nicolas Giard committed
88
    },
89 90 91 92 93 94 95 96
    path: {
      type: String,
      default: 'new-page'
    },
    locale: {
      type: String,
      default: 'en'
    },
Nicolas Giard's avatar
Nicolas Giard committed
97 98 99
    mode: {
      type: String,
      default: 'create'
100 101 102 103
    },
    openHandler: {
      type: Function,
      default: () => {}
104 105 106 107
    }
  },
  data() {
    return {
Nicolas Giard's avatar
Nicolas Giard committed
108
      searchLoading: false,
109 110
      currentLocale: 'en',
      currentPath: 'new-page',
Nicolas Giard's avatar
Nicolas Giard committed
111
      tree: [],
112 113
      treeChildren: [],
      namespaces: ['en']
114 115 116
    }
  },
  computed: {
117
    darkMode: get('site/dark'),
118 119 120
    isShown: {
      get() { return this.value },
      set(val) { this.$emit('input', val) }
Nicolas Giard's avatar
Nicolas Giard committed
121 122 123 124 125 126 127 128 129
    },
    treeFolders() {
      return [
        {
          id: '/',
          name: '/ (root)',
          children: []
        }
      ]
130 131
    }
  },
132 133 134 135 136 137 138 139
  watch: {
    isShown(newValue, oldValue) {
      if (newValue && !oldValue) {
        this.currentPath = this.path
        this.currentLocale = this.locale
      }
    }
  },
140 141 142
  methods: {
    close() {
      this.isShown = false
Nicolas Giard's avatar
Nicolas Giard committed
143 144
    },
    open() {
145 146 147 148 149 150
      const exit = this.openHandler({
        locale: this.currentLocale,
        path: this.currentPath
      })
      if (exit !== false) {
        this.close()
Nicolas Giard's avatar
Nicolas Giard committed
151 152 153 154
      }
    },
    async fetchFolders(item) {
      console.info(item)
155 156 157 158
    }
  }
}
</script>
Nicolas Giard's avatar
Nicolas Giard committed
159 160 161 162 163 164 165 166 167 168

<style lang='scss'>

.page-selector {
  .v-treeview-node__label {
    font-size: 13px;
  }
}

</style>