diff --git a/client/src/campaigns/CUD.js b/client/src/campaigns/CUD.js
index 02944ac5..792a17d2 100644
--- a/client/src/campaigns/CUD.js
+++ b/client/src/campaigns/CUD.js
@@ -238,6 +238,7 @@ export default class CUD extends Component {
click_tracking_disabled: false,
open_tracking_disabled: false,
work_send_config_current_namespace: false,
+ work_template_current_namespace: false,
unsubscribe_url: '',
@@ -526,6 +527,7 @@ export default class CUD extends Component {
const currentNamespace = this.getFormValue('namespace');
const useNamespaceSendConfig = this.getFormValue('work_send_config_current_namespace');
+ const useNamespaceTemplate = this.getFormValue('work_template_current_namespace');
for (const lstUid of lsts) {
const prefix = 'lists_' + lstUid + '_';
@@ -569,6 +571,7 @@ export default class CUD extends Component {
}
+
{useNamespaceLists &&
}
@@ -581,7 +584,6 @@ export default class CUD extends Component {
{selectedList && this.getFormValue(prefix + 'useSegmentation') &&
}
-
}
@@ -679,7 +681,13 @@ export default class CUD extends Component {
// The "key" property here and in the TableSelect below is to tell React that these tables are different and should be rendered by different instances. Otherwise, React will use
// only one instance, which fails because Table does not handle updates in "columns" property
- templateEdit = ;
+ if(useNamespaceTemplate){
+ templateEdit = ;
+ }
+ else{
+ templateEdit = ;
+ }
+
} else if (!isEdit && sourceTypeKey === CampaignSource.CUSTOM_FROM_CAMPAIGN) {
const campaignsColumns = [
@@ -753,16 +761,18 @@ export default class CUD extends Component {
{t('sendSettings')}
+
+
{useNamespaceSendConfig &&
}
{!useNamespaceSendConfig &&
}
-
+
{sendSettings}
-
+
@@ -770,10 +780,12 @@ export default class CUD extends Component {
- {sourceEdit &&
}
+ {t('template')}
{sourceEdit}
+
+
{templateEdit}
diff --git a/locales/en-US/common.json b/locales/en-US/common.json
index eab42641..ee60a4de 100644
--- a/locales/en-US/common.json
+++ b/locales/en-US/common.json
@@ -118,7 +118,7 @@
"blacklistedEmails": "Blacklisted Emails",
"createRegularCampaign": "Create Regular Campaign",
"sendSettings": "Send settings",
- "workWithCurrentNamespace": "Work with current namespace",
+ "workWithCampaignNamespace": "Work with campaign's namespace",
"createRssCampaign": "Create RSS Campaign",
"createTriggeredCampaign": "Create Triggered Campaign",
"editRegularCampaign": "Edit Regular Campaign",
diff --git a/locales/es-ES/common.json b/locales/es-ES/common.json
index bbc52fd9..980002e1 100644
--- a/locales/es-ES/common.json
+++ b/locales/es-ES/common.json
@@ -118,7 +118,7 @@
"blacklistedEmails": "Blacklisted Emails",
"createRegularCampaign": "Crear Campaña Regular",
"sendSettings": "Configuración de envío",
- "workWithCurrentNamespace": "Trabajar con el Espacio de nombres actual",
+ "workWithCampaignNamespace": "Trabajar con el espacio de nombres de la campaña",
"createRssCampaign": "Create RSS Campaign",
"createTriggeredCampaign": "Create Triggered Campaign",
"editRegularCampaign": "Edit Regular Campaign",
diff --git a/server/models/templates.js b/server/models/templates.js
index ba7f9334..b351df08 100644
--- a/server/models/templates.js
+++ b/server/models/templates.js
@@ -46,6 +46,16 @@ async function listDTAjax(context, params) {
);
}
+async function listByNamespaceDTAjax(context, params, namespaceId) {
+ return await dtHelpers.ajaxListWithPermissions(
+ context,
+ [{ entityTypeId: 'template', requiredOperations: ['view'] }],
+ params,
+ builder => builder.from('templates').innerJoin('namespaces', 'namespaces.id', 'templates.namespace').where('namespaces.id', namespaceId),
+ [ 'templates.id', 'templates.name', 'templates.description', 'templates.type', 'templates.created', 'namespaces.name' ]
+ );
+}
+
async function _validateAndPreprocess(tx, entity) {
await namespaceHelpers.validateEntity(tx, entity);
@@ -135,6 +145,7 @@ module.exports.hash = hash;
module.exports.getByIdTx = getByIdTx;
module.exports.getById = getById;
module.exports.listDTAjax = listDTAjax;
+module.exports.listByNamespaceDTAjax = listByNamespaceDTAjax;
module.exports.create = create;
module.exports.updateWithConsistencyCheck = updateWithConsistencyCheck;
module.exports.remove = remove;
diff --git a/server/routes/rest/templates.js b/server/routes/rest/templates.js
index 216b065f..0483d9c9 100644
--- a/server/routes/rest/templates.js
+++ b/server/routes/rest/templates.js
@@ -35,6 +35,10 @@ router.postAsync('/templates-table', passport.loggedIn, async (req, res) => {
return res.json(await templates.listDTAjax(req.context, req.body));
});
+router.postAsync('/templates-table-byNamespace/:namespaceId', passport.loggedIn, async (req, res) => {
+ return res.json(await templates.listByNamespaceDTAjax(req.context, req.body, castToInteger(req.params.namespaceId)));
+});
+
router.postAsync('/template-test-send', passport.loggedIn, passport.csrfProtection, async (req, res) => {
const data = req.body;
const result = await CampaignSender.testSend(req.context, data.listCid, data.subscriptionCid, data.campaignId, data.sendConfigurationId, data.html, data.text);