mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
0caa539330
refs https://github.com/TryGhost/Team/issues/581 requires https://github.com/TryGhost/Ghost/pull/12932 - added segment option and select to default newsletter recipients setting - updated segment selector to fetch labels/products and show as options - updated segment selector and count component to call an action when count changes so we can use it in the email confirmation modal - removed usage and mapping of older `'none'`, `'all'`, `'free'`, and `'paid'` email recipient filter values
34 lines
1009 B
JavaScript
34 lines
1009 B
JavaScript
import Component from '@glimmer/component';
|
|
import {inject as service} from '@ember/service';
|
|
import {task, taskGroup} from 'ember-concurrency-decorators';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class GhMembersSegmentCountComponent extends Component {
|
|
@service store;
|
|
@service session;
|
|
|
|
@tracked total = 0;
|
|
@tracked segmentTotal = 0;
|
|
|
|
@taskGroup fetchTasks;
|
|
|
|
@task({group: 'fetchTasks'})
|
|
*fetchTotalsTask() {
|
|
this.fetchSegmentTotalTask.perform();
|
|
|
|
const members = yield this.store.query('member', {limit: 1});
|
|
this.total = members.meta.pagination.total;
|
|
}
|
|
|
|
@task({group: 'fetchTasks'})
|
|
*fetchSegmentTotalTask() {
|
|
if (!this.args.segment) {
|
|
return this.segmentTotal = 0;
|
|
}
|
|
|
|
const members = yield this.store.query('member', {limit: 1, filter: this.args.segment});
|
|
this.segmentTotal = members.meta.pagination.total;
|
|
this.args.onSegmentCountChange?.(this.segmentTotal);
|
|
}
|
|
}
|