Skip to content

Commit

Permalink
revert for INDEPENDENT_SCHOOLS_ADMIN role
Browse files Browse the repository at this point in the history
  • Loading branch information
SodhiA1 committed Oct 25, 2023
1 parent 32b046f commit 89a9e6b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 21 deletions.
4 changes: 3 additions & 1 deletion backend/src/components/institute/institute.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion backend/src/routes/institute.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/institute/AuthoritiesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/institute/AuthorityDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 14 additions & 11 deletions frontend/src/components/institute/NewAuthorityPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
item-value="authorityTypeCode"
item-title="label"
variant="underlined"
:items="authorityTypes"
:items="filteredAuthorityTypeCodes"
:rules="[rules.required()]"
:clearable="true"
/>
Expand Down Expand Up @@ -306,35 +306,35 @@ export default {
physicalAddrPostal: null,
},
rules: Rules,
schoolFacilityTypes: [],
schoolCategoryTypes: [],
schoolOrganizationTypes: [],
schoolNeighborhoodLearningTypes: [],
schoolGradeTypes: [],
sameAsMailingCheckbox: true,
provinceCodeValues: [],
countryCodeValues: [],
authorityTypes: [],
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');
});
Expand All @@ -350,6 +350,9 @@ export default {
this.resetForm();
this.$emit('newAuthority:closeNewAuthorityPage');
},
isOffshoreOnlyUser() {
return this.OFFSHORE_SCHOOLS_ADMIN_ROLE;
},
addNewAuthority() {
this.processing = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/institute/authority/Details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 89a9e6b

Please sign in to comment.