Skip to content

Commit

Permalink
Merge pull request #169 from borkarsaish65/release-5.1.0
Browse files Browse the repository at this point in the history
Filtering out subentities
  • Loading branch information
aks30 authored Oct 3, 2024
2 parents 3330c23 + 3048c5e commit 9ab5118
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions generics/services/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ const configForStateLocation = function ( stateLocationCode, entityKey ) {
return fieldInstance.code == messageConstants.common.PERSONA
})[0].children.administrator;

let allowedLocationFields = ["state", "district", "block", "cluster", "school"];

//Entity type is stored in a key called code
let subEntities = subEntityData.map( subEntity => {
return subEntity.code;
})
let subEntities = subEntityData.filter( subEntity => {
if(allowedLocationFields.includes(subEntity.code)){
return true;
}else {
return false;
}
}).map(subEntity => subEntity.code)
//set cache data for given state
let setCache = cache.setValue(entityKey, subEntities, messageConstants.common.CACHE_TTL);
return resolve(subEntities);
Expand Down

0 comments on commit 9ab5118

Please sign in to comment.