PageSubNav.vue 6.23 KB
Newer Older
1 2
<template lang="pug">
  div
3
    template(v-if="currentConfig")
4
      q-btn.q-mr-sm(
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
        v-if="currentConfig.navLinks",
        v-for="b in currentConfig.navLinks",
        @click="$router.push({ name: b.name, params: { uuid: $route.params.uuid } })",
        :class="$route.name === b.name ? 'text-primary' : ''",
        :label="b.label",
        flat
        )
      template(v-if="currentConfig.specialFunctions")
        .ui-border-left.inline-block.q-pl-sm

          template(v-if="currentSpecialFunctions", v-for="f in currentSpecialFunctions")

            q-btn(v-if="f.type === 'popover'", :icon="f.icon", :class="f.iconClass", flat)
              q-popover
                q-list
                  q-item(v-for="i in f.items")
                    q-checkbox(
                      v-model="models[i.model]",
                      :label="i.label",
                      :class="i.class",
                      @input="i.onInput"
                      )

            q-btn(v-if="f.type === 'toggle'", @click="f.onToggle", :class="[f.model === true ? 'bg-primary text-white' : '']", flat)
              q-icon(v-if="f.icon", :name="f.icon", :class="f.iconClass")
30 31 32 33

</template>

<script>
34
  import { mapGetters } from 'vuex'
35 36 37 38 39 40 41 42

  export default {
    name: 'breadcrumb-nav',
    props: ['type'],
    components: {
    },
    data () {
      return {
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
        currentConfig: undefined,
        models: {
          annotationListVisibility: undefined,
          swimLaneVisibility: undefined,
          annotationDetailsVisibility: undefined,
          showSourceBrowser: true
        },
        config: {
          grid: {
            navLinks: [
              {
                name: 'mosys.grids.show',
                label: 'Preview'
              },
              {
                name: 'mosys.grids.annotate',
                label: 'Add cells'
              },
              {
                name: 'mosys.grids.edit',
                label: 'Edit'
              }
            ],
            specialFunctions: {
              'mosys.grids.annotate': [
                {
                  type: 'toggle',
                  icon: 'folder_open',
                  model: this.$store.state.mosys.showSources,
                  onToggle: () => {
                    this.$store.commit('mosys/toggleSources')
                  }
                }
              ]
77
            }
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
          },
          timeline: {
            navLinks: [
              {
                name: 'piecemaker.timelines.show',
                label: 'Videos'
              },
              {
                name: 'piecemaker.timelines.annotate',
                label: 'Live Annotate'
              },
              {
                name: 'piecemaker.timelines.edit',
                label: 'Edit'
              },
              {
                name: 'piecemaker.timelines.search',
                label: 'Search'
              }
            ]
          },
          video: {
            navLinks: [
              {
                name: 'piecemaker.videos.annotate',
                label: 'Annotate'
              },
              {
                name: 'piecemaker.videos.edit',
                label: 'Edit'
              },
              {
                name: 'piecemaker.videos.sync',
                label: 'Sync'
              }
            ],
            specialFunctions: {
              'piecemaker.videos.annotate': [
                {
                  type: 'popover',
                  icon: 'view_quilt',
                  iconClass: 'flip-horizontal',
                  items: [
                    {
                      label: 'Annotation List',
                      model: 'annotationListVisibility',
                      onInput: () => {
                        this.$store.commit('swimLaneSettings/setVisibilityDrawer')
                      }
                    },
                    {
                      label: 'Swim Lane',
                      model: 'swimLaneVisibility',
                      onInput: () => {
                        this.$store.commit('swimLaneSettings/setVisibilitySwimlanes')
                      }
                    },
                    {
                      label: 'Annotation Details',
                      model: 'annotationDetailsVisibility',
                      class: 'q-pl-lg',
                      onInput: () => {
                        this.$store.commit('swimLaneSettings/setVisibilityDetails')
                      }
                    }
                  ]
                }
              ]
146
            }
147
          }
148 149 150 151
        }
      }
    },
    computed: {
152 153 154 155 156 157 158 159 160 161 162 163 164
      ...mapGetters({
        // user: 'auth/getUserState',
        // isMobile: 'globalSettings/getIsMobile',
        visibilitySwimlanes: 'swimLaneSettings/getVisibilitySwimlanes',
        visibilityDetails: 'swimLaneSettings/getVisibilityDetails',
        visibilityDrawer: 'swimLaneSettings/getVisibilityDrawer'
      }),
      currentSpecialFunctions () {
        if (this.$route.name in this.currentConfig.specialFunctions) {
          return this.currentConfig.specialFunctions[this.$route.name]
        }
        else return undefined
      }
165 166
    },
    mounted () {
167 168 169 170 171 172
      this.models.swimLaneVisibility = this.visibilitySwimlanes
      this.models.annotationDetailsVisibility = this.visibilityDetails
      this.models.annotationListVisibility = this.visibilityDrawer
      // this.models.showSourceBrowser = this.$store.state.mosys.showSources

      this.currentConfig = this.getConfig()
173 174
    },
    watch: {
175 176 177 178 179 180 181 182 183 184 185 186 187
      // Watchers are in case the value is toggled from somewhere else than this component
      visibilityDrawer (val) {
        this.models.annotationListVisibility = val
      },
      visibilitySwimlanes (val) {
        this.models.swimLaneVisibility = val
      },
      visibilityDetails (val) {
        this.models.annotationDetailsVisibility = val
      }
      // '$store.state.mosys.showSources' (val) {
      //   this.models.showSourceBrowser = val
      // }
188 189 190 191 192
    },
    methods: {
      toProperCase (t) {
        return t.charAt(0).toUpperCase() + t.substr(1).toLowerCase()
      },
193 194 195
      getConfig () {
        if (this.type in this.config) {
          return this.config[this.type]
196 197 198 199 200 201 202 203 204 205 206
        }
        else return undefined
      }
    }
  }
</script>

<style scoped lang="stylus">
  @import '~variables'

</style>