Commit 11533405 authored by Scott Hampton's avatar Scott Hampton

Rename project ID variables

Renamed a couple variables to be more specific
and clear about what data they are in charge of.
parent 676c6d64
...@@ -34,7 +34,7 @@ export default { ...@@ -34,7 +34,7 @@ export default {
variables() { variables() {
return { return {
groupFullPath: this.groupFullPath, groupFullPath: this.groupFullPath,
projectIds: this.selectedProjectIds, projectIds: this.projectIdsToFetch,
}; };
}, },
result({ data }) { result({ data }) {
...@@ -74,7 +74,7 @@ export default { ...@@ -74,7 +74,7 @@ export default {
allCoverageData: [], // All data we have ever received whether selected or not allCoverageData: [], // All data we have ever received whether selected or not
hasError: false, hasError: false,
isLoading: false, isLoading: false,
projectIds: {}, // Which project IDs have been selected selectedProjectIds: {},
projects: {}, projects: {},
}; };
}, },
...@@ -84,19 +84,19 @@ export default { ...@@ -84,19 +84,19 @@ export default {
}, },
skipQuery() { skipQuery() {
// Skip if we haven't selected any projects yet // Skip if we haven't selected any projects yet
return !this.allProjectsSelected && !this.selectedProjectIds.length; return !this.allProjectsSelected && !this.projectIdsToFetch.length;
}, },
/** /**
* selectedProjectIds is a subset of projectIds * projectIdsToFetch is a subset of selectedProjectIds
* The difference is that it only returns the projects * The difference is that it only returns the projects
* that we have selected but haven't requested yet * that we have selected but haven't requested yet
*/ */
selectedProjectIds() { projectIdsToFetch() {
if (this.allProjectsSelected) { if (this.allProjectsSelected) {
return null; return null;
} }
// Get the IDs of the projects that we haven't requested yet // Get the IDs of the projects that we haven't requested yet
return Object.keys(this.projectIds).filter( return Object.keys(this.selectedProjectIds).filter(
(id) => !this.allCoverageData.some((project) => project.id === id), (id) => !this.allCoverageData.some((project) => project.id === id),
); );
}, },
...@@ -105,7 +105,7 @@ export default { ...@@ -105,7 +105,7 @@ export default {
return this.allCoverageData; return this.allCoverageData;
} }
return this.allCoverageData.filter(({ id }) => this.projectIds[id]); return this.allCoverageData.filter(({ id }) => this.selectedProjectIds[id]);
}, },
sortedCoverageData() { sortedCoverageData() {
// Sort the table by most recently updated coverage report // Sort the table by most recently updated coverage report
...@@ -135,17 +135,17 @@ export default { ...@@ -135,17 +135,17 @@ export default {
if (this.allProjectsSelected) { if (this.allProjectsSelected) {
// Reset all project selections to false // Reset all project selections to false
this.allProjectsSelected = false; this.allProjectsSelected = false;
this.projectIds = Object.fromEntries( this.selectedProjectIds = Object.fromEntries(
Object.entries(this.projectIds).map(([key]) => [key, false]), Object.entries(this.selectedProjectIds).map(([key]) => [key, false]),
); );
} }
if (Object.prototype.hasOwnProperty.call(this.projectIds, id)) { if (Object.prototype.hasOwnProperty.call(this.selectedProjectIds, id)) {
Vue.set(this.projectIds, id, !this.projectIds[id]); Vue.set(this.selectedProjectIds, id, !this.selectedProjectIds[id]);
return; return;
} }
Vue.set(this.projectIds, id, true); Vue.set(this.selectedProjectIds, id, true);
}, },
}, },
tableFields: [ tableFields: [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment