Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2485166
Tabs.vue
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
Tabs.vue
View Options
<template>
<ul class="nav nav-tabs" role="tablist">
<li v-for="(tab, index) in tabs" :key="index" class="nav-item">
<a role="tab" :aria-controls="tabKey(tab)" :aria-selected="!index" @click="tabClick"
:class="'nav-link' + (!index ? ' active' : '')"
:id="'tab-' + tabKey(tab)"
:href="'#' + tabKey(tab)"
>
{{ $t(tabLabel(tab)) + (typeof tab != 'string' && 'count' in tab ? ` (${tab.count})` : '') }}
</a>
</li>
</ul>
</template>
<script>
import { Tab } from 'bootstrap'
export default {
props: {
tabs: { type: Array, default: () => [] }
},
data() {
return {
clickHandlers: {}
}
},
methods: {
tabClick(event) {
event.preventDefault()
new Tab(event.target).show()
const key = event.target.id.replace('tab-', '')
if (key in this.clickHandlers) {
this.clickHandlers[key](event)
}
},
tabKey(tab) {
return this.tabLabel(tab).split(/[.-]/).slice(-1)
},
tabIndex(key) {
return this.tabs.findIndex(tab => this.tabKey(tab) == key)
},
tabLabel(tab) {
return typeof tab == 'string' ? tab : tab.label
},
updateCounter(key, count) {
const index = this.tabIndex(key)
let tab = this.tabs[index]
if (typeof tab == 'string') {
tab = { label: tab, count }
} else {
tab.count = count
}
this.$set(this.tabs, index, tab)
},
clickHandler(key, callback) {
this.clickHandlers[key] = callback
}
}
}
</script>
File Metadata
Details
Attached
Mime Type
text/html
Expires
Fri, Nov 21, 5:19 AM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
387384
Default Alt Text
Tabs.vue (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment