From 27e34ab40778caed901db074511c4a2555b0d30c Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Tue, 9 May 2023 15:21:07 +0200 Subject: [PATCH] Track user full name update in navigation [SCI-8315] --- app/javascript/vue/navigation/top_menu.vue | 39 ++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/app/javascript/vue/navigation/top_menu.vue b/app/javascript/vue/navigation/top_menu.vue index 17f38ada2..1112b6170 100644 --- a/app/javascript/vue/navigation/top_menu.vue +++ b/app/javascript/vue/navigation/top_menu.vue @@ -8,7 +8,7 @@
{ - this.rootUrl = result.root_url; - this.logo = result.logo; - this.current_team = result.current_team; - this.teams = result.teams; - this.searchUrl = result.search_url; - this.helpMenu = result.help_menu; - this.settingsMenu = result.settings_menu; - this.userMenu = result.user_menu; - this.user = result.user; - }) - + this.fetchData(); this.checkUnseenNotifications(); $(document).on('turbolinks:load', () => { this.notificationsOpened = false; this.checkUnseenNotifications(); }) + + // Track name update in user profile settings + $(document).on('inlineEditing::updated', '.inline-editing-container[data-field-to-update="full_name"]', this.fetchData); }, methods: { + fetchData() { + $.get(this.url, (result) => { + this.rootUrl = result.root_url; + this.logo = result.logo; + this.currentTeam = result.current_team; + this.teams = result.teams; + this.searchUrl = result.search_url; + this.helpMenu = result.help_menu; + this.settingsMenu = result.settings_menu; + this.userMenu = result.user_menu; + this.user = result.user; + }) + }, switchTeam(team) { - if (this.current_team == team) return; + if (this.currentTeam == team) return; $.post(this.teams.find(e => e.value == team).params.switch_url, (result) => { - this.current_team = result.current_team - dropdownSelector.selectValues('#sciNavigationTeamSelector', this.current_team); + this.currentTeam = result.current_team + dropdownSelector.selectValues('#sciNavigationTeamSelector', this.currentTeam); window.open(this.rootUrl, '_self') }).error((msg) => { HelperModule.flashAlertMsg(msg.responseJSON.message, 'danger');