@subiz/widget-v4 4.1.125 → 4.1.129
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/less/avatar.less +7 -3
- package/assets/less/chatbox.less +25 -2
- package/assets/less/form.less +77 -2
- package/assets/less/message.less +4 -0
- package/assets/less/widget.less +20 -0
- package/assets/less/widget_header.less +27 -7
- package/compiled_src/chatbox/ChatButton.js +22 -7
- package/compiled_src/chatbox/ConnectionStatus.js +58 -0
- package/compiled_src/chatbox/Event.js +10 -8
- package/compiled_src/chatbox/FormAttachment2.js +80 -0
- package/compiled_src/chatbox/Header.js +12 -1
- package/compiled_src/chatbox/Widget.js +5 -0
- package/compiled_src/form/Form.js +274 -0
- package/compiled_src/form/FormPage.js +131 -0
- package/compiled_src/form/index.js +72 -0
- package/compiled_src/store/api.js +3 -0
- package/compiled_src/store/realtime_fake.js +4 -0
- package/compiled_src/store/store.js +25 -0
- package/compiled_src/util/campaign.js +3 -5
- package/compiled_src/util/common.js +15 -0
- package/dist/127.js +273 -0
- package/dist/132.js +2575 -6434
- package/dist/185.js +1885 -0
- package/dist/1967c022bc1.127.js +1 -0
- package/dist/1967c022bc1.132.js +1 -0
- package/dist/1967c022bc1.185.js +1 -0
- package/dist/1967c022bc1.27.js +1 -0
- package/dist/1967c022bc1.278.js +1 -0
- package/dist/1967c022bc1.459.js +1 -0
- package/dist/1967c022bc1.490.js +1 -0
- package/dist/1967c022bc1.74.js +1 -0
- package/dist/1967c022bc1.997.js +1 -0
- package/dist/1967c022bc1.app.js +1 -0
- package/dist/1967c022bc1.form.html +1 -0
- package/dist/1967c022bc1.form.js +1 -0
- package/dist/{18a02a9c54e.index.html → 1967c022bc1.index.html} +28 -4
- package/dist/{18a02a9c54e.library.html → 1967c022bc1.library.html} +28 -4
- package/dist/1967c022bc1.library.js +1 -0
- package/dist/{18a02a9c54e.preview.html → 1967c022bc1.preview.html} +1 -1
- package/dist/1967c022bc1.preview.js +1 -0
- package/dist/1967c022bc1.webview.js +1 -0
- package/dist/27.js +107 -0
- package/dist/278.js +406 -0
- package/dist/459.js +107 -0
- package/dist/{605.js → 490.js} +82 -82
- package/dist/{335.js → 74.js} +35 -35
- package/dist/{678.js → 997.js} +6 -6
- package/dist/HASH +1 -1
- package/dist/assets/img/{subiz-mono.877e9f5.svg → subiz-mono.8fbc067.svg} +1 -1
- package/dist/malicious-app.js +6 -4
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +10133 -5182
- package/form.html +10 -0
- package/package.json +5 -4
- package/src/chatbox/ChatButton.js +22 -9
- package/src/chatbox/ConnectionStatus.js +42 -0
- package/src/chatbox/Event.js +10 -10
- package/src/chatbox/FormAttachment2.js +58 -0
- package/src/chatbox/Header.js +15 -0
- package/src/chatbox/Widget.js +2 -0
- package/src/form/Form.js +293 -0
- package/src/form/FormPage.js +95 -0
- package/src/form/index.js +79 -0
- package/src/store/api.js +8 -0
- package/src/store/realtime_fake.js +8 -4
- package/src/store/store.js +29 -0
- package/src/util/campaign.js +3 -5
- package/src/util/common.js +16 -0
- package/webpack.dev.js +2 -0
- package/webpack.prod.js +7 -0
- package/dist/178.js +0 -406
- package/dist/18a02a9c54e.132.js +0 -1
- package/dist/18a02a9c54e.178.js +0 -1
- package/dist/18a02a9c54e.213.js +0 -1
- package/dist/18a02a9c54e.335.js +0 -1
- package/dist/18a02a9c54e.362.js +0 -1
- package/dist/18a02a9c54e.441.js +0 -1
- package/dist/18a02a9c54e.605.js +0 -1
- package/dist/18a02a9c54e.678.js +0 -1
- package/dist/18a02a9c54e.782.js +0 -1
- package/dist/18a02a9c54e.app.js +0 -1
- package/dist/18a02a9c54e.library.js +0 -1
- package/dist/18a02a9c54e.preview.js +0 -1
- package/dist/18a02a9c54e.screenshoot.js +0 -1
- package/dist/18a02a9c54e.webview.js +0 -1
- package/dist/213.js +0 -2780
- package/dist/362.js +0 -107
- package/dist/441.js +0 -2855
- package/dist/782.js +0 -107
package/assets/less/avatar.less
CHANGED
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
border-radius: 35px;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.group-avatar--secondary {
|
|
18
|
-
}
|
|
19
|
-
|
|
20
17
|
.group-avatar--secondary .avatar {
|
|
21
18
|
position: relative;
|
|
22
19
|
width: 35px;
|
|
@@ -24,6 +21,13 @@
|
|
|
24
21
|
border-radius: 35px;
|
|
25
22
|
}
|
|
26
23
|
|
|
24
|
+
.avatar.avatar__account {
|
|
25
|
+
width: 38px;
|
|
26
|
+
height: 38px;
|
|
27
|
+
border-radius: 8px;
|
|
28
|
+
margin-right: @spacer2;
|
|
29
|
+
}
|
|
30
|
+
|
|
27
31
|
.group-avatar--primary .group-avatar--agent-middle {
|
|
28
32
|
width: 50px;
|
|
29
33
|
height: 50px;
|
package/assets/less/chatbox.less
CHANGED
|
@@ -133,10 +133,34 @@ body div#sbz92 {
|
|
|
133
133
|
.align-items-end {
|
|
134
134
|
align-items: flex-end;
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
.justify-content-center {
|
|
137
|
+
justify-content: center;
|
|
138
|
+
}
|
|
139
|
+
.h-full {
|
|
140
|
+
height: 100%;
|
|
141
|
+
}
|
|
142
|
+
.w-full {
|
|
143
|
+
width: 100%;
|
|
144
|
+
}
|
|
137
145
|
.text-muted {
|
|
138
146
|
.color(@text-muted);
|
|
139
147
|
}
|
|
148
|
+
.text-lg {
|
|
149
|
+
font-size: 18px;
|
|
150
|
+
}
|
|
151
|
+
.text-xl {
|
|
152
|
+
font-size: 20px;
|
|
153
|
+
}
|
|
154
|
+
.text-center {
|
|
155
|
+
text-align: center;
|
|
156
|
+
}
|
|
157
|
+
.text-danger {
|
|
158
|
+
color: #ea3d2f;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.text-italic {
|
|
162
|
+
font-style: italic;
|
|
163
|
+
}
|
|
140
164
|
|
|
141
165
|
// display utils
|
|
142
166
|
.d-none {
|
|
@@ -200,7 +224,6 @@ body div#sbz92 {
|
|
|
200
224
|
.mb-3 {
|
|
201
225
|
margin-bottom: @spacer3;
|
|
202
226
|
}
|
|
203
|
-
|
|
204
227
|
.mb-2 {
|
|
205
228
|
margin-bottom: @spacer2;
|
|
206
229
|
}
|
package/assets/less/form.less
CHANGED
|
@@ -116,7 +116,10 @@ select.form-control.input--error:focus {
|
|
|
116
116
|
display: block;
|
|
117
117
|
position: relative;
|
|
118
118
|
width: 100%;
|
|
119
|
-
|
|
119
|
+
margin-top: 5px;
|
|
120
|
+
}
|
|
121
|
+
.radio:first-of-type {
|
|
122
|
+
margin-top: 0;
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
input[type='radio'] {
|
|
@@ -180,7 +183,10 @@ select.form-control.input--error:focus {
|
|
|
180
183
|
display: block;
|
|
181
184
|
position: relative;
|
|
182
185
|
width: 100%;
|
|
183
|
-
|
|
186
|
+
margin-top: 5px;
|
|
187
|
+
}
|
|
188
|
+
.checkbox:first-of-type {
|
|
189
|
+
margin-top: 0;
|
|
184
190
|
}
|
|
185
191
|
|
|
186
192
|
input[type='checkbox'] {
|
|
@@ -417,3 +423,72 @@ select {
|
|
|
417
423
|
d: path('M 7 9.5 L 12 14.5 L 17 9.5 H 7 Z');
|
|
418
424
|
fill: black;
|
|
419
425
|
}
|
|
426
|
+
|
|
427
|
+
// css for form page
|
|
428
|
+
.form-component {
|
|
429
|
+
margin-bottom: 15px;
|
|
430
|
+
&:last-child {
|
|
431
|
+
margin-bottom: 0;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
&.submitted {
|
|
435
|
+
margin-bottom: 8px;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.form-wrapper.form {
|
|
440
|
+
padding: 20px;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.form-page {
|
|
444
|
+
max-width: 700px;
|
|
445
|
+
width: 100%;
|
|
446
|
+
margin: 0 auto;
|
|
447
|
+
padding: 40px 20px;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.form-page-header {
|
|
451
|
+
margin-bottom: 30px;
|
|
452
|
+
font-size: 18px;
|
|
453
|
+
font-weight: 500;
|
|
454
|
+
color: #ccc;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.form-wrapper.form-wrapper-attachment.form {
|
|
458
|
+
padding: 12px 15px;
|
|
459
|
+
margin-top: 5px;
|
|
460
|
+
|
|
461
|
+
input[type='text'].form-control,
|
|
462
|
+
input[type='number'].form-control,
|
|
463
|
+
input[type='date'].form-control,
|
|
464
|
+
select.form-control,
|
|
465
|
+
textarea.form-control {
|
|
466
|
+
padding: 6px 15px;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.form-component {
|
|
470
|
+
margin-bottom: 12px;
|
|
471
|
+
&:last-child {
|
|
472
|
+
margin-bottom: 0;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
&.submitted {
|
|
476
|
+
margin-bottom: 5px;
|
|
477
|
+
&:last-child {
|
|
478
|
+
margin-bottom: 0;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
.label {
|
|
484
|
+
padding-bottom: 4px;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.form-control--valid-input--error {
|
|
488
|
+
padding-top: 3px;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
.btn--start-convo {
|
|
492
|
+
height: 36px;
|
|
493
|
+
}
|
|
494
|
+
}
|
package/assets/less/message.less
CHANGED
package/assets/less/widget.less
CHANGED
|
@@ -541,3 +541,23 @@
|
|
|
541
541
|
.color(@primary-color);
|
|
542
542
|
margin: 0;
|
|
543
543
|
}
|
|
544
|
+
|
|
545
|
+
.widget-internet-status {
|
|
546
|
+
position: absolute;
|
|
547
|
+
bottom: 0;
|
|
548
|
+
left: 0;
|
|
549
|
+
width: 100%;
|
|
550
|
+
font-size: 14px;
|
|
551
|
+
z-index: 10;
|
|
552
|
+
text-align: center;
|
|
553
|
+
padding: 6px 5px;
|
|
554
|
+
|
|
555
|
+
&.negative {
|
|
556
|
+
background-color: #212325;
|
|
557
|
+
color: #fff;
|
|
558
|
+
}
|
|
559
|
+
&.positive {
|
|
560
|
+
background-color: #19b600;
|
|
561
|
+
color: #fff;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
|
|
45
45
|
.widget-header--description {
|
|
46
46
|
font-size: 14px;
|
|
47
|
-
|
|
47
|
+
overflow: hidden;
|
|
48
48
|
opacity: 0.7;
|
|
49
49
|
flex: 1;
|
|
50
50
|
.color(@text-color);
|
|
@@ -167,23 +167,43 @@
|
|
|
167
167
|
height: 24px;
|
|
168
168
|
display: block;
|
|
169
169
|
position: relative;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
.widget-header--button-close {
|
|
174
|
+
display: flex;
|
|
175
|
+
border-radius: 6px;
|
|
176
|
+
justify-self: flex-end;
|
|
177
|
+
align-items: center;
|
|
178
|
+
align-self: flex-start;
|
|
170
179
|
|
|
171
|
-
cursor: pointer;
|
|
172
|
-
scale: 1;
|
|
173
|
-
transition:
|
|
174
|
-
scale 0.15s ease,
|
|
175
|
-
filter 0.15s ease;
|
|
176
180
|
filter: brightness(0.95);
|
|
177
181
|
&:hover {
|
|
182
|
+
opacity: 1;
|
|
178
183
|
filter: brightness(1.1);
|
|
179
184
|
scale: 1.1;
|
|
180
185
|
}
|
|
181
186
|
}
|
|
182
|
-
|
|
187
|
+
*/
|
|
183
188
|
.widget-header--wrap-button-back {
|
|
184
189
|
display: flex;
|
|
185
190
|
position: relative;
|
|
186
191
|
margin-right: @spacer1;
|
|
192
|
+
|
|
193
|
+
cursor: pointer;
|
|
194
|
+
scale: 1;
|
|
195
|
+
opacity: 0.6;
|
|
196
|
+
|
|
197
|
+
transition:
|
|
198
|
+
opacity 0.15s ease,
|
|
199
|
+
scale 0.15s ease,
|
|
200
|
+
filter 0.15s ease;
|
|
201
|
+
filter: brightness(0.95);
|
|
202
|
+
&:hover {
|
|
203
|
+
opacity: 1;
|
|
204
|
+
filter: brightness(1.1);
|
|
205
|
+
scale: 1.1;
|
|
206
|
+
}
|
|
187
207
|
}
|
|
188
208
|
|
|
189
209
|
.fade-enter-active,
|
|
@@ -33,9 +33,15 @@ class ChatButton extends _common.Com {
|
|
|
33
33
|
isquickreplies = true;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (
|
|
36
|
+
let format = _index.default.get(ev, 'data.message.format');
|
|
37
|
+
let block = _index.default.get(ev, 'data.message.block');
|
|
38
|
+
if (block || format == 'block') {
|
|
39
|
+
if (_index.default.isBlockEmpty(block) && isquickreplies) return;
|
|
40
|
+
} else {
|
|
41
|
+
let message = _index.default.get(ev, 'data.message.text') || '';
|
|
42
|
+
if (!message && isquickreplies) return;
|
|
43
|
+
}
|
|
44
|
+
this.setState({
|
|
39
45
|
displayPreview: true,
|
|
40
46
|
previewEvent: ev
|
|
41
47
|
});
|
|
@@ -349,11 +355,20 @@ class ChatButton extends _common.Com {
|
|
|
349
355
|
}
|
|
350
356
|
renderMessagePreview(ev, defmsg) {
|
|
351
357
|
defmsg = defmsg || this.props.t('sent_you_a_message');
|
|
352
|
-
|
|
358
|
+
let format = _index.default.get(ev, 'data.message.format');
|
|
353
359
|
let block = _index.default.get(ev, 'data.message.block');
|
|
354
|
-
if (block || format == 'block')
|
|
355
|
-
block
|
|
356
|
-
|
|
360
|
+
if (block || format == 'block') {
|
|
361
|
+
if (_index.default.isBlockEmpty(block)) {
|
|
362
|
+
let attachments = _index.default.get(ev, 'data.message.attachments');
|
|
363
|
+
if (_index.default.size(attachments) > 0) {
|
|
364
|
+
return (0, _preact.h)("div", null, `${this.props.t('send')} ${_index.default.size(attachments)} ${_index.default.size(attachments) > 1 ? this.props.t('attachments') : this.props.t('attachment')}`);
|
|
365
|
+
}
|
|
366
|
+
return defmsg;
|
|
367
|
+
}
|
|
368
|
+
return (0, _preact.h)(_block.default, {
|
|
369
|
+
block: block
|
|
370
|
+
});
|
|
371
|
+
}
|
|
357
372
|
let message = _index.default.get(ev, 'data.message.text', defmsg);
|
|
358
373
|
if (!message && _index.default.size(_index.default.get(ev, 'data.message.attachments')) > 0) message = defmsg;
|
|
359
374
|
if (!message) return null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
8
|
+
var _common = require("../common.js");
|
|
9
|
+
var _preact = require("preact");
|
|
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 ConnectionStatus extends _common.Com {
|
|
15
|
+
constructor(props) {
|
|
16
|
+
super(props);
|
|
17
|
+
_defineProperty(this, "onChangeConnectionStatus", () => {
|
|
18
|
+
let newstatus = this.props.store.getConnectionStatus();
|
|
19
|
+
let currentstatus = this.state.status;
|
|
20
|
+
this.setState({
|
|
21
|
+
status: newstatus
|
|
22
|
+
});
|
|
23
|
+
if (currentstatus !== 'active' && newstatus === 'active') this.changeStatusFailedToSuccess();
|
|
24
|
+
});
|
|
25
|
+
_defineProperty(this, "changeStatusFailedToSuccess", () => {
|
|
26
|
+
this.setState({
|
|
27
|
+
status: 'just_active'
|
|
28
|
+
});
|
|
29
|
+
if (this.props.cid) this.props.store.fetchMoreEvents(this.props.cid);
|
|
30
|
+
if (this._timeout) clearTimeout(this._timeout);
|
|
31
|
+
this._timeout = setTimeout(() => {
|
|
32
|
+
this.setState({
|
|
33
|
+
status: 'active'
|
|
34
|
+
});
|
|
35
|
+
}, 2000);
|
|
36
|
+
});
|
|
37
|
+
this.props.store.onConnection(this, this.onChangeConnectionStatus);
|
|
38
|
+
this.state = {
|
|
39
|
+
status: this.props.store.getConnectionStatus()
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
render() {
|
|
43
|
+
if (this.state.status === 'active') return;
|
|
44
|
+
let cls = 'widget-internet-status';
|
|
45
|
+
let text = '';
|
|
46
|
+
if (this.state.status !== 'just_active') {
|
|
47
|
+
cls += ' negative';
|
|
48
|
+
text = `${this.props.t('network_error')}. ${this.props.t('try_reconnecting')}...`;
|
|
49
|
+
} else {
|
|
50
|
+
cls += ' positive';
|
|
51
|
+
text = this.props.t('reconnect_successfully');
|
|
52
|
+
}
|
|
53
|
+
return (0, _preact.h)("div", {
|
|
54
|
+
class: cls
|
|
55
|
+
}, text);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = ConnectionStatus;
|
|
@@ -9,7 +9,7 @@ var _AudioAttachments = _interopRequireDefault(require("./AudioAttachments.js"))
|
|
|
9
9
|
var _FileAttachments = _interopRequireDefault(require("./FileAttachments.js"));
|
|
10
10
|
var _ButtonAttachments = _interopRequireDefault(require("./ButtonAttachments.js"));
|
|
11
11
|
var _QuickReplies = _interopRequireDefault(require("./QuickReplies.js"));
|
|
12
|
-
var
|
|
12
|
+
var _FormAttachment = _interopRequireDefault(require("./FormAttachment2.js"));
|
|
13
13
|
var _FormSubmitAttachments = _interopRequireDefault(require("./FormSubmitAttachments.js"));
|
|
14
14
|
var _GenericTemplateAttachments = _interopRequireDefault(require("./GenericTemplateAttachments.js"));
|
|
15
15
|
var _ProductAttachments = _interopRequireDefault(require("./ProductAttachments.js"));
|
|
@@ -245,6 +245,9 @@ class Event extends _common.Com {
|
|
|
245
245
|
}
|
|
246
246
|
renderMessageSent() {
|
|
247
247
|
let ev = this.props.event.ev;
|
|
248
|
+
let attachments = _index.default.get(ev, 'data.message.attachments');
|
|
249
|
+
let hasForm = _index.default.find(attachments, att => att.type === 'form');
|
|
250
|
+
if (ev.id === 'evshpgaeetsplfqprzmynrvrl') hasForm = true;
|
|
248
251
|
this.tryLoadOrder(ev);
|
|
249
252
|
let t = new _index.default.Date(ev.created).toLocaleString();
|
|
250
253
|
if (_index.default.get(ev, 'by.type') !== 'user') {
|
|
@@ -252,10 +255,12 @@ class Event extends _common.Com {
|
|
|
252
255
|
if (this.props.event.mode === 'lead') $sender = this.renderAgentAvatar(ev);
|
|
253
256
|
let innercls = 'agent-convo-event-inner';
|
|
254
257
|
if (this.props.isLast) innercls += ' last';
|
|
258
|
+
let wrappercls = 'agent-convo-event-wrapper';
|
|
259
|
+
if (hasForm) wrappercls += ' full';
|
|
255
260
|
return (0, _preact.h)("div", {
|
|
256
261
|
class: "convo-event agent-message"
|
|
257
262
|
}, $sender, (0, _preact.h)("div", {
|
|
258
|
-
class:
|
|
263
|
+
class: wrappercls
|
|
259
264
|
}, (0, _preact.h)("div", {
|
|
260
265
|
class: innercls
|
|
261
266
|
}, (0, _preact.h)(_TextMessage.default, {
|
|
@@ -280,10 +285,8 @@ class Event extends _common.Com {
|
|
|
280
285
|
store: this.props.store,
|
|
281
286
|
ev: ev,
|
|
282
287
|
t: this.props.t
|
|
283
|
-
}), (0, _preact.h)(
|
|
288
|
+
}), (0, _preact.h)(_FormAttachment.default, {
|
|
284
289
|
store: this.props.store,
|
|
285
|
-
onSubmit: this.props.onFormSubmit,
|
|
286
|
-
ref: this.refForm,
|
|
287
290
|
ev: ev,
|
|
288
291
|
t: this.props.t
|
|
289
292
|
}), (0, _preact.h)(_FormSubmitAttachments.default, {
|
|
@@ -367,10 +370,9 @@ class Event extends _common.Com {
|
|
|
367
370
|
store: this.props.store,
|
|
368
371
|
ev: ev,
|
|
369
372
|
t: this.props.t
|
|
370
|
-
}), (0, _preact.h)(
|
|
373
|
+
}), (0, _preact.h)(_FormAttachment.default, {
|
|
371
374
|
store: this.props.store,
|
|
372
|
-
|
|
373
|
-
ref: this.refForm,
|
|
375
|
+
t: this.props.t,
|
|
374
376
|
ev: ev
|
|
375
377
|
}), (0, _preact.h)(_ProductAttachments.default, {
|
|
376
378
|
t: this.props.t,
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
8
|
+
var _common = require("../common.js");
|
|
9
|
+
var _preact = require("preact");
|
|
10
|
+
var _Form = _interopRequireDefault(require("../form/Form.js"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
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
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
14
|
+
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); }
|
|
15
|
+
class FormAttachment extends _common.Com {
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
18
|
+
_defineProperty(this, "onChangeFormValues", values => {
|
|
19
|
+
this.setState({
|
|
20
|
+
submission: {
|
|
21
|
+
values
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
_defineProperty(this, "onSubmit", async () => {
|
|
26
|
+
this.setState({
|
|
27
|
+
errorMessage: ''
|
|
28
|
+
});
|
|
29
|
+
if (this.state.submiting) return;
|
|
30
|
+
this.setState({
|
|
31
|
+
submiting: true
|
|
32
|
+
});
|
|
33
|
+
let res = await this.props.store.submitForm2(this.props.token, this.state.submission);
|
|
34
|
+
if (res.error) {
|
|
35
|
+
this.setState({
|
|
36
|
+
submiting: false,
|
|
37
|
+
errorMessage: _index.default.get(res, 'error.code')
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.setState({
|
|
42
|
+
submiting: false,
|
|
43
|
+
isSubmited: true
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
this.state = {
|
|
47
|
+
submission: {},
|
|
48
|
+
submiting: false,
|
|
49
|
+
errorMessage: '',
|
|
50
|
+
isSubmited: false
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
let attachments = _index.default.get(this.props.ev, 'data.message.attachments') || [];
|
|
55
|
+
let formAttachment = _index.default.find(attachments, att => att.type === 'form');
|
|
56
|
+
if (!formAttachment) return;
|
|
57
|
+
const {
|
|
58
|
+
submission,
|
|
59
|
+
errorMessage,
|
|
60
|
+
isSubmited,
|
|
61
|
+
submiting
|
|
62
|
+
} = this.state;
|
|
63
|
+
let formSetting = formAttachment.form || {};
|
|
64
|
+
return (0, _preact.h)("div", {
|
|
65
|
+
onClick: e => e.stopPropagation()
|
|
66
|
+
}, (0, _preact.h)(_Form.default, {
|
|
67
|
+
store: this.props.store,
|
|
68
|
+
formSetting: formSetting,
|
|
69
|
+
mode: "attachment",
|
|
70
|
+
t: this.props.t,
|
|
71
|
+
submission: submission,
|
|
72
|
+
errorMessage: errorMessage,
|
|
73
|
+
isSubmited: isSubmited,
|
|
74
|
+
submiting: submiting,
|
|
75
|
+
onChangeFormValues: this.onChangeFormValues,
|
|
76
|
+
onSubmit: this.onSubmit
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.default = FormAttachment;
|
|
@@ -14,6 +14,17 @@ class Header extends _common.Com {
|
|
|
14
14
|
constructor(props) {
|
|
15
15
|
super(props);
|
|
16
16
|
}
|
|
17
|
+
renderAccountAvatar() {
|
|
18
|
+
let acc = this.props.store.matchAccount() || {};
|
|
19
|
+
if (!acc.logo_url) return null;
|
|
20
|
+
return (0, _preact.h)("img", {
|
|
21
|
+
width: 38,
|
|
22
|
+
height: 38,
|
|
23
|
+
alt: acc.name,
|
|
24
|
+
class: "avatar avatar__account",
|
|
25
|
+
src: this.props.store.replaceFileUrl(acc.logo_url) || require('../../assets/img/image_default.png')
|
|
26
|
+
});
|
|
27
|
+
}
|
|
17
28
|
render() {
|
|
18
29
|
let headerMode = 'collapsed';
|
|
19
30
|
let cls = 'widget-header';
|
|
@@ -49,7 +60,7 @@ class Header extends _common.Com {
|
|
|
49
60
|
return (0, _preact.h)("div", {
|
|
50
61
|
class: cls,
|
|
51
62
|
style: style
|
|
52
|
-
}, $back, (0, _preact.h)("div", {
|
|
63
|
+
}, $back, this.renderAccountAvatar(), (0, _preact.h)("div", {
|
|
53
64
|
class: "widget-header--title-container"
|
|
54
65
|
}, (0, _preact.h)("div", {
|
|
55
66
|
class: "widget-header--title"
|
|
@@ -12,6 +12,7 @@ var _Header = _interopRequireDefault(require("./Header.js"));
|
|
|
12
12
|
var _MessageInput = _interopRequireDefault(require("./MessageInput.js"));
|
|
13
13
|
var _Events = _interopRequireDefault(require("./Events.js"));
|
|
14
14
|
var _Rating = _interopRequireDefault(require("./Rating.js"));
|
|
15
|
+
var _ConnectionStatus = _interopRequireDefault(require("./ConnectionStatus.js"));
|
|
15
16
|
var _ListField = _interopRequireDefault(require("./ListField.js"));
|
|
16
17
|
var _time = _interopRequireDefault(require("./time.js"));
|
|
17
18
|
var _common = require("../common.js");
|
|
@@ -834,6 +835,10 @@ class Widget extends _common.Com {
|
|
|
834
835
|
onPostback: e => this.createPostback(e),
|
|
835
836
|
t: this.props.t,
|
|
836
837
|
plugin: this.props.plugin
|
|
838
|
+
}), (0, _preact.h)(_ConnectionStatus.default, {
|
|
839
|
+
cid: this.props.cid,
|
|
840
|
+
store: this.props.store,
|
|
841
|
+
t: this.props.t
|
|
837
842
|
})), (0, _preact.h)(_Rating.default, {
|
|
838
843
|
forceView: this.props.view,
|
|
839
844
|
plugin: this.props.plugin,
|