LP#1835982 follow-up: Add cellTextGenerator to booking schedule grid
authorJane Sandberg <sandbej@linnbenton.edu>
Sat, 18 Jan 2020 18:44:02 +0000 (10:44 -0800)
committerJane Sandberg <sandbej@linnbenton.edu>
Sat, 18 Jan 2020 18:44:02 +0000 (10:44 -0800)
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.html
Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.ts

index 1d6e684..9addf19 100644 (file)
     </button>
   </div>
   <eg-grid #scheduleGrid
+    [cellTextGenerator]="cellTextGenerator"
     [sortable]="false"
     (onRowActivate)="openTheDialog([$event])"
     [dataSource]="scheduleSource"
     <eg-grid-toolbar-button label="Create Reservation" i18n-label (onClick)="openTheDialog($event)"></eg-grid-toolbar-button>
     <eg-grid-toolbar-action label="Create Reservation" i18n-label (onClick)="openTheDialog($event)"></eg-grid-toolbar-action>
     <eg-grid-column path="time" [index]="true" name="Time" i18n-name [cellTemplate]="timeTemplate" ></eg-grid-column>
-    <eg-grid-column *ngFor="let resource of resources" path="{{resource.barcode()}}" [cellTemplate]="reservationsTemplate" [disableTooltip]="true"></eg-grid-column>
+    <eg-grid-column *ngFor="let resource of resources" path="{{resource.barcode()}}" [cellTemplate]="reservationsTemplate" [name]="resource.barcode()" [disableTooltip]="true"></eg-grid-column>
   </eg-grid>
 </ng-container>
 <div class="text-sm-center" *ngIf="this.resourceType.value && !resources.length" i18n>
index 3395611..e026920 100644 (file)
@@ -8,7 +8,7 @@ import {AuthService} from '@eg/core/auth.service';
 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
 import {FormatService} from '@eg/core/format.service';
 import {GridComponent} from '@eg/share/grid/grid.component';
-import {GridDataSource, GridRowFlairEntry} from '@eg/share/grid/grid';
+import {GridDataSource, GridRowFlairEntry, GridCellTextGenerator} from '@eg/share/grid/grid';
 import {IdlObject} from '@eg/core/idl.service';
 import {NetService} from '@eg/core/net.service';
 import {PcrudService} from '@eg/core/pcrud.service';
@@ -43,6 +43,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit, OnDest
     attributes: IdlObject[] = [];
     multiday = false;
     resourceAvailabilityIcon: (row: ScheduleRow) => GridRowFlairEntry;
+    cellTextGenerator: GridCellTextGenerator;
 
     patronId: number;
     resourceBarcode: string;
@@ -305,6 +306,19 @@ export class CreateReservationComponent implements OnInit, AfterViewInit, OnDest
                 this.granularity,
                 this.format.wsOrgTimezone
             );
+        }, (err) => {
+        }, () => {
+            this.cellTextGenerator = {
+                'Time': row => {
+                    return this.multiday ? row['time'].format('LT') :
+                        this.format.transform({value: row['time'], datatype: 'timestamp', datePlusTime: true});
+                }
+            };
+            this.resources.forEach(resource => {
+                this.cellTextGenerator[resource.barcode()] = row =>  {
+                    return row[resource.barcode()] ? row[resource.barcode()].map(reservation => reservation['patronLabel']).join(', ') : '';
+                };
+            });
         });
     }
     // TODO: make this into cross-field validation, and don't fetch data if true