Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Issue #12421 - Change page title based on the site section being viewed #12627

Merged
merged 21 commits into from Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions website/client/src/components/challenges/challengeDetail.vue
Expand Up @@ -433,6 +433,10 @@ export default {
this.$router.push('/challenges/findChallenges');
return;
}
this.$store.dispatch('common:setTitle', {
subSection: this.challenge.name,
section: this.$t('challenges'),
});
const tasks = await this.$store.dispatch('tasks:getChallengeTasks', { challengeId: this.searchId });
this.tasksByType = {
habit: [],
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/challenges/findChallenges.vue
Expand Up @@ -175,6 +175,10 @@ export default {
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('findChallenges'),
section: this.$t('challenges'),
});
this.loadChallenges();
},
methods: {
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/challenges/myChallenges.vue
Expand Up @@ -218,6 +218,10 @@ export default {
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('myChallenges'),
section: this.$t('challenges'),
});
this.loadChallenges();
},
methods: {
Expand Down
Expand Up @@ -224,7 +224,10 @@ export default {
this.group = await this.$store.dispatch('guilds:getGroup', {
groupId: this.searchId,
});

this.$store.dispatch('common:setTitle', {
subSection: this.group.name,
section: this.$t('group'),
});
const members = await this.$store.dispatch('members:getGroupMembers', { groupId: this.searchId });
this.group.members = members;

Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/groups/discovery.vue
Expand Up @@ -155,6 +155,12 @@ export default {
return this.guilds.filter(guild => filterGuild(guild, filters, search, user));
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('guildsDiscovery'),
section: this.$t('guilds'),
});
},
methods: {
async updateSearch (eventData) {
// this.search = eventData.searchTerm; @TODO: Probably don't need this anymore
Expand Down
5 changes: 3 additions & 2 deletions website/client/src/components/groups/group.vue
Expand Up @@ -497,15 +497,16 @@ export default {
if (this.isParty) this.searchId = 'party';
if (!this.searchId) this.searchId = this.groupId;
await this.fetchGuild();

this.$store.dispatch('common:setTitle', {
section: this.group.name,
});
this.$root.$on('updatedGroup', this.onGroupUpdate);
},
beforeDestroy () {
this.$root.$off('updatedGroup', this.onGroupUpdate);
},
beforeRouteUpdate (to, from, next) {
this.$set(this, 'searchId', to.params.groupId);

next();
},
methods: {
Expand Down
3 changes: 3 additions & 0 deletions website/client/src/components/groups/groupPlan.vue
Expand Up @@ -486,6 +486,9 @@ export default {
},
mounted () {
this.activePage = this.PAGES.BENEFITS;
this.$store.dispatch('common:setTitle', {
section: this.$t('groupPlans'),
});
},
methods: {
launchModal () {
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/groups/myGuilds.vue
Expand Up @@ -165,6 +165,12 @@ export default {
});
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('myGuilds'),
section: this.$t('guilds'),
});
},
created () {
this.fetchGuilds();
},
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/groups/tavern.vue
Expand Up @@ -843,6 +843,10 @@ export default {
},
},
async mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('tavern'),
section: this.$t('guilds'),
});
this.group = await this.$store.dispatch('guilds:getGroup', { groupId: TAVERN_ID });
},
methods: {
Expand Down
5 changes: 5 additions & 0 deletions website/client/src/components/inventory/equipment/index.vue
Expand Up @@ -440,6 +440,11 @@ export default {
this.costumeMode = getLocalSetting(
CONSTANTS.keyConstants.CURRENT_EQUIPMENT_DRAWER_TAB,
) === CONSTANTS.equipmentDrawerTabValues.COSTUME_TAB;

this.$store.dispatch('common:setTitle', {
subSection: this.$t('equipment'),
section: this.$t('inventory'),
});
},
methods: {
selectDrawerTab (tabName) {
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/inventory/items/index.vue
Expand Up @@ -506,6 +506,12 @@ export default {
return this.groups.some(g => g.selected);
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('items'),
section: this.$t('inventory'),
});
},
watch: {
searchText: throttle(function throttleSearch () {
this.searchTextThrottled = this.searchText.toLowerCase();
Expand Down
6 changes: 6 additions & 0 deletions website/client/src/components/inventory/stable/index.vue
Expand Up @@ -675,6 +675,12 @@ export default {
return Object.values(this.viewOptions).some(g => g.selected);
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('stable'),
section: this.$t('inventory'),
});
},
watch: {
searchText: _throttle(function throttleSearch () {
const search = this.searchText.toLowerCase();
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/shops/market/index.vue
Expand Up @@ -304,6 +304,10 @@ export default {
}, 250),
},
async mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('market'),
section: this.$t('shops'),
});
await this.$store.dispatch('worldState:getWorldState');
},
methods: {
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/shops/quests/index.vue
Expand Up @@ -544,6 +544,10 @@ export default {
}, 250),
},
async mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('quests'),
section: this.$t('shops'),
});
await this.$store.dispatch('worldState:getWorldState');
},
methods: {
Expand Down
5 changes: 5 additions & 0 deletions website/client/src/components/shops/seasonal/index.vue
Expand Up @@ -517,6 +517,11 @@ export default {
}, 250),
},
async mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('seasonalShop'),
section: this.$t('shops'),
});

this.$root.$on('buyModal::boughtItem', () => {
this.backgroundUpdate = new Date();
});
Expand Down
4 changes: 4 additions & 0 deletions website/client/src/components/shops/timeTravelers/index.vue
Expand Up @@ -399,6 +399,10 @@ export default {
}, 250),
},
mounted () {
this.$store.dispatch('common:setTitle', {
subSection: this.$t('timeTravelers'),
section: this.$t('shops'),
});
this.$root.$on('buyModal::boughtItem', () => {
this.backgroundUpdate = new Date();
});
Expand Down
5 changes: 5 additions & 0 deletions website/client/src/components/tasks/user.vue
Expand Up @@ -495,6 +495,11 @@ export default {
return tagsByType;
},
},
mounted () {
this.$store.dispatch('common:setTitle', {
section: this.$t('tasks'),
});
},
watch: {
searchText: throttle(function throttleSearch () {
this.searchTextThrottled = this.searchText.toLowerCase();
Expand Down
8 changes: 8 additions & 0 deletions website/client/src/store/actions/common.js
Expand Up @@ -23,6 +23,14 @@ export function hatch (store, params) {
// .catch((err) => console.error('equip', err));
}

export function setTitle (store, params) {
if (params.subSection) {
store.state.title = `${params.subSection} | ${params.section} | Habitica`;
} else {
store.state.title = `${params.section} | Habitica`;
}
}

export async function feed (store, params) {
const user = store.state.user.data;
feedOp(user, { params });
Expand Down
1 change: 1 addition & 0 deletions website/common/locales/en/groups.json
Expand Up @@ -77,6 +77,7 @@
"guildBankPop2": "Gems which your guild leader can use for challenge prizes.",
"guildGems": "Guild Gems",
"group": "Group",
"groupPlans": "Group Plans",
"editGroup": "Edit Group",
"newGroupName": "<%= groupType %> Name",
"groupName": "Group Name",
Expand Down