staff portal: fix bug that could prevent entries from being rendered user/gmcharlt/customizable-staff-portal-wip
authorGalen Charlton <gmc@equinoxOLI.org>
Thu, 16 Sep 2021 14:39:26 +0000 (10:39 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Thu, 16 Sep 2021 14:39:26 +0000 (10:39 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/splash.component.ts

index 987a3e3..75e2e23 100644 (file)
@@ -31,7 +31,13 @@ export class StaffSplashComponent implements OnInit {
                 if (tmpPortalEntries[page_col] === undefined) {
                     tmpPortalEntries[page_col] = [];
                 }
-                tmpPortalEntries[page_col][item.col_pos()] = item;
+                if (tmpPortalEntries[page_col][item.col_pos()] === undefined) {
+                    tmpPortalEntries[page_col][item.col_pos()] = [];
+                }
+                // we push here, then flatten the results when we filter
+                // by owner later because (page_col, col_pos) is not
+                // guaranteed to be unique
+                tmpPortalEntries[page_col][item.col_pos()].push(item);
             },
             err => {},
             () => {
@@ -42,7 +48,8 @@ export class StaffSplashComponent implements OnInit {
                 for (let ou of wsAncestors) {
                     tmpPortalEntries.forEach((col) => {
                         if (col !== undefined) {
-                            const filtered = col.filter(x => x !== undefined)
+                            const filtered = col.reduce((prev, curr) => prev.concat(curr), [])
+                                                .filter(x => x !== undefined)
                                                 .filter(x => ou === x.owner());
                             if (filtered.length) {
                                 foundMatch = true;