From 8683f8c91e9cc5c92c71558c49e668e3247542c4 Mon Sep 17 00:00:00 2001 From: Tomas Bures Date: Wed, 14 Nov 2018 23:21:45 +0100 Subject: [PATCH] Some bugfixes --- client/src/campaigns/TestSendModalDialog.js | 2 +- client/src/lists/imports/CUD.js | 6 +++++- client/src/templates/TestSendModalDialog.js | 2 +- lib/dt-helpers.js | 2 +- models/campaigns.js | 2 +- models/links.js | 6 +++--- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/client/src/campaigns/TestSendModalDialog.js b/client/src/campaigns/TestSendModalDialog.js index 02f6b086..a54b2aaa 100644 --- a/client/src/campaigns/TestSendModalDialog.js +++ b/client/src/campaigns/TestSendModalDialog.js @@ -74,7 +74,7 @@ export class TestSendModalDialog extends Component { data.sendConfigurationId = props.entity.send_configuration; data.campaignId = props.entity.id; - console.log(await axios.post(getUrl('rest/template-test-send'), data)); + await axios.post(getUrl('rest/template-test-send'), data); this.clearFormStatusMessage(); diff --git a/client/src/lists/imports/CUD.js b/client/src/lists/imports/CUD.js index 4c74d7e4..ceb82b8a 100644 --- a/client/src/lists/imports/CUD.js +++ b/client/src/lists/imports/CUD.js @@ -286,7 +286,11 @@ export default class CUD extends Component { } } - onFileSelected() { + onFileSelected(evt, x) { + if (!this.getFormValue('name') && this.csvFile.files.length > 0) { + this.updateFormValue('name', this.csvFile.files[0].name); + } + this.scheduleFormRevalidate(); } diff --git a/client/src/templates/TestSendModalDialog.js b/client/src/templates/TestSendModalDialog.js index b7f1e82f..06663068 100644 --- a/client/src/templates/TestSendModalDialog.js +++ b/client/src/templates/TestSendModalDialog.js @@ -71,7 +71,7 @@ export class TestSendModalDialog extends Component { data.subscriptionCid = this.getFormValue('testUser'); data.sendConfigurationId = this.getFormValue('sendConfiguration'); - console.log(await axios.post(getUrl('rest/template-test-send'), data)); + await axios.post(getUrl('rest/template-test-send'), data); this.clearFormStatusMessage(); diff --git a/lib/dt-helpers.js b/lib/dt-helpers.js index 6c557ecb..255f225f 100644 --- a/lib/dt-helpers.js +++ b/lib/dt-helpers.js @@ -137,7 +137,7 @@ async function ajaxListWithPermissionsTx(tx, context, fetchSpecs, params, queryF query = query.innerJoin( function () { - return this.from(entityType.permissionsTable).select('entity').where('user', context.user.id).whereIn('operation', fetchSpec.requiredOperations).as(`permitted__${fetchSpec.entityTypeId}`); + return this.from(entityType.permissionsTable).distinct('entity').where('user', context.user.id).whereIn('operation', fetchSpec.requiredOperations).as(`permitted__${fetchSpec.entityTypeId}`); }, `permitted__${fetchSpec.entityTypeId}.entity`, entityIdColumn) } diff --git a/models/campaigns.js b/models/campaigns.js index 04aadde1..fbf670ef 100644 --- a/models/campaigns.js +++ b/models/campaigns.js @@ -478,7 +478,7 @@ async function remove(context, id) { await triggers.removeAllByCampaignIdTx(tx, context, id); await tx('template_dep_campaigns') - .where('campaign', entity.id) + .where('campaign', id) .del(); await tx('campaigns').where('id', id).del(); diff --git a/models/links.js b/models/links.js index d803b6f6..ff403b0f 100644 --- a/models/links.js +++ b/models/links.js @@ -146,11 +146,11 @@ async function updateLinks(campaign, list, subscription, mergeTags, message) { } if (!campaign.click_tracking_disabled) { - const re = /(]* href\s*=[\s"']*)(http[^"'>\s]+)/gi; + const re = /(]* href\s*=\s*["']\s*)(http[^"'>\s]+)/gi; const urlsToBeReplaced = new Set(); - message = message.replace(re, (match, prefix, encodedUrl) => { + message.replace(re, (match, prefix, encodedUrl) => { const url = he.decode(encodedUrl, {isAttributeValue: true}); urlsToBeReplaced.add(url); }); @@ -166,7 +166,7 @@ async function updateLinks(campaign, list, subscription, mergeTags, message) { message = message.replace(re, (match, prefix, encodedUrl) => { const url = he.decode(encodedUrl, {isAttributeValue: true}); const link = urls.get(url); - return getPublicUrl(`/links/${campaign.cid}/${list.cid}/${subscription.cid}/${link.cid}`); + return prefix + (link ? getPublicUrl(`/links/${campaign.cid}/${list.cid}/${subscription.cid}/${link.cid}`) : url); }); }