From 9ca7a8f672e41b39815479d7d4ed53bf89cce460 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 8 Mar 2024 15:05:44 +0530 Subject: [PATCH 1/3] Improved: code to get permissions description when fetching permissionByClassification (#128) --- src/components/PermissionItems.vue | 5 ++--- src/store/modules/permission/actions.ts | 1 + src/store/modules/permission/getters.ts | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/PermissionItems.vue b/src/components/PermissionItems.vue index 3aea1ef..64df5f0 100644 --- a/src/components/PermissionItems.vue +++ b/src/components/PermissionItems.vue @@ -21,7 +21,7 @@
{{ permission.permissionId }} - {{ getPermissionDescription(permission.permissionId) }} + {{ permission.description }}
@@ -79,8 +79,7 @@ export default defineComponent({ query: 'permission/getQuery', currentGroupPermissions: 'permission/getCurrentGroupPermissions', currentGroup: "permission/getCurrentGroup", - filteredPermissions: "permission/getFilteredPermissions", - getPermissionDescription: "permission/getPermissionDescription" + filteredPermissions: "permission/getFilteredPermissions" }) }, methods: { diff --git a/src/store/modules/permission/actions.ts b/src/store/modules/permission/actions.ts index 02fba35..2581814 100644 --- a/src/store/modules/permission/actions.ts +++ b/src/store/modules/permission/actions.ts @@ -88,6 +88,7 @@ const actions: ActionTree = { const otherPermissions = JSON.parse(JSON.stringify(state.allPermissions)) Object.values(groupTypes).map((group: any) => { group.permissions.map((permission: any) => { + permission.description = state.allPermissions[permission.permissionId]?.description delete otherPermissions[permission.permissionId] }) }) diff --git a/src/store/modules/permission/getters.ts b/src/store/modules/permission/getters.ts index eb950e5..fec5df7 100644 --- a/src/store/modules/permission/getters.ts +++ b/src/store/modules/permission/getters.ts @@ -44,9 +44,6 @@ const getters: GetterTree = { }, getAllPermissions(state) { return state.allPermissions - }, - getPermissionDescription: (state) => (permissionId: any) => { - return state.allPermissions[permissionId]?.description ? state.allPermissions[permissionId].description : permissionId } } export default getters; \ No newline at end of file From 255a846f2da0afa154363f0cf44665c8ef430fb5 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 8 Mar 2024 15:44:32 +0530 Subject: [PATCH 2/3] Improved: removed other category, mapped permission description to permissions data with category and improved alert message (#128) --- src/locales/en.json | 4 ++-- src/store/modules/permission/actions.ts | 14 +++----------- src/views/Permissions.vue | 4 ++-- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 69ed082..d7a224e 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -120,8 +120,8 @@ "Name is required.": "Name is required.", "New password": "New password", "No": "No", - "No permissions associated": "No permissions associated", - "No permissions have been linked to this group yet. Permissions for a group cannot be downloaded.": "No permissions have been linked to this group yet. Permissions for a group cannot be downloaded.", + "No permission associated": "No permission associated", + "No permission have been linked to this group yet. Permissions for a group cannot be downloaded.": "No permission have been linked to this group yet. Permissions for a group cannot be downloaded.", "No product stores found": "No product stores found", "No record found": "No record found", "No users found": "No users found", diff --git a/src/store/modules/permission/actions.ts b/src/store/modules/permission/actions.ts index 2581814..d0194bf 100644 --- a/src/store/modules/permission/actions.ts +++ b/src/store/modules/permission/actions.ts @@ -84,22 +84,14 @@ const actions: ActionTree = { } }) - // Filtering all the permissions which are not part of any group type. - const otherPermissions = JSON.parse(JSON.stringify(state.allPermissions)) + // Mapping permission description to the desciption of permission data fetched. + const allPermissions = state.allPermissions Object.values(groupTypes).map((group: any) => { group.permissions.map((permission: any) => { - permission.description = state.allPermissions[permission.permissionId]?.description - delete otherPermissions[permission.permissionId] + permission.description = allPermissions[permission.permissionId]?.description }) }) - // Others category for permissions not in any internal group. - groupTypes['OTHERS'] = { - groupId: 'OTHERS', - groupName: 'Other Category', - permissions: Object.values(otherPermissions) - } - commit(types.PERMISSION_BY_CLASSIFICATION_GROUPS_UPDATED, groupTypes) }, diff --git a/src/views/Permissions.vue b/src/views/Permissions.vue index 6cc90f1..39ce78e 100644 --- a/src/views/Permissions.vue +++ b/src/views/Permissions.vue @@ -177,8 +177,8 @@ export default defineComponent({ async downloadCSVForPermissions() { if(!Object.keys(this.currentGroupPermissions).length) { const alert = await alertController.create({ - header: translate("No permissions associated"), - message: translate("No permissions have been linked to this group yet. Permissions for a group cannot be downloaded."), + header: translate("No permission associated"), + message: translate("No permission have been linked to this group yet. Permissions for a group cannot be downloaded."), buttons: [ { text: translate("Dismiss"), From 25cabfe4b60142f6c063c773c145db7ee7421142 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 8 Mar 2024 19:39:43 +0530 Subject: [PATCH 3/3] Reverted: alert message changes to old version (#128) --- src/locales/en.json | 4 ++-- src/views/Permissions.vue | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index d7a224e..69ed082 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -120,8 +120,8 @@ "Name is required.": "Name is required.", "New password": "New password", "No": "No", - "No permission associated": "No permission associated", - "No permission have been linked to this group yet. Permissions for a group cannot be downloaded.": "No permission have been linked to this group yet. Permissions for a group cannot be downloaded.", + "No permissions associated": "No permissions associated", + "No permissions have been linked to this group yet. Permissions for a group cannot be downloaded.": "No permissions have been linked to this group yet. Permissions for a group cannot be downloaded.", "No product stores found": "No product stores found", "No record found": "No record found", "No users found": "No users found", diff --git a/src/views/Permissions.vue b/src/views/Permissions.vue index 39ce78e..6cc90f1 100644 --- a/src/views/Permissions.vue +++ b/src/views/Permissions.vue @@ -177,8 +177,8 @@ export default defineComponent({ async downloadCSVForPermissions() { if(!Object.keys(this.currentGroupPermissions).length) { const alert = await alertController.create({ - header: translate("No permission associated"), - message: translate("No permission have been linked to this group yet. Permissions for a group cannot be downloaded."), + header: translate("No permissions associated"), + message: translate("No permissions have been linked to this group yet. Permissions for a group cannot be downloaded."), buttons: [ { text: translate("Dismiss"),