minuteStep: () => number;
+ openCreateDialog: (rows: IdlObject[]) => void;
+
resources: IdlObject[] = [];
limitByAttr: (attributeId: number, $event: ComboboxEntry) => void;
useCurrentResourceBarcode: () => void;
this.dateLimiters.forEach((dl) => dl.initialDate = new Date());
this.setGranularity();
this.fetchData();
- }
- openCreateDialog(rows: IdlObject[]) {
- if (this.multiday) {
- this.defaultTimes['start_time'] = this.format.momentizeDateString(rows[0]['time'], this.format.wsOrgTimezone);
- this.defaultTimes['end_time'] = this.format.momentizeDateString(
- rows[rows.length - 1]['time'], this.format.wsOrgTimezone).clone()
- .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.openCreateDialog = (rows: IdlObject[]) => {
+ if (rows.length) {
+ if (this.multiday) {
+ this.defaultTimes['start_time'] = this.format.momentizeDateString(rows[0]['time'], this.format.wsOrgTimezone);
+ this.defaultTimes['end_time'] = this.format.momentizeDateString(
+ rows[rows.length - 1]['time'], this.format.wsOrgTimezone).clone()
+ .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');
+ }
+ } else {
+ if (this.multiday) { this.defaultTimes['end_time'] = this.defaultTimes['start_time'].clone().add(1, 'days'); }
+ }
+ return this.newDialog.open({size: 'lg'}).then(
+ response => {
+ console.log(response);
+ this.toast.success('Reservation successfully created'); // TODO: needs i18n, pluralization
+ this.fetchData();
+ },
+ err => {}
+ );
}
- return this.newDialog.open({size: 'lg'}).then(
- response => {
- console.log(response);
- this.toast.success('Reservation successfully created'); // TODO: needs i18n, pluralization
- this.fetchData();
- },
- err => {}
- );
}
handleResourceTypeChange($event: ComboboxEntry) {
this.resourceBarcode = null;