GridEditorSources.vue 2.34 KB
Newer Older
Anton's avatar
Intial  
Anton committed
1
2
3
4
5
<template lang="pug">

  q-tabs.grid-editor-sources-tabs.shadow-11(v-model="selectedTab")
    q-tab(slot="title", name="tab-default-cells", default, icon="add")
    q-tab(slot="title", name="tab-piecemaker") Piecemaker
6
    q-tab(slot="title", name="tab-documents", v-if="userHasDocuments") Documents
Anton's avatar
Intial  
Anton committed
7
8
    q-btn(slot="title", icon="close",
      small, flat, round, class="fixed", style="right: 2px; margin-top: 3px",
9
      @click="event => {$store.commit('mosys/hideSources')}")
Anton's avatar
Intial  
Anton committed
10
11
12
13
14
15
16
17
18
19

    q-tab-pane(name="tab-default-cells")
      template(v-if="this.selectedCells.length > 0")
        cell-editor(:cells="selectedCells")
      template(v-else)
        grid-editor-default-source

    q-tab-pane(name="tab-piecemaker")
      grid-editor-source-piece-maker

20
21
22
    q-tab-pane(name="tab-documents", v-if="userHasDocuments")
      grid-editor-source-documents

Anton's avatar
Intial  
Anton committed
23
24
25
26
27
</template>

<script>
  import CellEditor from './CellEditor'
  import GridEditorDefaultSource from './GridEditorDefaultSource'
28
  import GridEditorSourceDocuments from './GridEditorSourceDocuments'
Anton's avatar
Intial  
Anton committed
29
30
  import GridEditorSourcePieceMaker from './GridEditorSourcePieceMaker'

31
32
33
  import { mapGetters } from 'vuex'
  import { userHasFeature } from 'mbjs-quasar/src/lib'

Anton's avatar
Intial  
Anton committed
34
35
36
37
  export default {
    components: {
      CellEditor,
      GridEditorDefaultSource,
38
      GridEditorSourceDocuments,
Anton's avatar
Anton committed
39
      GridEditorSourcePieceMaker
Anton's avatar
Intial  
Anton committed
40
41
42
43
44
45
46
    },
    data () {
      return {
        selectedTab: ''
      }
    },
    computed: {
47
48
49
50
51
52
      ...mapGetters({
        user: 'auth/getUserState'
      }),
      userHasDocuments () {
        return userHasFeature(this.user, 'documents')
      },
Anton's avatar
Intial  
Anton committed
53
      currentStoreTab () {
54
        return this.$store.state.mosys.sourcesTabName
Anton's avatar
Intial  
Anton committed
55
56
      },
      selectedCells () {
57
        return this.$store.state.mosys.selectedCells
Anton's avatar
Intial  
Anton committed
58
59
60
61
62
63
64
65
66
67
      }
    },
    watch: {
      currentStoreTab () {
        if (this.selectedTab !== this.currentStoreTab) {
          this.selectedTab = this.currentStoreTab
        }
      },
      selectedTab () {
        if (this.selectedTab !== this.currentStoreTab) {
68
          this.$store.commit('mosys/setSourcesTab', this.selectedTab)
Anton's avatar
Intial  
Anton committed
69
70
71
72
        }
      }
    },
    beforeDestroy () {
73
      this.$store.commit('mosys/hideSources')
Anton's avatar
Intial  
Anton committed
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
    }
  }
</script>

<style lang="stylus">

  .grid-editor-sources-tabs
    background-color white

    .q-tabs-panes
      display flex
      flex-direction column
      overflow auto

</style>