Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDX-3093: refreshing collection object after resolving remaining dupl… #2165

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading