@subiz/widget-v4 4.1.141 → 4.1.143
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/chatbox/Widget.js +2 -2
- package/compiled_src/form/Form.js +19 -5
- package/compiled_src/form/rating-stars.js +129 -0
- package/dist/19680dc0775.278.js +1 -0
- package/dist/19680dc0775.app.js +1 -0
- package/dist/19680dc0775.form.html +1 -0
- package/dist/19680dc0775.form.js +1 -0
- package/dist/{1967c022bc1.index.html → 19680dc0775.index.html} +1 -1
- package/dist/{1967c022bc1.library.html → 19680dc0775.library.html} +1 -1
- package/dist/19680dc0775.library.js +1 -0
- package/dist/{1967c022bc1.preview.html → 19680dc0775.preview.html} +1 -1
- package/dist/19680dc0775.preview.js +1 -0
- package/dist/19680dc0775.webview.js +1 -0
- package/dist/278.js +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.js +79 -90
- package/package.json +1 -1
- package/src/chatbox/FormAttachment2.js +83 -0
- package/src/chatbox/Widget.js +2 -2
- package/src/form/Form.js +54 -36
- package/src/form/FormPage.js +81 -1
- package/src/form/rating-stars.js +89 -0
- package/dist/1967c022bc1.278.js +0 -1
- package/dist/1967c022bc1.app.js +0 -1
- package/dist/1967c022bc1.form.html +0 -1
- package/dist/1967c022bc1.form.js +0 -1
- package/dist/1967c022bc1.library.js +0 -1
- package/dist/1967c022bc1.preview.js +0 -1
- package/dist/1967c022bc1.webview.js +0 -1
- /package/dist/{1967c022bc1.127.js → 19680dc0775.127.js} +0 -0
- /package/dist/{1967c022bc1.132.js → 19680dc0775.132.js} +0 -0
- /package/dist/{1967c022bc1.185.js → 19680dc0775.185.js} +0 -0
- /package/dist/{1967c022bc1.27.js → 19680dc0775.27.js} +0 -0
- /package/dist/{1967c022bc1.459.js → 19680dc0775.459.js} +0 -0
- /package/dist/{1967c022bc1.490.js → 19680dc0775.490.js} +0 -0
- /package/dist/{1967c022bc1.74.js → 19680dc0775.74.js} +0 -0
- /package/dist/{1967c022bc1.997.js → 19680dc0775.997.js} +0 -0
package/dist/HASH
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
19680dc0775
|
package/dist/screenshoot.js
CHANGED
|
@@ -3793,8 +3793,8 @@ function jsonifyTextPlain(param, done) {
|
|
|
3793
3793
|
_defineProperty(this, "list_provinces", () => this.apireq.get(`/accounts/${this.accid}/provinces`));
|
|
3794
3794
|
_defineProperty(this, "list_districts", p => this.apireq.setQuery(p).get(`/accounts/${this.accid}/districts`));
|
|
3795
3795
|
_defineProperty(this, "list_wards", p => this.apireq.setQuery(p).get(`/accounts/${this.accid}/wards`));
|
|
3796
|
-
_defineProperty(this, "checkFormToken", token => this.api41.get(`/submissions/${token}`));
|
|
3797
|
-
_defineProperty(this, "submitForm2", (token, data) => this.api41.post(`/submissions/${token}`, data));
|
|
3796
|
+
_defineProperty(this, "checkFormToken", (accid, token) => this.api41.addQuery('account-id', accid).get(`/submissions/${token}`));
|
|
3797
|
+
_defineProperty(this, "submitForm2", (accid, token, data) => this.api41.addQuery('account-id', accid).post(`/submissions/${token}`, data));
|
|
3798
3798
|
_defineProperty(this, "suggest_address", keyword => this.apireq.setQuery({
|
|
3799
3799
|
keyword: keyword
|
|
3800
3800
|
}).get(`/accounts/${this.accid}/addresses`));
|
|
@@ -4849,8 +4849,8 @@ class Store {
|
|
|
4849
4849
|
store_defineProperty(this, "matchIsOpen", () => !!this.kv.match('isopen'));
|
|
4850
4850
|
store_defineProperty(this, "matchHasManuallyClosed", () => !!this.kv.match('hasManuallyClosed'));
|
|
4851
4851
|
store_defineProperty(this, "matchClosePreviewAt", () => this.kv.match('close_preview_at') || 0);
|
|
4852
|
-
store_defineProperty(this, "checkFormToken", token => this.api.checkFormToken(token));
|
|
4853
|
-
store_defineProperty(this, "submitForm2", (token, data) => this.api.submitForm2(token, data));
|
|
4852
|
+
store_defineProperty(this, "checkFormToken", (accid, token) => this.api.checkFormToken(accid, token));
|
|
4853
|
+
store_defineProperty(this, "submitForm2", (accid, token, data) => this.api.submitForm2(accid, token, data));
|
|
4854
4854
|
store_defineProperty(this, "sendPresence", util/* default */.A.throttle(async () => {
|
|
4855
4855
|
if (this._die) return dieErr;
|
|
4856
4856
|
await this.readyGate.entry();
|
|
@@ -7412,7 +7412,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7412
7412
|
});
|
|
7413
7413
|
Form_defineProperty(this, "renderFormComponent", (com, idx) => {
|
|
7414
7414
|
if (com.type === 'input') return this.renderField(com, idx);
|
|
7415
|
-
if (com.type === '
|
|
7415
|
+
if (com.type === 'button') return this.renderSubmitButton(com, idx);
|
|
7416
7416
|
if (this.props.isSubmited) return;
|
|
7417
7417
|
return (0,preact_module.h)("div", {
|
|
7418
7418
|
class: "form-component form-component-block"
|
|
@@ -7424,8 +7424,8 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7424
7424
|
if (this.props.isSubmited) return;
|
|
7425
7425
|
return (0,preact_module.h)("div", {
|
|
7426
7426
|
class: "form-component form-component-submit-button"
|
|
7427
|
-
}, (0,preact_module.h)("div", {
|
|
7428
|
-
class: "form-control--valid-input--error"
|
|
7427
|
+
}, this.props.errorMessage && (0,preact_module.h)("div", {
|
|
7428
|
+
class: "form-control--valid-input--error mb-1"
|
|
7429
7429
|
}, this.props.errorMessage), (0,preact_module.h)("div", null, (0,preact_module.h)("button", {
|
|
7430
7430
|
class: "btn--start-convo",
|
|
7431
7431
|
disabled: this.props.submiting
|
|
@@ -7434,7 +7434,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7434
7434
|
Form_defineProperty(this, "renderField", (com, idx) => {
|
|
7435
7435
|
let errorMsg = this.state.errorFields[com.key];
|
|
7436
7436
|
if (this.props.isSubmited) {
|
|
7437
|
-
let val = util/* default */.A.find(this.props.
|
|
7437
|
+
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7438
7438
|
val = val.value || '""';
|
|
7439
7439
|
val = util/* default */.A.parseJSON(val);
|
|
7440
7440
|
if (Array.isArray(val)) val = val.join(', ');
|
|
@@ -7461,7 +7461,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7461
7461
|
Form_defineProperty(this, "renderFieldTextInput", (com, idx) => {
|
|
7462
7462
|
let cls = 'form-control';
|
|
7463
7463
|
if (this.state.errorFields[com.key]) cls = 'form-control input--error';
|
|
7464
|
-
let val = util/* default */.A.find(this.props.
|
|
7464
|
+
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7465
7465
|
val = val.value || '""';
|
|
7466
7466
|
val = util/* default */.A.parseJSON(val);
|
|
7467
7467
|
return (0,preact_module.h)("input", {
|
|
@@ -7477,12 +7477,14 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7477
7477
|
});
|
|
7478
7478
|
});
|
|
7479
7479
|
Form_defineProperty(this, "renderFieldDateInput", (com, idx) => {
|
|
7480
|
-
let val = util/* default */.A.find(this.props.
|
|
7480
|
+
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7481
7481
|
val = val.value || '""';
|
|
7482
7482
|
val = util/* default */.A.parseJSON(val);
|
|
7483
|
+
let cls = 'form-control';
|
|
7484
|
+
if (this.state.errorFields[com.key]) cls = 'form-control input--error';
|
|
7483
7485
|
return (0,preact_module.h)("input", {
|
|
7484
7486
|
ref: this[`${com.key}_input`],
|
|
7485
|
-
class:
|
|
7487
|
+
class: cls,
|
|
7486
7488
|
type: "date",
|
|
7487
7489
|
value: val,
|
|
7488
7490
|
onInput: e => {
|
|
@@ -7492,7 +7494,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7492
7494
|
});
|
|
7493
7495
|
});
|
|
7494
7496
|
Form_defineProperty(this, "renderFieldRadioInput", (com, idx) => {
|
|
7495
|
-
let val = util/* default */.A.find(this.props.
|
|
7497
|
+
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7496
7498
|
val = val.value || '""';
|
|
7497
7499
|
val = util/* default */.A.parseJSON(val);
|
|
7498
7500
|
return util/* default */.A.map(com.input_options, (option, oidx) => {
|
|
@@ -7514,7 +7516,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7514
7516
|
});
|
|
7515
7517
|
});
|
|
7516
7518
|
Form_defineProperty(this, "renderFieldCheckboxInput", (com, idx) => {
|
|
7517
|
-
let val = util/* default */.A.find(this.props.
|
|
7519
|
+
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7518
7520
|
val = val.value || '[]';
|
|
7519
7521
|
val = util/* default */.A.parseJSON(val);
|
|
7520
7522
|
return util/* default */.A.map(com.input_options, (option, oidx) => {
|
|
@@ -7536,7 +7538,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7536
7538
|
});
|
|
7537
7539
|
});
|
|
7538
7540
|
Form_defineProperty(this, "renderFieldDropdownInput", (com, idx) => {
|
|
7539
|
-
let val = util/* default */.A.find(this.props.
|
|
7541
|
+
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7540
7542
|
val = val.value || '""';
|
|
7541
7543
|
val = util/* default */.A.parseJSON(val);
|
|
7542
7544
|
return (0,preact_module.h)("select", {
|
|
@@ -7553,7 +7555,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7553
7555
|
}));
|
|
7554
7556
|
});
|
|
7555
7557
|
Form_defineProperty(this, "renderFieldTextareaInput", (com, idx) => {
|
|
7556
|
-
let val = util/* default */.A.find(this.props.
|
|
7558
|
+
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7557
7559
|
val = val.value || '""';
|
|
7558
7560
|
val = util/* default */.A.parseJSON(val);
|
|
7559
7561
|
return (0,preact_module.h)("textarea", {
|
|
@@ -7580,7 +7582,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7580
7582
|
util/* default */.A.each(components, com => {
|
|
7581
7583
|
if (com.type === 'input') {
|
|
7582
7584
|
if (com.is_required) {
|
|
7583
|
-
let val = util/* default */.A.find(this.props.
|
|
7585
|
+
let val = util/* default */.A.find(this.props.submission.values, f => f.key === com.key) || {};
|
|
7584
7586
|
val = val.value || '""';
|
|
7585
7587
|
val = util/* default */.A.parseJSON(val);
|
|
7586
7588
|
if (typeof val === 'string' && !val.trim()) {
|
|
@@ -7604,7 +7606,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7604
7606
|
return result;
|
|
7605
7607
|
});
|
|
7606
7608
|
Form_defineProperty(this, "onChangeValue", (key, v) => {
|
|
7607
|
-
let formValues = this.props.
|
|
7609
|
+
let formValues = util/* default */.A.get(this.props.submission, 'values') || [];
|
|
7608
7610
|
let f = util/* default */.A.find(formValues, field => field.key === key);
|
|
7609
7611
|
if (!f) {
|
|
7610
7612
|
formValues.push({
|
|
@@ -7635,7 +7637,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7635
7637
|
this.onChangeValue(key, v);
|
|
7636
7638
|
}
|
|
7637
7639
|
toggleCheckboxField(key, v) {
|
|
7638
|
-
let currentValues = util/* default */.A.find(this.props.
|
|
7640
|
+
let currentValues = util/* default */.A.find(this.props.submission.values, f => f.key === key) || {};
|
|
7639
7641
|
currentValues = currentValues.value || '[]';
|
|
7640
7642
|
currentValues = util/* default */.A.parseJSON(currentValues);
|
|
7641
7643
|
if (currentValues.includes(v)) {
|
|
@@ -7648,6 +7650,7 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7648
7650
|
}
|
|
7649
7651
|
render() {
|
|
7650
7652
|
let components = util/* default */.A.get(this.props.formSetting, 'components') || [];
|
|
7653
|
+
let title = util/* default */.A.get(this.props.formSetting, 'title') || '';
|
|
7651
7654
|
let cls = 'form-wrapper form';
|
|
7652
7655
|
if (this.props.mode === 'attachment') cls += ' form-wrapper-attachment';
|
|
7653
7656
|
return (0,preact_module.h)("div", {
|
|
@@ -7656,7 +7659,9 @@ class Form2 extends common/* Com */.Mw {
|
|
|
7656
7659
|
class: "form-component"
|
|
7657
7660
|
}, this.props.t('you_have_submitted_info_successfully')), (0,preact_module.h)("form", {
|
|
7658
7661
|
onSubmit: this.onSubmit
|
|
7659
|
-
},
|
|
7662
|
+
}, (0,preact_module.h)("div", {
|
|
7663
|
+
class: "form-component form-component-block"
|
|
7664
|
+
}, title), util/* default */.A.map(components, this.renderFormComponent)));
|
|
7660
7665
|
}
|
|
7661
7666
|
}
|
|
7662
7667
|
;// ./src/chatbox/FormAttachment2.js
|
|
@@ -7670,20 +7675,29 @@ function FormAttachment2_toPrimitive(t, r) { if ("object" != typeof t || !t) ret
|
|
|
7670
7675
|
class FormAttachment extends common/* Com */.Mw {
|
|
7671
7676
|
constructor(props) {
|
|
7672
7677
|
super(props);
|
|
7673
|
-
FormAttachment2_defineProperty(this, "
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7678
|
+
FormAttachment2_defineProperty(this, "fetchFormSetting", () => {
|
|
7679
|
+
let attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments') || [];
|
|
7680
|
+
let formAttachment = util/* default */.A.find(attachments, att => att.type === 'form');
|
|
7681
|
+
if (!formAttachment) return;
|
|
7682
|
+
let url = formAttachment.url;
|
|
7683
|
+
this.token = getUrlParameter(url, 'token');
|
|
7684
|
+
let formSetting = formAttachment.form || {};
|
|
7685
|
+
let submission = formAttachment.form_submission || {};
|
|
7686
|
+
let isSubmited = util/* default */.A.size(submission) > 0;
|
|
7687
|
+
this.setState({
|
|
7688
|
+
formSetting,
|
|
7689
|
+
submission,
|
|
7690
|
+
isSubmited
|
|
7691
|
+
});
|
|
7679
7692
|
});
|
|
7680
7693
|
FormAttachment2_defineProperty(this, "onChangeFormValues", values => {
|
|
7681
7694
|
this.setState({
|
|
7682
|
-
|
|
7695
|
+
submission: {
|
|
7696
|
+
values
|
|
7697
|
+
}
|
|
7683
7698
|
});
|
|
7684
7699
|
});
|
|
7685
7700
|
FormAttachment2_defineProperty(this, "onSubmit", async () => {
|
|
7686
|
-
console.log('submittttttt', this.state.formValues);
|
|
7687
7701
|
this.setState({
|
|
7688
7702
|
errorMessage: ''
|
|
7689
7703
|
});
|
|
@@ -7691,72 +7705,41 @@ class FormAttachment extends common/* Com */.Mw {
|
|
|
7691
7705
|
this.setState({
|
|
7692
7706
|
submiting: true
|
|
7693
7707
|
});
|
|
7694
|
-
|
|
7708
|
+
let res = await this.props.store.submitForm2(this.props.store.matchAccount().id, this.token, this.state.submission);
|
|
7709
|
+
if (res.error) {
|
|
7710
|
+
this.setState({
|
|
7711
|
+
submiting: false,
|
|
7712
|
+
errorMessage: util/* default */.A.get(res, 'error.code')
|
|
7713
|
+
});
|
|
7714
|
+
return;
|
|
7715
|
+
}
|
|
7695
7716
|
this.setState({
|
|
7696
7717
|
submiting: false,
|
|
7697
7718
|
isSubmited: true
|
|
7698
7719
|
});
|
|
7699
7720
|
});
|
|
7721
|
+
this.state = {
|
|
7722
|
+
submission: {},
|
|
7723
|
+
formSetting: {},
|
|
7724
|
+
submiting: false,
|
|
7725
|
+
errorMessage: '',
|
|
7726
|
+
isSubmited: false
|
|
7727
|
+
};
|
|
7728
|
+
}
|
|
7729
|
+
componentDidMount() {
|
|
7730
|
+
this.fetchFormSetting();
|
|
7700
7731
|
}
|
|
7701
7732
|
render() {
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
placeholder: 'Nguyen Van A',
|
|
7713
|
-
label: 'Họ và tên',
|
|
7714
|
-
input_type: 'text',
|
|
7715
|
-
is_required: true
|
|
7716
|
-
}, {
|
|
7717
|
-
type: 'input',
|
|
7718
|
-
key: 'phone',
|
|
7719
|
-
validation: 'phone',
|
|
7720
|
-
label: 'SĐT',
|
|
7721
|
-
input_type: 'text',
|
|
7722
|
-
is_required: true
|
|
7723
|
-
}, {
|
|
7724
|
-
type: 'input',
|
|
7725
|
-
label: 'Chọn ca',
|
|
7726
|
-
is_required: true,
|
|
7727
|
-
input_type: 'radio',
|
|
7728
|
-
key: 'shift',
|
|
7729
|
-
input_options: [{
|
|
7730
|
-
value: 'Buổi sáng',
|
|
7731
|
-
label: 'Buổi sáng'
|
|
7732
|
-
}, {
|
|
7733
|
-
value: 'Buổi chiều',
|
|
7734
|
-
label: 'Buổi chiều'
|
|
7735
|
-
}]
|
|
7736
|
-
}, {
|
|
7737
|
-
type: 'input',
|
|
7738
|
-
label: 'Chọn ca 2',
|
|
7739
|
-
is_required: true,
|
|
7740
|
-
input_type: 'checkbox',
|
|
7741
|
-
key: 'shift_2',
|
|
7742
|
-
input_options: [{
|
|
7743
|
-
value: 'Buổi sáng',
|
|
7744
|
-
label: 'Buổi sáng'
|
|
7745
|
-
}, {
|
|
7746
|
-
value: 'Buổi chiều',
|
|
7747
|
-
label: 'Buổi chiều'
|
|
7748
|
-
}]
|
|
7749
|
-
}, {
|
|
7750
|
-
type: 'input',
|
|
7751
|
-
key: 'schedule',
|
|
7752
|
-
label: 'Chọn ngày',
|
|
7753
|
-
is_required: true,
|
|
7754
|
-
input_type: 'date'
|
|
7755
|
-
}, {
|
|
7756
|
-
type: 'submit_button',
|
|
7757
|
-
label: 'Submit'
|
|
7758
|
-
}]
|
|
7759
|
-
};
|
|
7733
|
+
let attachments = util/* default */.A.get(this.props.ev, 'data.message.attachments') || [];
|
|
7734
|
+
let formAttachment = util/* default */.A.find(attachments, att => att.type === 'form');
|
|
7735
|
+
if (!formAttachment) return;
|
|
7736
|
+
const {
|
|
7737
|
+
submission,
|
|
7738
|
+
formSetting,
|
|
7739
|
+
errorMessage,
|
|
7740
|
+
isSubmited,
|
|
7741
|
+
submiting
|
|
7742
|
+
} = this.state;
|
|
7760
7743
|
return (0,preact_module.h)("div", {
|
|
7761
7744
|
onClick: e => e.stopPropagation()
|
|
7762
7745
|
}, (0,preact_module.h)(Form2, {
|
|
@@ -7764,15 +7747,21 @@ class FormAttachment extends common/* Com */.Mw {
|
|
|
7764
7747
|
formSetting: formSetting,
|
|
7765
7748
|
mode: "attachment",
|
|
7766
7749
|
t: this.props.t,
|
|
7767
|
-
|
|
7768
|
-
errorMessage:
|
|
7769
|
-
isSubmited:
|
|
7770
|
-
submiting:
|
|
7750
|
+
submission: submission,
|
|
7751
|
+
errorMessage: errorMessage,
|
|
7752
|
+
isSubmited: isSubmited,
|
|
7753
|
+
submiting: submiting,
|
|
7771
7754
|
onChangeFormValues: this.onChangeFormValues,
|
|
7772
7755
|
onSubmit: this.onSubmit
|
|
7773
7756
|
}));
|
|
7774
7757
|
}
|
|
7775
7758
|
}
|
|
7759
|
+
function getUrlParameter(url, name) {
|
|
7760
|
+
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
|
|
7761
|
+
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
|
|
7762
|
+
var results = regex.exec(url);
|
|
7763
|
+
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
|
7764
|
+
}
|
|
7776
7765
|
;// ./src/chatbox/FormSubmitAttachments.js
|
|
7777
7766
|
|
|
7778
7767
|
|
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/chatbox/Widget.js
CHANGED
|
@@ -501,9 +501,9 @@ export default class Widget extends Com {
|
|
|
501
501
|
)
|
|
502
502
|
} else if (sb.get(field, 'def.select') === 'checkbox') {
|
|
503
503
|
$field = this.renderCheckboxField(field)
|
|
504
|
-
} else if (sb.get(field, 'def.select') === 'radio') {
|
|
504
|
+
} else if (sb.get(field, 'def.select') === 'radio' && sb.size(sb.get(field, 'def.items', [])) < 5) {
|
|
505
505
|
$field = this.renderRadioField(field)
|
|
506
|
-
} else if (sb.get(field, 'def.select') === 'dropdown') {
|
|
506
|
+
} else if (sb.get(field, 'def.select') === 'dropdown' || sb.size(sb.get(field, 'def.items', [])) >= 5) {
|
|
507
507
|
$field = this.renderDropdownField(field)
|
|
508
508
|
} else {
|
|
509
509
|
$field = (
|
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 (
|