✨ Re: #255 - Adds an option for landing URL in workspace
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user