diff --git a/backend/src/components/institute/institute.js b/backend/src/components/institute/institute.js index 39866b3ae..3c2312345 100644 --- a/backend/src/components/institute/institute.js +++ b/backend/src/components/institute/institute.js @@ -865,7 +865,9 @@ function hasSchoolAdminRole(req, school){ } function hasAuthorityAdminRole(req, authority){ - if(authority?.authorityTypeCode === 'OFFSHORE'){ + if(authority?.authorityTypeCode === 'INDEPENDNT') { + return req.session.roles.includes('INDEPENDENT_AUTHORITY_ADMIN') || req.session.roles.includes('INDEPENDENT_SCHOOLS_ADMIN'); + } else if(authority?.authorityTypeCode === 'OFFSHORE'){ return req.session.roles.includes('INDEPENDENT_AUTHORITY_ADMIN') || req.session.roles.includes('OFFSHORE_SCHOOLS_ADMIN'); } return req.session.roles.includes('INDEPENDENT_AUTHORITY_ADMIN'); diff --git a/backend/src/routes/institute.js b/backend/src/routes/institute.js index e6cfda17a..44e83b917 100644 --- a/backend/src/routes/institute.js +++ b/backend/src/routes/institute.js @@ -42,7 +42,7 @@ router.put('/authority/contact/:contactId', passport.authenticate('jwt', {sessio router.delete('/authority/contact/:independentAuthorityId/:contactId', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, deleteAuthorityContact); -router.post('/authority', passport.authenticate('jwt', {session: false}, undefined), auth.isValidIndependentAuthorityAdmin, extendSession, addAuthority); +router.post('/authority', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, addAuthority); router.post('/authority/contact', passport.authenticate('jwt', {session: false}, undefined), auth.isLoggedInUser, extendSession, addAuthorityContact); diff --git a/frontend/src/components/institute/AuthoritiesList.vue b/frontend/src/components/institute/AuthoritiesList.vue index 7a814f93b..8a5778fad 100644 --- a/frontend/src/components/institute/AuthoritiesList.vue +++ b/frontend/src/components/institute/AuthoritiesList.vue @@ -299,7 +299,7 @@ export default { }; }, computed: { - ...mapState(authStore, ['userInfo', 'INDEPENDENT_AUTHORITY_ADMIN_ROLE']), + ...mapState(authStore, ['userInfo', 'INDEPENDENT_AUTHORITY_ADMIN_ROLE', 'OFFSHORE_SCHOOLS_ADMIN_ROLE']), ...mapState(instituteStore, ['authorityTypeCodes']), getSheetWidth() { @@ -444,7 +444,7 @@ export default { this.getAuthorityList(); }, canAddAuthority() { - return this.INDEPENDENT_AUTHORITY_ADMIN_ROLE; + return this.INDEPENDENT_AUTHORITY_ADMIN_ROLE || this.OFFSHORE_SCHOOLS_ADMIN_ROLE; }, newAuthorityAdded() { this.newAuthoritySheet = !this.newAuthoritySheet; diff --git a/frontend/src/components/institute/AuthorityDetails.vue b/frontend/src/components/institute/AuthorityDetails.vue index 6cbabee5a..e21596d97 100644 --- a/frontend/src/components/institute/AuthorityDetails.vue +++ b/frontend/src/components/institute/AuthorityDetails.vue @@ -205,7 +205,7 @@ export default { }, computed: { ...mapState(instituteStore, ['authorityTypeCodes', 'provinceCodes', 'countryCodes']), - ...mapState(authStore, ['INDEPENDENT_AUTHORITY_ADMIN_ROLE', 'OFFSHORE_SCHOOLS_ADMIN_ROLE']), + ...mapState(authStore, ['INDEPENDENT_AUTHORITY_ADMIN_ROLE', 'INDEPENDENT_SCHOOLS_ADMIN_ROLE', 'OFFSHORE_SCHOOLS_ADMIN_ROLE']), notesLoading() { return this.noteRequestCount > 0; }, @@ -267,7 +267,9 @@ export default { }, deepCloneObject, canEditAuthorities() { - if(this.authority?.authorityTypeCode === 'OFFSHORE') { + if(this.authority?.authorityTypeCode === 'INDEPENDNT') { + return this.INDEPENDENT_AUTHORITY_ADMIN_ROLE || this.INDEPENDENT_SCHOOLS_ADMIN_ROLE; + } else if(this.authority?.authorityTypeCode === 'OFFSHORE') { return this.INDEPENDENT_AUTHORITY_ADMIN_ROLE || this.OFFSHORE_SCHOOLS_ADMIN_ROLE; } return this.INDEPENDENT_AUTHORITY_ADMIN_ROLE; diff --git a/frontend/src/components/institute/NewAuthorityPage.vue b/frontend/src/components/institute/NewAuthorityPage.vue index 1003bcf71..7834d6ed6 100644 --- a/frontend/src/components/institute/NewAuthorityPage.vue +++ b/frontend/src/components/institute/NewAuthorityPage.vue @@ -29,7 +29,7 @@ item-value="authorityTypeCode" item-title="label" variant="underlined" - :items="authorityTypes" + :items="filteredAuthorityTypeCodes" :rules="[rules.required()]" :clearable="true" /> @@ -306,11 +306,6 @@ export default { physicalAddrPostal: null, }, rules: Rules, - schoolFacilityTypes: [], - schoolCategoryTypes: [], - schoolOrganizationTypes: [], - schoolNeighborhoodLearningTypes: [], - schoolGradeTypes: [], sameAsMailingCheckbox: true, provinceCodeValues: [], countryCodeValues: [], @@ -318,23 +313,28 @@ export default { excludeShowingPhysicalAddressesForAuthoritiesOfType: [ 'OFFSHORE', ], + offshoreArray: ['OFFSHORE'], }; }, computed: { - ...mapState(authStore, ['isAuthenticated', 'userInfo']), + ...mapState(authStore, ['isAuthenticated', 'userInfo', 'OFFSHORE_SCHOOLS_ADMIN_ROLE']), ...mapState(instituteStore, ['authorityTypeCodes', 'provinceCodes', 'countryCodes']), showPhysicalAddress() { return !this.excludeShowingPhysicalAddressesForAuthoritiesOfType.includes(this.newAuthority.authorityTypeCode); - } + }, + filteredAuthorityTypeCodes() { + if(this.isOffshoreOnlyUser()) { + return this.authorityTypeCodes?.filter(type => this.offshoreArray.includes(type.authorityTypeCode)); + } + return this.authorityTypeCodes; + }, }, mounted() { this.validateForm(); }, created() { const instStore = instituteStore(); - instStore.getAllAuthorityTypeCodes().then(() => { - this.authorityTypes = this.authorityTypeCodes; - }); + instStore.getAllAuthorityTypeCodes(); instStore.getAllProvinceCodes().then(() => { this.provinceCodeValues = this.provinceCodes.filter(province => province.provinceCode === 'BC' || province.provinceCode === 'YT'); }); @@ -350,6 +350,9 @@ export default { this.resetForm(); this.$emit('newAuthority:closeNewAuthorityPage'); }, + isOffshoreOnlyUser() { + return this.OFFSHORE_SCHOOLS_ADMIN_ROLE; + }, addNewAuthority() { this.processing = true; diff --git a/frontend/src/components/institute/authority/AuthoritiesContacts.vue b/frontend/src/components/institute/authority/AuthoritiesContacts.vue index 27acf6d78..4b5e55c86 100644 --- a/frontend/src/components/institute/authority/AuthoritiesContacts.vue +++ b/frontend/src/components/institute/authority/AuthoritiesContacts.vue @@ -169,13 +169,15 @@ export default { }; }, computed: { - ...mapState(authStore, ['isAuthenticated', 'INDEPENDENT_AUTHORITY_ADMIN_ROLE', 'OFFSHORE_SCHOOLS_ADMIN_ROLE']), + ...mapState(authStore, ['isAuthenticated', 'INDEPENDENT_AUTHORITY_ADMIN_ROLE', 'INDEPENDENT_SCHOOLS_ADMIN_ROLE', 'OFFSHORE_SCHOOLS_ADMIN_ROLE']), ...mapState(instituteStore, ['authorityContactTypeCodes', 'independentAuthorityAuthorityContacts', 'offshoreAuthorityContacts', 'regularAuthorityContactTypes']), loading() { return this.loadingCount !== 0; }, canEditAuthorityContact() { - if(this.authority?.authorityTypeCode === 'OFFSHORE') { + if(this.authority?.authorityTypeCode === 'INDEPENDNT') { + return (this.INDEPENDENT_AUTHORITY_ADMIN_ROLE || this.INDEPENDENT_SCHOOLS_ADMIN_ROLE) && this.isNotClosedAndNeverOpened(); + } else if(this.authority?.authorityTypeCode === 'OFFSHORE') { return this.INDEPENDENT_AUTHORITY_ADMIN_ROLE || this.OFFSHORE_SCHOOLS_ADMIN_ROLE; } return this.INDEPENDENT_AUTHORITY_ADMIN_ROLE && this.isNotClosedAndNeverOpened(); diff --git a/frontend/src/components/institute/authority/Details.vue b/frontend/src/components/institute/authority/Details.vue index 0d12356d2..b1450e0de 100644 --- a/frontend/src/components/institute/authority/Details.vue +++ b/frontend/src/components/institute/authority/Details.vue @@ -904,7 +904,7 @@ export default { }, computed: { ...mapState(instituteStore, ['authorityTypeCodes', 'provinceCodes', 'countryCodes']), - ...mapState(authStore, ['INDEPENDENT_AUTHORITY_ADMIN_ROLE', 'OFFSHORE_SCHOOLS_ADMIN_ROLE']), + ...mapState(authStore, ['INDEPENDENT_AUTHORITY_ADMIN_ROLE','INDEPENDENT_SCHOOLS_ADMIN_ROLE', 'OFFSHORE_SCHOOLS_ADMIN_ROLE']), notesLoading() { return this.noteRequestCount > 0; }, @@ -1061,7 +1061,9 @@ export default { } }, canEditAuthorities() { - if (this.authority?.authorityTypeCode === 'OFFSHORE') { + if (this.authority?.authorityTypeCode === 'INDEPENDNT') { + return this.INDEPENDENT_AUTHORITY_ADMIN_ROLE || this.INDEPENDENT_SCHOOLS_ADMIN_ROLE; + } else if (this.authority?.authorityTypeCode === 'OFFSHORE') { return this.INDEPENDENT_AUTHORITY_ADMIN_ROLE || this.OFFSHORE_SCHOOLS_ADMIN_ROLE; } return this.INDEPENDENT_AUTHORITY_ADMIN_ROLE;