@everymatrix/general-registration 1.10.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/checkbox-input_11.cjs.entry.js +1165 -0
- package/dist/cjs/general-registration.cjs.js +19 -0
- package/dist/cjs/index-c04f4a2a.js +1264 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/collection/collection-manifest.json +28 -0
- package/dist/collection/components/general-registration/general-registration.css +45 -0
- package/dist/collection/components/general-registration/general-registration.js +529 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/components/checkbox-input.js +6 -0
- package/dist/components/checkbox-input2.js +78 -0
- package/dist/components/date-input.js +6 -0
- package/dist/components/date-input2.js +90 -0
- package/dist/components/email-input.js +6 -0
- package/dist/components/email-input2.js +108 -0
- package/dist/components/general-input.js +6 -0
- package/dist/components/general-input2.js +120 -0
- package/dist/components/general-registration.d.ts +11 -0
- package/dist/components/general-registration.js +530 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/locale.utils.js +29 -0
- package/dist/components/number-input.js +6 -0
- package/dist/components/number-input2.js +96 -0
- package/dist/components/password-input.js +6 -0
- package/dist/components/password-input2.js +93 -0
- package/dist/components/radio-input.js +6 -0
- package/dist/components/radio-input2.js +89 -0
- package/dist/components/select-input.js +6 -0
- package/dist/components/select-input2.js +127 -0
- package/dist/components/tel-input.js +6 -0
- package/dist/components/tel-input2.js +111 -0
- package/dist/components/text-input.js +6 -0
- package/dist/components/text-input2.js +112 -0
- package/dist/esm/checkbox-input_11.entry.js +1151 -0
- package/dist/esm/general-registration.js +17 -0
- package/dist/esm/index-79f297c1.js +1238 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/general-registration/general-registration.esm.js +1 -0
- package/dist/general-registration/index.esm.js +0 -0
- package/dist/general-registration/p-0e7175cd.js +1 -0
- package/dist/general-registration/p-cadaffbe.entry.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.js +22 -0
- package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/locale.utils.d.ts +5 -0
- package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +55 -0
- package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-registration/.stencil/packages/general-registration/stencil.config.d.ts +2 -0
- package/dist/types/components/general-registration/general-registration.d.ts +67 -0
- package/dist/types/components.d.ts +77 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +22 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-c04f4a2a.js');
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
9
|
+
*/
|
|
10
|
+
const patchEsm = () => {
|
|
11
|
+
return index.promiseResolve();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const defineCustomElements = (win, options) => {
|
|
15
|
+
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
|
+
return patchEsm().then(() => {
|
|
17
|
+
return index.bootstrapLazy([["checkbox-input_11.cjs",[[1,"general-registration",{"endpoint":[1],"tenantId":[1,"tenant-id"],"clientId":[1,"client-id"],"apiKey":[1,"api-key"],"language":[1],"errorMessage":[32],"emitValue":[32],"isFormValid":[32],"listOfInputs":[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{"type":[1],"name":[1],"displayName":[1,"display-name"],"action":[1],"validation":[16],"options":[8],"language":[1],"defaultValue":[8,"default-value"],"emitValue":[4,"emit-value"]}],[1,"checkbox-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"date-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"email-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"language":[1],"emitValue":[4,"emit-value"],"checkValidity":[4,"check-validity"],"errorMessage":[32],"isValid":[32]}],[1,"number-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[2,"default-value"],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"password-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"radio-input",{"name":[1],"displayName":[1,"display-name"],"optionsGroup":[16],"validation":[16],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"select-input",{"name":[1],"displayName":[1,"display-name"],"action":[1],"options":[16],"validation":[16],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"tel-input",{"name":[1],"displayName":[1,"display-name"],"showLabels":[4,"show-labels"],"action":[1],"validation":[16],"defaultValue":[8,"default-value"],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"text-input",{"name":[1025],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1025,"default-value"],"rules":[1],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}]]]], options);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.defineCustomElements = defineCustomElements;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entries": [
|
|
3
|
+
"./components/general-registration/general-registration.js"
|
|
4
|
+
],
|
|
5
|
+
"compiler": {
|
|
6
|
+
"name": "@stencil/core",
|
|
7
|
+
"version": "2.15.2",
|
|
8
|
+
"typescriptVersion": "4.5.4"
|
|
9
|
+
},
|
|
10
|
+
"collections": [
|
|
11
|
+
{
|
|
12
|
+
"name": "@everymatrix/general-input",
|
|
13
|
+
"tags": [
|
|
14
|
+
"checkbox-input",
|
|
15
|
+
"date-input",
|
|
16
|
+
"email-input",
|
|
17
|
+
"general-input",
|
|
18
|
+
"number-input",
|
|
19
|
+
"password-input",
|
|
20
|
+
"radio-input",
|
|
21
|
+
"select-input",
|
|
22
|
+
"tel-input",
|
|
23
|
+
"text-input"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"bundles": []
|
|
28
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
*,
|
|
2
|
+
*::before,
|
|
3
|
+
*::after {
|
|
4
|
+
padding: 0;
|
|
5
|
+
margin: 0;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.registration {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
gap: 20px;
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
15
|
+
}
|
|
16
|
+
.registration__form {
|
|
17
|
+
display: grid;
|
|
18
|
+
grid-template-columns: repeat(2, minmax(min-content, 1fr));
|
|
19
|
+
column-gap: 65px;
|
|
20
|
+
row-gap: 30px;
|
|
21
|
+
justify-items: stretch;
|
|
22
|
+
align-content: flex-start;
|
|
23
|
+
overflow: scroll;
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 100%;
|
|
26
|
+
}
|
|
27
|
+
.registration__buttons-wrapper {
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: row-reverse;
|
|
30
|
+
justify-content: space-between;
|
|
31
|
+
}
|
|
32
|
+
.registration__button {
|
|
33
|
+
background-color: #e69200;
|
|
34
|
+
border-radius: 30px;
|
|
35
|
+
text-transform: uppercase;
|
|
36
|
+
padding: 10px 50px;
|
|
37
|
+
border: none;
|
|
38
|
+
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.5);
|
|
39
|
+
}
|
|
40
|
+
.registration__button--disabled {
|
|
41
|
+
background-color: grey;
|
|
42
|
+
}
|
|
43
|
+
.registration__button--done {
|
|
44
|
+
background-color: #176317;
|
|
45
|
+
}
|
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
import { Component, h, Listen, Prop, State, Watch } from '@stencil/core';
|
|
2
|
+
import { translate } from '../../../../general-input/src/utils/locale.utils';
|
|
3
|
+
import '@everymatrix/general-input';
|
|
4
|
+
export class GeneralRegistration {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.data = {
|
|
7
|
+
"type": "default",
|
|
8
|
+
"content": {
|
|
9
|
+
"step": "step1",
|
|
10
|
+
"fields": [
|
|
11
|
+
{
|
|
12
|
+
"name": "firstName",
|
|
13
|
+
"displayName": "Username",
|
|
14
|
+
"defaultValue": null,
|
|
15
|
+
"validate": {
|
|
16
|
+
"mandatory": true,
|
|
17
|
+
"minLength": 3,
|
|
18
|
+
"maxLength": 20
|
|
19
|
+
},
|
|
20
|
+
"autofill": false
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "firstName",
|
|
24
|
+
"displayName": "Username",
|
|
25
|
+
"defaultValue": null,
|
|
26
|
+
"validate": {
|
|
27
|
+
"mandatory": true,
|
|
28
|
+
"minLength": 3,
|
|
29
|
+
"maxLength": 20
|
|
30
|
+
},
|
|
31
|
+
"autofill": false
|
|
32
|
+
},
|
|
33
|
+
// {
|
|
34
|
+
// "name": "tel",
|
|
35
|
+
// "displayName": "Telephone",
|
|
36
|
+
// "defaultValue": null,
|
|
37
|
+
// "validate": {
|
|
38
|
+
// "mandatory": true
|
|
39
|
+
// },
|
|
40
|
+
// "autofill": false,
|
|
41
|
+
// "inputType": "tel"
|
|
42
|
+
// },
|
|
43
|
+
// {
|
|
44
|
+
// "name": "dateOfBirth",
|
|
45
|
+
// "displayName": "Date of Birth",
|
|
46
|
+
// "defaultValue": null,
|
|
47
|
+
// "validate": {
|
|
48
|
+
// "min": "2023-04-01",
|
|
49
|
+
// "max": "2023-04-29",
|
|
50
|
+
// "mandatory": true,
|
|
51
|
+
// },
|
|
52
|
+
// "inputType": "datetime"
|
|
53
|
+
// },
|
|
54
|
+
// {
|
|
55
|
+
// "name": "email",
|
|
56
|
+
// "displayName": "Email",
|
|
57
|
+
// "defaultValue": 'a@a.com',
|
|
58
|
+
// "validate": {
|
|
59
|
+
// "mandatory": true,
|
|
60
|
+
// "custom": [
|
|
61
|
+
// {
|
|
62
|
+
// "rule": "regex",
|
|
63
|
+
// "pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
64
|
+
// "errorMessage": "Please enter a valid email address"
|
|
65
|
+
// }
|
|
66
|
+
// ]
|
|
67
|
+
// },
|
|
68
|
+
// "inputType": "email"
|
|
69
|
+
// },
|
|
70
|
+
// {
|
|
71
|
+
// "name": "lastName",
|
|
72
|
+
// "displayName": "Last name",
|
|
73
|
+
// "defaultValue": null,
|
|
74
|
+
// "validate": {
|
|
75
|
+
// "mandatory": true,
|
|
76
|
+
// "minLength": 3,
|
|
77
|
+
// "maxLength": 20
|
|
78
|
+
// },
|
|
79
|
+
// },
|
|
80
|
+
// {
|
|
81
|
+
// "name": "password",
|
|
82
|
+
// "displayName": "Password",
|
|
83
|
+
// "defaultValue": null,
|
|
84
|
+
// "validate": {
|
|
85
|
+
// "mandatory": true,
|
|
86
|
+
// "minLength": 3,
|
|
87
|
+
// "maxLength": 20,
|
|
88
|
+
// "type": "password",
|
|
89
|
+
// "custom": [
|
|
90
|
+
// {
|
|
91
|
+
// "rule": "regex",
|
|
92
|
+
// "pattern": "(?=.*\\d+)(?=.*[A-Za-z]+).{8,20}",
|
|
93
|
+
// "errorMessage": "Password must contain at least 1 letter and 1 digit, and its minimal length is 8."
|
|
94
|
+
// }
|
|
95
|
+
// ]
|
|
96
|
+
// },
|
|
97
|
+
// "inputType": "password"
|
|
98
|
+
// },
|
|
99
|
+
// {
|
|
100
|
+
// "name": "email",
|
|
101
|
+
// "defaultValue": null,
|
|
102
|
+
// "validate": {
|
|
103
|
+
// "mandatory": true,
|
|
104
|
+
// "type": "email",
|
|
105
|
+
// "custom": [
|
|
106
|
+
// {
|
|
107
|
+
// "rule": "unique-email",
|
|
108
|
+
// "errorMessage": "Please check your email"
|
|
109
|
+
// },
|
|
110
|
+
// {
|
|
111
|
+
// "rule": "regex",
|
|
112
|
+
// "pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z-9.-]+\\.[a-zA-Z]{2,3}$",
|
|
113
|
+
// "errorMessage": "Please enter a valid email address"
|
|
114
|
+
// }
|
|
115
|
+
// ]
|
|
116
|
+
// }
|
|
117
|
+
// },
|
|
118
|
+
// {
|
|
119
|
+
// "name": "termsAndConditions",
|
|
120
|
+
// "displayName": "Terms and Conditions",
|
|
121
|
+
// "validate": {
|
|
122
|
+
// "mandatory": true,
|
|
123
|
+
// "type": "boolean"
|
|
124
|
+
// },
|
|
125
|
+
// "inputType": "checkbox"
|
|
126
|
+
// },
|
|
127
|
+
// {
|
|
128
|
+
// "name": "pepCheck",
|
|
129
|
+
// "validate": {
|
|
130
|
+
// "mandatory": true
|
|
131
|
+
// },
|
|
132
|
+
// "inputType": "checkbox"
|
|
133
|
+
// },
|
|
134
|
+
// {
|
|
135
|
+
// "name": "gender",
|
|
136
|
+
// "data": {
|
|
137
|
+
// "values": [
|
|
138
|
+
// {
|
|
139
|
+
// "label": "🍆",
|
|
140
|
+
// "value": "m"
|
|
141
|
+
// },
|
|
142
|
+
// {
|
|
143
|
+
// "label": "🍑",
|
|
144
|
+
// "value": "f"
|
|
145
|
+
// }
|
|
146
|
+
// ]
|
|
147
|
+
// },
|
|
148
|
+
// "validate": {
|
|
149
|
+
// "mandatory": true
|
|
150
|
+
// },
|
|
151
|
+
// "inputType": "radio"
|
|
152
|
+
// },
|
|
153
|
+
// {
|
|
154
|
+
// "name": "dateOfBirth",
|
|
155
|
+
// "validate": {
|
|
156
|
+
// "mandatory": true,
|
|
157
|
+
// "custom": [
|
|
158
|
+
// {
|
|
159
|
+
// "rule": "regex",
|
|
160
|
+
// "pattern": "(?:19\\d{2}|20[01][0-9]|2020)[-/.](?:0[1-9]|1[012])[-/.](?:0[1-9]|[12][0-9]|3[01])",
|
|
161
|
+
// "errorMessage": "Invalid date format"
|
|
162
|
+
// },
|
|
163
|
+
// {
|
|
164
|
+
// "rule": "min-18-years",
|
|
165
|
+
// "errorMessage": "Not old enough to ride the roller coaster"
|
|
166
|
+
// }
|
|
167
|
+
// ]
|
|
168
|
+
// }
|
|
169
|
+
// },
|
|
170
|
+
// {
|
|
171
|
+
// "name": "city",
|
|
172
|
+
// "displayName": "Cities",
|
|
173
|
+
// "action": null,
|
|
174
|
+
// "data": {
|
|
175
|
+
// "values": [
|
|
176
|
+
// {
|
|
177
|
+
// "label": "Budapest",
|
|
178
|
+
// "value": "Budapest"
|
|
179
|
+
// },
|
|
180
|
+
// {
|
|
181
|
+
// "label": "Debrecen",
|
|
182
|
+
// "value": "Debrecen"
|
|
183
|
+
// },
|
|
184
|
+
// {
|
|
185
|
+
// "label": "Miskolc",
|
|
186
|
+
// "value": "Miskolc"
|
|
187
|
+
// },
|
|
188
|
+
// {
|
|
189
|
+
// "label": "Szeged",
|
|
190
|
+
// "value": "Szeged"
|
|
191
|
+
// },
|
|
192
|
+
// {
|
|
193
|
+
// "label": "Zuglo",
|
|
194
|
+
// "value": "Zuglo"
|
|
195
|
+
// }
|
|
196
|
+
// ]
|
|
197
|
+
// },
|
|
198
|
+
// "validate": {
|
|
199
|
+
// "mandatory": true
|
|
200
|
+
// },
|
|
201
|
+
// "inputType" : "dropdown"
|
|
202
|
+
// },
|
|
203
|
+
// {
|
|
204
|
+
// "name": "city",
|
|
205
|
+
// "displayName": "Cities",
|
|
206
|
+
// "data": null,
|
|
207
|
+
// "action": "GET https://demo-api.stage.norway.everymatrix.com/v1/player/countries",
|
|
208
|
+
// "validate": {
|
|
209
|
+
// "mandatory": true
|
|
210
|
+
// },
|
|
211
|
+
// "inputType" : "dropdown"
|
|
212
|
+
// }
|
|
213
|
+
],
|
|
214
|
+
"actions": [
|
|
215
|
+
"get-next-step",
|
|
216
|
+
"some-async-action-before-submitting",
|
|
217
|
+
"submit-step-data"
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Currently selected language
|
|
223
|
+
*/
|
|
224
|
+
this.language = 'en';
|
|
225
|
+
this.emitValue = false;
|
|
226
|
+
this.listOfInputs = [];
|
|
227
|
+
this.isLoading = false;
|
|
228
|
+
this.listOfInputValues = [];
|
|
229
|
+
this.listOfActions = [];
|
|
230
|
+
this.actionsStepIndex = 0;
|
|
231
|
+
}
|
|
232
|
+
validityStateHandler() {
|
|
233
|
+
console.log('bababa', this.isFormValid);
|
|
234
|
+
this.buttonReference.disabled = this.isFormValid ? false : true;
|
|
235
|
+
}
|
|
236
|
+
checkInputsValidityHandler(event) {
|
|
237
|
+
console.log('se ajunge aici');
|
|
238
|
+
// Set isValid state of the input in the list.
|
|
239
|
+
this.listOfInputs.find(input => input.name == event.detail.name).isValid = event.detail.valid;
|
|
240
|
+
// Check if any one is invalid.
|
|
241
|
+
this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
|
|
242
|
+
}
|
|
243
|
+
getInputsValueHandler(event) {
|
|
244
|
+
console.log('sendInputValue');
|
|
245
|
+
this.listOfInputValues.find(input => input.name == event.detail.name).inputValue = event.detail.value;
|
|
246
|
+
/*Note to self: -- what about the inputs that received a default value.
|
|
247
|
+
They will send an undefined because there was no input
|
|
248
|
+
Handle it somehow!!!!!, one idea can be that value equals defaultValue but dependes on how the api wants stuff*/
|
|
249
|
+
}
|
|
250
|
+
connectedCallback() {
|
|
251
|
+
}
|
|
252
|
+
componentWillLoad() {
|
|
253
|
+
// const mockCall = Promise.resolve(this.data);
|
|
254
|
+
// return mockCall.then((data) => {
|
|
255
|
+
// this.listOfInputs = data.content.fields.map((field) => {
|
|
256
|
+
// return { ...field, isValid: false };
|
|
257
|
+
// });
|
|
258
|
+
// });
|
|
259
|
+
// Initial Fetch
|
|
260
|
+
return this.getRegisterConfig().then((config) => {
|
|
261
|
+
this.formatConfig(config);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
nextHandler(e) {
|
|
265
|
+
e.preventDefault();
|
|
266
|
+
// Trigger events in subwidgets.
|
|
267
|
+
this.emitValue = true;
|
|
268
|
+
if (this.isFormValid) {
|
|
269
|
+
this.setRegisterStep();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
getRegisterConfig(registrationID) {
|
|
273
|
+
const url = new URL(`${this.endpoint}/api/v1.0/registerCfg/`);
|
|
274
|
+
const headers = new Headers();
|
|
275
|
+
headers.append('X-Tenant-ID', this.tenantId);
|
|
276
|
+
headers.append('X-Client-ID', this.clientId);
|
|
277
|
+
headers.append('X-Api-Key', this.apiKey);
|
|
278
|
+
headers.append('Content-Type', 'application/json');
|
|
279
|
+
headers.append('Accept', 'application/json');
|
|
280
|
+
if (registrationID) {
|
|
281
|
+
url.searchParams.append('registrationId', registrationID);
|
|
282
|
+
}
|
|
283
|
+
const options = {
|
|
284
|
+
method: 'GET',
|
|
285
|
+
headers
|
|
286
|
+
};
|
|
287
|
+
return new Promise((resolve, reject) => {
|
|
288
|
+
this.isLoading = true;
|
|
289
|
+
fetch(url.href, options)
|
|
290
|
+
.then((res) => res.json())
|
|
291
|
+
.then((config) => {
|
|
292
|
+
resolve(config);
|
|
293
|
+
}).catch((err) => {
|
|
294
|
+
console.error(err);
|
|
295
|
+
reject(err);
|
|
296
|
+
}).finally(() => {
|
|
297
|
+
this.isLoading = false;
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
setRegisterStep() {
|
|
302
|
+
this.emitValue = false;
|
|
303
|
+
const url = new URL(`${this.endpoint}/api/v1.0/registerStep/`);
|
|
304
|
+
const registerStep = {
|
|
305
|
+
registrationId: this.registrationID,
|
|
306
|
+
registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
|
|
307
|
+
acc[curr.name] = curr.inputValue;
|
|
308
|
+
return acc;
|
|
309
|
+
}, {}),
|
|
310
|
+
step: this.registrationStep,
|
|
311
|
+
};
|
|
312
|
+
const headers = new Headers();
|
|
313
|
+
headers.append('X-Tenant-ID', this.tenantId);
|
|
314
|
+
headers.append('X-Client-ID', this.clientId);
|
|
315
|
+
headers.append('X-Api-Key', this.apiKey);
|
|
316
|
+
headers.append('Content-Type', 'application/json');
|
|
317
|
+
headers.append('Accept', 'application/json');
|
|
318
|
+
const options = {
|
|
319
|
+
method: 'POST',
|
|
320
|
+
body: JSON.stringify(registerStep),
|
|
321
|
+
headers
|
|
322
|
+
};
|
|
323
|
+
fetch(url.href, options)
|
|
324
|
+
.then((res) => {
|
|
325
|
+
if (res.status >= 300) {
|
|
326
|
+
throw new Error('err');
|
|
327
|
+
}
|
|
328
|
+
})
|
|
329
|
+
.then((data) => {
|
|
330
|
+
this.registrationID = data.registrationId;
|
|
331
|
+
if (this.listOfActions.some(action => action == '/register')) {
|
|
332
|
+
this.setRegister();
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
this.getRegisterConfig(this.registrationID).then((config) => this.formatConfig(config));
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
.catch((err) => {
|
|
339
|
+
console.error(err);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
setRegister() {
|
|
343
|
+
const url = new URL(`${this.endpoint}/api/v1.0/register/`);
|
|
344
|
+
const headers = new Headers();
|
|
345
|
+
headers.append('X-Tenant-ID', this.tenantId);
|
|
346
|
+
headers.append('X-Client-ID', this.clientId);
|
|
347
|
+
headers.append('X-Api-Key', this.apiKey);
|
|
348
|
+
headers.append('Content-Type', 'application/json');
|
|
349
|
+
headers.append('Accept', 'application/json');
|
|
350
|
+
const registerStep = {
|
|
351
|
+
registrationId: this.registrationID,
|
|
352
|
+
registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
|
|
353
|
+
acc[curr.name] = curr.inputValue;
|
|
354
|
+
return acc;
|
|
355
|
+
}, {}),
|
|
356
|
+
step: this.registrationStep,
|
|
357
|
+
};
|
|
358
|
+
const options = {
|
|
359
|
+
method: 'POST',
|
|
360
|
+
body: JSON.stringify(registerStep),
|
|
361
|
+
headers
|
|
362
|
+
};
|
|
363
|
+
fetch(url.href, options)
|
|
364
|
+
.then((res) => {
|
|
365
|
+
if (res.status >= 300) {
|
|
366
|
+
throw new Error('err');
|
|
367
|
+
}
|
|
368
|
+
})
|
|
369
|
+
.then((data) => {
|
|
370
|
+
console.log(data);
|
|
371
|
+
})
|
|
372
|
+
.catch((err) => {
|
|
373
|
+
console.log(err);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
formatConfig(config) {
|
|
377
|
+
// Populate the list of inputs and set as invalid in the beginning
|
|
378
|
+
this.listOfInputs = config.content.fields.map((field) => {
|
|
379
|
+
return Object.assign(Object.assign({}, field), { isValid: false });
|
|
380
|
+
});
|
|
381
|
+
// Populate the list of inputs values and set as null in the beginning
|
|
382
|
+
this.listOfInputValues = config.content.fields.map(field => {
|
|
383
|
+
return { name: field.name, inputValue: null };
|
|
384
|
+
});
|
|
385
|
+
// Set the list of actions
|
|
386
|
+
this.listOfActions = config.content.actions.map(action => action);
|
|
387
|
+
this.registrationID = config.content.registrationID;
|
|
388
|
+
this.registrationStep = config.content.step;
|
|
389
|
+
}
|
|
390
|
+
getInvalidStatus(listOfInputs) {
|
|
391
|
+
return listOfInputs.filter(input => input.isValid == false).length > 0;
|
|
392
|
+
}
|
|
393
|
+
renderInputs() {
|
|
394
|
+
/*let aux = this.listOfInputs;
|
|
395
|
+
this.listOfInputs = [];
|
|
396
|
+
this.listOfInputs = aux;*/
|
|
397
|
+
return (this.listOfInputs.map(input => h("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data ? input.data.values : [], defaultValue: input.defaultValue, emitValue: this.emitValue, language: this.language })));
|
|
398
|
+
}
|
|
399
|
+
;
|
|
400
|
+
renderButtons() {
|
|
401
|
+
return (h("div", { class: 'registration__buttons-wrapper' },
|
|
402
|
+
h("button", { class: 'registration__button', type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e), ref: (el) => this.buttonReference = el }, translate('nextButton', this.language)),
|
|
403
|
+
h("button", { class: 'registration__button' }, translate('backButton', this.language))));
|
|
404
|
+
}
|
|
405
|
+
render() {
|
|
406
|
+
return (h("div", { class: 'registration' },
|
|
407
|
+
h("form", { action: '.', id: 'RegistrationForm', class: 'registration__form' }, this.renderInputs()),
|
|
408
|
+
this.renderButtons()));
|
|
409
|
+
}
|
|
410
|
+
static get is() { return "general-registration"; }
|
|
411
|
+
static get encapsulation() { return "shadow"; }
|
|
412
|
+
static get originalStyleUrls() { return {
|
|
413
|
+
"$": ["general-registration.scss"]
|
|
414
|
+
}; }
|
|
415
|
+
static get styleUrls() { return {
|
|
416
|
+
"$": ["general-registration.css"]
|
|
417
|
+
}; }
|
|
418
|
+
static get properties() { return {
|
|
419
|
+
"endpoint": {
|
|
420
|
+
"type": "string",
|
|
421
|
+
"mutable": false,
|
|
422
|
+
"complexType": {
|
|
423
|
+
"original": "string",
|
|
424
|
+
"resolved": "string",
|
|
425
|
+
"references": {}
|
|
426
|
+
},
|
|
427
|
+
"required": false,
|
|
428
|
+
"optional": false,
|
|
429
|
+
"docs": {
|
|
430
|
+
"tags": [],
|
|
431
|
+
"text": "NorWAy Endpoint for all the calls."
|
|
432
|
+
},
|
|
433
|
+
"attribute": "endpoint",
|
|
434
|
+
"reflect": false
|
|
435
|
+
},
|
|
436
|
+
"tenantId": {
|
|
437
|
+
"type": "string",
|
|
438
|
+
"mutable": false,
|
|
439
|
+
"complexType": {
|
|
440
|
+
"original": "string",
|
|
441
|
+
"resolved": "string",
|
|
442
|
+
"references": {}
|
|
443
|
+
},
|
|
444
|
+
"required": false,
|
|
445
|
+
"optional": false,
|
|
446
|
+
"docs": {
|
|
447
|
+
"tags": [],
|
|
448
|
+
"text": "The tenandId of the domain"
|
|
449
|
+
},
|
|
450
|
+
"attribute": "tenant-id",
|
|
451
|
+
"reflect": false
|
|
452
|
+
},
|
|
453
|
+
"clientId": {
|
|
454
|
+
"type": "string",
|
|
455
|
+
"mutable": false,
|
|
456
|
+
"complexType": {
|
|
457
|
+
"original": "string",
|
|
458
|
+
"resolved": "string",
|
|
459
|
+
"references": {}
|
|
460
|
+
},
|
|
461
|
+
"required": false,
|
|
462
|
+
"optional": false,
|
|
463
|
+
"docs": {
|
|
464
|
+
"tags": [],
|
|
465
|
+
"text": "ClientID? OperatorID? GM knows ..."
|
|
466
|
+
},
|
|
467
|
+
"attribute": "client-id",
|
|
468
|
+
"reflect": false
|
|
469
|
+
},
|
|
470
|
+
"apiKey": {
|
|
471
|
+
"type": "string",
|
|
472
|
+
"mutable": false,
|
|
473
|
+
"complexType": {
|
|
474
|
+
"original": "string",
|
|
475
|
+
"resolved": "string",
|
|
476
|
+
"references": {}
|
|
477
|
+
},
|
|
478
|
+
"required": false,
|
|
479
|
+
"optional": false,
|
|
480
|
+
"docs": {
|
|
481
|
+
"tags": [],
|
|
482
|
+
"text": "The APIKey for that endpoint"
|
|
483
|
+
},
|
|
484
|
+
"attribute": "api-key",
|
|
485
|
+
"reflect": false
|
|
486
|
+
},
|
|
487
|
+
"language": {
|
|
488
|
+
"type": "string",
|
|
489
|
+
"mutable": false,
|
|
490
|
+
"complexType": {
|
|
491
|
+
"original": "string",
|
|
492
|
+
"resolved": "string",
|
|
493
|
+
"references": {}
|
|
494
|
+
},
|
|
495
|
+
"required": false,
|
|
496
|
+
"optional": false,
|
|
497
|
+
"docs": {
|
|
498
|
+
"tags": [],
|
|
499
|
+
"text": "Currently selected language"
|
|
500
|
+
},
|
|
501
|
+
"attribute": "language",
|
|
502
|
+
"reflect": false,
|
|
503
|
+
"defaultValue": "'en'"
|
|
504
|
+
}
|
|
505
|
+
}; }
|
|
506
|
+
static get states() { return {
|
|
507
|
+
"errorMessage": {},
|
|
508
|
+
"emitValue": {},
|
|
509
|
+
"isFormValid": {},
|
|
510
|
+
"listOfInputs": {}
|
|
511
|
+
}; }
|
|
512
|
+
static get watchers() { return [{
|
|
513
|
+
"propName": "isFormValid",
|
|
514
|
+
"methodName": "validityStateHandler"
|
|
515
|
+
}]; }
|
|
516
|
+
static get listeners() { return [{
|
|
517
|
+
"name": "sendValidityState",
|
|
518
|
+
"method": "checkInputsValidityHandler",
|
|
519
|
+
"target": undefined,
|
|
520
|
+
"capture": false,
|
|
521
|
+
"passive": false
|
|
522
|
+
}, {
|
|
523
|
+
"name": "sendInputValue",
|
|
524
|
+
"method": "getInputsValueHandler",
|
|
525
|
+
"target": undefined,
|
|
526
|
+
"capture": false,
|
|
527
|
+
"passive": false
|
|
528
|
+
}]; }
|
|
529
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|