@subiz/widget-v4 4.1.141 → 4.1.142
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/assets/img/stars_v2.png +0 -0
- package/assets/less/form-page.less +1 -1
- package/assets/less/form.less +79 -0
- package/compiled_src/form/Form.js +19 -5
- package/compiled_src/form/rating-stars.js +129 -0
- package/package.json +1 -1
- package/src/chatbox/FormAttachment2.js +83 -0
- package/src/form/Form.js +54 -36
- package/src/form/FormPage.js +81 -1
- package/src/form/rating-stars.js +89 -0
- package/compiled_src/store/store.js +0 -1257
- package/compiled_src/util/campaign.js +0 -88
- package/compiled_src/util/common.js +0 -1294
- package/compiled_src/util/common.test.js +0 -496
- package/compiled_src/util/extractor.test.js +0 -299
- package/compiled_src/util/gate.js +0 -38
- package/compiled_src/util/gate.test.js +0 -18
- package/compiled_src/util/index.js +0 -20
- package/compiled_src/util/mutex.js +0 -31
- package/compiled_src/util/op.js +0 -55
- package/compiled_src/util/pubsub.js +0 -29
- package/compiled_src/util/pubsub.test.js +0 -35
|
Binary file
|
package/assets/less/form.less
CHANGED
|
@@ -496,3 +496,82 @@ select {
|
|
|
496
496
|
select.form-control.form-control--empty {
|
|
497
497
|
.color(@text-muted);
|
|
498
498
|
}
|
|
499
|
+
|
|
500
|
+
@media only screen and (min-width: 968px) {
|
|
501
|
+
.form-radios-wrapper.horizontal {
|
|
502
|
+
display: flex;
|
|
503
|
+
flex-wrap: wrap;
|
|
504
|
+
|
|
505
|
+
.radio {
|
|
506
|
+
margin-right: 10px;
|
|
507
|
+
width: 300px; // form wrapper width is 620px
|
|
508
|
+
|
|
509
|
+
&:first-child {
|
|
510
|
+
margin-top: 0;
|
|
511
|
+
}
|
|
512
|
+
&:nth-child(2) {
|
|
513
|
+
margin-top: 0;
|
|
514
|
+
}
|
|
515
|
+
&:nth-child(2n) {
|
|
516
|
+
margin-right: 0;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
.form-checkboxes-wrapper.horizontal {
|
|
522
|
+
display: flex;
|
|
523
|
+
flex-wrap: wrap;
|
|
524
|
+
|
|
525
|
+
.checkbox {
|
|
526
|
+
margin-right: 10px;
|
|
527
|
+
width: 300px; // form wrapper width is 620px
|
|
528
|
+
|
|
529
|
+
&:first-child {
|
|
530
|
+
margin-top: 0;
|
|
531
|
+
}
|
|
532
|
+
&:nth-child(2) {
|
|
533
|
+
margin-top: 0;
|
|
534
|
+
}
|
|
535
|
+
&:nth-child(2n) {
|
|
536
|
+
margin-right: 0;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.form-ratings-wrapper {
|
|
543
|
+
display: inline-flex;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
.star {
|
|
547
|
+
width: 32px; // please keep widthxheight always 32x30
|
|
548
|
+
height: 30px;
|
|
549
|
+
background-image: url('../img/stars_v2.png');
|
|
550
|
+
background-position: 0px 0px;
|
|
551
|
+
background-size: cover;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.form-wrapper-attachment .star-wrapper {
|
|
555
|
+
padding-right: 12px;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
.star-wrapper {
|
|
559
|
+
cursor: pointer;
|
|
560
|
+
padding-right: 20px;
|
|
561
|
+
&:last-child {
|
|
562
|
+
padding-right: 0;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
&.hovering {
|
|
566
|
+
.star {
|
|
567
|
+
background-position: -32px 0;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
&.selected {
|
|
572
|
+
cursor: auto;
|
|
573
|
+
.star {
|
|
574
|
+
background-position: -64px 0;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
@@ -8,6 +8,7 @@ var _common = require("../common.js");
|
|
|
8
8
|
var _preact = require("preact");
|
|
9
9
|
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
10
10
|
var _block = _interopRequireDefault(require("../chatbox/block.js"));
|
|
11
|
+
var _ratingStars = _interopRequireDefault(require("./rating-stars.js"));
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
14
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
@@ -63,7 +64,7 @@ class Form2 extends _common.Com {
|
|
|
63
64
|
class: "label"
|
|
64
65
|
}, com.label, " ", com.is_required && (0, _preact.h)("span", {
|
|
65
66
|
class: "red"
|
|
66
|
-
}, "*")), com.input_type === 'text' && this.renderFieldTextInput(com, idx), com.input_type === 'textarea' && this.renderFieldTextareaInput(com, idx), com.input_type === 'date' && this.renderFieldDateInput(com, idx), com.input_type === 'radio' && this.renderFieldRadioInput(com, idx), com.input_type === 'checkbox' && this.renderFieldCheckboxInput(com, idx), (com.input_type === 'dropdown' || com.input_type === 'select') && this.renderFieldDropdownInput(com, idx), errorMsg && (0, _preact.h)("div", {
|
|
67
|
+
}, "*")), com.input_type === 'text' && this.renderFieldTextInput(com, idx), com.input_type === 'textarea' && this.renderFieldTextareaInput(com, idx), com.input_type === 'date' && this.renderFieldDateInput(com, idx), com.input_type === 'radio' && this.renderFieldRadioInput(com, idx), com.input_type === 'checkbox' && this.renderFieldCheckboxInput(com, idx), (com.input_type === 'dropdown' || com.input_type === 'select') && this.renderFieldDropdownInput(com, idx), com.input_type === 'rating' && this.renderFieldRatingInput(com, idx), errorMsg && (0, _preact.h)("div", {
|
|
67
68
|
class: "form-control--valid-input--error"
|
|
68
69
|
}, errorMsg));
|
|
69
70
|
});
|
|
@@ -106,7 +107,11 @@ class Form2 extends _common.Com {
|
|
|
106
107
|
let val = _index.default.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
107
108
|
val = val.value || '""';
|
|
108
109
|
val = _index.default.parseJSON(val);
|
|
109
|
-
|
|
110
|
+
let wrappercls = 'form-radios-wrapper';
|
|
111
|
+
if (_index.default.size(com.input_options) >= 3 && this.props.mode !== 'attachment') wrappercls += ' horizontal';
|
|
112
|
+
return (0, _preact.h)("div", {
|
|
113
|
+
class: wrappercls
|
|
114
|
+
}, _index.default.map(com.input_options, (option, oidx) => {
|
|
110
115
|
let id = com.key + '_' + oidx;
|
|
111
116
|
return (0, _preact.h)("div", {
|
|
112
117
|
class: "radio"
|
|
@@ -122,13 +127,17 @@ class Form2 extends _common.Com {
|
|
|
122
127
|
}, option.label), (0, _preact.h)("div", {
|
|
123
128
|
class: "radio--check"
|
|
124
129
|
}));
|
|
125
|
-
});
|
|
130
|
+
}));
|
|
126
131
|
});
|
|
127
132
|
_defineProperty(this, "renderFieldCheckboxInput", (com, idx) => {
|
|
128
133
|
let val = _index.default.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
129
134
|
val = val.value || '[]';
|
|
130
135
|
val = _index.default.parseJSON(val);
|
|
131
|
-
|
|
136
|
+
let wrappercls = 'form-checkboxes-wrapper';
|
|
137
|
+
if (_index.default.size(com.input_options) >= 3 && this.props.mode !== 'attachment') wrappercls += ' horizontal';
|
|
138
|
+
return (0, _preact.h)("div", {
|
|
139
|
+
class: wrappercls
|
|
140
|
+
}, _index.default.map(com.input_options, (option, oidx) => {
|
|
132
141
|
let id = com.key + '_' + oidx;
|
|
133
142
|
return (0, _preact.h)("div", {
|
|
134
143
|
class: "checkbox"
|
|
@@ -144,7 +153,7 @@ class Form2 extends _common.Com {
|
|
|
144
153
|
}, option.label), (0, _preact.h)("div", {
|
|
145
154
|
class: "checkbox--check"
|
|
146
155
|
}));
|
|
147
|
-
});
|
|
156
|
+
}));
|
|
148
157
|
});
|
|
149
158
|
_defineProperty(this, "renderFieldDropdownInput", (com, idx) => {
|
|
150
159
|
let val = _index.default.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
@@ -183,6 +192,11 @@ class Form2 extends _common.Com {
|
|
|
183
192
|
placeholder: com.placeholder
|
|
184
193
|
});
|
|
185
194
|
});
|
|
195
|
+
_defineProperty(this, "renderFieldRatingInput", (com, idx) => {
|
|
196
|
+
return (0, _preact.h)(_ratingStars.default, {
|
|
197
|
+
onChange: v => this.onChangeValue(com.key, v)
|
|
198
|
+
});
|
|
199
|
+
});
|
|
186
200
|
_defineProperty(this, "onSubmit", e => {
|
|
187
201
|
e.preventDefault();
|
|
188
202
|
if (!this.validateForm()) return;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _common = require("../common.js");
|
|
8
|
+
var _preact = require("preact");
|
|
9
|
+
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
class Form2 extends _common.Com {
|
|
15
|
+
constructor(props) {
|
|
16
|
+
super(props);
|
|
17
|
+
_defineProperty(this, "state", {
|
|
18
|
+
hovering: 0,
|
|
19
|
+
selected: 0
|
|
20
|
+
});
|
|
21
|
+
_defineProperty(this, "onMouseEnter", v => {
|
|
22
|
+
let {
|
|
23
|
+
selected,
|
|
24
|
+
hovering
|
|
25
|
+
} = this.state;
|
|
26
|
+
if (v <= selected) {
|
|
27
|
+
this.setState({
|
|
28
|
+
hovering: selected
|
|
29
|
+
});
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.setState({
|
|
33
|
+
hovering: v
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
_defineProperty(this, "onMouseLeave", () => {
|
|
37
|
+
let {
|
|
38
|
+
selected,
|
|
39
|
+
hovering
|
|
40
|
+
} = this.state;
|
|
41
|
+
this.setState({
|
|
42
|
+
hovering: 0
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
onToggleValue(v) {
|
|
47
|
+
let {
|
|
48
|
+
selected
|
|
49
|
+
} = this.state;
|
|
50
|
+
let newVal = v;
|
|
51
|
+
if (v === selected) newVal = 0;
|
|
52
|
+
this.setState({
|
|
53
|
+
selected: newVal,
|
|
54
|
+
hovering: newVal
|
|
55
|
+
});
|
|
56
|
+
this.props.onChange(newVal);
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
let {
|
|
60
|
+
selected,
|
|
61
|
+
hovering
|
|
62
|
+
} = this.state;
|
|
63
|
+
let star1Cls = 'star-wrapper';
|
|
64
|
+
if (selected >= 1) {
|
|
65
|
+
star1Cls += ' selected';
|
|
66
|
+
} else if (hovering >= 1) {
|
|
67
|
+
star1Cls += ' hovering';
|
|
68
|
+
}
|
|
69
|
+
let star2Cls = 'star-wrapper';
|
|
70
|
+
if (selected >= 2) {
|
|
71
|
+
star2Cls += ' selected';
|
|
72
|
+
} else if (hovering >= 2) {
|
|
73
|
+
star2Cls += ' hovering';
|
|
74
|
+
}
|
|
75
|
+
let star3Cls = 'star-wrapper';
|
|
76
|
+
if (selected >= 3) {
|
|
77
|
+
star3Cls += ' selected';
|
|
78
|
+
} else if (hovering >= 3) {
|
|
79
|
+
star3Cls += ' hovering';
|
|
80
|
+
}
|
|
81
|
+
let star4Cls = 'star-wrapper';
|
|
82
|
+
if (selected >= 4) {
|
|
83
|
+
star4Cls += ' selected';
|
|
84
|
+
} else if (hovering >= 4) {
|
|
85
|
+
star4Cls += ' hovering';
|
|
86
|
+
}
|
|
87
|
+
let star5Cls = 'star-wrapper';
|
|
88
|
+
if (selected >= 5) {
|
|
89
|
+
star5Cls += ' selected';
|
|
90
|
+
} else if (hovering >= 5) {
|
|
91
|
+
star5Cls += ' hovering';
|
|
92
|
+
}
|
|
93
|
+
return (0, _preact.h)("div", {
|
|
94
|
+
class: "form-ratings-wrapper",
|
|
95
|
+
onMouseLeave: () => this.onMouseLeave()
|
|
96
|
+
}, (0, _preact.h)("div", {
|
|
97
|
+
class: star1Cls,
|
|
98
|
+
onClick: () => this.onToggleValue(1),
|
|
99
|
+
onMouseEnter: () => this.onMouseEnter(1)
|
|
100
|
+
}, (0, _preact.h)("div", {
|
|
101
|
+
class: "star"
|
|
102
|
+
})), (0, _preact.h)("div", {
|
|
103
|
+
class: star2Cls,
|
|
104
|
+
onClick: () => this.onToggleValue(2),
|
|
105
|
+
onMouseEnter: () => this.onMouseEnter(2)
|
|
106
|
+
}, (0, _preact.h)("div", {
|
|
107
|
+
class: "star"
|
|
108
|
+
})), (0, _preact.h)("div", {
|
|
109
|
+
class: star3Cls,
|
|
110
|
+
onClick: () => this.onToggleValue(3),
|
|
111
|
+
onMouseEnter: () => this.onMouseEnter(3)
|
|
112
|
+
}, (0, _preact.h)("div", {
|
|
113
|
+
class: "star"
|
|
114
|
+
})), (0, _preact.h)("div", {
|
|
115
|
+
class: star4Cls,
|
|
116
|
+
onClick: () => this.onToggleValue(4),
|
|
117
|
+
onMouseEnter: () => this.onMouseEnter(4)
|
|
118
|
+
}, (0, _preact.h)("div", {
|
|
119
|
+
class: "star"
|
|
120
|
+
})), (0, _preact.h)("div", {
|
|
121
|
+
class: star5Cls,
|
|
122
|
+
onClick: () => this.onToggleValue(5),
|
|
123
|
+
onMouseEnter: () => this.onMouseEnter(5)
|
|
124
|
+
}, (0, _preact.h)("div", {
|
|
125
|
+
class: "star"
|
|
126
|
+
})));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.default = Form2;
|
package/package.json
CHANGED
|
@@ -31,6 +31,89 @@ export default class FormAttachment extends Com {
|
|
|
31
31
|
let formSetting = formAttachment.form || {}
|
|
32
32
|
let submission = formAttachment.form_submission || {}
|
|
33
33
|
let isSubmited = sb.size(submission) > 0
|
|
34
|
+
//if (this.props.ev.id === 'evshwmvhbthkrvbceozazgxno') {
|
|
35
|
+
//formSetting = {
|
|
36
|
+
//id: 'atshrpqxzuufzzdkzquz_dlbgwyib',
|
|
37
|
+
//title: 'Đặt lịch khám',
|
|
38
|
+
//components: [
|
|
39
|
+
//{
|
|
40
|
+
//type: 'input',
|
|
41
|
+
//label: 'Họ và tên',
|
|
42
|
+
//input_type: 'text',
|
|
43
|
+
//is_required: true,
|
|
44
|
+
//key: 'fullname',
|
|
45
|
+
//},
|
|
46
|
+
//{
|
|
47
|
+
//type: 'input',
|
|
48
|
+
//label: 'SĐT',
|
|
49
|
+
//input_type: 'text',
|
|
50
|
+
//is_required: true,
|
|
51
|
+
//key: 'phone',
|
|
52
|
+
//},
|
|
53
|
+
//{
|
|
54
|
+
//type: 'input',
|
|
55
|
+
//label: 'Chọn ca',
|
|
56
|
+
//input_type: 'radio',
|
|
57
|
+
//is_required: true,
|
|
58
|
+
//key: 'shift',
|
|
59
|
+
//input_options: [
|
|
60
|
+
//{
|
|
61
|
+
//label: 'Buổi sáng',
|
|
62
|
+
//value: 'Buổi sáng',
|
|
63
|
+
//},
|
|
64
|
+
//{
|
|
65
|
+
//label: 'Buổi chiều',
|
|
66
|
+
//value: 'Buổi chiều',
|
|
67
|
+
//},
|
|
68
|
+
//{
|
|
69
|
+
//label: 'Buổi toi',
|
|
70
|
+
//value: 'Buổi toi',
|
|
71
|
+
//},
|
|
72
|
+
//{
|
|
73
|
+
//label: 'Buổi dem ',
|
|
74
|
+
//value: 'Buổi dem',
|
|
75
|
+
//},
|
|
76
|
+
//{
|
|
77
|
+
//label: 'Other',
|
|
78
|
+
//value: 'Other',
|
|
79
|
+
//},
|
|
80
|
+
//],
|
|
81
|
+
//},
|
|
82
|
+
//{
|
|
83
|
+
//type: 'input',
|
|
84
|
+
//label: 'Chọn ngày',
|
|
85
|
+
//input_type: 'date',
|
|
86
|
+
//is_required: true,
|
|
87
|
+
//key: 'schedule',
|
|
88
|
+
//},
|
|
89
|
+
//{
|
|
90
|
+
//type: 'input',
|
|
91
|
+
//label: 'Đánh giá',
|
|
92
|
+
//label_description: 'Chọn theo thang điểm 1-5',
|
|
93
|
+
//input_type: 'rating',
|
|
94
|
+
//key: 'rating',
|
|
95
|
+
//},
|
|
96
|
+
//{
|
|
97
|
+
//type: 'button',
|
|
98
|
+
//label: 'Đặt lịch',
|
|
99
|
+
//},
|
|
100
|
+
//],
|
|
101
|
+
//primary_color: 'rgb(224, 31, 111)',
|
|
102
|
+
//header_style: {
|
|
103
|
+
//font_family: 'Roboto',
|
|
104
|
+
//font_size: '20',
|
|
105
|
+
//},
|
|
106
|
+
//text_style: {
|
|
107
|
+
//font_family: 'Yeseva One',
|
|
108
|
+
//font_size: '16',
|
|
109
|
+
//},
|
|
110
|
+
//input_style: {
|
|
111
|
+
//font_family: 'Dancing Script',
|
|
112
|
+
//font_size: '18',
|
|
113
|
+
//},
|
|
114
|
+
|
|
115
|
+
//}
|
|
116
|
+
//}
|
|
34
117
|
this.setState({formSetting, submission, isSubmited})
|
|
35
118
|
}
|
|
36
119
|
|
package/src/form/Form.js
CHANGED
|
@@ -2,6 +2,7 @@ import {Com} from '../common.js'
|
|
|
2
2
|
import {h, createRef, Fragment} from 'preact'
|
|
3
3
|
import sb from '../util/index.js'
|
|
4
4
|
import Block from '../chatbox/block.js'
|
|
5
|
+
import RatingStars from './rating-stars.js'
|
|
5
6
|
|
|
6
7
|
export default class Form2 extends Com {
|
|
7
8
|
state = {
|
|
@@ -71,6 +72,7 @@ export default class Form2 extends Com {
|
|
|
71
72
|
{com.input_type === 'radio' && this.renderFieldRadioInput(com, idx)}
|
|
72
73
|
{com.input_type === 'checkbox' && this.renderFieldCheckboxInput(com, idx)}
|
|
73
74
|
{(com.input_type === 'dropdown' || com.input_type === 'select') && this.renderFieldDropdownInput(com, idx)}
|
|
75
|
+
{com.input_type === 'rating' && this.renderFieldRatingInput(com, idx)}
|
|
74
76
|
{errorMsg && <div class='form-control--valid-input--error'>{errorMsg}</div>}
|
|
75
77
|
</div>
|
|
76
78
|
)
|
|
@@ -121,48 +123,60 @@ export default class Form2 extends Com {
|
|
|
121
123
|
let val = sb.find(this.props.submission.values, (f) => f.key === com.key) || {}
|
|
122
124
|
val = val.value || '""'
|
|
123
125
|
val = sb.parseJSON(val)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
126
|
+
let wrappercls = 'form-radios-wrapper'
|
|
127
|
+
if (sb.size(com.input_options) >= 3 && this.props.mode !== 'attachment') wrappercls += ' horizontal'
|
|
128
|
+
return (
|
|
129
|
+
<div class={wrappercls}>
|
|
130
|
+
{sb.map(com.input_options, (option, oidx) => {
|
|
131
|
+
let id = com.key + '_' + oidx
|
|
132
|
+
return (
|
|
133
|
+
<div class='radio'>
|
|
134
|
+
<input
|
|
135
|
+
type='radio'
|
|
136
|
+
name={com.key}
|
|
137
|
+
id={id}
|
|
138
|
+
checked={option.value === val}
|
|
139
|
+
onChange={() => this.toggleRadioField(com.key, option.value)}
|
|
140
|
+
/>
|
|
141
|
+
<label class='radio--label' for={id}>
|
|
142
|
+
{option.label}
|
|
143
|
+
</label>
|
|
144
|
+
<div class='radio--check' />
|
|
145
|
+
</div>
|
|
146
|
+
)
|
|
147
|
+
})}
|
|
148
|
+
</div>
|
|
149
|
+
)
|
|
142
150
|
}
|
|
143
151
|
|
|
144
152
|
renderFieldCheckboxInput = (com, idx) => {
|
|
145
153
|
let val = sb.find(this.props.submission.values, (f) => f.key === com.key) || {}
|
|
146
154
|
val = val.value || '[]'
|
|
147
155
|
val = sb.parseJSON(val)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
156
|
+
let wrappercls = 'form-checkboxes-wrapper'
|
|
157
|
+
if (sb.size(com.input_options) >= 3 && this.props.mode !== 'attachment') wrappercls += ' horizontal'
|
|
158
|
+
return (
|
|
159
|
+
<div class={wrappercls}>
|
|
160
|
+
{sb.map(com.input_options, (option, oidx) => {
|
|
161
|
+
let id = com.key + '_' + oidx
|
|
162
|
+
return (
|
|
163
|
+
<div class='checkbox'>
|
|
164
|
+
<input
|
|
165
|
+
type='checkbox'
|
|
166
|
+
name={com.key}
|
|
167
|
+
id={id}
|
|
168
|
+
checked={val.includes(option.value)}
|
|
169
|
+
onChange={() => this.toggleCheckboxField(com.key, option.value)}
|
|
170
|
+
/>
|
|
171
|
+
<label class='checkbox--label' for={id}>
|
|
172
|
+
{option.label}
|
|
173
|
+
</label>
|
|
174
|
+
<div class='checkbox--check' />
|
|
175
|
+
</div>
|
|
176
|
+
)
|
|
177
|
+
})}
|
|
178
|
+
</div>
|
|
179
|
+
)
|
|
166
180
|
}
|
|
167
181
|
|
|
168
182
|
renderFieldDropdownInput = (com, idx) => {
|
|
@@ -207,6 +221,10 @@ export default class Form2 extends Com {
|
|
|
207
221
|
)
|
|
208
222
|
}
|
|
209
223
|
|
|
224
|
+
renderFieldRatingInput = (com, idx) => {
|
|
225
|
+
return <RatingStars onChange={(v) => this.onChangeValue(com.key, v)} />
|
|
226
|
+
}
|
|
227
|
+
|
|
210
228
|
onSubmit = (e) => {
|
|
211
229
|
e.preventDefault()
|
|
212
230
|
if (!this.validateForm()) return
|
package/src/form/FormPage.js
CHANGED
|
@@ -98,6 +98,86 @@ export default class FormPage extends Com {
|
|
|
98
98
|
let json = atob(this.props.previewJson)
|
|
99
99
|
json = decodeURIComponent(json)
|
|
100
100
|
json = sb.parseJSON(json)
|
|
101
|
+
//json = {
|
|
102
|
+
//id: 'atshrpqxzuufzzdkzquz_dlbgwyib',
|
|
103
|
+
//title: 'Đặt lịch khám',
|
|
104
|
+
//components: [
|
|
105
|
+
//{
|
|
106
|
+
//type: 'input',
|
|
107
|
+
//label: 'Họ và tên',
|
|
108
|
+
//input_type: 'text',
|
|
109
|
+
//is_required: true,
|
|
110
|
+
//key: 'fullname',
|
|
111
|
+
//},
|
|
112
|
+
//{
|
|
113
|
+
//type: 'input',
|
|
114
|
+
//label: 'SĐT',
|
|
115
|
+
//input_type: 'text',
|
|
116
|
+
//is_required: true,
|
|
117
|
+
//key: 'phone',
|
|
118
|
+
//},
|
|
119
|
+
//{
|
|
120
|
+
//type: 'input',
|
|
121
|
+
//label: 'Chọn ca',
|
|
122
|
+
//input_type: 'radio',
|
|
123
|
+
//is_required: true,
|
|
124
|
+
//key: 'shift',
|
|
125
|
+
//input_options: [
|
|
126
|
+
//{
|
|
127
|
+
//label: 'Buổi sáng',
|
|
128
|
+
//value: 'Buổi sáng',
|
|
129
|
+
//},
|
|
130
|
+
//{
|
|
131
|
+
//label: 'Buổi chiều',
|
|
132
|
+
//value: 'Buổi chiều',
|
|
133
|
+
//},
|
|
134
|
+
//{
|
|
135
|
+
//label: 'Buổi toi',
|
|
136
|
+
//value: 'Buổi toi',
|
|
137
|
+
//},
|
|
138
|
+
//{
|
|
139
|
+
//label: 'Buổi dem ',
|
|
140
|
+
//value: 'Buổi dem',
|
|
141
|
+
//},
|
|
142
|
+
//{
|
|
143
|
+
//label: 'Other',
|
|
144
|
+
//value: 'Other',
|
|
145
|
+
//},
|
|
146
|
+
//],
|
|
147
|
+
//},
|
|
148
|
+
//{
|
|
149
|
+
//type: 'input',
|
|
150
|
+
//label: 'Chọn ngày',
|
|
151
|
+
//input_type: 'date',
|
|
152
|
+
//is_required: true,
|
|
153
|
+
//key: 'schedule',
|
|
154
|
+
//},
|
|
155
|
+
//{
|
|
156
|
+
//type: 'input',
|
|
157
|
+
//label: 'Đánh giá',
|
|
158
|
+
//label_description: 'Chọn theo thang điểm 1-5',
|
|
159
|
+
//input_type: 'rating',
|
|
160
|
+
//key: 'rating',
|
|
161
|
+
//},
|
|
162
|
+
//{
|
|
163
|
+
//type: 'button',
|
|
164
|
+
//label: 'Đặt lịch',
|
|
165
|
+
//},
|
|
166
|
+
//],
|
|
167
|
+
//primary_color: 'rgb(224, 31, 111)',
|
|
168
|
+
//header_style: {
|
|
169
|
+
//font_family: 'Roboto',
|
|
170
|
+
//font_size: '20',
|
|
171
|
+
//},
|
|
172
|
+
//text_style: {
|
|
173
|
+
//font_family: 'Yeseva One',
|
|
174
|
+
//font_size: '16',
|
|
175
|
+
//},
|
|
176
|
+
//input_style: {
|
|
177
|
+
//font_family: 'Dancing Script',
|
|
178
|
+
//font_size: '18',
|
|
179
|
+
//},
|
|
180
|
+
//}
|
|
101
181
|
await this.insertCss(chatbox, json)
|
|
102
182
|
this.setState({formSetting: json, loading: false})
|
|
103
183
|
return
|
|
@@ -170,7 +250,7 @@ export default class FormPage extends Com {
|
|
|
170
250
|
let brandLogo = sb.get(formSetting, 'logo.url')
|
|
171
251
|
let coverUrl = sb.get(formSetting, 'cover_image.url')
|
|
172
252
|
//coverUrl =
|
|
173
|
-
|
|
253
|
+
//'https://lh7-us.googleusercontent.com/fX5mhofX-12ygFkS6I3UbMh6_NYtd7ySVQkuFxm7Y7ArYMvWu_Ew65l4Ic3QC8eMaBJpUU_5ZNITgigAbqkNJcQRbPjnddxGGE7YOaNBACoWws7b6AuNaAjlisDDY3GCvPHFhh-99Jt0SBiJKnNloWrxxdel_EkVI6MMf6ENTwj2NDQ8MvkCI8ow6z75pwK9C1ZMxDZn?key=-6fBH6GC0hPnLatLRgG5tA'
|
|
174
254
|
let wrappercls = 'form-page'
|
|
175
255
|
if (coverUrl) wrappercls += ' sketch'
|
|
176
256
|
return (
|