Skip to content

Commit 46f30f7

Browse files
authored
Merge pull request #7163 from Countly/rating-widget
[SER-2472] [SER-2557] Rating widget fixes
2 parents 677e69d + 48ac8b4 commit 46f30f7

7 files changed

Lines changed: 67 additions & 52 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## Version 25.03.XX
22
Fixes:
33
- [compliance-hub] Correctly merge user history on user merge
4+
- [star-rating] Fix active status checkbox in drawer
5+
- [star-rating] Fix consent fields in drawer
46

57
## Version 25.03.32
68
Fixes:

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
});
@@ -125,32 +140,25 @@
125140
// drawer event handlers
126141
onConsentCheckbox: function(ev) {
127142
if (!ev.links || ev.links.length < 1) {
128-
ev.links = {
129-
"link": [
130-
{
131-
"text": "Terms and Conditions",
132-
"link": "https://termsandconditions.com",
133-
"textValue": "Terms and Conditions",
134-
"linkValue": "https://termsandconditions.com"
135-
},
136-
{
137-
"text": "Privacy Policy",
138-
"link": "https://privacyPolicy.com",
139-
"textValue": "Privacy Policy",
140-
"linkValue": "https://privacyPolicy.com"
141-
}
142-
],
143-
"finalText": "I agree to the Terms and Conditions and Privacy Policy.",
144-
};
143+
ev.links = defaultLinks;
144+
}
145+
146+
if (typeof ev.finalText !== "string" || !ev.finalText) {
147+
ev.finalText = "I agree to the Terms and Conditions and Privacy Policy.";
145148
}
146149
},
147-
finalTxt: function(links) {
148-
let finalText = links.finalText;
150+
finalTxt: function(links, inpFinalText) {
151+
var finalText = inpFinalText;
149152

150-
links.link.forEach(link => {
151-
const regex = new RegExp(`\\b${link.textValue}\\b`, 'g');
152-
finalText = finalText.replace(regex, `<a href="${link.linkValue}" target="_blank">${link.textValue}</a>`);
153-
});
153+
if (links && !Array.isArray(links) && typeof links.finalText === 'string') {
154+
finalText = links.finalText;
155+
}
156+
else if (Array.isArray(links) && typeof finalText === 'string') {
157+
links.forEach(link => {
158+
const regex = new RegExp(`\\b${link.textValue}\\b`, 'g');
159+
finalText = finalText.replace(regex, `<a href="${link.linkValue}" target="_blank">${link.textValue}</a>`);
160+
});
161+
}
154162

155163
return finalText;
156164
},
@@ -171,14 +179,19 @@
171179
onSubmit: function(submitted, done) {
172180
var self = this;
173181
if (submitted.links) {
174-
submitted.finalText = submitted.links.finalText;
175-
submitted.links = submitted.links.link;
176-
submitted.links.forEach(function(link) {
177-
var separator = link.linkValue.indexOf('?') !== -1 ? '&' : '?';
178-
link.linkValue = link.linkValue + separator + CLY_X_INT + '=1';
179-
delete link.text;
180-
delete link.link;
181-
});
182+
if (!submitted.finalText && !Array.isArray(submitted.links) && submitted.links.finalText && Array.isArray(submitted.links.link)) {
183+
submitted.finalText = submitted.links.finalText;
184+
submitted.links = submitted.links.link;
185+
}
186+
187+
if (Array.isArray(submitted.links)) {
188+
submitted.links.forEach(function(link) {
189+
var separator = link.linkValue.indexOf('?') !== -1 ? '&' : '?';
190+
link.linkValue = link.linkValue + separator + CLY_X_INT + '=1';
191+
delete link.text;
192+
delete link.link;
193+
});
194+
}
182195
}
183196
if (this.logoFile !== "") {
184197
submitted.logo = this.logoFile;
@@ -892,6 +905,8 @@
892905
}
893906
this.openDrawer("widget", {
894907
consent: false,
908+
finalText: "I agree to the Terms and Conditions and Privacy Policy.",
909+
links: defaultLinks,
895910
popup_header_text: 'What\'s your opinion about this page?',
896911
popup_thanks_message: 'Thanks for your feedback!',
897912
popup_button_callout: 'Submit Feedback',
@@ -1172,7 +1187,7 @@
11721187
}
11731188

11741189
}
1175-
starRatingPlugin.editFeedbackWidget({ _id: this.widget._id, status: (state), target_pages: target_pages, targeting: finalizedTargeting }, function() {
1190+
starRatingPlugin.editFeedbackWidget({ _id: this.widget._id, status: (state), target_pages: target_pages, targeting: finalizedTargeting, links: this.widget.links }, function() {
11761191
self.widget.is_active = (state ? "true" : "false");
11771192
self.widget.status = state;
11781193

@@ -1217,7 +1232,6 @@
12171232
}
12181233
link.linkValue = link.linkValue.replace(new RegExp('[?&]' + CLY_X_INT + '=[^&]*'), '').replace(/[?&]$/, '');
12191234
});
1220-
this.widget.links = {"link": this.widget.links, "finalText": this.widget.finalText};
12211235
}
12221236
else {
12231237
this.widget.links = {
@@ -1261,7 +1275,7 @@
12611275
if (!this.widget.trigger_size) {
12621276
this.widget.trigger_size = 'm';
12631277
}
1264-
if (!this.widget.status) {
1278+
if (typeof this.widget.status !== 'boolean') {
12651279
this.widget.status = true;
12661280
}
12671281
if (!this.widget.logo) {

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<input data-test-id="ratings-drawer-ratingspopup-consent-checkbox" type="checkbox"
5656
value="consent" checked
5757
>
58-
<span v-html="finalTxt(drawerScope.editedObject.links)" data-test-id="ratings-drawer-ratingspopup-consent-text"></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')}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{{i18n('rating.drawer.consent.links')}}
2323
<cly-tooltip-icon :tooltip="i18n('rating.drawer.links.tooltip')" icon="ion-help-circled" data-test-id="ratings-drawer-settings-add-user-consent-links-tooltip"></cly-tooltip-icon>
2424
</div>
25-
<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">
25+
<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">
2626
<div class="cly-vue-surveys-drawer__consent__basis-text">
2727
<validation-provider :name="item.text" rules="required" v-slot="v">
2828
<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
@@ -403,7 +403,7 @@ const verifyAppearancePageDefaultElements = () => {
403403
ratingSymbol: "Emojis",
404404
isLogoDefault: true,
405405
selectedMainIconColor: "#0166D6",
406-
selectedFontIconColor: "#0166D6",
406+
selectedFontIconColor: "#FFFFFF",
407407
isButtonSizeMedium: true,
408408
isPositionCenterLeft: true,
409409
triggerText: "Feedback",

0 commit comments

Comments
 (0)