From 12c8d69d11295f40db107735303df4ebe58bfc08 Mon Sep 17 00:00:00 2001 From: Danu Widatama Date: Fri, 18 Oct 2024 17:45:59 +0700 Subject: [PATCH] [star-rating] Fix consent field --- .../public/javascripts/countly.views.js | 92 ++++++------------- .../public/templates/widget-detail.html | 4 +- 2 files changed, 31 insertions(+), 65 deletions(-) diff --git a/plugins/star-rating/frontend/public/javascripts/countly.views.js b/plugins/star-rating/frontend/public/javascripts/countly.views.js index f5423f2763f..f8cc504087d 100644 --- a/plugins/star-rating/frontend/public/javascripts/countly.views.js +++ b/plugins/star-rating/frontend/public/javascripts/countly.views.js @@ -116,24 +116,25 @@ methods: { // drawer event handlers onConsentCheckbox: function(ev) { - ev.links = { - "link": [ - { - "text": "Terms and Conditions", - "link": "https://termsandconditions.com", - "textValue": "Terms and Conditions", - "linkValue": "https://termsandconditions.com" - }, - { - "text": "Privacy Policy", - "link": "https://privacyPolicy.com", - "textValue": "Privacy Policy", - "linkValue": "https://privacyPolicy.com" - } - ], - "finalText": "I agree to the Terms and Conditions and Privacy Policy." - - }; + if (!ev.links || ev.links.length < 1) { + ev.links = { + "link": [ + { + "text": "Terms and Conditions", + "link": "https://termsandconditions.com", + "textValue": "Terms and Conditions", + "linkValue": "https://termsandconditions.com" + }, + { + "text": "Privacy Policy", + "link": "https://privacyPolicy.com", + "textValue": "Privacy Policy", + "linkValue": "https://privacyPolicy.com" + } + ], + "finalText": "I agree to the Terms and Conditions and Privacy Policy.", + }; + } }, finalTxt: function(links) { let finalText = links.finalText; @@ -222,31 +223,7 @@ onOpen: function() { var self = this; var loadImage = new Image(); - if (this.controls.initialEditedObject.consent === true || this.controls.initialEditedObject.consent === "true") { - this.controls.initialEditedObject.consent = true; - this.consent = true; - } - else { - this.controls.initialEditedObject.consent = false; - } - if (Array.isArray(this.controls.initialEditedObject.links)) { - this.controls.initialEditedObject.links.forEach(function(link) { - if (link.linkValue.indexOf('term')) { - link.text = "Terms and Conditions"; - link.link = "https://termsandconditions.com"; - } - else if (link.linkValue.indexOf('privacy')) { - link.text = "Privacy Policy"; - link.link = "https://privacyPolicy.com"; - } - else { - link.text = "Another Link"; - link.link = "https://otherlink.com"; - } - link.linkValue = link.linkValue.replace(new RegExp('[?&]' + CLY_X_INT + '=[^&]*'), '').replace(/[?&]$/, ''); - }); - this.controls.initialEditedObject.links = {"link": this.controls.initialEditedObject.links, "finalText": this.controls.initialEditedObject.finalText}; - } + if (this.controls.initialEditedObject.logo) { if (this.controls.initialEditedObject.logo.indexOf("feedback_logo") > -1 @@ -806,24 +783,6 @@ } } this.openDrawer("widget", { - links: { - "link": [ - { - "text": "Terms and Conditions", - "link": "https://termsandconditions.com", - "textValue": "Terms and Conditions", - "linkValue": "https://termsandconditions.com" - }, - { - "text": "Privacy Policy", - "link": "https://privacyPolicy.com", - "textValue": "Privacy Policy", - "linkValue": "https://privacyPolicy.com" - } - ], - "finalText": "I agree to the Terms and Conditions and Privacy Policy." - - }, consent: false, popup_header_text: 'What\'s your opinion about this page?', popup_thanks_message: 'Thanks for your feedback!', @@ -1145,6 +1104,14 @@ steps: null }; } + + if (this.widget.consent === true || this.widget.consent === "true") { + this.widget.consent = true; + } + else { + this.widget.consent = false; + } + if (Array.isArray(this.widget.links) && this.widget.links.length) { this.widget.links.forEach(function(link) { if (link.linkValue.indexOf('term')) { @@ -1162,7 +1129,6 @@ link.linkValue = link.linkValue.replace(new RegExp('[?&]' + CLY_X_INT + '=[^&]*'), '').replace(/[?&]$/, ''); }); this.widget.links = {"link": this.widget.links, "finalText": this.widget.finalText}; - this.widget.consent = true; } else { this.widget.links = { @@ -1183,8 +1149,8 @@ "finalText": "I agree to the Terms and Conditions and Privacy Policy." }; - this.widget.consent = false; } + if (!this.widget.rating_symbol) { this.widget.rating_symbol = "emojis"; } diff --git a/plugins/star-rating/frontend/public/templates/widget-detail.html b/plugins/star-rating/frontend/public/templates/widget-detail.html index 7752fb12685..8ba25e7ade1 100644 --- a/plugins/star-rating/frontend/public/templates/widget-detail.html +++ b/plugins/star-rating/frontend/public/templates/widget-detail.html @@ -82,5 +82,5 @@

- \ No newline at end of file + +