Campaign status show send settings Bug
This commit is contained in:
parent
4b1b1a380d
commit
1a61067ff9
9 changed files with 119 additions and 26 deletions
|
@ -76,6 +76,19 @@ async function listDTAjax(context, params) {
|
|||
);
|
||||
}
|
||||
|
||||
async function listByNamespaceDTAjax(context, namespaceId, params) {
|
||||
return await dtHelpers.ajaxListWithPermissions(
|
||||
context,
|
||||
[{ entityTypeId: 'campaign', requiredOperations: ['view'] }],
|
||||
params,
|
||||
builder => builder.from('campaigns')
|
||||
.innerJoin('namespaces', 'namespaces.id', 'campaigns.namespace')
|
||||
.where('namespaces.id', namespaceId)
|
||||
.whereNull('campaigns.parent'),
|
||||
['campaigns.id', 'campaigns.name', 'campaigns.cid', 'campaigns.description', 'campaigns.type', 'campaigns.status', 'campaigns.scheduled', 'campaigns.source', 'campaigns.created', 'namespaces.name']
|
||||
);
|
||||
}
|
||||
|
||||
async function listChildrenDTAjax(context, campaignId, params) {
|
||||
return await dtHelpers.ajaxListWithPermissions(
|
||||
context,
|
||||
|
@ -730,9 +743,9 @@ async function changeStatusByCampaignCidAndSubscriptionIdTx(tx, context, campaig
|
|||
])
|
||||
.first();
|
||||
|
||||
if (!message) {
|
||||
//if (!message) {
|
||||
throw new Error('Invalid campaign.')
|
||||
}
|
||||
//}
|
||||
|
||||
await _changeStatusByMessageTx(tx, context, message, subscriptionStatus);
|
||||
}
|
||||
|
@ -934,6 +947,7 @@ module.exports.Content = Content;
|
|||
module.exports.hash = hash;
|
||||
|
||||
module.exports.listDTAjax = listDTAjax;
|
||||
module.exports.listByNamespaceDTAjax = listByNamespaceDTAjax;
|
||||
module.exports.listChildrenDTAjax = listChildrenDTAjax;
|
||||
module.exports.listWithContentDTAjax = listWithContentDTAjax;
|
||||
module.exports.listOthersWhoseListsAreIncludedDTAjax = listOthersWhoseListsAreIncludedDTAjax;
|
||||
|
|
|
@ -53,6 +53,33 @@ async function listDTAjax(context, params) {
|
|||
);
|
||||
}
|
||||
|
||||
async function listByNamespaceDTAjax(context, params) {
|
||||
const campaignEntityType = entitySettings.getEntityType('campaign');
|
||||
|
||||
return await dtHelpers.ajaxListWithPermissions(
|
||||
context,
|
||||
[{ entityTypeId: 'list', requiredOperations: ['view'] }],
|
||||
params,
|
||||
builder => builder
|
||||
.from('lists')
|
||||
.innerJoin('namespaces', 'namespaces.id', 'lists.namespace'),
|
||||
['lists.id', 'lists.name', 'lists.cid', 'lists.subscribers', 'lists.description', 'namespaces.name',
|
||||
{
|
||||
name: 'triggerCount',
|
||||
query: builder =>
|
||||
builder.from('campaigns')
|
||||
.innerJoin('campaign_lists', 'campaigns.id', 'campaign_lists.campaign')
|
||||
.innerJoin('triggers', 'campaigns.id', 'triggers.campaign')
|
||||
.innerJoin(campaignEntityType.permissionsTable, 'campaigns.id', `${campaignEntityType.permissionsTable}.entity`)
|
||||
.whereRaw('campaign_lists.list = lists.id')
|
||||
.where(`${campaignEntityType.permissionsTable}.operation`, 'viewTriggers')
|
||||
.count()
|
||||
.as('triggerCount')
|
||||
}
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
async function listWithSegmentByCampaignDTAjax(context, campaignId, params) {
|
||||
return await dtHelpers.ajaxListWithPermissions(
|
||||
context,
|
||||
|
@ -260,6 +287,7 @@ async function remove(context, id) {
|
|||
module.exports.UnsubscriptionMode = UnsubscriptionMode;
|
||||
module.exports.hash = hash;
|
||||
module.exports.listDTAjax = listDTAjax;
|
||||
module.exports.listByNamespaceDTAjax = listByNamespaceDTAjax;
|
||||
module.exports.listWithSegmentByCampaignDTAjax = listWithSegmentByCampaignDTAjax;
|
||||
module.exports.getByIdTx = getByIdTx;
|
||||
module.exports.getById = getById;
|
||||
|
|
|
@ -19,6 +19,10 @@ router.postAsync('/campaigns-others-by-list-table/:campaignId/:listIds', passpor
|
|||
return res.json(await campaigns.listOthersWhoseListsAreIncludedDTAjax(req.context, castToInteger(req.params.campaignId), req.params.listIds.split(';').map(x => castToInteger(x)), req.body));
|
||||
});
|
||||
|
||||
router.postAsync('/campaigns-namespace/:namespaceId', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await campaigns.listByNamespaceDTAjax(req.context, castToInteger(req.params.namespaceId), req.body));
|
||||
});
|
||||
|
||||
router.postAsync('/campaigns-children/:campaignId', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await campaigns.listChildrenDTAjax(req.context, castToInteger(req.params.campaignId), req.body));
|
||||
});
|
||||
|
|
|
@ -11,6 +11,10 @@ router.postAsync('/lists-table', passport.loggedIn, async (req, res) => {
|
|||
return res.json(await lists.listDTAjax(req.context, req.body));
|
||||
});
|
||||
|
||||
router.postAsync('/users-table-byNamespace/:namespaceId', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await lists.listDTAjax(req.context, 1));
|
||||
});
|
||||
|
||||
router.postAsync('/lists-with-segment-by-campaign-table/:campaignId', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await lists.listWithSegmentByCampaignDTAjax(req.context, castToInteger(req.params.campaignId), req.body));
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue