Module collections override (#614)

* Fix errors in repeater

* Use custom module listing in sidebar

* Refresh user store on role update

* Add custom module info to type

* Add collections interface

* Add collections interface translations

* Add collections listing types

* Use custom collections listing in collections module nav

* Remove outdated nav test
This commit is contained in:
Rijk van Zanten
2020-05-22 17:04:20 -04:00
committed by GitHub
parent 82d4210ff3
commit 085f6dc581
13 changed files with 220 additions and 157 deletions

View File

@@ -27,11 +27,12 @@
</template>
<script lang="ts">
import { defineComponent, Ref } from '@vue/composition-api';
import { defineComponent, Ref, computed } from '@vue/composition-api';
import { useProjectsStore } from '@/stores/projects';
import { modules } from '@/modules/';
import ModuleBarLogo from '../module-bar-logo/';
import ModuleBarAvatar from '../module-bar-avatar/';
import useUserStore from '@/stores/user';
export default defineComponent({
components: {
@@ -40,25 +41,51 @@ export default defineComponent({
},
setup() {
const projectsStore = useProjectsStore();
const userStore = useUserStore();
const { currentProjectKey } = projectsStore.state;
const _modules = modules
.map((module) => ({
...module,
href: module.link || null,
to: module.link === undefined ? `/${currentProjectKey}/${module.id}/` : null,
}))
.filter((module) => {
if (module.hidden !== undefined) {
if (
(module.hidden as boolean) === true ||
(module.hidden as Ref<boolean>).value === true
) {
return false;
const _modules = computed(() => {
const customModuleListing = userStore.state.currentUser?.role.module_listing;
if (
customModuleListing &&
Array.isArray(customModuleListing) &&
customModuleListing.length > 0
) {
return customModuleListing.map((custom) => {
if (custom.link.startsWith('http') || custom.link.startsWith('//')) {
return {
...custom,
href: custom.link,
};
} else {
return {
...custom,
to: custom.link,
};
}
}
return true;
});
});
}
return modules
.map((module) => ({
...module,
href: module.link || null,
to: module.link === undefined ? `/${currentProjectKey}/${module.id}/` : null,
}))
.filter((module) => {
if (module.hidden !== undefined) {
if (
(module.hidden as boolean) === true ||
(module.hidden as Ref<boolean>).value === true
) {
return false;
}
}
return true;
});
});
return { _modules };
},