Skip to content

Commit

Permalink
add schools filter for district report based on district collection s…
Browse files Browse the repository at this point in the history
…chools
  • Loading branch information
alexmcdermid committed Oct 8, 2024
1 parent 55a81a5 commit 66150ba
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 8 deletions.
17 changes: 16 additions & 1 deletion backend/src/components/sdc/sdc.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,20 @@ async function getSdcDistrictCollections(req, res) {
}
}

async function getSdcSchoolCollectionsFromSdcDistrictCollectionID(req, res) {
try {
const data = await getData(`${config.get('sdc:districtCollectionURL')}/${req.params.sdcDistrictCollectionID}/sdcSchoolCollections`);

data?.forEach(value => {
value.schoolName = getSchoolName(cacheService.getSchoolBySchoolID(value.schoolID));
});
return res.status(HttpStatus.OK).json(data);
} catch (e) {
await logApiError(e, 'getSdcSchoolCollectionBySdcDistrictCollectionId', 'error getSdcSchoolCollectionBySdcDistrictCollectionId');
return errorResponse(res);
}
}

async function downloadSdcReport(req, res) {
const reportTypeValues = [
['csv_school', 'ALL_STUDENT_SCHOOL_CSV'],
Expand Down Expand Up @@ -962,5 +976,6 @@ module.exports = {
downloadSdcReport,
updateBandCode,
moveSld,
getDistrictHeadcounts
getDistrictHeadcounts,
getSdcSchoolCollectionsFromSdcDistrictCollectionID
};
3 changes: 2 additions & 1 deletion backend/src/routes/sdc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 85 additions & 4 deletions frontend/src/components/common/Filters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@
School and District Filtering
</v-col>
</v-row>
<v-row
>
<v-col cols="6" class="pt-0">
<v-row>
<v-col
cols="6"
class="pt-0"
>
<v-row v-if="false">
<v-text-field
id="searchInput"
Expand Down Expand Up @@ -224,7 +226,10 @@
/>
</slot>
</v-col>
<v-col cols="6" class="pt-0">
<v-col
cols="6"
class="pt-0"
>
<slot
name="text-search"
>
Expand All @@ -246,6 +251,41 @@
</v-col>
</v-row>
</div>
<div v-if="isDistrict === true">
<v-row>
<v-col
id="schoolFilters"
class="filter-heading pb-0"
>
School Filtering
</v-col>
</v-row>
<v-row>
<v-col
cols="6"
class="pt-0"
>
<slot
name="text-search"
>
<v-autocomplete
id="selectSchool"
v-model="schoolNameNumberFilterForDistrict"
variant="underlined"
:items="schoolSearchNamesForDistrict"
color="#003366"
label="School Name or Number"
single-line
:clearable="true"
item-title="schoolCodeName"
item-value="sdcSchoolCollectionID"
autocomplete="off"
@update:model-value="setSchoolNameNumberFilterForDistrict('schoolNameNumber', $event)"
/>
</slot>
</v-col>
</v-row>
</div>
<div
v-for="(filter, key) in filters"
:key="key"
Expand Down Expand Up @@ -392,6 +432,11 @@ export default {
required: false,
default: null
},
isDistrict: {
type: Boolean,
required: false,
default: false
},
},
emits: ['clearFilters', 'apply-filters', 'close'],
data() {
Expand All @@ -402,6 +447,7 @@ export default {
courseRange: [0, 15],
penLocalIdNameFilter: null,
schoolNameNumberFilter: null,
schoolNameNumberFilterForDistrict: null,
districtNameNumberFilter: null,
legalFirstName: null,
legalMiddleNames: null,
Expand All @@ -413,6 +459,7 @@ export default {
assignedPen: null,
localID: null,
schoolSearchNames: [],
schoolSearchNamesForDistrict: [],
districtSearchNames: [],
sdcCollection: sdcCollectionStore(),
};
Expand Down Expand Up @@ -442,6 +489,9 @@ export default {
Object.keys(this.filters).forEach(key => {
this.selected[key] = [];
});
if (this.isDistrict) {
this.setupSchoolListForDistrict(this.indySchoolDistrictObject.id);
}
},
methods: {
setupSchoolList(){
Expand All @@ -464,6 +514,27 @@ export default {
console.error(error);
});
},
setupSchoolListForDistrict(sdcDistrictCollectionID){
this.schoolSearchNames = [];
ApiService.apiAxios.get(`${Routes.sdc.SDC_DISTRICT_COLLECTION}/${sdcDistrictCollectionID}/sdcSchoolCollections`)
.then((res) => {
res.data.forEach(schoolCollection => {
const school = this.schoolsMap.get(schoolCollection.schoolID);
if (school) {
let schoolItem = {
schoolCodeName: school.schoolName + ' - ' + school.mincode,
schoolID: school.schoolID,
districtID: school.districtID
};
this.schoolSearchNames.push(schoolItem);
}
});
this.schoolSearchNamesForDistrict = sortBy(this.schoolSearchNames, ['schoolCodeName']);
})
.catch(error => {
console.error(error);
});
},
setupDistrictList(){
this.schoolSearchNames = [];
ApiService.apiAxios.get(`${Routes.sdc.BASE_URL}/collection/${this.$route.params.collectionID}/sdcDistrictCollections`)
Expand Down Expand Up @@ -518,6 +589,16 @@ export default {
this.apply();
}
},
setSchoolNameNumberFilterForDistrict(key, $event) {
this.setPenLocalIdNameFilter($event, null);
if($event) {
this.selected[key] = [{title: 'SchoolNameOrNumber', value: $event}];
this.apply();
} else {
delete this.selected[key];
this.apply();
}
},
setDistrictNameNumberFilter(key, $event) {
this.setPenLocalIdNameFilter($event, null);
if($event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
:filters="config.allowedFilters"
:collection-object="collectionObject"
:indy-school-district-object="indySchoolDistrictObject"
:is-district="isDistrict"
@apply-filters="applyFilters"
@clear-filters="clearFilters"
@close="showFilters= !showFilters"
Expand Down Expand Up @@ -146,6 +147,11 @@ export default {
required: false,
default: () => null
},
isDistrict: {
type: Boolean,
required: false,
default: false
},
showExportBtn: {
type: Boolean,
required: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
:config="indySchoolsNameNumberFilter != null ? configSchools : configDistricts"
:collection-object="collectionObject"
:indy-school-district-object="indySchoolDistrictObject"
:is-district="isDistrict"
:show-export-btn="true"
:read-only="true"
/>
Expand Down Expand Up @@ -84,6 +85,7 @@ export default {
configDistricts: FTE_DISTRICT,
configSchools: FTE_SCHOOL,
indySchoolDistrictObject: null,
isDistrict: false,
};
},
computed: {
Expand All @@ -99,8 +101,10 @@ export default {
setIndySchoolsDistrictsNameNumberFilter(key, $event) {
if ($event) {
this.indySchoolDistrictObject = { type: key, id: $event };
this.isDistrict = key === 'district';
} else {
this.indySchoolDistrictObject = null;
this.isDistrict = false;
}
},
setupIndySchoolsDistrictsList() {
Expand Down
Loading

0 comments on commit 66150ba

Please sign in to comment.