Namespace filtering when create/edit campaigns

This commit is contained in:
Carlos 2019-03-14 16:15:37 +01:00
parent 7b08e2e97b
commit 74fe5e73e2
6 changed files with 752 additions and 9 deletions

View file

@ -53,7 +53,7 @@ async function listDTAjax(context, params) {
);
}
async function listByNamespaceDTAjax(context, params) {
async function listByNamespaceDTAjax(context, namespaceId, params) {
const campaignEntityType = entitySettings.getEntityType('campaign');
return await dtHelpers.ajaxListWithPermissions(
@ -62,7 +62,8 @@ async function listByNamespaceDTAjax(context, params) {
params,
builder => builder
.from('lists')
.innerJoin('namespaces', 'namespaces.id', 'lists.namespace'),
.innerJoin('namespaces', 'namespaces.id', 'lists.namespace')
.where('lists.namespace', namespaceId),
['lists.id', 'lists.name', 'lists.cid', 'lists.subscribers', 'lists.description', 'namespaces.name',
{
name: 'triggerCount',

View file

@ -34,6 +34,19 @@ async function listDTAjax(context, params) {
);
}
async function listDTAjaxByNamespace(context, namespaceId, params) {
return await dtHelpers.ajaxListWithPermissions(
context,
[{ entityTypeId: 'sendConfiguration', requiredOperations: ['viewPublic'] }],
params,
builder => builder
.from('send_configurations')
.innerJoin('namespaces', 'namespaces.id', 'send_configurations.namespace')
.where('send_configurations.namespace', namespaceId),
['send_configurations.id', 'send_configurations.name', 'send_configurations.cid', 'send_configurations.description', 'send_configurations.mailer_type', 'send_configurations.created', 'namespaces.name']
);
}
async function listWithSendPermissionDTAjax(context, params) {
return await dtHelpers.ajaxListWithPermissions(
context,
@ -175,6 +188,7 @@ async function getSystemSendConfiguration() {
module.exports.hash = hash;
module.exports.listDTAjax = listDTAjax;
module.exports.listDTAjaxByNamespace = listDTAjaxByNamespace;
module.exports.listWithSendPermissionDTAjax = listWithSendPermissionDTAjax;
module.exports.getByIdTx = getByIdTx;
module.exports.getById = getById;

View file

@ -12,7 +12,7 @@ router.postAsync('/lists-table', passport.loggedIn, async (req, res) => {
});
router.postAsync('/users-table-byNamespace/:namespaceId', passport.loggedIn, async (req, res) => {
return res.json(await lists.listDTAjax(req.context, 1));
return res.json(await lists.listByNamespaceDTAjax(req.context, castToInteger(req.params.namespaceId), req.body));
});
router.postAsync('/lists-with-segment-by-campaign-table/:campaignId', passport.loggedIn, async (req, res) => {

View file

@ -40,6 +40,10 @@ router.postAsync('/send-configurations-table', passport.loggedIn, async (req, re
return res.json(await sendConfigurations.listDTAjax(req.context, req.body));
});
router.postAsync('/send-configurations-table-byNamespace/:namespaceId', passport.loggedIn, async (req, res) => {
return res.json(await sendConfigurations.listDTAjaxByNamespace(req.context, castToInteger(req.params.namespaceId), req.body));
});
router.postAsync('/send-configurations-with-send-permission-table', passport.loggedIn, async (req, res) => {
return res.json(await sendConfigurations.listWithSendPermissionDTAjax(req.context, req.body));
});