Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
import classic from 'ember-classic-decorator';
import Component from '@ember/component';

import moment from 'moment';
@classic
export default class CellAction extends Component {}
export default class CellAction extends Component {
currentlyCheckedin = [];
eventdates = [];
get allDates() {
const dates = [];
const date1 = moment(this.extraRecords.event.get('endsAtDate'));
const date2 = moment(this.extraRecords.event.get('startsAtDate'));
const diff = date1.diff(date2, 'days');
for (let i = 0; i < diff; i++) {
dates.push((moment(this.extraRecords.event.get('startsAtDate'), 'MM-DD-YYYY').add(i, 'days').format('MM-DD-YYYY')));
this.eventdates.push(moment(this.extraRecords.event.get('startsAtDate'), 'MM-DD-YYYY').add(i, 'days').format('MM-DD-YYYY'));
}
return dates;
}

get checkinTimes() {
if (this.extraRecords.checkinTimes) {
const x = this.extraRecords.checkinTimes?.split(',');
const checkinDates = [];
for (const i of x) {
checkinDates.push(moment(i).format('MM-DD-YYYY'));
}
return checkinDates;
}
return [];
}

get checkoutTimes() {
if (this.extraRecords.checkoutTimes) {
const x = this.extraRecords.checkoutTimes?.split(',');
const checkoutDates = [];
for (const i of x) {
checkoutDates.push(moment(i).format('MM-DD-YYYY'));
}
return checkoutDates;
}
return [];
}

get currentlyChecked() {
for (const i of this.eventdates) {
const checkinCount = this.checkinTimes?.filter(x => x === i).length || 0;
const checkoutCount = this.checkoutTimes?.filter(x => x === i).length || 0;
if (checkinCount > checkoutCount && !this.currentlyCheckedin.includes(i)) {
this.currentlyCheckedin.push(i);
}
}
return this.currentlyCheckedin;
}
}
33 changes: 20 additions & 13 deletions app/controllers/events/view/tickets/attendees/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
},
{
name : 'Date and Time',
width : 140,
width : 120,
valuePath : 'order.completed_at',
extraValuePaths : ['order'],
cellComponent : 'ui-table/cell/events/view/tickets/attendees/cell-date',
Expand All @@ -34,7 +34,7 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
},
{
name : 'Ticket Price',
width : 90,
width : 50,
valuePath : 'ticket.price',
extraValuePaths : ['event', 'discountCode'],
cellComponent : 'ui-table/cell/events/view/tickets/attendees/cell-price',
Expand All @@ -44,23 +44,23 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
{
name : 'First Name',
valuePath : 'firstname',
width : 100
width : 60
},
{
name : 'Last Name',
valuePath : 'lastname',
width : 90
width : 60
},
{
name : 'Email',
valuePath : 'email',
width : 120
width : 130
},
{
name : 'Actions',
valuePath : 'id',
width : 90,
extraValuePaths : ['order', 'isCheckedIn'],
width : 130,
extraValuePaths : ['order', 'isCheckedIn', 'event', 'checkinTimes', 'checkoutTimes'],
cellComponent : 'ui-table/cell/events/view/tickets/attendees/cell-action',
actions : {
toggleCheckIn: this.toggleCheckIn.bind(this)
Expand All @@ -70,16 +70,23 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
}

@action
toggleCheckIn(attendee_id) {
toggleCheckIn(attendee_id, date, isCheckedInCurrently) {
const attendee = this.store.peekRecord('attendee', attendee_id, { backgroundReload: false });
attendee.toggleProperty('isCheckedIn');
if (attendee.isCheckedIn) {
const newCheckinTimes = attendee.get('checkinTimes') === null ? `${moment().toISOString()}` : `${attendee.get('checkinTimes')},${moment().toISOString()}`;
let myTime = moment().toISOString();
if (moment(date, 'MM-DD-YYYY').format('MM-DD-YYYY') !== moment().format('MM-DD-YYYY')) {
myTime = moment(date, 'MM-DD-YYYY');
myTime = myTime.format('YYYY-MM-DD') + 'T13:00:00.000Z';
}
if (!isCheckedInCurrently) {
const newCheckinTimes = attendee.get('checkinTimes') === null ? `${myTime}` : `${attendee.get('checkinTimes')},${myTime}`;
attendee.set('checkinTimes', newCheckinTimes);
} else {
const newCheckoutTimes = attendee.get('checkoutTimes') === null ? `${myTime}` : `${attendee.get('checkoutTimes')},${myTime}`;
attendee.set('checkoutTimes', newCheckoutTimes);
}
attendee.save()
.then(savedAttendee => {
const message = savedAttendee.isCheckedIn ? this.l10n.t('Attendee Checked-In Successfully') : this.l10n.t('Attendee Checked-Out Successfully');
.then(() => {
const message = !isCheckedInCurrently ? this.l10n.t('Attendee Checked-In Successfully') : this.l10n.t('Attendee Checked-Out Successfully');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not able to checkout. @maze-runnar Are you able to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

this.notify.success(message);
this.refreshModel.bind(this)();
})
Expand Down
1 change: 1 addition & 0 deletions app/models/attendee.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default ModelBase.extend({
lastname : attr('string'),
isCheckedIn : attr('boolean', { defaultValue: false }),
checkinTimes : attr('string'),
checkoutTimes : attr('string'),
state : attr('string'),
address : attr('string'),
pdfUrl : attr('string'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
{{#if (eq this.extraRecords.order.status 'completed')}}
{{#if this.extraRecords.isCheckedIn}}
<button class="tiny ui labeled icon negative button" {{action this.props.actions.toggleCheckIn this.record}}><i class="remove icon"></i>{{t 'Check-Out'}}</button>
{{else}}
<button class="tiny ui labeled icon positive button" {{action this.props.actions.toggleCheckIn this.record}}><i class="checkmark icon"></i>{{t 'Check‑In'}}</button>
{{/if}}
<UiDropdown @class="d-flex items-center pl-4 fluid multiple selection">
<div class="default">
{{t 'Checkin'}}
</div>
<i class="dropdown icon"></i>
<div class="menu">
{{#each this.allDates as |date|}}
<UiCheckbox
@class="item"
@label={{date}}
@checked={{if (includes this.currentlyChecked date) true}}
@onChange={{action this.props.actions.toggleCheckIn this.record date (includes this.currentlyChecked date)}}
/>
{{/each}}
</div>
</UiDropdown>
{{/if}}