File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
contentcuration/contentcuration/frontend/shared/data Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -700,6 +700,20 @@ class Resource extends mix(APIResource, IndexedDBResource) {
700
700
this . _requests = { } ;
701
701
}
702
702
703
+ /**
704
+ * Apply filters after fetching data from the server
705
+ * and update it with the local changes
706
+ * @param {Object[] } collection
707
+ * @param {Object } params
708
+ * @return {Object[] }
709
+ */
710
+ _applyFilters ( data , params ) {
711
+ if ( params . parent ) {
712
+ return data . filter ( obj => obj . parent === params . parent ) ;
713
+ }
714
+ return data ;
715
+ }
716
+
703
717
fetchCollection ( params ) {
704
718
const now = Date . now ( ) ;
705
719
const queryString = paramsSerializer ( params ) ;
@@ -725,6 +739,7 @@ class Resource extends mix(APIResource, IndexedDBResource) {
725
739
itemData = [ ] ;
726
740
}
727
741
return this . setData ( itemData ) . then ( data => {
742
+ data = this . _applyFilters ( data , params ) ;
728
743
// setData also applies any outstanding local change events to the data
729
744
// so we return the data returned from setData to make sure the most up to date
730
745
// representation is returned from the fetch.
You can’t perform that action at this time.
0 commit comments