staff portal: fix card header and body styling
authorGalen Charlton <gmc@equinoxOLI.org>
Tue, 3 Aug 2021 15:03:44 +0000 (11:03 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Wed, 1 Sep 2021 18:42:30 +0000 (14:42 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/splash.component.html
Open-ILS/src/eg2/src/app/staff/splash.component.ts

index 620876b..99392aa 100644 (file)
   </div>
 
   <div class="row" id="splash-nav">
-    <div class="col-lg-4" *ngFor="let col of portalEntries">
+    <div class="col-lg-4" *ngFor="let header of portalHeaders; index as i">
       <div class="card">
-        <ng-container *ngFor="let entry of col">
-          <div class="card-header" *ngIf="entry.entry_type() === 'header'">
-            <h2 class="panel-title text-center" i18n>{{entry.label()}}</h2>
-          </div>
-          <div class="list-group-item border-0 p-2" *ngIf="entry.entry_type() === 'menuitem'">
-            <a href="{{entry.target_url()}}" i18n>
-              <img src="{{entry.image_url()}}" alt="" role="presentation"/>
-              {{entry.label()}}
-            </a>
-          </div>
-          <div class="list-group-item border-0 p-2" *ngIf="entry.entry_type() === 'catalogsearch'">
-            <div class="input-group">
-              <input type="text" class="form-control" 
-                [(ngModel)]="catSearchQuery"
-                id='catalog-search-input'
-                autofocus
-                (keyup.enter)="searchCatalog()"
-                i18n-placeholder placeholder="Search for..."
-                i18n-aria-label aria-label="Search for...">
-              <span class="input-group-btn">
-                <button class="btn btn-outline-secondary" 
-                  (click)="searchCatalog()" type="button" i18n>
+        <div class="card-header" *ngIf="header">
+          <h2 class="panel-title text-center" i18n>{{header.label()}}</h2>
+        </div>
+        <div class="card-body">
+          <div class="list-group">
+            <ng-container *ngFor="let entry of portalEntries[i]">
+              <div class="list-group-item border-0 p-2" *ngIf="entry.entry_type() === 'menuitem'">
+                <a href="{{entry.target_url()}}" i18n>
+                  <img src="{{entry.image_url()}}" alt="" role="presentation"/>
                   {{entry.label()}}
-                </button>
-              </span>
-            </div>
-          </div>
-          <div class="list-group-item border-0 p-2" *ngIf="entry.entry_type() === 'link'">
-            <a target="_top" href="{{entry.target_url()}}" i18n>
-              <img src="{{entry.image_url()}}" alt="" role="presentation"/>
-              {{entry.label()}}
-            </a>
+                </a>
+              </div>
+              <div class="list-group-item border-0 p-2" *ngIf="entry.entry_type() === 'catalogsearch'">
+                <div class="input-group">
+                  <input type="text" class="form-control" 
+                    [(ngModel)]="catSearchQuery"
+                    id='catalog-search-input'
+                    autofocus
+                    (keyup.enter)="searchCatalog()"
+                    i18n-placeholder placeholder="Search for..."
+                    i18n-aria-label aria-label="Search for...">
+                  <span class="input-group-btn">
+                    <button class="btn btn-outline-secondary" 
+                      (click)="searchCatalog()" type="button" i18n>
+                      {{entry.label()}}
+                    </button>
+                  </span>
+                </div>
+              </div>
+              <div class="list-group-item border-0 p-2" *ngIf="entry.entry_type() === 'link'">
+                <a target="_top" href="{{entry.target_url()}}" i18n>
+                  <img src="{{entry.image_url()}}" alt="" role="presentation"/>
+                  {{entry.label()}}
+                </a>
+              </div>
+            </ng-container>
           </div>
-        </ng-container>
+        </div>
       </div>
     </div>
   </div>
index 78c05ca..eace52b 100644 (file)
@@ -10,6 +10,7 @@ export class StaffSplashComponent implements OnInit {
 
     catSearchQuery: string;
     portalEntries: any[][] = [];
+    portalHeaders: any[] = [];
 
     constructor(
         private renderer: Renderer2,
@@ -18,14 +19,32 @@ export class StaffSplashComponent implements OnInit {
     ) {}
 
     ngOnInit() {
-
-        this.pcrud.search('cusppe', {owner: 1}).subscribe(item => {
-            const page_col = item.page_col() - 1;
-            if (this.portalEntries[page_col] === undefined) {
-                this.portalEntries[page_col] = [];
+        const tmpPortalEntries: any[][] = [];
+        this.pcrud.search('cusppe', {owner: 1}).subscribe(
+            item => {
+                const page_col = item.page_col();
+                if (tmpPortalEntries[page_col] === undefined) {
+                    tmpPortalEntries[page_col] = [];
+                }
+                tmpPortalEntries[page_col][item.col_pos()] = item;
+            },
+            err => {},
+            () => {
+                // munge the results so that we don't need to
+                // care if there are gaps in the page_col or col_pos
+                // sequences
+                tmpPortalEntries.forEach((col) => {
+                    if (col !== undefined) {
+                        this.portalEntries.push(col);
+                        col.forEach((entry) => {
+                            if (entry.entry_type() === 'header') {
+                                this.portalHeaders[this.portalEntries.length - 1] = entry;
+                            }
+                        });
+                    }
+                });
             }
-            this.portalEntries[page_col][item.col_pos()] = item;
-        });
+        );
     }
 
     searchCatalog(): void {