@experium/findy-form 1.2.22 → 1.2.26
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/app.js +10 -10
- package/lib/components/formComponents/HtmlOpdForm.js +13 -4
- package/lib/components/formComponents/PersonalDataAgreement.js +3 -2
- package/lib/constants/translations.js +9 -9
- package/lib/utils/validation.js +19 -24
- package/package.json +1 -1
- package/src/components/formComponents/HtmlOpdForm.js +50 -6
- package/src/components/formComponents/PersonalDataAgreement.js +3 -2
- package/src/constants/translations.js +9 -9
- package/src/utils/validation.js +22 -30
|
@@ -74,13 +74,15 @@ var styles = {
|
|
|
74
74
|
"timeIndicator": "index__timeIndicator",
|
|
75
75
|
"modalButtonGroup": "index__modalButtonGroup"
|
|
76
76
|
};
|
|
77
|
-
var commonStyle = "\n .opd-html-form {\n line-height: 20px;\n }\n .opd-html-form input {\n border: none;\n border-bottom: 1px solid #000;\n font-size: 16px;\n pointer-events: auto;\n }\n .opd-html-form label {\n pointer-events: auto;\n }\n .opd-html-form input:focus {\n outline: none;\n }\n .opd-html-form.submitted input:invalid {\n border-bottom: 1px solid red;\n }\n .opd-html-form input[type=\"checkbox\"] {\n position: relative;\n margin-right:
|
|
77
|
+
var commonStyle = "\n .opd-html-form {\n line-height: 20px;\n margin-bottom: 24px;\n }\n .opd-html-form input {\n border: none;\n border-bottom: 1px solid #000;\n font-size: 16px;\n pointer-events: auto;\n }\n .opd-html-form label {\n pointer-events: auto;\n }\n .opd-html-form input:focus {\n outline: none;\n }\n .opd-html-form.submitted input:invalid {\n border-bottom: 1px solid red;\n }\n .opd-html-form label{\n cursor: pointer;\n }\n .opd-html-form input[type=\"checkbox\"] {\n position: relative;\n margin-right: 8px;\n margin-bottom: 0;\n border: 1px solid #ccc;\n appearance: none;\n width: 18px;\n height: 18px;\n border-radius: 2px;\n }\n .opd-html-form input[type=\"checkbox\"]:checked {\n background: #3a70bb;\n border-color: #3a70bb;\n }\n .opd-html-form input[type=\"checkbox\"]:checked:before {\n transform: rotate(45deg);\n position: absolute;\n left: 5px;\n top: 2px;\n display: table;\n width: 4px;\n height: 7px;\n border: 2px solid #ffffff;\n border-top: 0;\n border-left: 0;\n content: ' ';\n }\n .opd-html-form input[type=\"checkbox\"]:required::after {\n content: \"*\";\n color: red;\n top: -6px;\n right: -8px;\n position: absolute;\n }\n .opd-html-form.submitted input[type=\"checkbox\"]:invalid {\n border-color: red;\n }\n .opd-html-form > div p {\n display: inline-block;\n margin: 0 0 8px;\n }\n .opd-html-form > div p + p {\n display: block;\n }\n";
|
|
78
78
|
|
|
79
79
|
var getHtml = function getHtml(body) {
|
|
80
80
|
return "\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>OPD</title>\n <style>\n ".concat(commonStyle, "\n .opd-html-form {\n font-family: Arial;\n font-size: 16px;\n }\n .opd-html-form input,\n .opd-html-form label {\n pointer-events: none;\n }\n .opd-html-form input[type=\"checkbox\"]:required::after {\n content: \"\";\n }\n </style>\n </head>\n <body>\n <div style=\"margin: 10px auto; max-width: 1080px;\">\n ").concat(body, "\n </div>\n </body>\n </html>\n");
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
exports.getHtml = getHtml;
|
|
84
|
+
var TEXT_FIELDS = ['text', 'email', 'phone', 'date'];
|
|
85
|
+
var SELECT_FIELDS = ['dictionary', 'company_dictionary', 'list', 'city', 'country', 'region'];
|
|
84
86
|
|
|
85
87
|
var HtmlOpdForm = /*#__PURE__*/function (_Component) {
|
|
86
88
|
(0, _inherits2["default"])(HtmlOpdForm, _Component);
|
|
@@ -112,9 +114,16 @@ var HtmlOpdForm = /*#__PURE__*/function (_Component) {
|
|
|
112
114
|
if (value) {
|
|
113
115
|
var field = (0, _ramda.find)((0, _ramda.propEq)('field', input.name), _this.props.formFields);
|
|
114
116
|
|
|
115
|
-
if (!field || field.type
|
|
117
|
+
if (!field || (0, _ramda.includes)(field.type, TEXT_FIELDS)) {
|
|
116
118
|
input.value = value;
|
|
117
119
|
input.setAttribute('value', value);
|
|
120
|
+
} else if (field && (0, _ramda.includes)(field.type, SELECT_FIELDS)) {
|
|
121
|
+
var selectValue = (0, _ramda.path)(['innerHTML'], document.querySelector("#field-".concat(input.name, " .jobot-forms-rc-select-selection-item")));
|
|
122
|
+
|
|
123
|
+
if (selectValue) {
|
|
124
|
+
input.value = selectValue;
|
|
125
|
+
input.setAttribute('value', selectValue);
|
|
126
|
+
}
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
129
|
}, inputs);
|
|
@@ -170,7 +179,7 @@ var HtmlOpdForm = /*#__PURE__*/function (_Component) {
|
|
|
170
179
|
input.setAttribute('value', input.value);
|
|
171
180
|
var field = (0, _ramda.find)((0, _ramda.propEq)('field', input.name), _this.props.formFields);
|
|
172
181
|
|
|
173
|
-
if (field && field.type
|
|
182
|
+
if (field && (0, _ramda.includes)(field.type, TEXT_FIELDS)) {
|
|
174
183
|
form.change(input.name, input.value);
|
|
175
184
|
}
|
|
176
185
|
}
|
|
@@ -276,7 +285,7 @@ var HtmlOpdFormClear = /*#__PURE__*/function (_Component2) {
|
|
|
276
285
|
(0, _createClass2["default"])(HtmlOpdFormClear, [{
|
|
277
286
|
key: "componentDidUpdate",
|
|
278
287
|
value: function componentDidUpdate(prevProps) {
|
|
279
|
-
if (prevProps.value && !(0, _ramda.equals)(prevProps.values, this.props.values)) {
|
|
288
|
+
if (prevProps.value && !prevProps.open && !(0, _ramda.equals)(prevProps.values, this.props.values)) {
|
|
280
289
|
this.props.onSubmitHtml();
|
|
281
290
|
}
|
|
282
291
|
}
|
|
@@ -82,7 +82,7 @@ var styles = {
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
var getConstructorOpd = function getConstructorOpd(opdSettings, language) {
|
|
85
|
-
var opdConstructor =
|
|
85
|
+
var opdConstructor = (0, _ramda.pathOr)([], ['data', 'opdConstructor'], opdSettings);
|
|
86
86
|
var text = (opdConstructor || []).reduce(function (res, cur) {
|
|
87
87
|
switch (cur.type) {
|
|
88
88
|
case 'question':
|
|
@@ -92,7 +92,7 @@ var getConstructorOpd = function getConstructorOpd(opdSettings, language) {
|
|
|
92
92
|
return res + (cur.text || '');
|
|
93
93
|
|
|
94
94
|
case 'checkbox':
|
|
95
|
-
return "".concat(res, "<p>\n <input type=\"checkbox\" id=\"", "checkbox-".concat(cur.id), "\" ").concat(cur.required ? 'required="required"' : '', " />\n <label for=\"", "checkbox-".concat(cur.id), "\">").concat(cur.label || ''
|
|
95
|
+
return "".concat(res, "<p>\n <input type=\"checkbox\" id=\"", "checkbox-".concat(cur.id), "\" ").concat(cur.required ? 'required="required"' : '', " />\n <label for=\"", "checkbox-".concat(cur.id), "\">").concat(cur.label || '', "</label>\n </p>");
|
|
96
96
|
|
|
97
97
|
case 'opdCheckbox':
|
|
98
98
|
return "".concat(res, "<p>\n <input type=\"checkbox\" id=\"").concat(cur.opdType, "\" ").concat((0, _ramda.path)([cur.opdType, 'required'], opdSettings) ? 'required="required"' : '', " />\n <label for=\"").concat(cur.opdType, "\">").concat((0, _ramda.pathOr)('', [cur.opdType, 'label'], opdSettings), "</label>\n </p>");
|
|
@@ -244,6 +244,7 @@ var PersonalDataAgreementComponent = /*#__PURE__*/function (_Component) {
|
|
|
244
244
|
subscription: ['values']
|
|
245
245
|
}, function (formProps) {
|
|
246
246
|
return /*#__PURE__*/_react["default"].createElement(_HtmlOpdForm.HtmlOpdFormClear, {
|
|
247
|
+
open: _this2.state.openedHtml,
|
|
247
248
|
value: _this2.props.input.value,
|
|
248
249
|
values: _this2.getOpdValues(formProps),
|
|
249
250
|
onSubmitHtml: _this2.onSubmitHtml
|
|
@@ -96,7 +96,7 @@ var TRANSLATIONS = {
|
|
|
96
96
|
'composite': 'Required block',
|
|
97
97
|
'incompleteDate': 'Full date is required',
|
|
98
98
|
'captchaRequired': 'Verification required',
|
|
99
|
-
'incorrectBirthDate': 'Date
|
|
99
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date'
|
|
100
100
|
},
|
|
101
101
|
'invalidCaptcha': 'Invalid captcha'
|
|
102
102
|
}
|
|
@@ -191,7 +191,7 @@ var TRANSLATIONS = {
|
|
|
191
191
|
'composite': 'Блок обязателен для заполнения',
|
|
192
192
|
'incompleteDate': 'Необходимо указать дату полностью',
|
|
193
193
|
'captchaRequired': 'Необходимо пройти проверку',
|
|
194
|
-
'incorrectBirthDate': 'Дата
|
|
194
|
+
'incorrectBirthDate': 'Дата не может быть меньше даты рождения'
|
|
195
195
|
},
|
|
196
196
|
'invalidCaptcha': 'Неверно введена капча'
|
|
197
197
|
}
|
|
@@ -286,7 +286,7 @@ var TRANSLATIONS = {
|
|
|
286
286
|
'composite': 'Блок обов\'язковий для заповнення',
|
|
287
287
|
'incompleteDate': 'Необхідно вказати дату повністю',
|
|
288
288
|
'captchaRequired': 'Необхідно пройти перевірку',
|
|
289
|
-
'incorrectBirthDate': 'Date
|
|
289
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date'
|
|
290
290
|
},
|
|
291
291
|
'invalidCaptcha': 'Невірно введена капча'
|
|
292
292
|
}
|
|
@@ -380,7 +380,7 @@ var TRANSLATIONS = {
|
|
|
380
380
|
'composite': 'Nõutav plokk',
|
|
381
381
|
'incompleteDate': 'Täiskuupäev on kohustuslik',
|
|
382
382
|
'captchaRequired': 'Nõutav kontrollimine',
|
|
383
|
-
'incorrectBirthDate': 'Date
|
|
383
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date'
|
|
384
384
|
},
|
|
385
385
|
'invalidCaptcha': 'Sisestati sobimatu captcha'
|
|
386
386
|
}
|
|
@@ -474,7 +474,7 @@ var TRANSLATIONS = {
|
|
|
474
474
|
'composite': 'Nepieciešamais bloks',
|
|
475
475
|
'incompleteDate': 'Nepieciešams norādīt pilnu datumu',
|
|
476
476
|
'captchaRequired': 'Nepieciešama verifikācija',
|
|
477
|
-
'incorrectBirthDate': 'Date
|
|
477
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date'
|
|
478
478
|
},
|
|
479
479
|
'invalidCaptcha': 'Ievadīta nederīga captcha'
|
|
480
480
|
}
|
|
@@ -568,7 +568,7 @@ var TRANSLATIONS = {
|
|
|
568
568
|
'composite': 'Reikalingas blokas',
|
|
569
569
|
'incompleteDate': 'Būtina nurodyti visą datą',
|
|
570
570
|
'captchaRequired': 'Būtina patvirtinti',
|
|
571
|
-
'incorrectBirthDate': 'Date
|
|
571
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date'
|
|
572
572
|
},
|
|
573
573
|
'invalidCaptcha': 'Įvesta netinkama captcha'
|
|
574
574
|
}
|
|
@@ -663,7 +663,7 @@ var TRANSLATIONS = {
|
|
|
663
663
|
'composite': 'Блок қажет',
|
|
664
664
|
'incompleteDate': 'Сіз толық күнді көрсетуіңіз керек',
|
|
665
665
|
'captchaRequired': 'Тексеру қажет',
|
|
666
|
-
'incorrectBirthDate': 'Date
|
|
666
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date'
|
|
667
667
|
},
|
|
668
668
|
'invalidCaptcha': 'Жарамсыз captcha енгізілді'
|
|
669
669
|
}
|
|
@@ -758,7 +758,7 @@ var TRANSLATIONS = {
|
|
|
758
758
|
'composite': 'จำเป็นต้องบล็อก',
|
|
759
759
|
'incompleteDate': 'คุณต้องระบุวันที่แบบเต็ม',
|
|
760
760
|
'captchaRequired': 'ต้องยืนยัน',
|
|
761
|
-
'incorrectBirthDate': 'Date
|
|
761
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date'
|
|
762
762
|
},
|
|
763
763
|
'validCaptcha': 'ป้อน captcha ไม่ถูกต้อง'
|
|
764
764
|
}
|
|
@@ -853,7 +853,7 @@ var TRANSLATIONS = {
|
|
|
853
853
|
'composite': 'Bloklash shart',
|
|
854
854
|
'incompleteDate': 'To\'liq sanani ko\'rsatish kerak',
|
|
855
855
|
'captchaRequired': 'Tasdiqlash kerak',
|
|
856
|
-
'incorrectBirthDate': 'Date
|
|
856
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date'
|
|
857
857
|
},
|
|
858
858
|
'invalidCaptcha': "Noto'g'ri captcha kiritildi"
|
|
859
859
|
}
|
package/lib/utils/validation.js
CHANGED
|
@@ -25,6 +25,10 @@ var _regexps = require("../constants/regexps");
|
|
|
25
25
|
|
|
26
26
|
var _allowFileExtensions = require("../constants/allowFileExtensions");
|
|
27
27
|
|
|
28
|
+
var checkDate = function checkDate(value) {
|
|
29
|
+
return !value || value === 'incomplete';
|
|
30
|
+
};
|
|
31
|
+
|
|
28
32
|
var checkFileType = function checkFileType(fileType, mimeType) {
|
|
29
33
|
var allowFileExtensions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
30
34
|
|
|
@@ -282,39 +286,30 @@ var rules = {
|
|
|
282
286
|
});
|
|
283
287
|
}
|
|
284
288
|
};
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
education: ['yearEnd']
|
|
289
|
-
};
|
|
290
|
-
var additionalRules = {
|
|
291
|
-
birthDate: function birthDate(rule, form) {
|
|
289
|
+
|
|
290
|
+
var validateBirthDate = function validateBirthDate(format) {
|
|
291
|
+
return function (rule, form) {
|
|
292
292
|
return rule.test({
|
|
293
293
|
name: 'incorrectBirthDate',
|
|
294
294
|
message: _i18n["default"].t('errors.incorrectBirthDate'),
|
|
295
295
|
test: function test(value) {
|
|
296
|
-
if (
|
|
296
|
+
if (checkDate(value) || checkDate(form.birthDate)) {
|
|
297
297
|
return true;
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
var
|
|
301
|
-
var
|
|
302
|
-
|
|
303
|
-
if (form[block]) {
|
|
304
|
-
(0, _ramda.forEach)(function (blockItem) {
|
|
305
|
-
(0, _ramda.forEach)(function (linkedField) {
|
|
306
|
-
if (blockItem[linkedField]) {
|
|
307
|
-
var linkedDate = (0, _moment["default"])(blockItem[linkedField], block === 'experience' ? 'MM.YYYY' : 'YYYY');
|
|
308
|
-
valid = valid ? linkedDate.isAfter(date) : valid;
|
|
309
|
-
}
|
|
310
|
-
}, incorrectBirthDateLinked[block]);
|
|
311
|
-
}, form[block]);
|
|
312
|
-
}
|
|
313
|
-
}, (0, _ramda.keys)(incorrectBirthDateLinked));
|
|
314
|
-
return valid;
|
|
300
|
+
var birthDate = (0, _moment["default"])(form.birthDate, 'DD.MM.YYYY');
|
|
301
|
+
var date = (0, _moment["default"])(value, format);
|
|
302
|
+
return date.isAfter(birthDate);
|
|
315
303
|
}
|
|
316
304
|
});
|
|
317
|
-
}
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
var additionalRules = {
|
|
309
|
+
yearEnd: validateBirthDate('YYYY'),
|
|
310
|
+
courseYearEnd: validateBirthDate('YYYY'),
|
|
311
|
+
experienceStart: validateBirthDate('DD.YYYY'),
|
|
312
|
+
experienceEnd: validateBirthDate('DD.YYYY')
|
|
318
313
|
};
|
|
319
314
|
|
|
320
315
|
var validate = function validate(value, form, field, fieldsWithoutValidation, props) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Component, Fragment } from 'react';
|
|
2
2
|
import { withTranslation } from 'react-i18next';
|
|
3
|
-
import { all, equals, find, forEach, is, path, propEq, trim } from 'ramda';
|
|
3
|
+
import { all, equals, find, forEach, includes, is, path, propEq, trim } from 'ramda';
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
|
|
6
6
|
import styles from '../../styles/index.module.css';
|
|
@@ -11,6 +11,7 @@ import { EMAIL_EXPERIUM } from '../../constants/regexps';
|
|
|
11
11
|
const commonStyle = `
|
|
12
12
|
.opd-html-form {
|
|
13
13
|
line-height: 20px;
|
|
14
|
+
margin-bottom: 24px;
|
|
14
15
|
}
|
|
15
16
|
.opd-html-form input {
|
|
16
17
|
border: none;
|
|
@@ -27,9 +28,35 @@ const commonStyle = `
|
|
|
27
28
|
.opd-html-form.submitted input:invalid {
|
|
28
29
|
border-bottom: 1px solid red;
|
|
29
30
|
}
|
|
31
|
+
.opd-html-form label{
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
30
34
|
.opd-html-form input[type="checkbox"] {
|
|
31
35
|
position: relative;
|
|
32
|
-
margin-right:
|
|
36
|
+
margin-right: 8px;
|
|
37
|
+
margin-bottom: 0;
|
|
38
|
+
border: 1px solid #ccc;
|
|
39
|
+
appearance: none;
|
|
40
|
+
width: 18px;
|
|
41
|
+
height: 18px;
|
|
42
|
+
border-radius: 2px;
|
|
43
|
+
}
|
|
44
|
+
.opd-html-form input[type="checkbox"]:checked {
|
|
45
|
+
background: #3a70bb;
|
|
46
|
+
border-color: #3a70bb;
|
|
47
|
+
}
|
|
48
|
+
.opd-html-form input[type="checkbox"]:checked:before {
|
|
49
|
+
transform: rotate(45deg);
|
|
50
|
+
position: absolute;
|
|
51
|
+
left: 5px;
|
|
52
|
+
top: 2px;
|
|
53
|
+
display: table;
|
|
54
|
+
width: 4px;
|
|
55
|
+
height: 7px;
|
|
56
|
+
border: 2px solid #ffffff;
|
|
57
|
+
border-top: 0;
|
|
58
|
+
border-left: 0;
|
|
59
|
+
content: ' ';
|
|
33
60
|
}
|
|
34
61
|
.opd-html-form input[type="checkbox"]:required::after {
|
|
35
62
|
content: "*";
|
|
@@ -39,7 +66,14 @@ const commonStyle = `
|
|
|
39
66
|
position: absolute;
|
|
40
67
|
}
|
|
41
68
|
.opd-html-form.submitted input[type="checkbox"]:invalid {
|
|
42
|
-
|
|
69
|
+
border-color: red;
|
|
70
|
+
}
|
|
71
|
+
.opd-html-form > div p {
|
|
72
|
+
display: inline-block;
|
|
73
|
+
margin: 0 0 8px;
|
|
74
|
+
}
|
|
75
|
+
.opd-html-form > div p + p {
|
|
76
|
+
display: block;
|
|
43
77
|
}
|
|
44
78
|
`;
|
|
45
79
|
|
|
@@ -73,6 +107,9 @@ export const getHtml = body => `
|
|
|
73
107
|
</html>
|
|
74
108
|
`;
|
|
75
109
|
|
|
110
|
+
const TEXT_FIELDS = ['text', 'email', 'phone', 'date'];
|
|
111
|
+
const SELECT_FIELDS = ['dictionary', 'company_dictionary', 'list', 'city', 'country', 'region'];
|
|
112
|
+
|
|
76
113
|
class HtmlOpdForm extends Component {
|
|
77
114
|
state = {
|
|
78
115
|
submitted: false,
|
|
@@ -101,9 +138,16 @@ class HtmlOpdForm extends Component {
|
|
|
101
138
|
if (value) {
|
|
102
139
|
const field = find(propEq('field', input.name), this.props.formFields);
|
|
103
140
|
|
|
104
|
-
if (!field || field.type
|
|
141
|
+
if (!field || includes(field.type, TEXT_FIELDS)) {
|
|
105
142
|
input.value = value;
|
|
106
143
|
input.setAttribute('value', value);
|
|
144
|
+
} else if (field && includes(field.type, SELECT_FIELDS)) {
|
|
145
|
+
const selectValue = path(['innerHTML'], document.querySelector(`#field-${input.name} .jobot-forms-rc-select-selection-item`));
|
|
146
|
+
|
|
147
|
+
if (selectValue) {
|
|
148
|
+
input.value = selectValue;
|
|
149
|
+
input.setAttribute('value', selectValue);
|
|
150
|
+
}
|
|
107
151
|
}
|
|
108
152
|
}
|
|
109
153
|
}, inputs);
|
|
@@ -154,7 +198,7 @@ class HtmlOpdForm extends Component {
|
|
|
154
198
|
input.setAttribute('value', input.value);
|
|
155
199
|
|
|
156
200
|
const field = find(propEq('field', input.name), this.props.formFields);
|
|
157
|
-
if (field && field.type
|
|
201
|
+
if (field && includes(field.type, TEXT_FIELDS)) {
|
|
158
202
|
form.change(input.name, input.value);
|
|
159
203
|
}
|
|
160
204
|
}
|
|
@@ -196,7 +240,7 @@ class HtmlOpdForm extends Component {
|
|
|
196
240
|
|
|
197
241
|
export class HtmlOpdFormClear extends Component {
|
|
198
242
|
componentDidUpdate(prevProps) {
|
|
199
|
-
if (prevProps.value && !equals(prevProps.values, this.props.values)) {
|
|
243
|
+
if (prevProps.value && !prevProps.open && !equals(prevProps.values, this.props.values)) {
|
|
200
244
|
this.props.onSubmitHtml();
|
|
201
245
|
}
|
|
202
246
|
}
|
|
@@ -14,7 +14,7 @@ import { FormContext } from '../../context/FormContext';
|
|
|
14
14
|
import { getAttrs } from '../../utils/attrs';
|
|
15
15
|
|
|
16
16
|
const getConstructorOpd = (opdSettings, language) => {
|
|
17
|
-
const opdConstructor =
|
|
17
|
+
const opdConstructor = pathOr([], ['data', 'opdConstructor'], opdSettings);
|
|
18
18
|
|
|
19
19
|
const text = (opdConstructor || []).reduce((res, cur) => {
|
|
20
20
|
switch (cur.type) {
|
|
@@ -25,7 +25,7 @@ const getConstructorOpd = (opdSettings, language) => {
|
|
|
25
25
|
case 'checkbox':
|
|
26
26
|
return `${res}<p>
|
|
27
27
|
<input type="checkbox" id="${`checkbox-${cur.id}`}" ${cur.required ? 'required="required"' : ''} />
|
|
28
|
-
<label for="${`checkbox-${cur.id}`}">${cur.label || ''}
|
|
28
|
+
<label for="${`checkbox-${cur.id}`}">${cur.label || ''}</label>
|
|
29
29
|
</p>`;
|
|
30
30
|
case 'opdCheckbox':
|
|
31
31
|
return `${res}<p>
|
|
@@ -168,6 +168,7 @@ class PersonalDataAgreementComponent extends Component {
|
|
|
168
168
|
<FormSpy subscription={['values']}>
|
|
169
169
|
{ formProps => (
|
|
170
170
|
<HtmlOpdFormClear
|
|
171
|
+
open={this.state.openedHtml}
|
|
171
172
|
value={this.props.input.value}
|
|
172
173
|
values={this.getOpdValues(formProps)}
|
|
173
174
|
onSubmitHtml={this.onSubmitHtml}
|
|
@@ -66,7 +66,7 @@ export const TRANSLATIONS = {
|
|
|
66
66
|
'composite': 'Required block',
|
|
67
67
|
'incompleteDate': 'Full date is required',
|
|
68
68
|
'captchaRequired': 'Verification required',
|
|
69
|
-
'incorrectBirthDate': 'Date
|
|
69
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date',
|
|
70
70
|
},
|
|
71
71
|
'invalidCaptcha': 'Invalid captcha'
|
|
72
72
|
},
|
|
@@ -138,7 +138,7 @@ export const TRANSLATIONS = {
|
|
|
138
138
|
'composite': 'Блок обязателен для заполнения',
|
|
139
139
|
'incompleteDate': 'Необходимо указать дату полностью',
|
|
140
140
|
'captchaRequired': 'Необходимо пройти проверку',
|
|
141
|
-
'incorrectBirthDate': 'Дата
|
|
141
|
+
'incorrectBirthDate': 'Дата не может быть меньше даты рождения',
|
|
142
142
|
},
|
|
143
143
|
'invalidCaptcha': 'Неверно введена капча'
|
|
144
144
|
},
|
|
@@ -210,7 +210,7 @@ export const TRANSLATIONS = {
|
|
|
210
210
|
'composite': 'Блок обов\'язковий для заповнення',
|
|
211
211
|
'incompleteDate': 'Необхідно вказати дату повністю',
|
|
212
212
|
'captchaRequired': 'Необхідно пройти перевірку',
|
|
213
|
-
'incorrectBirthDate': 'Date
|
|
213
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date',
|
|
214
214
|
},
|
|
215
215
|
'invalidCaptcha': 'Невірно введена капча'
|
|
216
216
|
},
|
|
@@ -281,7 +281,7 @@ export const TRANSLATIONS = {
|
|
|
281
281
|
'composite': 'Nõutav plokk',
|
|
282
282
|
'incompleteDate': 'Täiskuupäev on kohustuslik',
|
|
283
283
|
'captchaRequired': 'Nõutav kontrollimine',
|
|
284
|
-
'incorrectBirthDate': 'Date
|
|
284
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date',
|
|
285
285
|
},
|
|
286
286
|
'invalidCaptcha': 'Sisestati sobimatu captcha'
|
|
287
287
|
},
|
|
@@ -352,7 +352,7 @@ export const TRANSLATIONS = {
|
|
|
352
352
|
'composite': 'Nepieciešamais bloks',
|
|
353
353
|
'incompleteDate': 'Nepieciešams norādīt pilnu datumu',
|
|
354
354
|
'captchaRequired': 'Nepieciešama verifikācija',
|
|
355
|
-
'incorrectBirthDate': 'Date
|
|
355
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date',
|
|
356
356
|
},
|
|
357
357
|
'invalidCaptcha': 'Ievadīta nederīga captcha'
|
|
358
358
|
},
|
|
@@ -423,7 +423,7 @@ export const TRANSLATIONS = {
|
|
|
423
423
|
'composite': 'Reikalingas blokas',
|
|
424
424
|
'incompleteDate': 'Būtina nurodyti visą datą',
|
|
425
425
|
'captchaRequired': 'Būtina patvirtinti',
|
|
426
|
-
'incorrectBirthDate': 'Date
|
|
426
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date',
|
|
427
427
|
},
|
|
428
428
|
'invalidCaptcha': 'Įvesta netinkama captcha'
|
|
429
429
|
},
|
|
@@ -495,7 +495,7 @@ export const TRANSLATIONS = {
|
|
|
495
495
|
'composite': 'Блок қажет',
|
|
496
496
|
'incompleteDate': 'Сіз толық күнді көрсетуіңіз керек',
|
|
497
497
|
'captchaRequired': 'Тексеру қажет',
|
|
498
|
-
'incorrectBirthDate': 'Date
|
|
498
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date',
|
|
499
499
|
},
|
|
500
500
|
'invalidCaptcha': 'Жарамсыз captcha енгізілді'
|
|
501
501
|
},
|
|
@@ -567,7 +567,7 @@ export const TRANSLATIONS = {
|
|
|
567
567
|
'composite': 'จำเป็นต้องบล็อก',
|
|
568
568
|
'incompleteDate': 'คุณต้องระบุวันที่แบบเต็ม',
|
|
569
569
|
'captchaRequired': 'ต้องยืนยัน',
|
|
570
|
-
'incorrectBirthDate': 'Date
|
|
570
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date',
|
|
571
571
|
},
|
|
572
572
|
'validCaptcha': 'ป้อน captcha ไม่ถูกต้อง'
|
|
573
573
|
},
|
|
@@ -639,7 +639,7 @@ export const TRANSLATIONS = {
|
|
|
639
639
|
'composite': 'Bloklash shart',
|
|
640
640
|
'incompleteDate': 'To\'liq sanani ko\'rsatish kerak',
|
|
641
641
|
'captchaRequired': 'Tasdiqlash kerak',
|
|
642
|
-
'incorrectBirthDate': 'Date
|
|
642
|
+
'incorrectBirthDate': 'Date cant be earlier then birth date',
|
|
643
643
|
},
|
|
644
644
|
'invalidCaptcha': "Noto'g'ri captcha kiritildi"
|
|
645
645
|
},
|
package/src/utils/validation.js
CHANGED
|
@@ -9,6 +9,8 @@ import i18n from './i18n';
|
|
|
9
9
|
import { EMAIL_EXPERIUM, EMAIL_DOMAIN, EMAIL_RFC, EMAIL_RFC_LOCALPART } from '../constants/regexps';
|
|
10
10
|
import { defaultAllowFileExtensions, VALIDATION_FILE_TYPES } from '../constants/allowFileExtensions';
|
|
11
11
|
|
|
12
|
+
const checkDate = value => !value || value === 'incomplete';
|
|
13
|
+
|
|
12
14
|
export const checkFileType = (fileType, mimeType, allowFileExtensions = {}) => {
|
|
13
15
|
switch (fileType) {
|
|
14
16
|
case 'audio':
|
|
@@ -216,38 +218,27 @@ const rules = {
|
|
|
216
218
|
test: value => value !== 'incomplete'
|
|
217
219
|
}),
|
|
218
220
|
};
|
|
219
|
-
const incorrectBirthDateLinked = {
|
|
220
|
-
experience: ['experienceStart', 'experienceEnd'],
|
|
221
|
-
courses: ['courseYearEnd'],
|
|
222
|
-
education: ['yearEnd'],
|
|
223
|
-
};
|
|
224
221
|
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return true;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const date = moment(value, 'DD.MM.YYYY');
|
|
235
|
-
let valid = true;
|
|
236
|
-
forEach(block => {
|
|
237
|
-
if (form[block]) {
|
|
238
|
-
forEach(blockItem => {
|
|
239
|
-
forEach(linkedField => {
|
|
240
|
-
if (blockItem[linkedField]) {
|
|
241
|
-
const linkedDate = moment(blockItem[linkedField], block === 'experience' ? 'MM.YYYY' : 'YYYY');
|
|
242
|
-
valid = valid ? linkedDate.isAfter(date) : valid;
|
|
243
|
-
}
|
|
244
|
-
}, incorrectBirthDateLinked[block]);
|
|
245
|
-
}, form[block]);
|
|
246
|
-
}
|
|
247
|
-
}, keys(incorrectBirthDateLinked));
|
|
248
|
-
return valid;
|
|
222
|
+
const validateBirthDate = format => (rule, form) => rule.test({
|
|
223
|
+
name: 'incorrectBirthDate',
|
|
224
|
+
message: i18n.t('errors.incorrectBirthDate'),
|
|
225
|
+
test: value => {
|
|
226
|
+
if (checkDate(value) || checkDate(form.birthDate)) {
|
|
227
|
+
return true;
|
|
249
228
|
}
|
|
250
|
-
|
|
229
|
+
|
|
230
|
+
const birthDate = moment(form.birthDate, 'DD.MM.YYYY');
|
|
231
|
+
const date = moment(value, format);
|
|
232
|
+
|
|
233
|
+
return date.isAfter(birthDate);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const additionalRules = {
|
|
238
|
+
yearEnd: validateBirthDate('YYYY'),
|
|
239
|
+
courseYearEnd: validateBirthDate('YYYY'),
|
|
240
|
+
experienceStart: validateBirthDate('DD.YYYY'),
|
|
241
|
+
experienceEnd: validateBirthDate('DD.YYYY'),
|
|
251
242
|
};
|
|
252
243
|
|
|
253
244
|
export const validate = (value, form, field, fieldsWithoutValidation, props) => {
|
|
@@ -258,6 +249,7 @@ export const validate = (value, form, field, fieldsWithoutValidation, props) =>
|
|
|
258
249
|
rule = (field.type === 'personalDataAgreement') ? rule.nullable().required(() => i18n.t('errors.required')) : (
|
|
259
250
|
(field.required || validateLink(field, form)) && !fieldsWithoutValidation[field.field] ? rule.nullable().required(() => i18n.t('errors.required')) : rule.nullable()
|
|
260
251
|
);
|
|
252
|
+
|
|
261
253
|
rule = customValidation ? customValidation(rule, form) : rule;
|
|
262
254
|
|
|
263
255
|
rule.validateSync(value);
|