Re: #255 - Adds an option for landing URL in workspace

This commit is contained in:
Alicia Sykes
2021-09-29 20:26:24 +01:00
parent 5ec2abcf81
commit 2f1dd2a9fa
3 changed files with 29 additions and 8 deletions

View File

@@ -39,6 +39,7 @@ export default {
inject: ['config'],
props: {
sections: Array,
initUrl: String,
},
data() {
return {
@@ -56,9 +57,22 @@ export default {
openSection(index) {
this.isOpen = this.isOpen.map((val, ind) => (ind !== index ? false : !val));
},
/* When item clicked, emit a launch event */
launchApp(url) {
this.$emit('launch-app', url);
},
/* If an initial URL is specified, then open relevant section */
openDefaultSection() {
if (!this.initUrl) return;
const process = (url) => url.replace(/[^\w\s]/gi, '').toLowerCase();
const compare = (item) => (process(item.url) === process(this.initUrl));
this.sections.forEach((section, sectionIndex) => {
if (section.items.findIndex(compare) !== -1) this.openSection(sectionIndex);
});
},
},
mounted() {
this.openDefaultSection();
},
};
</script>