Skip to content

Commit

Permalink
Merge pull request #219 from bcgov/ofmcc-3837-ea-sign-fa
Browse files Browse the repository at this point in the history
ofmcc-3837 - use isExpenseAuthority flag to check Sign FA permission
  • Loading branch information
vietle-cgi authored May 30, 2024
2 parents d9f8876 + 2b6ee25 commit f6809c1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 16 deletions.
7 changes: 6 additions & 1 deletion backend/src/components/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ async function getUserProfile(userGuid, userName) {
function parseFacilityPermissions(userResponse) {
return userResponse.facility_permission
.filter((fp) => fp.ofm_portal_access)
.map((fp) => new MappableObjectForFront(fp.facility, UserProfileFacilityMappings).data)
.map((fp) => {
return {
...new MappableObjectForFront(fp, UsersPermissionsFacilityMappings).data,
...new MappableObjectForFront(fp.facility, UserProfileFacilityMappings).data,
}
})
.sort((a, b) => a.facilityName.localeCompare(b.facilityName))
}

Expand Down
17 changes: 15 additions & 2 deletions frontend/src/components/funding/FundingAgreementsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
</template>

<script>
import { mapState } from 'pinia'
import FundingSearchCard from '@/components/funding/FundingSearchCard.vue'
import alertMixin from '@/mixins/alertMixin.js'
import { useAuthStore } from '@/stores/auth'
import FundingAgreementService from '@/services/fundingAgreementService'
import { FUNDING_AGREEMENT_STATUS_CODES } from '@/utils/constants'
import format from '@/utils/format'
Expand All @@ -54,6 +56,10 @@ export default {
}
},
computed: {
...mapState(useAuthStore, ['userInfo']),
},
created() {
this.format = format
this.FUNDING_AGREEMENT_STATUS_CODES = FUNDING_AGREEMENT_STATUS_CODES
Expand Down Expand Up @@ -85,11 +91,18 @@ export default {
},
showSign(fundingAgreement) {
return fundingAgreement?.statusCode === FUNDING_AGREEMENT_STATUS_CODES.SIGNATURE_PENDING
return fundingAgreement?.statusCode === FUNDING_AGREEMENT_STATUS_CODES.SIGNATURE_PENDING && this.isExpenseAuthority(fundingAgreement)
},
showOpen(fundingAgreement) {
return [FUNDING_AGREEMENT_STATUS_CODES.SUBMITTED, FUNDING_AGREEMENT_STATUS_CODES.ACTIVE].includes(fundingAgreement?.statusCode)
return (
[FUNDING_AGREEMENT_STATUS_CODES.SUBMITTED, FUNDING_AGREEMENT_STATUS_CODES.ACTIVE].includes(fundingAgreement?.statusCode) ||
(fundingAgreement?.statusCode === FUNDING_AGREEMENT_STATUS_CODES.SIGNATURE_PENDING && !this.isExpenseAuthority(fundingAgreement))
)
},
isExpenseAuthority(fundingAgreement) {
return this.userInfo?.facilities?.some((facility) => facility.facilityId === fundingAgreement?.facilityId && facility.isExpenseAuthority)
},
goToFundingAgreement(fundingAgreement) {
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/components/funding/SignFundingPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@ export default {
fundingAgreements: [],
}
},
computed: {
...mapState(useAuthStore, ['userInfo']),
filteredFacilities() {
return this.userInfo?.facilities?.filter((facility) => facility.isExpenseAuthority)
},
},
async created() {
//TODO - JB: check if user has permissions to view / sign the FA before we bother loading all the Funding Agreements
await this.loadFundingAgreements()
},
methods: {
closeDialog() {
this.isDisplayed = false
Expand All @@ -71,7 +77,7 @@ export default {
//I use for of here so I can break out of the loop when I hit 3 facilities.
//We show 3 max so the popup doesn't take over the screen, and we save on calls to Dynamics.
for (const fac of this.userInfo.facilities) {
for (const fac of this.filteredFacilities) {
const fa = await FundingAgreementService.getActiveFundingAgreementByFacilityIdAndStatus(fac.facilityId, FUNDING_AGREEMENT_STATUS_CODES.SIGNATURE_PENDING)
if (fa) {
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/views/funding/FundingView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</li>
<li class="pl-4">
All information provided in the Form or otherwise in support of the Provider to receive funding under the Funding Agreement is true and complete to the best of my knowledge and belief. I
understand and acknowledge thatproviding false or misleading information either on the Form or otherwise to the Province to obtain any funding under the Funding Agreement or otherwise
understand and acknowledge that providing false or misleading information either on the Form or otherwise to the Province to obtain any funding under the Funding Agreement or otherwise
failing to comply with the Funding Agreement could result in certain penalties or repayment obligations, or both, under any or all of the Child Care BC Act, any successor legislation, or
the Funding Agreement.
<br />
Expand All @@ -81,7 +81,7 @@
</div>
</v-col>

<v-checkbox v-model="fundingAgreement.agreeConsentCertify" class="ml-3" :disabled="!canEditFA" label="I agree, consent and certify" />
<v-checkbox v-model="fundingAgreement.agreeConsentCertify" class="ml-3" :disabled="readonly" color="primary" label="I agree, consent and certify" />
</v-row>

<v-row v-if="!loading" class="justify-center justify-md-space-between mx-md-7 my-3">
Expand All @@ -104,7 +104,6 @@ import FundingAgreementService from '@/services/fundingAgreementService'
import LicenceService from '@/services/licenceService'
import LicenceHeader from '@/components/licences/LicenceHeader.vue'
import LicenceDetails from '@/components/licences/LicenceDetails.vue'
import permissionsMixin from '@/mixins/permissionsMixin'
import { FUNDING_AGREEMENT_STATUS_CODES } from '@/utils/constants'
import VuePdfEmbed from 'vue-pdf-embed'
Expand All @@ -121,7 +120,7 @@ const LOCKED_STATUSES = [
export default {
name: 'FundingView',
components: { AppBackButton, AppButton, OrganizationHeader, LicenceDetails, LicenceHeader, VuePdfEmbed },
mixins: [alertMixin, permissionsMixin],
mixins: [alertMixin],
data() {
return {
pdfFile: undefined,
Expand All @@ -132,22 +131,22 @@ export default {
loading: false,
}
},
computed: {
...mapState(useAuthStore, ['userInfo']),
canEditFA() {
//TODO - JB: add permissions back in when complete
return !this.isFundingAgreementLocked
},
isFundingAgreementLocked() {
return LOCKED_STATUSES.includes(this.fundingAgreement?.statusCode)
readonly() {
const isExpenseAuthority = this.userInfo?.facilities?.some((facility) => facility.facilityId === this.fundingAgreement?.facilityId && facility.isExpenseAuthority)
return !isExpenseAuthority || LOCKED_STATUSES.includes(this.fundingAgreement?.statusCode)
},
submitDisabled() {
return this.isFundingAgreementLocked || !this.fundingAgreement.agreeConsentCertify
return this.readonly || !this.fundingAgreement.agreeConsentCertify
},
},
async created() {
await this.loadData()
},
methods: {
async loadData() {
try {
Expand All @@ -163,6 +162,7 @@ export default {
this.loading = false
}
},
async getLicences() {
try {
this.licences = await FacilityService.getLicences(this.fundingAgreement?.facilityId)
Expand Down

0 comments on commit f6809c1

Please sign in to comment.