Implement URL handling for profile modal (#10844)

* Implement URL handling for profile modal

* Fix issue where paths would break when using back button

* move tiers import to index
This commit is contained in:
Phillip Thelen
2019-02-07 17:25:30 +01:00
committed by Matteo Pagliazzi
parent 93290ec6d5
commit 63f5773172
14 changed files with 476 additions and 315 deletions

View File

@@ -0,0 +1,50 @@
<template lang="pug">
b-modal#profile(size='lg', :hide-footer="true", :hide-header="true", @hidden="onHidden", @shown="onShown()")
profile(:userId='userId', :startingPage='startingPage', style="margin-top:24px;")
</template>
<style lang="scss" scoped>
@import '~client/assets/scss/colors.scss';
.header {
width: 100%;
}
</style>
<script>
import profile from './profile';
export default {
components: {
profile,
},
data () {
return {
userId: undefined,
startingPage: undefined,
path: undefined,
};
},
mounted () {
this.$root.$on('habitica:show-profile', (data) => {
this.userId = data.userId;
this.startingPage = data.startingPage || 'profile';
this.path = data.path;
this.$root.$emit('bv::show::modal', 'profile');
});
},
destroyed () {
this.$root.$off('habitica:show-profile');
},
methods: {
onShown () {
history.pushState('', null, this.path);
},
onHidden () {
if (this.$route.path !== window.location.pathname) {
this.$router.go(-1);
}
},
},
};
</script>