Enabled product options for email recipient segment

refs https://github.com/TryGhost/Team/issues/801
refs 0caa539330

- adds back product options to email recipient segment filter in publish menu
This commit is contained in:
Rishabh 2021-06-24 11:32:04 +05:30 committed by Rishabh Garg
parent 3c5e334041
commit f9a25d4e41
2 changed files with 43 additions and 17 deletions

View File

@ -13,6 +13,7 @@ export default class GhMembersRecipientSelect extends Component {
@service membersUtils;
@service session;
@service store;
@service feature;
baseFilters = new TrackedSet();
specificFilters = new TrackedSet();
@ -144,6 +145,29 @@ export default class GhMembersRecipientSelect extends Component {
options.push(labelsGroup);
}
if (this.feature.get('multipleProducts')) {
// fetch all products w̶i̶t̶h̶ c̶o̶u̶n̶t̶s̶
// TODO: add `include: 'count.members` to query once API supports
const products = yield this.store.query('product', {limit: 'all'});
if (products.length > 1) {
const productsGroup = {
groupName: 'Products',
options: []
};
products.forEach((product) => {
productsGroup.options.push({
name: product.name,
segment: `product:${product.slug}`,
count: product.count?.members,
class: 'segment-product'
});
});
options.push(productsGroup);
}
}
this.specificOptions = options;
}

View File

@ -6,6 +6,7 @@ import {tracked} from '@glimmer/tracking';
export default class GhMembersSegmentSelect extends Component {
@service store;
@service feature;
@tracked _options = [];
@ -89,27 +90,28 @@ export default class GhMembersSegmentSelect extends Component {
options.push(labelsGroup);
}
if (this.feature.get('multipleProducts')) {
// fetch all products w̶i̶t̶h̶ c̶o̶u̶n̶t̶s̶
// TODO: add `include: 'count.members` to query once API supports
const products = yield this.store.query('product', {limit: 'all'});
// fetch all products w̶i̶t̶h̶ c̶o̶u̶n̶t̶s̶
// TODO: add `include: 'count.members` to query once API supports
const products = yield this.store.query('product', {limit: 'all'});
if (products.length > 0) {
const productsGroup = {
groupName: 'Products',
options: []
};
if (products.length > 0) {
const productsGroup = {
groupName: 'Products',
options: []
};
products.forEach((product) => {
productsGroup.options.push({
name: product.name,
segment: `product:${product.slug}`,
count: product.count?.members,
class: 'segment-product'
products.forEach((product) => {
productsGroup.options.push({
name: product.name,
segment: `product:${product.slug}`,
count: product.count?.members,
class: 'segment-product'
});
});
});
options.push(productsGroup);
options.push(productsGroup);
}
}
this._options = options;