};
this.store.getItem('eg.booking.create.multiday').then(multiday => {
- if (multiday) { this.multiday = multiday; }
- }
+ if (multiday) { this.multiday = multiday; }});
this.route.paramMap.subscribe((params: ParamMap) => {
this.patronId = +params.get('patron_id');
this.fetchData();
};
- this.handlePickupLibChange = ($event) => {
+ this.handlePickupLibChange = ($event) => {
this.newDialog.record.pickup_lib($event);
this.org.settings('lib.timezone', $event.id()).then((tz) => {
if (tz['lib.timezone'] && (this.format.wsOrgTimezone !== tz['lib.timezone'])) {
- this.pickupLibUsesDifferentTz = tz['lib.timezone']
+ this.pickupLibUsesDifferentTz = tz['lib.timezone'];
} else {
this.pickupLibUsesDifferentTz = null;
}
this.newDialog.record.current_resource($event);
this.newDialog.record.target_resource($event);
}
- }
+ };
this.useCurrentResourceBarcode = () => {
if (this.resourceBarcode) {
this.router.navigate(['/staff', 'booking', 'create_reservation', 'for_resource', this.resourceBarcode]);
}
};
+
this.findPatronByBarcode = () => {
if (this.patronBarcode) {
this.patron.bcSearch(this.patronBarcode).pipe(single()).subscribe(
);
}
};
+
this.minuteStep = () => {
return (this.granularity < 60) ? this.granularity : 15;
- }
+ };
}
this.setGranularity();
this.fetchData();
- this.openTheDialog = (rows: IdlObject[]) => {
+ this.openTheDialog = (rows: IdlObject[]) => {
return this.newDialog.open({size: 'lg'}).then(
response => {
this.toast.success('Reservation successfully created'); // TODO: needs i18n, pluralization
},
err => {}
);
- }
+ };
- this.openCreateDialog = (rows: IdlObject[]) => {
+ this.openCreateDialog = (rows: IdlObject[]) => {
if (rows.length) {
if (this.multiday) {
this.defaultTimes['start_time'] = this.format.momentizeDateString(rows[0]['time'], this.format.wsOrgTimezone);
.add(this.granularity, 'minutes');
} else {
this.defaultTimes['start_time'] = Moment.tz(rows[0]['time'], 'LT', this.format.wsOrgTimezone);
- this.defaultTimes['end_time'] = Moment.tz(rows[rows.length - 1]['time'], 'LT', this.format.wsOrgTimezone).add(this.granularity, 'minutes');
+ this.defaultTimes['end_time'] =
+ Moment.tz(rows[rows.length - 1]['time'], 'LT', this.format.wsOrgTimezone).add(this.granularity, 'minutes');
}
} else {
if (this.multiday) { this.defaultTimes['end_time'] = this.defaultTimes['start_time'].clone().add(1, 'days'); }
this.transferable = t.transferable();
this.openTheDialog(rows).then(newId => {
if (this.selectedAttributes.length) {
- let creates$ = [];
+ const creates$ = [];
this.selectedAttributes.forEach(attrValue => {
if (attrValue) {
const bravm = this.idl.create('bravm');
this.net.request('open-ils.storage', 'open-ils.storage.booking.reservation.resource_targeter', [newId]);
}
});
- })
+ });
}
- }
+ };
}
handleResourceTypeChange($event: ComboboxEntry) {
this.resourceBarcode = null;
let select = {};
let where = {};
- if (this.resourceId) {
+ if (this.resourceId) {
where = {id: this.resourceId};
} else if (this.resourceTypeId) {
where = {type: this.resourceTypeId};
}
if (this.multiday) {
- this.dateRangeLimiters.forEach((drl) => {
- select = {'curr_rsrcs': {'end_time': {'>' : Moment.tz([drl.fromDate.year, drl.fromDate.month - 1, drl.fromDate.day], this.format.wsOrgTimezone).startOf('day').toISOString()},
- 'start_time': { '<': Moment.tz([drl.toDate.year, drl.toDate.month - 1, drl.toDate.day], this.format.wsOrgTimezone).endOf('day').toISOString() }}}
+ this.dateRangeLimiters.forEach((drl) => { select = {
+ 'curr_rsrcs': {'end_time': {'>' : Moment.tz([drl.fromDate.year, drl.fromDate.month - 1, drl.fromDate.day],
+ this.format.wsOrgTimezone).startOf('day').toISOString()},
+ 'start_time': { '<': Moment.tz([drl.toDate.year, drl.toDate.month - 1, drl.toDate.day],
+ this.format.wsOrgTimezone).endOf('day').toISOString() }}};
});
- } else {
- select = {'curr_rsrcs': {'end_time': {'>' : Moment.tz([this.idealDate.getFullYear(), this.idealDate.getMonth(), this.idealDate.getDate()], this.format.wsOrgTimezone).startOf('day').toISOString()},
- 'start_time': { '<': Moment.tz([this.idealDate.getFullYear(), this.idealDate.getMonth(), this.idealDate.getDate()], this.format.wsOrgTimezone).add(1, 'days').endOf('day').toISOString() }}}
+ } else { select = { 'curr_rsrcs': {
+ 'end_time': {'>' : Moment.tz([this.idealDate.getFullYear(), this.idealDate.getMonth(), this.idealDate.getDate()],
+ this.format.wsOrgTimezone).startOf('day').toISOString()},
+ 'start_time': { '<': Moment.tz([this.idealDate.getFullYear(), this.idealDate.getMonth(), this.idealDate.getDate()],
+ this.format.wsOrgTimezone).add(1, 'days').endOf('day').toISOString() }}};
}
if (this.selectedAttributes.length) {
- where['id'] = {"in": {"from": "bram", "select": {"bram": ["resource"]}, "where": {"value": this.selectedAttributes.filter((a) => (a !== null))}}};
+ where['id'] = {'in': {'from': 'bram', 'select': {'bram': ['resource']}, 'where': {'value': this.selectedAttributes.filter((a) => (a !== null))}}};
}
this.scheduleSource.data = [];
this.pcrud.search('brsrc', where, {
let endTime = Moment();
if (this.multiday) {
this.dateRangeLimiters.forEach((drl) => {
- startTime = Moment.tz([drl.fromDate.year, drl.fromDate.month - 1, drl.fromDate.day], this.format.wsOrgTimezone).startOf('day');
- endTime = Moment.tz([drl.toDate.year, drl.toDate.month - 1, drl.toDate.day], this.format.wsOrgTimezone).endOf('day');
+ startTime = Moment.tz([drl.fromDate.year, drl.fromDate.month - 1, drl.fromDate.day],
+ this.format.wsOrgTimezone).startOf('day');
+ endTime = Moment.tz([drl.toDate.year, drl.toDate.month - 1, drl.toDate.day],
+ this.format.wsOrgTimezone).endOf('day');
});
} else {
this.dateLimiters.forEach((dl) => {
this.format.wsOrgTimezone);
});
}
- let currentTime = startTime;
+ const currentTime = startTime;
while (currentTime < endTime) {
let idx: number;
let existingRow: number;
if (this.multiday) {
- existingRow = this.scheduleSource.data.findIndex((row) => row['time'] === this.format.transform({value: currentTime, datatype: 'timestamp'}));
- idx = (existingRow > -1) ? existingRow : (this.scheduleSource.data.push({'time': this.format.transform({value: currentTime, datatype: 'timestamp'})}) - 1);
+ existingRow = this.scheduleSource.data.findIndex(
+ (row) => row['time'] === this.format.transform({value: currentTime, datatype: 'timestamp'}));
+ idx = (existingRow > -1) ? existingRow :
+ (this.scheduleSource.data.push(
+ {'time': this.format.transform({value: currentTime, datatype: 'timestamp'})}) - 1);
} else {
existingRow = this.scheduleSource.data.findIndex((row) => row['time'] === currentTime.format('LT')) ;
idx = (existingRow > -1) ? existingRow : (this.scheduleSource.data.push({'time': currentTime.format('LT')}) - 1);
}
r.curr_rsrcs().forEach((reservation) => {
- if ((Moment(reservation.start_time(), this.format.wsOrgTimezone) < (currentTime.clone().add(this.granularity, 'minutes'))) &&
+ if ((Moment(reservation.start_time(), this.format.wsOrgTimezone) <
+ (currentTime.clone().add(this.granularity, 'minutes'))) &&
(Moment(reservation.end_time(), this.format.wsOrgTimezone) > currentTime)) {
if (!this.scheduleSource.data[idx][r.barcode()]) { this.scheduleSource.data[idx][r.barcode()] = []; }
- this.scheduleSource.data[idx][r.barcode()].push({'patronLabel': reservation.usr().usrname(), 'patronId': reservation.usr().id()});
+ this.scheduleSource.data[idx][r.barcode()].push(
+ {'patronLabel': reservation.usr().usrname(), 'patronId': reservation.usr().id()});
}
});
currentTime.add(this.granularity, 'minutes');