<eg-fm-record-editor #newDialog
idlClass="bresv"
+ datetimeFields="start_time,end_time"
[fieldOptions]="{usr:{customTemplate:{template:patronTemplate,context:{'patronId':this.patronId}}}}"
hiddenFields="id,xact_start,request_time,capture_time,pickup_time,return_time,capture_staff,xact_finish,cancel_time,booking_interval,target_resource,unrecovered,request_lib,fine_interval,fine_amount,max_fine">
</eg-fm-record-editor>
</ng-container>
</ng-template>
<ng-template #patronTemplate let-patronId="patronId">
- <ng-container *ngIf="patronId">
- <input type="text" disabled value="{{patronId}}">
- </ng-container>
+ <input *ngIf="patronId" type="text" disabled value="{{patronId}}" class="form-control" name="usr" (beforeSave$="record['usr'] = patronId">
+ <div *ngIf="!patronId" class="input-group flex-nowrap">
+ <div class="input-group-prepend">
+ <label class="input-group-text" for="patron-barcode" i18n>Patron barcode</label>
+ <input type="text" id="patron-barcode" class="form-control" i18n-placeholder placeholder="Patron barcode" [(ngModel)]="patronBarcode" (change)="findPatronByBarcode()">
+ <input type="hidden" value="{{patronId}}" name="usr" (beforeSave$)="record['usr'] = patronId">
+ </div>
+ </div>
</ng-template>
import {GridDataSource, GridRowFlairEntry} from '@eg/share/grid/grid';
import {IdlObject} from '@eg/core/idl.service';
import {NetService} from '@eg/core/net.service';
+import {PatronService} from '@eg/staff/share/patron.service';
import {PcrudService} from '@eg/core/pcrud.service';
import {ResourceTypeComboboxComponent} from './resource-type-combobox.component';
import {ServerStoreService} from '@eg/core/server-store.service';
isBooked: (col: any, row: any) => string;
resourceAvailabilityIcon: (row: any) => GridRowFlairEntry;
+ patronBarcode: string;
patronId: number;
resourceBarcode: string;
resourceId: number;
resources: IdlObject[] = [];
limitByAttr: (attributeId: number, $event: ComboboxEntry) => void;
useCurrentResourceBarcode: () => void;
+ findPatronByBarcode: () => void;
setGranularity: () => void;
handleMultiDayReservation: () => void;
private auth: AuthService,
private format: FormatService,
private net: NetService,
+ private patron: PatronService,
private pcrud: PcrudService,
private route: ActivatedRoute,
private router: Router,
this.router.navigate(['/staff', 'booking', 'create_reservation', 'for_resource', this.resourceBarcode]);
}
};
+ this.findPatronByBarcode = () => {
+ if (this.patronBarcode) {
+ this.patron.bcSearch(this.patronBarcode).pipe(single()).subscribe(
+ resp => { this.patronId = resp[0].id; },
+ err => { this.toast.danger('No patron found with this barcode'); },
+ );
+ }
+ };
}
showNewDialog(idlThing: IdlObject) {
return this.newDialog.open({size: 'lg'}).then(
- ok => {
+ response => {
+ console.log(response);
this.toast.success('Reservation successfully created'); // TODO: needs i18n, pluralization
this.fetchData();
},