#407 Add collection filtering by field and value
This commit is contained in:
committed by
David Calavera
parent
6d5ff45e66
commit
544cb786ee
@ -84,6 +84,7 @@ class Backend {
|
||||
listEntries(collection) {
|
||||
const listMethod = this.implementation[selectListMethod(collection)];
|
||||
const extension = selectFolderEntryExtension(collection);
|
||||
const collectionFilter = collection.get('filter');
|
||||
return listMethod.call(this.implementation, collection, extension)
|
||||
.then(loadedEntries => (
|
||||
loadedEntries.map(loadedEntry => createEntry(
|
||||
@ -97,6 +98,14 @@ class Backend {
|
||||
{
|
||||
entries: entries.map(this.entryWithFormat(collection)),
|
||||
}
|
||||
))
|
||||
// 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'))
|
||||
),
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user