remove unused var and rename filteredTabs->sortedTabs

This commit is contained in:
Westly Wright 2020-06-22 08:46:29 -07:00
parent 4e42542ba4
commit ec316f4a1d
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
1 changed files with 14 additions and 16 deletions

View File

@ -12,14 +12,11 @@ export default {
}, },
data() { data() {
return { return { tabs: [] };
tabs: [],
initialTabOrder: []
};
}, },
computed: { computed: {
filteredTabs() { sortedTabs() {
// keep the tabs list ordered for dynamic tabs // keep the tabs list ordered for dynamic tabs
const { tabs } = this; const { tabs } = this;
@ -31,7 +28,8 @@ export default {
'$route.hash'() { '$route.hash'() {
this.hashChange(); this.hashChange();
}, },
filteredTabs(tabs) {
sortedTabs(tabs) {
const { const {
defaultTab, defaultTab,
$route: { hash } $route: { hash }
@ -74,7 +72,7 @@ export default {
$children, $children,
$route: { hash }, $route: { hash },
defaultTab, defaultTab,
filteredTabs, sortedTabs,
} = this; } = this;
this.tabs = $children; this.tabs = $children;
@ -91,7 +89,7 @@ export default {
} }
if ( !tab ) { if ( !tab ) {
tab = head(filteredTabs); tab = head(sortedTabs);
} }
if ( tab ) { if ( tab ) {
@ -105,12 +103,12 @@ export default {
}, },
find(name) { find(name) {
return this.filteredTabs.find(x => x.name === name ); return this.sortedTabs.find(x => x.name === name );
}, },
select(name/* , event */) { select(name/* , event */) {
const { const {
filteredTabs, sortedTabs,
$router, $router,
$route: { $route: {
name: routeName, name: routeName,
@ -128,7 +126,7 @@ export default {
$router.replace({ name: routeName, hash: hashName }); $router.replace({ name: routeName, hash: hashName });
} }
for ( const tab of filteredTabs ) { for ( const tab of sortedTabs ) {
tab.active = (tab.name === selected.name); tab.active = (tab.name === selected.name);
} }
@ -136,10 +134,10 @@ export default {
}, },
selectNext(direction) { selectNext(direction) {
const { filteredTabs } = this; const { sortedTabs } = this;
const currentIdx = filteredTabs.findIndex(x => x.active); const currentIdx = sortedTabs.findIndex(x => x.active);
const nextIdx = getCyclicalIdx(currentIdx, direction, filteredTabs.length); const nextIdx = getCyclicalIdx(currentIdx, direction, sortedTabs.length);
const nextName = filteredTabs[nextIdx].name; const nextName = sortedTabs[nextIdx].name;
this.select(nextName); this.select(nextName);
@ -174,7 +172,7 @@ export default {
@keyup.37.stop="selectNext(-1)" @keyup.37.stop="selectNext(-1)"
> >
<li <li
v-for="tab in filteredTabs" v-for="tab in sortedTabs"
:id="tab.name" :id="tab.name"
:key="tab.name" :key="tab.name"
:class="{tab: true, active: tab.active, disabled: tab.disabled}" :class="{tab: true, active: tab.active, disabled: tab.disabled}"