From 5ef681eea861464a0102e26cabbe4e9eb0072d57 Mon Sep 17 00:00:00 2001 From: Cindy Chang Date: Fri, 9 Aug 2024 14:16:28 +0800 Subject: [PATCH] fix: #313 fix again. Don't know why sonar-qube causes this --- src/stores/acctMgmt.ts | 8 ++++++-- .../AccountManagement/AccountAdmin/AccountAdmin.vue | 13 ++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/stores/acctMgmt.ts b/src/stores/acctMgmt.ts index 883ae59..2f18e84 100644 --- a/src/stores/acctMgmt.ts +++ b/src/stores/acctMgmt.ts @@ -9,6 +9,7 @@ interface User { name?: string; is_admin?: boolean; is_sso?: boolean; + isCurrentLoggedIn: boolean, isDeleteHovered?: boolean; isRowHovered?: boolean; isEditHovered?: boolean; @@ -23,8 +24,6 @@ interface EditDetail { is_active: boolean; } -const loginStore = piniaLoginStore(); - export default defineStore('acctMgmtStore', { state: () => ({ allUserAccoutList: [] as User[], @@ -99,8 +98,12 @@ export default defineStore('acctMgmtStore', { * Add some customization. For example, add isHovered field */ async customizeAllUserList(rawResponseData: User[]): Promise { + const loginStore = piniaLoginStore(); + await loginStore.getUserData(); + const loginUserData:User = loginStore.userData; return rawResponseData.map(user => ({ ...user, // 保留後端傳來的欄位 + isCurrentLoggedIn: loginUserData.username === user.username, isDeleteHovered: false, // 針對前端顯示而額外增加的欄位 isRowHovered: false, isEditHovered: false, @@ -110,6 +113,7 @@ export default defineStore('acctMgmtStore', { * Current logged in user should be placed at the first row on list */ async moveCurrentLoginUserToFirstRow(fetchedUserList: User[]): Promise { + const loginStore = piniaLoginStore(); await loginStore.getUserData(); const loginUserData:User = loginStore.userData; const foundLoginUserIndex = fetchedUserList.findIndex(user => user.username === loginUserData.username); diff --git a/src/views/AccountManagement/AccountAdmin/AccountAdmin.vue b/src/views/AccountManagement/AccountAdmin/AccountAdmin.vue index abf8ed6..b0942d0 100644 --- a/src/views/AccountManagement/AccountAdmin/AccountAdmin.vue +++ b/src/views/AccountManagement/AccountAdmin/AccountAdmin.vue @@ -39,7 +39,7 @@ @@ -88,7 +90,7 @@