#407 Move filtering into separate collection method
This commit is contained in:
parent
544cb786ee
commit
7e7642c5ce
@ -102,9 +102,7 @@ class Backend {
|
||||
// If this collection has a "filter" property, filter entries accordingly
|
||||
.then(loadedCollection => (
|
||||
{
|
||||
entries: loadedCollection.entries.filter(
|
||||
entry => (!collectionFilter || entry.data[collectionFilter.get('field')] === collectionFilter.get('value'))
|
||||
),
|
||||
entries: collectionFilter ? this.filterEntries(loadedCollection, collectionFilter) : loadedCollection.entries
|
||||
}
|
||||
));
|
||||
}
|
||||
@ -249,6 +247,12 @@ class Backend {
|
||||
}
|
||||
return file.get('fields').map(f => f.get('name')).toArray();
|
||||
}
|
||||
|
||||
filterEntries(collection, filterRule) {
|
||||
return collection.entries.filter(entry => (
|
||||
entry.data[filterRule.get('field')] === filterRule.get('value')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveBackend(config) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user