From 1b90758009d214f661a39437bb7b954f14573bff Mon Sep 17 00:00:00 2001 From: Lumbardh Agaj Date: Mon, 21 Mar 2022 16:30:11 +0100 Subject: [PATCH 1/6] fix: Update enabled number of users error when no users found --- .../push/frontend/public/javascripts/countly.views.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/push/frontend/public/javascripts/countly.views.js b/plugins/push/frontend/public/javascripts/countly.views.js index 6da293f3dbb..08e671a613b 100644 --- a/plugins/push/frontend/public/javascripts/countly.views.js +++ b/plugins/push/frontend/public/javascripts/countly.views.js @@ -460,11 +460,6 @@ var preparePushNotificationModel = Object.assign({}, self.pushNotificationUnderEdit); preparePushNotificationModel.type = self.type; countlyPushNotification.service.estimate(preparePushNotificationModel, options).then(function(response) { - if (response.total === 0) { - resolve(false); - CountlyHelpers.notify({ message: 'No users were found from selected configuration.', type: "error"}); - return; - } self.setLocalizationOptions(response.localizations); self.setCurrentNumberOfUsers(response.total); if (self.pushNotificationUnderEdit.type === self.TypeEnum.ONE_TIME || self.type === self.TypeEnum.ONE_TIME) { @@ -475,6 +470,11 @@ if (response._id) { self.setId(response._id); } + if (response.total === 0) { + resolve(false); + CountlyHelpers.notify({ message: 'No users were found from selected configuration.', type: "error"}); + return; + } resolve(true); }).catch(function(error) { console.error(error); From 9acdd514bc12e71654114b2c9c0536e5c567d958 Mon Sep 17 00:00:00 2001 From: Lumbardh Agaj Date: Mon, 21 Mar 2022 17:35:14 +0100 Subject: [PATCH 2/6] fix: Dates not reset error on duplicate --- .../public/javascripts/countly.views.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/plugins/push/frontend/public/javascripts/countly.views.js b/plugins/push/frontend/public/javascripts/countly.views.js index 08e671a613b..04f4d46b411 100644 --- a/plugins/push/frontend/public/javascripts/countly.views.js +++ b/plugins/push/frontend/public/javascripts/countly.views.js @@ -1063,7 +1063,20 @@ this.updateIosPlatformSettingsStateIfFound(); this.updateAndroidPlatformSettingsStateIfFound(); }, + updateOneTimeOptions: function() { + if (this.userCommand === this.UserCommandEnum.DUPLICATE) { + this.pushNotificationUnderEdit.delivery.startDate = Date.now(); + this.pushNotificationUnderEdit.delivery.endDate = null; + this.pushNotificationUnderEdit.delivery.type = this.SendEnum.NOW; + } + }, updateAutomaticOptions: function() { + if (this.userCommand === this.UserCommandEnum.DUPLICATE) { + this.pushNotificationUnderEdit.delivery.startDate = Date.now(); + this.pushNotificationUnderEdit.delivery.endDate = null; + this.pushNotificationUnderEdit.delivery.type = this.SendEnum.NOW; + this.pushNotificationUnderEdit.automatic.usersTimezone = null; + } if (this.pushNotificationUnderEdit.automatic.usersTimezone) { this.isUsersTimezoneSet = true; } @@ -1071,6 +1084,13 @@ this.isEndDateSet = true; } }, + updateTransactionalOptions: function() { + if (this.userCommand === this.UserCommandEnum.DUPLICATE) { + this.pushNotificationUnderEdit.delivery.startDate = Date.now(); + this.pushNotificationUnderEdit.delivery.endDate = null; + this.pushNotificationUnderEdit.delivery.type = this.SendEnum.NOW; + } + }, fetchPushNotificationById: function() { var self = this; this.setIsLoading(true); @@ -1085,6 +1105,12 @@ if (self.pushNotificationUnderEdit.type === self.TypeEnum.AUTOMATIC) { self.updateAutomaticOptions(); } + if (self.pushNotificationUnderEdit.type === self.TypeEnum.ONE_TIME) { + self.updateOneTimeOptions(); + } + if (self.pushNotificationUnderEdit.type === self.TypeEnum.TRANSACTIONAL) { + self.updateTransactionalOptions(); + } }) .catch(function(error) { console.error(error); From 341538c5484a07720fa48d1bda60bc9c5596c2c3 Mon Sep 17 00:00:00 2001 From: Lumbardh Agaj Date: Mon, 21 Mar 2022 17:35:52 +0100 Subject: [PATCH 3/6] fix: timezone is true when same error --- .../frontend/public/javascripts/countly.models.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/push/frontend/public/javascripts/countly.models.js b/plugins/push/frontend/public/javascripts/countly.models.js index fbf88f8f1b7..9733f9decfc 100644 --- a/plugins/push/frontend/public/javascripts/countly.models.js +++ b/plugins/push/frontend/public/javascripts/countly.models.js @@ -1346,7 +1346,7 @@ type: dto.info && dto.info.scheduled ? SendEnum.LATER : SendEnum.NOW, }; model.audienceSelection = triggerDto.delayed ? AudienceSelectionEnum.BEFORE : AudienceSelectionEnum.NOW; - model.timezone = triggerDto.tz ? TimezoneEnum.SAME : TimezoneEnum.DEVICE; + model.timezone = triggerDto.tz ? TimezoneEnum.DEVICE : TimezoneEnum.SAME; return model; }, mapDtoToAutomaticModel: function(dto) { @@ -1354,7 +1354,6 @@ model.type = TypeEnum.AUTOMATIC; var triggerDto = dto.triggers[0]; model.cohorts = triggerDto.cohorts || []; - model.timezone = triggerDto.tz ? TimezoneEnum.SAME : TimezoneEnum.DEVICE; model.delivery = { startDate: moment(triggerDto.start).valueOf(), endDate: triggerDto.end ? moment(triggerDto.end).valueOf() : null, @@ -1746,12 +1745,12 @@ start: model.delivery.startDate, }; if (model.delivery.type === SendEnum.LATER) { - result.tz = model.timezone === TimezoneEnum.SAME; + if (model.timezone === TimezoneEnum.DEVICE) { + result.tz = true; + result.sctz = new Date().getTimezoneOffset(); + } result.delayed = model.audienceSelection === AudienceSelectionEnum.BEFORE; } - if (model.timezone === TimezoneEnum.SAME && model.delivery.type === SendEnum.LATER) { - result.sctz = new Date().getTimezoneOffset(); - } return [result]; }, mapAutomaticTrigger: function(model, options) { From 247c1b5cafc8166579de8c751764f97ab284df96 Mon Sep 17 00:00:00 2001 From: Lumbardh Agaj Date: Mon, 21 Mar 2022 17:43:02 +0100 Subject: [PATCH 4/6] fix: Title missing error when title user props not empty --- plugins/push/frontend/public/javascripts/countly.models.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/push/frontend/public/javascripts/countly.models.js b/plugins/push/frontend/public/javascripts/countly.models.js index 9733f9decfc..b667ee332dd 100644 --- a/plugins/push/frontend/public/javascripts/countly.models.js +++ b/plugins/push/frontend/public/javascripts/countly.models.js @@ -1726,6 +1726,9 @@ } if (self.hasUserProperties(pushNotificationModel.message[localizationKey], 'title')) { localeDto.titlePers = self.mapUserProperties(pushNotificationModel.message[localizationKey], 'title'); + if (!title) { + localeDto.title = title; + } } if (pushNotificationModel.message[localizationKey].buttons.length) { localeDto.buttons = self.mapButtons(pushNotificationModel.message[localizationKey]); From 43dee42e2c9219284f84d152779c0898aa21e490 Mon Sep 17 00:00:00 2001 From: Lumbardh Agaj Date: Tue, 22 Mar 2022 09:08:29 +0100 Subject: [PATCH 5/6] refactor: Create and use resetDelivery() method --- .../public/javascripts/countly.views.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/plugins/push/frontend/public/javascripts/countly.views.js b/plugins/push/frontend/public/javascripts/countly.views.js index 04f4d46b411..4bc5c4131dc 100644 --- a/plugins/push/frontend/public/javascripts/countly.views.js +++ b/plugins/push/frontend/public/javascripts/countly.views.js @@ -1063,18 +1063,19 @@ this.updateIosPlatformSettingsStateIfFound(); this.updateAndroidPlatformSettingsStateIfFound(); }, + resetDelivery: function() { + this.pushNotificationUnderEdit.delivery.startDate = Date.now(); + this.pushNotificationUnderEdit.delivery.endDate = null; + this.pushNotificationUnderEdit.delivery.type = this.SendEnum.NOW; + }, updateOneTimeOptions: function() { if (this.userCommand === this.UserCommandEnum.DUPLICATE) { - this.pushNotificationUnderEdit.delivery.startDate = Date.now(); - this.pushNotificationUnderEdit.delivery.endDate = null; - this.pushNotificationUnderEdit.delivery.type = this.SendEnum.NOW; + this.resetDelivery(); } }, updateAutomaticOptions: function() { if (this.userCommand === this.UserCommandEnum.DUPLICATE) { - this.pushNotificationUnderEdit.delivery.startDate = Date.now(); - this.pushNotificationUnderEdit.delivery.endDate = null; - this.pushNotificationUnderEdit.delivery.type = this.SendEnum.NOW; + this.resetDelivery(); this.pushNotificationUnderEdit.automatic.usersTimezone = null; } if (this.pushNotificationUnderEdit.automatic.usersTimezone) { @@ -1086,9 +1087,7 @@ }, updateTransactionalOptions: function() { if (this.userCommand === this.UserCommandEnum.DUPLICATE) { - this.pushNotificationUnderEdit.delivery.startDate = Date.now(); - this.pushNotificationUnderEdit.delivery.endDate = null; - this.pushNotificationUnderEdit.delivery.type = this.SendEnum.NOW; + this.resetDelivery(); } }, fetchPushNotificationById: function() { From b01f69986f774475f64f4f60a8c89ad78f8804ad Mon Sep 17 00:00:00 2001 From: Lumbardh Agaj Date: Tue, 22 Mar 2022 09:21:10 +0100 Subject: [PATCH 6/6] fix: Missing dash for empty geolocations --- .../frontend/public/templates/common-components.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/push/frontend/public/templates/common-components.html b/plugins/push/frontend/public/templates/common-components.html index 55767ef27ce..6268074926c 100644 --- a/plugins/push/frontend/public/templates/common-components.html +++ b/plugins/push/frontend/public/templates/common-components.html @@ -373,9 +373,12 @@
{{ category }}
-
- {{locationName}} -
+ +