diff --git a/src/components/Main.vue b/src/components/Main.vue index 5b70982..e34cc01 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -100,7 +100,7 @@ export default { this.permittedUsers = patrons const { permission } = this.$route.meta.self const permissionRequired = permission ? permission : null - this.owners = this.filterUsersByPermissions(permissionRequired, false) + this.owners = this.filterUsersByPermissions(permissionRequired) this.visibleGroups = this.filterLibGroupsByUsersBranchcode() }, error => {} diff --git a/src/stores/acquisitions.js b/src/stores/acquisitions.js index 8c8e90b..00c8431 100644 --- a/src/stores/acquisitions.js +++ b/src/stores/acquisitions.js @@ -72,7 +72,7 @@ export const useAcquisitionsStore = defineStore("acquisitions", { }) return codes }, - filterUsersByPermissions(operation, returnAll, branchcodes) { + filterUsersByPermissions(operation, branchcodes = null, returnAll = false) { const filteredUsers = [] this.permittedUsers.forEach(user => { user.displayName = user.firstname + ' ' + user.surname @@ -123,7 +123,7 @@ export const useAcquisitionsStore = defineStore("acquisitions", { }, filterGroupsBasedOnOwner(e, data, groups) { const libGroups = this.filterLibGroupsByUsersBranchcode(null, groups) - const permittedUsers = this.filterUsersByPermissions(this.currentPermission, false) + const permittedUsers = this.filterUsersByPermissions(this.currentPermission) if (!e) { this.visibleGroups = libGroups this.owners = permittedUsers @@ -135,7 +135,7 @@ export const useAcquisitionsStore = defineStore("acquisitions", { }, filterOwnersBasedOnGroup(e, data, groups) { const libGroups = this.filterLibGroupsByUsersBranchcode(null, groups) - const permittedUsers = this.filterUsersByPermissions(this.currentPermission, false, null) + const permittedUsers = this.filterUsersByPermissions(this.currentPermission) if (!e.length) { this.visibleGroups = libGroups this.owners = permittedUsers @@ -143,16 +143,16 @@ export const useAcquisitionsStore = defineStore("acquisitions", { } else { const filteredGroups = libGroups.filter(group => e.includes(group.id)) const branchcodes = this._findBranchCodesInGroup(filteredGroups) - this.owners = this.filterUsersByPermissions(this.currentPermission, false, branchcodes) + this.owners = this.filterUsersByPermissions(this.currentPermission, branchcodes) } }, setOwnersBasedOnPermission(permission) { if(this.permittedUsers) { - this.owners = this.filterUsersByPermissions(permission, false, null) + this.owners = this.filterUsersByPermissions(permission) } }, resetOwnersAndVisibleGroups(groups) { - this.owners = this.filterUsersByPermissions(this.currentPermission, false) + this.owners = this.filterUsersByPermissions(this.currentPermission) this.visibleGroups = this.filterLibGroupsByUsersBranchcode(null, groups) }, getSetting(input) { diff --git a/tests/cypress/specs/unit/AcquisitionsStore_spec.js b/tests/cypress/specs/unit/AcquisitionsStore_spec.js index f2ef82d..3111248 100644 --- a/tests/cypress/specs/unit/AcquisitionsStore_spec.js +++ b/tests/cypress/specs/unit/AcquisitionsStore_spec.js @@ -69,12 +69,12 @@ describe("AcquisitionsStore", () => { testPermission: ['something'] } - let filteredUsers = store.filterUsersByPermissions(null, false, null) + let filteredUsers = store.filterUsersByPermissions(null) expect(filteredUsers).to.have.length(2) expect(filteredUsers[0].displayName).to.eq('Test Patron') expect(filteredUsers[1].displayName).to.eq('Another Patron') - filteredUsers = store.filterUsersByPermissions('testPermission', false, null) + filteredUsers = store.filterUsersByPermissions('testPermission') expect(filteredUsers).to.have.length(1) expect(filteredUsers[0].displayName).to.eq('Test Patron') @@ -92,12 +92,12 @@ describe("AcquisitionsStore", () => { "surname": "Patron", }) - filteredUsers = store.filterUsersByPermissions('testPermission', false, null) + filteredUsers = store.filterUsersByPermissions('testPermission') expect(filteredUsers).to.have.length(2) expect(filteredUsers[0].displayName).to.eq('Test Patron') expect(filteredUsers[1].displayName).to.eq('Permitted Patron') - filteredUsers = store.filterUsersByPermissions('testPermission', false, ['XYZ']) + filteredUsers = store.filterUsersByPermissions('testPermission', ['XYZ']) expect(filteredUsers).to.have.length(1) expect(filteredUsers[0].displayName).to.eq('Permitted Patron') })