@everymatrix/user-action-controller 1.27.10 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{player-legislation-wrapper_3.cjs.entry.js → player-user-consents_2.cjs.entry.js} +112 -70
- package/dist/cjs/user-action-controller.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +0 -6
- package/dist/collection/components/user-action-controller/user-action-controller.js +89 -60
- package/dist/collection/utils/locale.utils.js +60 -0
- package/dist/components/user-action-controller.js +120 -48
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{player-legislation-wrapper_3.entry.js → player-user-consents_2.entry.js} +114 -71
- package/dist/esm/user-action-controller.js +1 -1
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/user-action-controller/.stencil/packages/user-action-controller/stencil.config.d.ts +2 -0
- package/dist/types/components/user-action-controller/user-action-controller.d.ts +13 -10
- package/dist/types/components.d.ts +16 -8
- package/dist/types/utils/locale.utils.d.ts +2 -0
- package/dist/user-action-controller/p-711fa494.entry.js +1 -0
- package/dist/user-action-controller/user-action-controller.esm.js +1 -1
- package/package.json +1 -1
- package/dist/components/player-legislation-wrapper.js +0 -6
- package/dist/components/player-legislation-wrapper2.js +0 -54
- package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/emfe-widgets/widgets-stencil/packages/user-action-controller/.stencil/packages/user-action-controller/stencil.config.d.ts +0 -2
- package/dist/user-action-controller/p-073a0fe2.entry.js +0 -1
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["player-
|
|
17
|
+
return index.bootstrapLazy([["player-user-consents_2.cjs",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"lang":[1537],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"gmVersion":[1,"gm-version"],"translationUrl":[513,"translation-url"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"activeUserActions":[32],"userActionsValidated":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32],"isLoading":[32],"mandatoryActionsChecked":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
package/dist/cjs/{player-legislation-wrapper_3.cjs.entry.js → player-user-consents_2.cjs.entry.js}
RENAMED
|
@@ -4,38 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-87049e21.js');
|
|
6
6
|
|
|
7
|
-
const playerLegislationWrapperCss = ":host{display:block}";
|
|
8
|
-
|
|
9
|
-
const PlayerLegislationWrapper = class {
|
|
10
|
-
constructor(hostRef) {
|
|
11
|
-
index.registerInstance(this, hostRef);
|
|
12
|
-
/**
|
|
13
|
-
* Client custom styling via inline style
|
|
14
|
-
*/
|
|
15
|
-
this.clientStyling = '';
|
|
16
|
-
this.limitStylingAppends = false;
|
|
17
|
-
this.setClientStyling = () => {
|
|
18
|
-
let sheet = document.createElement('style');
|
|
19
|
-
sheet.innerHTML = this.clientStyling;
|
|
20
|
-
this.stylingContainer.prepend(sheet);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
componentDidRender() {
|
|
24
|
-
// start custom styling area
|
|
25
|
-
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
26
|
-
if (this.clientStyling)
|
|
27
|
-
this.setClientStyling();
|
|
28
|
-
this.limitStylingAppends = true;
|
|
29
|
-
}
|
|
30
|
-
// end custom styling area
|
|
31
|
-
}
|
|
32
|
-
render() {
|
|
33
|
-
const activeUAList = this.activeUserActions.replace(/ /g, '').split(',');
|
|
34
|
-
return (index.h("div", { class: "PlayerLegislationWrapper", ref: el => this.stylingContainer = el }, activeUAList.map(action => (index.h("slot", { name: action })))));
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
PlayerLegislationWrapper.style = playerLegislationWrapperCss;
|
|
38
|
-
|
|
39
7
|
const playerUserConsentsCss = ":host{display:block}.ConsentTitle{margin-bottom:0.2rem;font-weight:600}.userConsent:hover{border-bottom:1px solid #000;cursor:pointer}.MandatoryItem{color:#f00;font-size:1.2rem}";
|
|
40
8
|
|
|
41
9
|
const PlayerUserConsents = class {
|
|
@@ -122,19 +90,84 @@ const PlayerUserConsents = class {
|
|
|
122
90
|
};
|
|
123
91
|
PlayerUserConsents.style = playerUserConsentsCss;
|
|
124
92
|
|
|
93
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
94
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en', 'cz', 'de', 'hr'];
|
|
95
|
+
const TRANSLATIONS = {
|
|
96
|
+
en: {
|
|
97
|
+
termsandconditions: 'Terms and Conditions',
|
|
98
|
+
sms: 'SMS marketing',
|
|
99
|
+
emailmarketing: 'Email marketing'
|
|
100
|
+
},
|
|
101
|
+
ro: {
|
|
102
|
+
termsandconditions: 'Terms and Conditions',
|
|
103
|
+
sms: 'SMS marketing',
|
|
104
|
+
emailmarketing: 'Email marketing'
|
|
105
|
+
},
|
|
106
|
+
hr: {
|
|
107
|
+
termsandconditions: 'Terms and Conditions',
|
|
108
|
+
sms: 'SMS marketing',
|
|
109
|
+
emailmarketing: 'Email marketing'
|
|
110
|
+
},
|
|
111
|
+
fr: {
|
|
112
|
+
termsandconditions: 'Terms and Conditions',
|
|
113
|
+
sms: 'SMS marketing',
|
|
114
|
+
emailmarketing: 'Email marketing'
|
|
115
|
+
},
|
|
116
|
+
cs: {
|
|
117
|
+
termsandconditions: 'Terms and Conditions',
|
|
118
|
+
sms: 'SMS marketing',
|
|
119
|
+
emailmarketing: 'Email marketing'
|
|
120
|
+
},
|
|
121
|
+
de: {
|
|
122
|
+
termsandconditions: 'Terms and Conditions',
|
|
123
|
+
sms: 'SMS marketing',
|
|
124
|
+
emailmarketing: 'Email marketing'
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
const getTranslations = (url) => {
|
|
128
|
+
// fetch url, get the data, replace the TRANSLATIONS content
|
|
129
|
+
return new Promise((resolve) => {
|
|
130
|
+
fetch(url)
|
|
131
|
+
.then((res) => res.json())
|
|
132
|
+
.then((data) => {
|
|
133
|
+
Object.keys(data).forEach((item) => {
|
|
134
|
+
for (let key in data[item]) {
|
|
135
|
+
TRANSLATIONS[item][key] = data[item][key];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
resolve(true);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
const translate = (key, customLang, values) => {
|
|
143
|
+
const lang = customLang;
|
|
144
|
+
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
145
|
+
if (values !== undefined) {
|
|
146
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
147
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
148
|
+
translation = translation.replace(regex, value);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return translation;
|
|
152
|
+
};
|
|
153
|
+
|
|
125
154
|
const userActionControllerCss = ":host{display:block}.QueryReferenceContainer{height:100%;width:100%}.UserConsentNotice{font-size:1.2rem;font-weight:200;text-align:center}.CloseButton{width:25px;height:25px;align-self:flex-end}.UserActionController{font-family:Arial, Helvetica, sans-serif;font-weight:100;height:100%;width:100%;padding:1rem 1.5rem 2rem;background-color:#fff;display:flex;flex-direction:column;justify-content:space-between;border-radius:5%}.ConsentSubmitButton{font-size:1rem;padding:0.4rem 1.4rem;background:#fff;border:2px solid #000;color:#000;border-radius:5px;align-self:flex-end}.ConsentSubmitButton:disabled{border:2px solid #ccc;color:#ccc}@media screen and (max-width: 320px){.QueryReferenceContainer{font-size:0.8rem;color:blue}}.spinner{animation:rotate 2s linear infinite;z-index:2;position:absolute;top:50%;left:50%;margin:-25px 0 0 -25px;width:50px;height:50px}.spinner .path{stroke:var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C));stroke-linecap:round;animation:dash 1.5s ease-in-out infinite}@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1, 150;stroke-dashoffset:0}50%{stroke-dasharray:90, 150;stroke-dashoffset:-35}100%{stroke-dasharray:90, 150;stroke-dashoffset:-124}}";
|
|
126
155
|
|
|
127
156
|
const UserActionController = class {
|
|
128
157
|
constructor(hostRef) {
|
|
129
158
|
index.registerInstance(this, hostRef);
|
|
130
159
|
/**
|
|
131
|
-
*
|
|
160
|
+
* Language
|
|
132
161
|
*/
|
|
133
|
-
this.
|
|
162
|
+
this.lang = 'en';
|
|
134
163
|
/**
|
|
135
164
|
* Select GM version
|
|
136
165
|
*/
|
|
137
166
|
this.gmVersion = '';
|
|
167
|
+
/**
|
|
168
|
+
* Translation url
|
|
169
|
+
*/
|
|
170
|
+
this.translationUrl = '';
|
|
138
171
|
/**
|
|
139
172
|
* Client custom styling via inline style
|
|
140
173
|
*/
|
|
@@ -148,17 +181,19 @@ const UserActionController = class {
|
|
|
148
181
|
*/
|
|
149
182
|
this.queryFired = false;
|
|
150
183
|
this.readyActionsCount = 0;
|
|
184
|
+
this.activeUserActions = [];
|
|
185
|
+
this.userActionsValidated = true;
|
|
151
186
|
this.receivedQueryResponses = 0;
|
|
152
187
|
this.limitStylingAppends = false;
|
|
153
188
|
this.isLoading = true;
|
|
189
|
+
this.mandatoryActionsChecked = 0;
|
|
190
|
+
//for now this variable is hardcoded bcs we have only terms and conditions mandatory and we dont receive with these new functionality the mandatory actions
|
|
154
191
|
this.mandatoryActions = ['termsandconditions'];
|
|
155
|
-
this.requiredActionsCount = 0;
|
|
156
|
-
this.expectedQueryResponses = 0;
|
|
157
192
|
this.userActions = [];
|
|
158
193
|
this.consentTitles = {
|
|
159
|
-
termsandconditions:
|
|
160
|
-
sms:
|
|
161
|
-
emailmarketing:
|
|
194
|
+
termsandconditions: translate('termsandconditions', this.lang),
|
|
195
|
+
sms: translate('sms', this.lang),
|
|
196
|
+
emailmarketing: translate('emailmarketing', this.lang)
|
|
162
197
|
};
|
|
163
198
|
this.setClientStyling = () => {
|
|
164
199
|
let sheet = document.createElement('style');
|
|
@@ -180,44 +215,45 @@ const UserActionController = class {
|
|
|
180
215
|
});
|
|
181
216
|
};
|
|
182
217
|
}
|
|
218
|
+
handleNewTranslations() {
|
|
219
|
+
getTranslations(this.translationUrl);
|
|
220
|
+
}
|
|
183
221
|
handleQueryResponse() {
|
|
184
|
-
if (this.receivedQueryResponses === this.
|
|
222
|
+
if (this.receivedQueryResponses === this.activeUserActions.length) {
|
|
185
223
|
this.updateUserConsents();
|
|
186
224
|
}
|
|
187
225
|
}
|
|
188
|
-
hasToSetConsentsHandler(_) {
|
|
189
|
-
this.hasToSetConsents = true;
|
|
190
|
-
}
|
|
191
226
|
userLegislationConsentHandler(event) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
else
|
|
197
|
-
this.readyActionsCount--;
|
|
227
|
+
const actionType = event.detail.type;
|
|
228
|
+
const actionTypeChecked = event.detail.value;
|
|
229
|
+
if (this.mandatoryActions.includes(actionType) && this.queryFired === false) {
|
|
230
|
+
actionTypeChecked === true ? this.mandatoryActionsChecked++ : this.mandatoryActionsChecked--;
|
|
198
231
|
}
|
|
199
232
|
// Register final user choices only if we're ready to update
|
|
200
233
|
if (this.queryFired) {
|
|
201
|
-
this.userActions.push({ tagCode:
|
|
234
|
+
this.userActions.push({ tagCode: actionType, status: actionTypeChecked ? 'Accepted' : 'Denied' });
|
|
202
235
|
this.receivedQueryResponses++;
|
|
203
236
|
}
|
|
204
237
|
}
|
|
205
|
-
|
|
206
|
-
const url = new URL(`${this.endpoint}/v1/player/
|
|
238
|
+
determineUserActions() {
|
|
239
|
+
const url = new URL(`${this.endpoint}/v1/player/${this.userId}/consent`);
|
|
240
|
+
const headers = new Headers();
|
|
241
|
+
headers.append('X-SessionId', this.userSession);
|
|
207
242
|
let requestOptions;
|
|
208
243
|
requestOptions = {
|
|
209
244
|
method: 'GET',
|
|
210
|
-
headers
|
|
211
|
-
'X-SessionId': `${this.userSession}`,
|
|
212
|
-
},
|
|
245
|
+
headers
|
|
213
246
|
};
|
|
214
247
|
if (url && requestOptions) {
|
|
215
248
|
return fetch(url.href, requestOptions)
|
|
216
249
|
.then(res => res.json())
|
|
217
250
|
.then(data => {
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
251
|
+
const actionItems = data.items;
|
|
252
|
+
actionItems.forEach(element => {
|
|
253
|
+
if (element.status === 'Expired') {
|
|
254
|
+
this.activeUserActions.push(element.tagCode);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
221
257
|
this.isLoading = false;
|
|
222
258
|
})
|
|
223
259
|
.catch(error => {
|
|
@@ -287,14 +323,17 @@ const UserActionController = class {
|
|
|
287
323
|
handleApplyClick() {
|
|
288
324
|
this.queryFired = true;
|
|
289
325
|
}
|
|
290
|
-
componentWillLoad() {
|
|
326
|
+
async componentWillLoad() {
|
|
291
327
|
if (this.gmVersion === 'gmcore') {
|
|
292
|
-
return this.
|
|
328
|
+
return this.determineUserActions();
|
|
293
329
|
}
|
|
294
330
|
else {
|
|
295
|
-
this.activeUserActions = 'termsandconditions';
|
|
331
|
+
this.activeUserActions = ['termsandconditions'];
|
|
296
332
|
this.isLoading = false;
|
|
297
333
|
}
|
|
334
|
+
if (this.translationUrl.length > 2) {
|
|
335
|
+
await getTranslations(this.translationUrl);
|
|
336
|
+
}
|
|
298
337
|
}
|
|
299
338
|
componentDidRender() {
|
|
300
339
|
// start custom styling area
|
|
@@ -308,21 +347,24 @@ const UserActionController = class {
|
|
|
308
347
|
// end custom styling area
|
|
309
348
|
}
|
|
310
349
|
render() {
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
350
|
+
const isMandatoryPresent = this.mandatoryActions.every(action => this.activeUserActions.includes(action));
|
|
351
|
+
if (isMandatoryPresent) {
|
|
352
|
+
this.userActionsValidated = !(this.mandatoryActionsChecked === this.mandatoryActions.length);
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
this.userActionsValidated = false;
|
|
356
|
+
}
|
|
357
|
+
return (index.h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (index.h("slot", { name: 'spinner' })
|
|
358
|
+
&&
|
|
359
|
+
index.h("svg", { class: "spinner", viewBox: "0 0 50 50" }, index.h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (index.h("div", { class: "UserActionController" }, index.h("h2", { class: "UserConsentNotice" }, this.userNoticeText), index.h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (index.h("slot", { name: action }, index.h("player-user-consents", { slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
|
|
360
|
+
index.h("button", { class: "ConsentSubmitButton", disabled: this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
|
|
319
361
|
}
|
|
320
362
|
static get watchers() { return {
|
|
363
|
+
"translationUrl": ["handleNewTranslations"],
|
|
321
364
|
"receivedQueryResponses": ["handleQueryResponse"]
|
|
322
365
|
}; }
|
|
323
366
|
};
|
|
324
367
|
UserActionController.style = userActionControllerCss;
|
|
325
368
|
|
|
326
|
-
exports.player_legislation_wrapper = PlayerLegislationWrapper;
|
|
327
369
|
exports.player_user_consents = PlayerUserConsents;
|
|
328
370
|
exports.user_action_controller = UserActionController;
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["player-
|
|
18
|
+
return index.bootstrapLazy([["player-user-consents_2.cjs",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"lang":[1537],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"gmVersion":[1,"gm-version"],"translationUrl":[513,"translation-url"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"activeUserActions":[32],"userActionsValidated":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32],"isLoading":[32],"mandatoryActionsChecked":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { Component, h, Prop, Listen, State, Watch } from '@stencil/core';
|
|
2
|
-
import '
|
|
2
|
+
import { getTranslations, translate } from '../../utils/locale.utils';
|
|
3
3
|
import '@everymatrix/player-user-consents';
|
|
4
4
|
export class UserActionController {
|
|
5
5
|
constructor() {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Language
|
|
8
8
|
*/
|
|
9
|
-
this.
|
|
9
|
+
this.lang = 'en';
|
|
10
10
|
/**
|
|
11
11
|
* Select GM version
|
|
12
12
|
*/
|
|
13
13
|
this.gmVersion = '';
|
|
14
|
+
/**
|
|
15
|
+
* Translation url
|
|
16
|
+
*/
|
|
17
|
+
this.translationUrl = '';
|
|
14
18
|
/**
|
|
15
19
|
* Client custom styling via inline style
|
|
16
20
|
*/
|
|
@@ -24,17 +28,19 @@ export class UserActionController {
|
|
|
24
28
|
*/
|
|
25
29
|
this.queryFired = false;
|
|
26
30
|
this.readyActionsCount = 0;
|
|
31
|
+
this.activeUserActions = [];
|
|
32
|
+
this.userActionsValidated = true;
|
|
27
33
|
this.receivedQueryResponses = 0;
|
|
28
34
|
this.limitStylingAppends = false;
|
|
29
35
|
this.isLoading = true;
|
|
36
|
+
this.mandatoryActionsChecked = 0;
|
|
37
|
+
//for now this variable is hardcoded bcs we have only terms and conditions mandatory and we dont receive with these new functionality the mandatory actions
|
|
30
38
|
this.mandatoryActions = ['termsandconditions'];
|
|
31
|
-
this.requiredActionsCount = 0;
|
|
32
|
-
this.expectedQueryResponses = 0;
|
|
33
39
|
this.userActions = [];
|
|
34
40
|
this.consentTitles = {
|
|
35
|
-
termsandconditions:
|
|
36
|
-
sms:
|
|
37
|
-
emailmarketing:
|
|
41
|
+
termsandconditions: translate('termsandconditions', this.lang),
|
|
42
|
+
sms: translate('sms', this.lang),
|
|
43
|
+
emailmarketing: translate('emailmarketing', this.lang)
|
|
38
44
|
};
|
|
39
45
|
this.setClientStyling = () => {
|
|
40
46
|
let sheet = document.createElement('style');
|
|
@@ -56,44 +62,45 @@ export class UserActionController {
|
|
|
56
62
|
});
|
|
57
63
|
};
|
|
58
64
|
}
|
|
65
|
+
handleNewTranslations() {
|
|
66
|
+
getTranslations(this.translationUrl);
|
|
67
|
+
}
|
|
59
68
|
handleQueryResponse() {
|
|
60
|
-
if (this.receivedQueryResponses === this.
|
|
69
|
+
if (this.receivedQueryResponses === this.activeUserActions.length) {
|
|
61
70
|
this.updateUserConsents();
|
|
62
71
|
}
|
|
63
72
|
}
|
|
64
|
-
hasToSetConsentsHandler(_) {
|
|
65
|
-
this.hasToSetConsents = true;
|
|
66
|
-
}
|
|
67
73
|
userLegislationConsentHandler(event) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
else
|
|
73
|
-
this.readyActionsCount--;
|
|
74
|
+
const actionType = event.detail.type;
|
|
75
|
+
const actionTypeChecked = event.detail.value;
|
|
76
|
+
if (this.mandatoryActions.includes(actionType) && this.queryFired === false) {
|
|
77
|
+
actionTypeChecked === true ? this.mandatoryActionsChecked++ : this.mandatoryActionsChecked--;
|
|
74
78
|
}
|
|
75
79
|
// Register final user choices only if we're ready to update
|
|
76
80
|
if (this.queryFired) {
|
|
77
|
-
this.userActions.push({ tagCode:
|
|
81
|
+
this.userActions.push({ tagCode: actionType, status: actionTypeChecked ? 'Accepted' : 'Denied' });
|
|
78
82
|
this.receivedQueryResponses++;
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
|
-
|
|
82
|
-
const url = new URL(`${this.endpoint}/v1/player/
|
|
85
|
+
determineUserActions() {
|
|
86
|
+
const url = new URL(`${this.endpoint}/v1/player/${this.userId}/consent`);
|
|
87
|
+
const headers = new Headers();
|
|
88
|
+
headers.append('X-SessionId', this.userSession);
|
|
83
89
|
let requestOptions;
|
|
84
90
|
requestOptions = {
|
|
85
91
|
method: 'GET',
|
|
86
|
-
headers
|
|
87
|
-
'X-SessionId': `${this.userSession}`,
|
|
88
|
-
},
|
|
92
|
+
headers
|
|
89
93
|
};
|
|
90
94
|
if (url && requestOptions) {
|
|
91
95
|
return fetch(url.href, requestOptions)
|
|
92
96
|
.then(res => res.json())
|
|
93
97
|
.then(data => {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
const actionItems = data.items;
|
|
99
|
+
actionItems.forEach(element => {
|
|
100
|
+
if (element.status === 'Expired') {
|
|
101
|
+
this.activeUserActions.push(element.tagCode);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
97
104
|
this.isLoading = false;
|
|
98
105
|
})
|
|
99
106
|
.catch(error => {
|
|
@@ -163,14 +170,17 @@ export class UserActionController {
|
|
|
163
170
|
handleApplyClick() {
|
|
164
171
|
this.queryFired = true;
|
|
165
172
|
}
|
|
166
|
-
componentWillLoad() {
|
|
173
|
+
async componentWillLoad() {
|
|
167
174
|
if (this.gmVersion === 'gmcore') {
|
|
168
|
-
return this.
|
|
175
|
+
return this.determineUserActions();
|
|
169
176
|
}
|
|
170
177
|
else {
|
|
171
|
-
this.activeUserActions = 'termsandconditions';
|
|
178
|
+
this.activeUserActions = ['termsandconditions'];
|
|
172
179
|
this.isLoading = false;
|
|
173
180
|
}
|
|
181
|
+
if (this.translationUrl.length > 2) {
|
|
182
|
+
await getTranslations(this.translationUrl);
|
|
183
|
+
}
|
|
174
184
|
}
|
|
175
185
|
componentDidRender() {
|
|
176
186
|
// start custom styling area
|
|
@@ -184,20 +194,22 @@ export class UserActionController {
|
|
|
184
194
|
// end custom styling area
|
|
185
195
|
}
|
|
186
196
|
render() {
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
h("
|
|
197
|
-
h("
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
const isMandatoryPresent = this.mandatoryActions.every(action => this.activeUserActions.includes(action));
|
|
198
|
+
if (isMandatoryPresent) {
|
|
199
|
+
this.userActionsValidated = !(this.mandatoryActionsChecked === this.mandatoryActions.length);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
this.userActionsValidated = false;
|
|
203
|
+
}
|
|
204
|
+
return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (h("slot", { name: 'spinner' })
|
|
205
|
+
&&
|
|
206
|
+
h("svg", { class: "spinner", viewBox: "0 0 50 50" },
|
|
207
|
+
h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (h("div", { class: "UserActionController" },
|
|
208
|
+
h("h2", { class: "UserConsentNotice" }, this.userNoticeText),
|
|
209
|
+
h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action },
|
|
210
|
+
h("player-user-consents", { slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))),
|
|
211
|
+
this.includeSubmitButton &&
|
|
212
|
+
h("button", { class: "ConsentSubmitButton", disabled: this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
|
|
201
213
|
}
|
|
202
214
|
static get is() { return "user-action-controller"; }
|
|
203
215
|
static get encapsulation() { return "shadow"; }
|
|
@@ -259,6 +271,24 @@ export class UserActionController {
|
|
|
259
271
|
"attribute": "user-id",
|
|
260
272
|
"reflect": true
|
|
261
273
|
},
|
|
274
|
+
"lang": {
|
|
275
|
+
"type": "string",
|
|
276
|
+
"mutable": true,
|
|
277
|
+
"complexType": {
|
|
278
|
+
"original": "string",
|
|
279
|
+
"resolved": "string",
|
|
280
|
+
"references": {}
|
|
281
|
+
},
|
|
282
|
+
"required": false,
|
|
283
|
+
"optional": false,
|
|
284
|
+
"docs": {
|
|
285
|
+
"tags": [],
|
|
286
|
+
"text": "Language"
|
|
287
|
+
},
|
|
288
|
+
"attribute": "lang",
|
|
289
|
+
"reflect": true,
|
|
290
|
+
"defaultValue": "'en'"
|
|
291
|
+
},
|
|
262
292
|
"includeSubmitButton": {
|
|
263
293
|
"type": "boolean",
|
|
264
294
|
"mutable": false,
|
|
@@ -310,7 +340,7 @@ export class UserActionController {
|
|
|
310
340
|
"attribute": "user-notice-text",
|
|
311
341
|
"reflect": true
|
|
312
342
|
},
|
|
313
|
-
"
|
|
343
|
+
"gmVersion": {
|
|
314
344
|
"type": "string",
|
|
315
345
|
"mutable": false,
|
|
316
346
|
"complexType": {
|
|
@@ -322,13 +352,13 @@ export class UserActionController {
|
|
|
322
352
|
"optional": false,
|
|
323
353
|
"docs": {
|
|
324
354
|
"tags": [],
|
|
325
|
-
"text": "
|
|
355
|
+
"text": "Select GM version"
|
|
326
356
|
},
|
|
327
|
-
"attribute": "
|
|
328
|
-
"reflect":
|
|
357
|
+
"attribute": "gm-version",
|
|
358
|
+
"reflect": false,
|
|
329
359
|
"defaultValue": "''"
|
|
330
360
|
},
|
|
331
|
-
"
|
|
361
|
+
"translationUrl": {
|
|
332
362
|
"type": "string",
|
|
333
363
|
"mutable": false,
|
|
334
364
|
"complexType": {
|
|
@@ -340,10 +370,10 @@ export class UserActionController {
|
|
|
340
370
|
"optional": false,
|
|
341
371
|
"docs": {
|
|
342
372
|
"tags": [],
|
|
343
|
-
"text": "
|
|
373
|
+
"text": "Translation url"
|
|
344
374
|
},
|
|
345
|
-
"attribute": "
|
|
346
|
-
"reflect":
|
|
375
|
+
"attribute": "translation-url",
|
|
376
|
+
"reflect": true,
|
|
347
377
|
"defaultValue": "''"
|
|
348
378
|
},
|
|
349
379
|
"clientStyling": {
|
|
@@ -386,22 +416,21 @@ export class UserActionController {
|
|
|
386
416
|
static get states() { return {
|
|
387
417
|
"queryFired": {},
|
|
388
418
|
"readyActionsCount": {},
|
|
419
|
+
"activeUserActions": {},
|
|
420
|
+
"userActionsValidated": {},
|
|
389
421
|
"receivedQueryResponses": {},
|
|
390
422
|
"limitStylingAppends": {},
|
|
391
|
-
"
|
|
392
|
-
"
|
|
423
|
+
"isLoading": {},
|
|
424
|
+
"mandatoryActionsChecked": {}
|
|
393
425
|
}; }
|
|
394
426
|
static get watchers() { return [{
|
|
427
|
+
"propName": "translationUrl",
|
|
428
|
+
"methodName": "handleNewTranslations"
|
|
429
|
+
}, {
|
|
395
430
|
"propName": "receivedQueryResponses",
|
|
396
431
|
"methodName": "handleQueryResponse"
|
|
397
432
|
}]; }
|
|
398
433
|
static get listeners() { return [{
|
|
399
|
-
"name": "hasToSetConsents",
|
|
400
|
-
"method": "hasToSetConsentsHandler",
|
|
401
|
-
"target": undefined,
|
|
402
|
-
"capture": false,
|
|
403
|
-
"passive": false
|
|
404
|
-
}, {
|
|
405
434
|
"name": "userLegislationConsent",
|
|
406
435
|
"method": "userLegislationConsentHandler",
|
|
407
436
|
"target": undefined,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const SUPPORTED_LANGUAGES = ['ro', 'en', 'cz', 'de', 'hr'];
|
|
3
|
+
const TRANSLATIONS = {
|
|
4
|
+
en: {
|
|
5
|
+
termsandconditions: 'Terms and Conditions',
|
|
6
|
+
sms: 'SMS marketing',
|
|
7
|
+
emailmarketing: 'Email marketing'
|
|
8
|
+
},
|
|
9
|
+
ro: {
|
|
10
|
+
termsandconditions: 'Terms and Conditions',
|
|
11
|
+
sms: 'SMS marketing',
|
|
12
|
+
emailmarketing: 'Email marketing'
|
|
13
|
+
},
|
|
14
|
+
hr: {
|
|
15
|
+
termsandconditions: 'Terms and Conditions',
|
|
16
|
+
sms: 'SMS marketing',
|
|
17
|
+
emailmarketing: 'Email marketing'
|
|
18
|
+
},
|
|
19
|
+
fr: {
|
|
20
|
+
termsandconditions: 'Terms and Conditions',
|
|
21
|
+
sms: 'SMS marketing',
|
|
22
|
+
emailmarketing: 'Email marketing'
|
|
23
|
+
},
|
|
24
|
+
cs: {
|
|
25
|
+
termsandconditions: 'Terms and Conditions',
|
|
26
|
+
sms: 'SMS marketing',
|
|
27
|
+
emailmarketing: 'Email marketing'
|
|
28
|
+
},
|
|
29
|
+
de: {
|
|
30
|
+
termsandconditions: 'Terms and Conditions',
|
|
31
|
+
sms: 'SMS marketing',
|
|
32
|
+
emailmarketing: 'Email marketing'
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
export const getTranslations = (url) => {
|
|
36
|
+
// fetch url, get the data, replace the TRANSLATIONS content
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
fetch(url)
|
|
39
|
+
.then((res) => res.json())
|
|
40
|
+
.then((data) => {
|
|
41
|
+
Object.keys(data).forEach((item) => {
|
|
42
|
+
for (let key in data[item]) {
|
|
43
|
+
TRANSLATIONS[item][key] = data[item][key];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
resolve(true);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export const translate = (key, customLang, values) => {
|
|
51
|
+
const lang = customLang;
|
|
52
|
+
let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
|
|
53
|
+
if (values !== undefined) {
|
|
54
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
55
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
56
|
+
translation = translation.replace(regex, value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return translation;
|
|
60
|
+
};
|