@everymatrix/user-action-controller 1.34.0 → 1.34.2
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-user-consents_2.cjs.entry.js +200 -131
- package/dist/cjs/user-action-controller.cjs.js +1 -1
- package/dist/collection/components/user-action-controller/user-action-controller.js +87 -81
- package/dist/collection/utils/locale.utils.js +12 -6
- package/dist/components/player-user-consents2.js +102 -44
- package/dist/components/user-action-controller.js +99 -87
- package/dist/esm/loader.js +1 -1
- package/dist/esm/player-user-consents_2.entry.js +200 -131
- package/dist/esm/user-action-controller.js +1 -1
- 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 +2 -0
- package/dist/types/components/user-action-controller/user-action-controller.d.ts +2 -1
- package/dist/user-action-controller/p-02211033.entry.js +1 -0
- package/dist/user-action-controller/user-action-controller.esm.js +1 -1
- package/package.json +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 +0 -2
- package/dist/user-action-controller/p-1b7bd94a.entry.js +0 -1
|
@@ -7,32 +7,38 @@ const TRANSLATIONS = {
|
|
|
7
7
|
en: {
|
|
8
8
|
termsandconditions: 'Terms and Conditions',
|
|
9
9
|
sms: 'SMS marketing',
|
|
10
|
-
emailmarketing: 'Email marketing'
|
|
10
|
+
emailmarketing: 'Email marketing',
|
|
11
|
+
privacypolicy: 'Privacy Policy'
|
|
11
12
|
},
|
|
12
13
|
ro: {
|
|
13
14
|
termsandconditions: 'Termeni şi condiţii',
|
|
14
15
|
sms: 'SMS marketing',
|
|
15
|
-
emailmarketing: 'Email marketing'
|
|
16
|
+
emailmarketing: 'Email marketing',
|
|
17
|
+
privacypolicy: 'Privacy Policy'
|
|
16
18
|
},
|
|
17
19
|
hr: {
|
|
18
20
|
termsandconditions: 'Terms and Conditions',
|
|
19
21
|
sms: 'SMS marketing',
|
|
20
|
-
emailmarketing: 'Email marketing'
|
|
22
|
+
emailmarketing: 'Email marketing',
|
|
23
|
+
privacypolicy: 'Privacy Policy'
|
|
21
24
|
},
|
|
22
25
|
fr: {
|
|
23
26
|
termsandconditions: 'Terms and Conditions',
|
|
24
27
|
sms: 'SMS marketing',
|
|
25
|
-
emailmarketing: 'Email marketing'
|
|
28
|
+
emailmarketing: 'Email marketing',
|
|
29
|
+
privacypolicy: 'Privacy Policy'
|
|
26
30
|
},
|
|
27
31
|
cs: {
|
|
28
32
|
termsandconditions: 'Terms and Conditions',
|
|
29
33
|
sms: 'SMS marketing',
|
|
30
|
-
emailmarketing: 'Email marketing'
|
|
34
|
+
emailmarketing: 'Email marketing',
|
|
35
|
+
privacypolicy: 'Privacy Policy'
|
|
31
36
|
},
|
|
32
37
|
de: {
|
|
33
38
|
termsandconditions: 'Terms and Conditions',
|
|
34
39
|
sms: 'SMS marketing',
|
|
35
|
-
emailmarketing: 'Email marketing'
|
|
40
|
+
emailmarketing: 'Email marketing',
|
|
41
|
+
privacypolicy: 'Privacy Policy'
|
|
36
42
|
},
|
|
37
43
|
};
|
|
38
44
|
const getTranslations = (url) => {
|
|
@@ -100,13 +106,14 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
100
106
|
this.limitStylingAppends = false;
|
|
101
107
|
this.isLoading = true;
|
|
102
108
|
this.mandatoryActionsChecked = 0;
|
|
103
|
-
//for now this variable is hardcoded bcs we have
|
|
104
|
-
this.mandatoryActions = ['termsandconditions'];
|
|
109
|
+
//for now this variable is hardcoded bcs we have terms and conditions and privacy policy mandatory and we dont receive with these new functionality the mandatory actions
|
|
110
|
+
this.mandatoryActions = ['termsandconditions', 'privacypolicy'];
|
|
105
111
|
this.userActions = [];
|
|
106
112
|
this.consentTitles = {
|
|
107
113
|
termsandconditions: translate('termsandconditions', this.lang),
|
|
108
114
|
sms: translate('sms', this.lang),
|
|
109
|
-
emailmarketing: translate('emailmarketing', this.lang)
|
|
115
|
+
emailmarketing: translate('emailmarketing', this.lang),
|
|
116
|
+
privacypolicy: translate('privacypolicy', this.lang)
|
|
110
117
|
};
|
|
111
118
|
this.setClientStyling = () => {
|
|
112
119
|
let sheet = document.createElement('style');
|
|
@@ -148,56 +155,62 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
148
155
|
this.receivedQueryResponses++;
|
|
149
156
|
}
|
|
150
157
|
}
|
|
151
|
-
|
|
158
|
+
determineUserActionsCore() {
|
|
152
159
|
const url = new URL(`${this.endpoint}/v1/player/${this.userId}/consent`);
|
|
153
160
|
const headers = new Headers();
|
|
154
161
|
headers.append('X-SessionId', this.userSession);
|
|
155
|
-
let requestOptions
|
|
156
|
-
requestOptions = {
|
|
162
|
+
let requestOptions = {
|
|
157
163
|
method: 'GET',
|
|
158
164
|
headers
|
|
159
165
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
this.isLoading = false;
|
|
171
|
-
})
|
|
172
|
-
.catch(error => {
|
|
173
|
-
console.error('Error fetching data:', error);
|
|
174
|
-
this.isLoading = false;
|
|
166
|
+
return fetch(url.href, requestOptions)
|
|
167
|
+
.then(res => res.json())
|
|
168
|
+
.then(data => {
|
|
169
|
+
const actionItems = data.items;
|
|
170
|
+
actionItems.forEach(element => {
|
|
171
|
+
if (element.status === 'Expired') {
|
|
172
|
+
this.activeUserActions.push(element.tagCode);
|
|
173
|
+
}
|
|
175
174
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
this.isLoading = false;
|
|
176
|
+
})
|
|
177
|
+
.catch(error => {
|
|
178
|
+
console.error('Error fetching data:', error);
|
|
179
|
+
this.isLoading = false;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
determineUserActions16() {
|
|
183
|
+
const url = new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
|
|
184
|
+
const headers = new Headers();
|
|
185
|
+
headers.append('X-SessionId', this.userSession);
|
|
186
|
+
let requestOptions = {
|
|
187
|
+
method: 'GET',
|
|
188
|
+
headers
|
|
189
|
+
};
|
|
190
|
+
return fetch(url.href, requestOptions)
|
|
191
|
+
.then(res => res.json())
|
|
192
|
+
.then(data => {
|
|
193
|
+
const actionItems = data.consents;
|
|
194
|
+
actionItems.forEach(element => {
|
|
195
|
+
if (element.status === 2) {
|
|
196
|
+
this.activeUserActions.push(element.tagCode);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
this.isLoading = false;
|
|
200
|
+
})
|
|
201
|
+
.catch(error => {
|
|
202
|
+
console.error('Error fetching data:', error);
|
|
203
|
+
this.isLoading = false;
|
|
204
|
+
});
|
|
180
205
|
}
|
|
181
206
|
updateUserConsents() {
|
|
182
|
-
|
|
183
|
-
let requestOptions;
|
|
184
|
-
url = (this.gmVersion === 'gmcore')
|
|
207
|
+
const url = (this.gmVersion === 'gmcore')
|
|
185
208
|
? new URL(`${this.endpoint}/v1/player/${this.userId}/consent`)
|
|
186
209
|
: new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
|
|
187
|
-
const body =
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
: {
|
|
192
|
-
consents: [
|
|
193
|
-
{
|
|
194
|
-
tagCode: "termsandconditions",
|
|
195
|
-
note: "",
|
|
196
|
-
status: 1
|
|
197
|
-
}
|
|
198
|
-
]
|
|
199
|
-
};
|
|
200
|
-
requestOptions = {
|
|
210
|
+
const body = {
|
|
211
|
+
items: this.userActions
|
|
212
|
+
};
|
|
213
|
+
let requestOptions = {
|
|
201
214
|
method: 'POST',
|
|
202
215
|
headers: {
|
|
203
216
|
'Content-Type': 'application/json',
|
|
@@ -206,43 +219,40 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
206
219
|
},
|
|
207
220
|
body: JSON.stringify(body)
|
|
208
221
|
};
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
});
|
|
234
|
-
}
|
|
222
|
+
fetch(url.href, requestOptions)
|
|
223
|
+
.then(res => res.json())
|
|
224
|
+
.then(() => {
|
|
225
|
+
window.postMessage({
|
|
226
|
+
type: 'WidgetNotification',
|
|
227
|
+
data: {
|
|
228
|
+
type: 'success',
|
|
229
|
+
message: 'Consent update successful!'
|
|
230
|
+
}
|
|
231
|
+
}, window.location.href);
|
|
232
|
+
})
|
|
233
|
+
.catch((err) => {
|
|
234
|
+
window.postMessage({
|
|
235
|
+
type: 'WidgetNotification',
|
|
236
|
+
data: {
|
|
237
|
+
type: 'error',
|
|
238
|
+
message: 'Server might not be responding',
|
|
239
|
+
err
|
|
240
|
+
}
|
|
241
|
+
}, window.location.href);
|
|
242
|
+
})
|
|
243
|
+
.finally(() => {
|
|
244
|
+
window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
|
|
245
|
+
});
|
|
235
246
|
}
|
|
236
247
|
handleApplyClick() {
|
|
237
248
|
this.queryFired = true;
|
|
238
249
|
}
|
|
239
250
|
async componentWillLoad() {
|
|
240
251
|
if (this.gmVersion === 'gmcore') {
|
|
241
|
-
|
|
252
|
+
this.determineUserActionsCore();
|
|
242
253
|
}
|
|
243
|
-
|
|
244
|
-
this.
|
|
245
|
-
this.isLoading = false;
|
|
254
|
+
if (this.gmVersion === 'gm16') {
|
|
255
|
+
this.determineUserActions16();
|
|
246
256
|
}
|
|
247
257
|
if (this.translationUrl.length > 2) {
|
|
248
258
|
await getTranslations(this.translationUrl);
|
|
@@ -260,17 +270,19 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
|
|
|
260
270
|
// end custom styling area
|
|
261
271
|
}
|
|
262
272
|
render() {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
273
|
+
let mandatoryItems = 0;
|
|
274
|
+
const isMandatoryPresent = this.mandatoryActions.some(action => {
|
|
275
|
+
const isPresent = this.activeUserActions.includes(action);
|
|
276
|
+
if (isPresent) {
|
|
277
|
+
mandatoryItems++;
|
|
278
|
+
}
|
|
279
|
+
return isPresent;
|
|
280
|
+
});
|
|
281
|
+
this.userActionsValidated = isMandatoryPresent && (this.mandatoryActionsChecked === mandatoryItems);
|
|
270
282
|
return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (h("slot", { name: 'spinner' })
|
|
271
283
|
&&
|
|
272
|
-
h("svg", { class: "spinner", viewBox: "0 0 50 50" }, h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (h("div", { class: "UserActionController" }, h("h2", { class: "UserConsentNotice" }, this.userNoticeText), h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action }, h("player-user-consents", { lang: this.lang, "translation-url": this.translationUrl, slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
|
|
273
|
-
h("button", { class: "ConsentSubmitButton", disabled: this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
|
|
284
|
+
h("svg", { class: "spinner", viewBox: "0 0 50 50" }, h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (h("div", { class: "UserActionController" }, h("h2", { class: "UserConsentNotice" }, this.userNoticeText), h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action }, h("player-user-consents", { lang: this.lang, "gm-version": this.gmVersion, "translation-url": this.translationUrl, slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
|
|
285
|
+
h("button", { class: "ConsentSubmitButton", disabled: !this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
|
|
274
286
|
}
|
|
275
287
|
static get watchers() { return {
|
|
276
288
|
"translationUrl": ["handleNewTranslations"],
|
package/dist/esm/loader.js
CHANGED
|
@@ -10,7 +10,7 @@ const patchEsm = () => {
|
|
|
10
10
|
const defineCustomElements = (win, options) => {
|
|
11
11
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
12
12
|
return patchEsm().then(() => {
|
|
13
|
-
return bootstrapLazy([["player-user-consents_2",[[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",{"lang":[1537],"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"translationUrl":[513,"translation-url"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
13
|
+
return bootstrapLazy([["player-user-consents_2",[[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",{"lang":[1537],"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"gmVersion":[1,"gm-version"],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"translationUrl":[513,"translation-url"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|