2017-11-13 01:23:39 -05:00
|
|
|
<template lang="html">
|
2018-03-30 17:58:56 -04:00
|
|
|
<div
|
|
|
|
v-if="item.tabs"
|
|
|
|
class="ffz--tab-container"
|
|
|
|
@keyup.alt.page-up.stop="focusPrevTab"
|
|
|
|
@keyup.alt.page-down.stop="focusNextTab"
|
2017-11-13 01:23:39 -05:00
|
|
|
>
|
2018-03-30 17:58:56 -04:00
|
|
|
<header
|
|
|
|
class="tw-flex"
|
|
|
|
tabindex="0"
|
|
|
|
role="tablist"
|
|
|
|
@keyup.home="firstTab"
|
|
|
|
@keyup.end="lastTab"
|
|
|
|
@keyup.page-up="prevTab"
|
|
|
|
@keyup.up="prevTab"
|
|
|
|
@keyup.left="prevTab"
|
|
|
|
@keyup.page-down="nextTab"
|
|
|
|
@keyup.right="nextTab"
|
|
|
|
@keyup.down="nextTab"
|
2017-11-13 01:23:39 -05:00
|
|
|
>
|
2018-03-30 17:58:56 -04:00
|
|
|
<div
|
|
|
|
v-for="(i, idx) in item.tabs"
|
|
|
|
:id="'tab-for-' + i.full_key"
|
2019-06-20 15:15:54 -04:00
|
|
|
:key="i.full_key"
|
2018-03-30 17:58:56 -04:00
|
|
|
:aria-selected="selected === idx"
|
|
|
|
:aria-controls="'tab-panel-' + i.full_key"
|
2018-07-05 20:27:17 -04:00
|
|
|
:class="{'active': selected === idx, 'ffz-unmatched-item': showing && ! shouldShow(i)}"
|
2018-03-30 17:58:56 -04:00
|
|
|
role="tab"
|
|
|
|
class="tab tw-pd-y-05 tw-pd-x-1"
|
2019-05-03 22:36:26 -04:00
|
|
|
@click="select(idx)"
|
2018-03-30 17:58:56 -04:00
|
|
|
>
|
2019-10-04 14:57:13 -04:00
|
|
|
{{ t(i.i18n_key, i.title) }}
|
2019-05-03 22:36:26 -04:00
|
|
|
<span v-if="i.unseen > 0" class="tw-pill">{{ i.unseen }}</span>
|
2018-03-30 17:58:56 -04:00
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
<section
|
|
|
|
:id="'tab-panel-' + tab.full_key"
|
|
|
|
:aria-labelledby="'tab-for-' + tab.full_key"
|
|
|
|
class="tw-border"
|
|
|
|
role="tabpanel"
|
|
|
|
aria-hidden="false"
|
|
|
|
aria-expanded="true"
|
|
|
|
>
|
|
|
|
<section v-if="tab.description" class="tw-pd-b-1">
|
2019-10-04 14:57:13 -04:00
|
|
|
{{ t(tab.desc_i18n_key, tab.description) }}
|
2018-03-30 17:58:56 -04:00
|
|
|
</section>
|
2018-07-05 20:27:17 -04:00
|
|
|
<div
|
2018-03-30 17:58:56 -04:00
|
|
|
v-for="i in tab.contents"
|
|
|
|
:key="i.full_key"
|
2018-07-05 20:27:17 -04:00
|
|
|
:class="{'ffz-unmatched-item': showing && ! shouldShow(i)}"
|
|
|
|
>
|
|
|
|
<component
|
|
|
|
:is="i.component"
|
|
|
|
:current-profile="currentProfile"
|
|
|
|
:profiles="profiles"
|
|
|
|
:context="context"
|
|
|
|
:item="i"
|
|
|
|
:filter="filter"
|
|
|
|
/>
|
|
|
|
</div>
|
2018-03-30 17:58:56 -04:00
|
|
|
</section>
|
|
|
|
</div>
|
2017-11-13 01:23:39 -05:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
2018-07-05 20:27:17 -04:00
|
|
|
props: ['item', 'profiles', 'currentProfile', 'context', 'filter'],
|
2017-11-13 01:23:39 -05:00
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
selected: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2018-07-05 20:27:17 -04:00
|
|
|
showing() {
|
|
|
|
return this.shouldShow(this.item)
|
|
|
|
},
|
|
|
|
|
2017-11-13 01:23:39 -05:00
|
|
|
tab() {
|
|
|
|
return this.item.tabs[this.selected];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-05-03 22:36:26 -04:00
|
|
|
mounted() {
|
|
|
|
this.markSeen()
|
|
|
|
},
|
|
|
|
|
2017-11-13 01:23:39 -05:00
|
|
|
methods: {
|
|
|
|
focus() {
|
|
|
|
this.$el.querySelector('header').focus();
|
|
|
|
},
|
|
|
|
|
|
|
|
focusNextTab() {
|
|
|
|
this.focus();
|
|
|
|
this.nextTab();
|
|
|
|
},
|
|
|
|
|
|
|
|
focusPrevTab() {
|
|
|
|
this.focus();
|
|
|
|
this.prevTab();
|
|
|
|
},
|
|
|
|
|
|
|
|
focusFirstTab() {
|
|
|
|
this.focus();
|
|
|
|
this.firstTab();
|
|
|
|
},
|
|
|
|
|
|
|
|
focusLastTab() {
|
|
|
|
this.focus();
|
|
|
|
this.lastTab();
|
|
|
|
},
|
|
|
|
|
2019-05-03 22:36:26 -04:00
|
|
|
markSeen() {
|
|
|
|
this.$emit('mark-seen', this.item.tabs[this.selected]);
|
|
|
|
},
|
|
|
|
|
2017-11-13 01:23:39 -05:00
|
|
|
firstTab() {
|
|
|
|
this.selected = 0;
|
2019-05-03 22:36:26 -04:00
|
|
|
this.markSeen();
|
2017-11-13 01:23:39 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
lastTab() {
|
|
|
|
this.selected = this.item.tabs.length - 1;
|
2019-05-03 22:36:26 -04:00
|
|
|
this.markSeen();
|
2017-11-13 01:23:39 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
prevTab() {
|
2019-05-03 22:36:26 -04:00
|
|
|
if ( this.selected > 0 ) {
|
2017-11-13 01:23:39 -05:00
|
|
|
this.selected--;
|
2019-05-03 22:36:26 -04:00
|
|
|
this.markSeen();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
select(idx) {
|
|
|
|
this.selected = idx;
|
|
|
|
this.markSeen();
|
2017-11-13 01:23:39 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
nextTab() {
|
2019-05-03 22:36:26 -04:00
|
|
|
if ( this.selected + 1 < this.item.tabs.length ) {
|
2017-11-13 01:23:39 -05:00
|
|
|
this.selected++;
|
2019-05-03 22:36:26 -04:00
|
|
|
this.markSeen();
|
|
|
|
}
|
2018-07-05 20:27:17 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
shouldShow(item) {
|
|
|
|
if ( ! this.filter || ! this.filter.length || ! item.search_terms )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return item.search_terms.includes(this.filter);
|
2017-11-13 01:23:39 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|