Skip to content

Commit e4bdc83

Browse files
authored
Merge pull request #7166 from Countly/rating-widget-24
[SER-2472] [SER-2557] Rating widget fixes
2 parents 3cca0bd + 35d0d67 commit e4bdc83

File tree

7 files changed

+69
-54
lines changed

7 files changed

+69
-54
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
## Version 24.05.XX
22
Fixes:
3-
- [onboarding] Fix redirection to newsletter page
43
- [compliance-hub] Correctly merge user history on user merge
4+
- [onboarding] Fix redirection to newsletter page
5+
- [star-rating] Fix active status checkbox in drawer
6+
- [star-rating] Fix consent fields in drawer
57

68
Enterprise Fixes:
79
- [retention_segments] Adding null check for breakdown filtering

plugins/star-rating/api/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if (cohortsEnabled) {
2323
if (!surveysEnabled) {
2424
plugins.setConfigs("feedback", {
2525
main_color: "#0166D6",
26-
font_color: "#0166D6",
26+
font_color: "#FFFFFF",
2727
feedback_logo: ""
2828

2929
});

plugins/star-rating/frontend/public/javascripts/countly.views.js

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414
return str;
1515
}
1616

17+
var defaultLinks = [
18+
{
19+
"text": "Terms and Conditions",
20+
"link": "https://termsandconditions.com",
21+
"textValue": "Terms and Conditions",
22+
"linkValue": "https://termsandconditions.com"
23+
},
24+
{
25+
"text": "Privacy Policy",
26+
"link": "https://privacyPolicy.com",
27+
"textValue": "Privacy Policy",
28+
"linkValue": "https://privacyPolicy.com"
29+
}
30+
];
31+
1732
var consentLink = countlyVue.views.create({
1833
template: CV.T("/star-rating/templates/star-consent-link.html"),
1934
props: {
@@ -38,12 +53,12 @@
3853
this.$delete(this.links, index);
3954
},
4055
onDelete: function(id) {
41-
if (this.value.link.length > 1 && this.value.link.length <= this.maxLinks) {
42-
this.value.link.splice(id, 1);
56+
if (this.value.links.length > 1 && this.value.links.length <= this.maxLinks) {
57+
this.value.links.splice(id, 1);
4358
}
4459
},
4560
add: function() {
46-
this.value.link.push({
61+
this.value.links.push({
4762
"text": "Another Link",
4863
"link": "https://otherlink.com",
4964
"textValue": "Another Link",
@@ -53,7 +68,7 @@
5368
},
5469
computed: {
5570
newLinkAllowed: function() {
56-
return !this.readOnly && this.value.link.length < this.maxLinks;
71+
return !this.readOnly && this.value.links.length < this.maxLinks;
5772
}
5873
}
5974
});
@@ -117,32 +132,25 @@
117132
// drawer event handlers
118133
onConsentCheckbox: function(ev) {
119134
if (!ev.links || ev.links.length < 1) {
120-
ev.links = {
121-
"link": [
122-
{
123-
"text": "Terms and Conditions",
124-
"link": "https://termsandconditions.com",
125-
"textValue": "Terms and Conditions",
126-
"linkValue": "https://termsandconditions.com"
127-
},
128-
{
129-
"text": "Privacy Policy",
130-
"link": "https://privacyPolicy.com",
131-
"textValue": "Privacy Policy",
132-
"linkValue": "https://privacyPolicy.com"
133-
}
134-
],
135-
"finalText": "I agree to the Terms and Conditions and Privacy Policy.",
136-
};
135+
ev.links = defaultLinks;
136+
}
137+
138+
if (typeof ev.finalText !== "string" || !ev.finalText) {
139+
ev.finalText = "I agree to the Terms and Conditions and Privacy Policy.";
137140
}
138141
},
139-
finalTxt: function(links) {
140-
let finalText = links.finalText;
142+
finalTxt: function(links, inpFinalText) {
143+
var finalText = inpFinalText;
141144

142-
links.link.forEach(link => {
143-
const regex = new RegExp(`\\b${link.textValue}\\b`, 'g');
144-
finalText = finalText.replace(regex, `<a href="${link.linkValue}" target="_blank">${link.textValue}</a>`);
145-
});
145+
if (links && !Array.isArray(links) && typeof links.finalText === 'string') {
146+
finalText = links.finalText;
147+
}
148+
else if (Array.isArray(links) && typeof finalText === 'string') {
149+
links.forEach(link => {
150+
const regex = new RegExp(`\\b${link.textValue}\\b`, 'g');
151+
finalText = finalText.replace(regex, `<a href="${link.linkValue}" target="_blank">${link.textValue}</a>`);
152+
});
153+
}
146154

147155
return finalText;
148156
},
@@ -163,14 +171,19 @@
163171
onSubmit: function(submitted, done) {
164172
var self = this;
165173
if (submitted.links) {
166-
submitted.finalText = submitted.links.finalText;
167-
submitted.links = submitted.links.link;
168-
submitted.links.forEach(function(link) {
169-
var separator = link.linkValue.indexOf('?') !== -1 ? '&' : '?';
170-
link.linkValue = link.linkValue + separator + CLY_X_INT + '=1';
171-
delete link.text;
172-
delete link.link;
173-
});
174+
if (!submitted.finalText && !Array.isArray(submitted.links) && submitted.links.finalText && Array.isArray(submitted.links.link)) {
175+
submitted.finalText = submitted.links.finalText;
176+
submitted.links = submitted.links.link;
177+
}
178+
179+
if (Array.isArray(submitted.links)) {
180+
submitted.links.forEach(function(link) {
181+
var separator = link.linkValue.indexOf('?') !== -1 ? '&' : '?';
182+
link.linkValue = link.linkValue + separator + CLY_X_INT + '=1';
183+
delete link.text;
184+
delete link.link;
185+
});
186+
}
174187
}
175188
if (this.logoFile !== "") {
176189
submitted.logo = this.logoFile;
@@ -861,6 +874,8 @@
861874
}
862875
this.openDrawer("widget", {
863876
consent: false,
877+
finalText: "I agree to the Terms and Conditions and Privacy Policy.",
878+
links: defaultLinks,
864879
popup_header_text: 'What\'s your opinion about this page?',
865880
popup_thanks_message: 'Thanks for your feedback!',
866881
popup_button_callout: 'Submit Feedback',
@@ -1141,7 +1156,7 @@
11411156
}
11421157

11431158
}
1144-
starRatingPlugin.editFeedbackWidget({ _id: this.widget._id, status: (state), target_pages: target_pages, targeting: finalizedTargeting }, function() {
1159+
starRatingPlugin.editFeedbackWidget({ _id: this.widget._id, status: (state), target_pages: target_pages, targeting: finalizedTargeting, links: this.widget.links }, function() {
11451160
self.widget.is_active = (state ? "true" : "false");
11461161
self.widget.status = state;
11471162

@@ -1186,7 +1201,6 @@
11861201
}
11871202
link.linkValue = link.linkValue.replace(new RegExp('[?&]' + CLY_X_INT + '=[^&]*'), '').replace(/[?&]$/, '');
11881203
});
1189-
this.widget.links = {"link": this.widget.links, "finalText": this.widget.finalText};
11901204
}
11911205
else {
11921206
this.widget.links = {
@@ -1230,7 +1244,7 @@
12301244
if (!this.widget.trigger_size) {
12311245
this.widget.trigger_size = 'm';
12321246
}
1233-
if (!this.widget.status) {
1247+
if (typeof this.widget.status !== 'boolean') {
12341248
this.widget.status = true;
12351249
}
12361250
if (!this.widget.logo) {

plugins/star-rating/frontend/public/templates/drawer.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<input type="checkbox"
5656
value="consent" checked
5757
>
58-
<span v-html="finalTxt(drawerScope.editedObject.links)"></span>
58+
<span v-html="finalTxt(drawerScope.editedObject.links, drawerScope.editedObject.finalText)" data-test-id="ratings-drawer-ratingspopup-consent-text"></span>
5959
</label>
6060
</div>
6161
<div class="ratings-drawer__rp-action-area">
@@ -190,12 +190,11 @@
190190
</el-checkbox>
191191
</div>
192192
<star-consent-link
193-
v-if="drawerScope.editedObject.consent"
194-
ref="links"
195-
:max-links="3"
196-
:read-only="!!drawerScope.editedObject._id"
197-
v-model="drawerScope.editedObject.links">
198-
</star-consent-link>
193+
v-if="drawerScope.editedObject.consent"
194+
ref="links"
195+
:max-links="3"
196+
v-model="drawerScope.editedObject">
197+
</star-consent-link>
199198
<div class="cly-vue-drawer-step__section">
200199
<div class="text-medium-big bu-has-text-weight-medium bu-pb-2 bu-pt-4">
201200
{{i18n('feedback.buttons.heading')}}
@@ -412,4 +411,4 @@ <h3 class="dropzone-custom-title">
412411
</cly-form-step>
413412
</template>
414413
</cly-drawer>
415-
</div>
414+
</div>

plugins/star-rating/frontend/public/templates/star-consent-link.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
{{i18n('rating.drawer.consent.links')}}
2222
<cly-tooltip-icon :tooltip="i18n('rating.drawer.links.tooltip')" icon="ion-help-circled"></cly-tooltip-icon>
2323
</div>
24-
<div style="gap:8px" class="bu-is-flex bu-is-justify-content-space-between bu-is-align-items-center bu-py-1" :key="idx" v-for="(item, idx) in value.link">
24+
<div style="gap:8px" class="bu-is-flex bu-is-justify-content-space-between bu-is-align-items-center bu-py-1" :key="idx" v-for="(item, idx) in value.links">
2525
<div class="cly-vue-surveys-drawer__consent__basis-text">
2626
<validation-provider :name="item.text" rules="required" v-slot="v">
2727
<el-input

ui-tests/cypress/e2e/dashboard/feedback/ratings/widgets.cy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('Create New Widget', () => {
3636
contactViaCheckboxLabelText: "Contact me via e-mail",
3737
submitButtonText: "Submit Feedback",
3838
submitButtonColor: "#0166D6",
39-
submitButtonFontColor: "#0166D6",
39+
submitButtonFontColor: "#FFFFFF",
4040
hasPoweredByLogo: true
4141
});
4242

@@ -49,7 +49,7 @@ describe('Create New Widget', () => {
4949
widgetsHelpers.verifyPreviewTriggerButtonPopUpElements({
5050
triggerButtonText: "Feedback",
5151
triggerButtonColor: "#0166D6",
52-
triggerButtonFontColor: "#0166D6"
52+
triggerButtonFontColor: "#FFFFFF"
5353
});
5454

5555
widgetsHelpers.clickNextStepButton();
@@ -68,7 +68,7 @@ describe('Create New Widget', () => {
6868
contactViaCheckboxLabelText: "Contact me via e-mail",
6969
submitButtonText: "Submit Feedback",
7070
submitButtonColor: "#0166D6",
71-
submitButtonFontColor: "#0166D6",
71+
submitButtonFontColor: "#FFFFFF",
7272
hasPoweredByLogo: true
7373
});
7474

@@ -97,7 +97,7 @@ describe('Create New Widget', () => {
9797
selectedEmojiItemIndex: 5,
9898
submitButtonText: "Submit Feedback",
9999
selectedMainColor: '#0166D6',
100-
selectedFontColor: '#0166D6',
100+
selectedFontColor: '#FFFFFF',
101101
hasPoweredByLogo: true,
102102
thankYouMessageText: 'Thanks for your feedback!',
103103
successIconColor: '#0166D6'

ui-tests/cypress/lib/dashboard/feedback/ratings/widgets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ const verifyAppearancePageDefaultElements = () => {
329329
ratingSymbol: "Emojis",
330330
isLogoDefault: true,
331331
selectedMainIconColor: "#0166D6",
332-
selectedFontIconColor: "#0166D6",
332+
selectedFontIconColor: "#FFFFFF",
333333
isButtonSizeMedium: true,
334334
isPositionCenterLeft: true,
335335
triggerText: "Feedback",

0 commit comments

Comments
 (0)