Many big improvments to items + sections

This commit is contained in:
Alicia Sykes
2022-04-14 14:34:20 +01:00
parent b1de7bc7e5
commit a6f3c90722
14 changed files with 84 additions and 56 deletions

View File

@@ -1,6 +1,7 @@
<template>
<nav class="side-bar">
<div v-for="(section, index) in sections" :key="index" class="side-bar-section">
<!-- Section button -->
<div @click="openSection(index)" class="side-bar-item-container">
<SideBarItem
class="item"
@@ -8,6 +9,7 @@
:title="section.name"
/>
</div>
<!-- Section inner -->
<transition name="slide">
<SideBarSection
v-if="isOpen[index]"
@@ -16,6 +18,7 @@
/>
</transition>
</div>
<!-- Show links for switching back to Home / Minimal views -->
<div class="switch-view-buttons">
<router-link to="/home">
<IconHome class="view-icon" v-tooltip="$t('alternate-views.default')" />
@@ -66,8 +69,12 @@ export default {
if (!this.initUrl) return;
const process = (url) => (url ? url.replace(/[^\w\s]/gi, '').toLowerCase() : undefined);
const compare = (item) => (process(item.url) === process(this.initUrl));
this.sections.forEach((section, secIndex) => {
if (section.items && section.items.findIndex(compare) !== -1) this.openSection(secIndex);
this.sections.forEach((section, secIndx) => {
if (!section.items) return; // Cancel if no items
if (section.items.findIndex(compare) !== -1) this.openSection(secIndx);
section.items.forEach((item) => { // Do the same for sub-items, if set
if (item.subItems && item.subItems.findIndex(compare) !== -1) this.openSection(secIndx);
});
});
},
},