Skip to content

Commit

Permalink
Merge pull request #2165 from bcgov/fix/edx-3093
Browse files Browse the repository at this point in the history
EDX-3093: refreshing collection object after resolving remaining dupl…
  • Loading branch information
eckermania authored Jan 8, 2025
2 parents f7181bc + ee1da48 commit 905076e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
43 changes: 29 additions & 14 deletions frontend/src/components/data-collection/CollectionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@
transition="false"
reverse-transition="false"
>
<DuplicatesPosting :collection-object="collectionObject"/>
<DuplicatesPosting
:collection-object="collectionObject"
@refresh-collection-object="getCollectionByID"
/>
</v-window-item>
<v-window-item
:value="6"
Expand Down Expand Up @@ -179,24 +182,27 @@ export default {
},
data() {
return {
requestCount: 0,
registerNextEvent: false,
collectionObject: {},
collectionType: null,
collectionYear: null,
isCollectionActive: false,
isLoading: true,
tab: ''
};
},
computed: {
...mapState(authStore, ['userInfo'])
...mapState(authStore, ['userInfo']),
isLoading() {
return this.requestCount > 0;
}
},
async created() {
this.requestCount += 1;
await sdcCollectionStore().getCollectionTypeCodesMap();
await this.getActiveCollection();
await this.getCollectionByID().then(() => {
this.isLoading = !this.isLoading;
});
await this.getCollectionByID();
this.requestCount -= 1;
this.setTab();
},
methods: {
Expand All @@ -212,23 +218,32 @@ export default {
|| hasRequiredPermission(this.userInfo, PERMISSION.REPORTS_SDC_HEADCOUNTS_PERMISSION);
},
async getActiveCollection() {
this.requestCount += 1;
ApiService.apiAxios.get(`${Routes.sdc.ACTIVE_COLLECTION}`).then((response) => {
this.isCollectionActive = response.data.collectionID === this.collectionID;
}).finally(() => {
this.requestCount -= 1;
});
},
async getCollectionByID() {
if(this.activeCollection == null) {
const response = await ApiService.apiAxios.get(`${Routes.sdc.COLLECTION}/` + this.collectionID);
this.collectionObject = response.data;
this.collectionType = formatCollectionTypeCode(this.collectionObject.collectionTypeCode);
this.collectionYear = this.collectionObject.snapshotDate.slice(0, 4);
}
this.requestCount += 1;
ApiService.apiAxios.get(`${Routes.sdc.COLLECTION}/${this.collectionID}`)
.then((response) => {
this.collectionObject = response.data;
this.collectionType = formatCollectionTypeCode(this.collectionObject.collectionTypeCode);
this.collectionYear = this.collectionObject.snapshotDate.slice(0, 4);
})
.catch(error => {
console.error(error);
this.setFailureAlert(error.response?.data?.message || error.message);
})
.finally(() => {
this.requestCount -= 1;
});
},
next() {
this.registerNextEvent = true;
},
navigationCompleted() {
this.registerNextEvent = false;
},
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/components/data-collection/DuplicatesPosting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export default {
required: true
}
},
emits: ['refreshCollectionObject'],
data() {
return {
edxURL: '',
Expand Down Expand Up @@ -248,7 +249,7 @@ export default {
await ApiService.apiAxios.get(`${Routes.sdc.BASE_URL}/collection/${this.collectionObject.collectionID}/sdcSchoolCollections`)
.then((res) => {
this.sdcSchoolCollectionsNotSubmitted = res.data.filter(schools =>
schools.sdcSchoolCollectionStatusCode !== 'SUBMITTED' && schools.sdcSchoolCollectionStatusCode !== 'COMPLETED' && schools.sdcSchoolCollectionStatusCode !== 'P_DUP_POST'
schools.sdcSchoolCollectionStatusCode !== 'SUBMITTED' && schools.sdcSchoolCollectionStatusCode !== 'COMPLETED' && schools.sdcSchoolCollectionStatusCode !== 'P_DUP_POST'
&& schools.sdcSchoolCollectionStatusCode !== 'P_DUP_VRFD')?.length;
this.sdcSchoolCollectionsNotCompleted = res.data.filter(schools => schools.sdcSchoolCollectionStatusCode !== 'COMPLETED')?.length;
}).catch(error => {
Expand All @@ -264,7 +265,7 @@ export default {
await ApiService.apiAxios.get(`${Routes.sdc.BASE_URL}/collection/${this.collectionObject.collectionID}/sdcDistrictCollections`)
.then((res) => {
this.sdcDistrictCollectionsNotSubmitted = res.data.filter(district =>
district.sdcDistrictCollectionStatusCode !== 'SUBMITTED' && district.sdcDistrictCollectionStatusCode !== 'COMPLETED' && district.sdcDistrictCollectionStatusCode !== 'P_DUP_POST'
district.sdcDistrictCollectionStatusCode !== 'SUBMITTED' && district.sdcDistrictCollectionStatusCode !== 'COMPLETED' && district.sdcDistrictCollectionStatusCode !== 'P_DUP_POST'
&& district.sdcDistrictCollectionStatusCode !== 'P_DUP_VRFD')?.length;
this.sdcDistrictCollectionsNotCompleted = res.data.filter(district => district.sdcDistrictCollectionStatusCode !== 'COMPLETED')?.length;
}).catch(error => {
Expand Down Expand Up @@ -302,13 +303,17 @@ export default {
if (!confirmation) {
return;
}
this.isLoading = true;
ApiService.apiAxios.post(`${Routes.sdc.BASE_URL}/collection/${this.collectionID}/resolve-duplicates`)
.then(() => {
this.setSuccessAlert('Remaining Duplicates Resolved Successfully.');
})
.catch(error => {
console.error(error);
this.setFailureAlert(error?.response?.data?.message ? error?.response?.data?.message : 'An error occurred while resolving remaining duplicates. Please try again later.');
}).finally(() => {
this.$emit('refreshCollectionObject');
this.isLoading = false;
});
},
async loadStudents() {
Expand Down

0 comments on commit 905076e

Please sign in to comment.