2022-10-21 11:31:25 +03:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import {action} from '@ember/object';
|
|
|
|
|
|
|
|
const eventTypes = {
|
2022-10-24 12:11:44 +03:00
|
|
|
sent: ['email_sent_event'],
|
2022-10-21 11:31:25 +03:00
|
|
|
opened: ['email_opened_event'],
|
2022-10-27 18:23:45 +03:00
|
|
|
clicked: ['aggregated_click_event'],
|
2022-10-21 11:31:25 +03:00
|
|
|
feedback: ['feedback_event'],
|
|
|
|
conversion: ['subscription_event', 'signup_event']
|
|
|
|
};
|
|
|
|
|
|
|
|
export default class PostActivityFeed extends Component {
|
|
|
|
_pageSize = 5;
|
|
|
|
|
|
|
|
get getEventTypes() {
|
2022-10-27 18:23:45 +03:00
|
|
|
return eventTypes[this.args.eventType];
|
2022-10-21 11:31:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get pageSize() {
|
|
|
|
return this._pageSize;
|
|
|
|
}
|
|
|
|
|
2022-10-21 19:33:37 +03:00
|
|
|
get eventType() {
|
|
|
|
return this.args.eventType;
|
|
|
|
}
|
|
|
|
|
2022-10-21 11:31:25 +03:00
|
|
|
// calculate amount of empty rows which require to keep table height the same for each tab/page
|
|
|
|
@action
|
|
|
|
getAmountOfStubs({data}) {
|
|
|
|
const stubs = this._pageSize - data.length;
|
|
|
|
|
|
|
|
return new Array(stubs).fill(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
isPreviousButtonDisabled({hasReachedStart, isLoading}) {
|
|
|
|
return hasReachedStart || isLoading;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
isNextButtonDisabled({hasReachedEnd, isLoading}) {
|
|
|
|
return hasReachedEnd || isLoading;
|
|
|
|
}
|
2022-10-25 14:55:03 +03:00
|
|
|
|
|
|
|
@action
|
2022-10-25 18:59:29 +03:00
|
|
|
isPaginationNotNeeded({totalEvents}) {
|
2022-10-25 14:55:03 +03:00
|
|
|
return (totalEvents <= this._pageSize);
|
|
|
|
}
|
2022-10-25 18:59:29 +03:00
|
|
|
|
|
|
|
@action
|
|
|
|
areStubsNeeded({totalEvents}) {
|
|
|
|
return totalEvents > this._pageSize || this.args.eventType === 'feedback';
|
|
|
|
}
|
2022-10-21 11:31:25 +03:00
|
|
|
}
|