@subiz/widget-v4 4.0.91 → 4.0.92
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/compiled_src/chatbox/main.js +2 -3
- package/compiled_src/store/api.js +4 -1
- package/compiled_src/store/store.js +4 -9
- package/compiled_src/util/common.js +0 -5
- package/dist/132.js +405 -90
- package/dist/178.js +174 -341
- package/dist/18364d15f37.132.js +1 -0
- package/dist/18364d15f37.178.js +1 -0
- package/dist/{17f00e48d38.213.js → 18364d15f37.213.js} +1 -1
- package/dist/{17f00e48d38.335.js → 18364d15f37.335.js} +1 -1
- package/dist/18364d15f37.362.js +1 -0
- package/dist/18364d15f37.441.js +1 -0
- package/dist/{17f00e48d38.605.js → 18364d15f37.605.js} +0 -0
- package/dist/18364d15f37.678.js +1 -0
- package/dist/18364d15f37.782.js +1 -0
- package/dist/18364d15f37.app.js +1 -0
- package/dist/{17f00e48d38.index.html → 18364d15f37.index.html} +7 -3
- package/dist/{17f00e48d38.library.html → 18364d15f37.library.html} +7 -3
- package/dist/18364d15f37.library.js +1 -0
- package/dist/{17f00e48d38.preview.html → 18364d15f37.preview.html} +1 -1
- package/dist/18364d15f37.preview.js +1 -0
- package/dist/18364d15f37.screenshoot.js +1 -0
- package/dist/213.js +28 -1
- package/dist/335.js +2 -2
- package/dist/362.js +21 -71
- package/dist/441.js +202 -100
- package/dist/678.js +20 -70
- package/dist/782.js +21 -118
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +209 -175
- package/package.json +8 -8
- package/src/chatbox/main.js +3 -3
- package/src/store/api.js +1 -1
- package/src/store/store.js +7 -9
- package/src/util/common.js +0 -4
- package/dist/0b82fa7e5c3b07b40a44.png +0 -1
- package/dist/0f4af006e38ee8b93633.png +0 -1
- package/dist/17f00e48d38.132.js +0 -1
- package/dist/17f00e48d38.178.js +0 -1
- package/dist/17f00e48d38.362.js +0 -1
- package/dist/17f00e48d38.441.js +0 -1
- package/dist/17f00e48d38.678.js +0 -1
- package/dist/17f00e48d38.782.js +0 -1
- package/dist/17f00e48d38.app.js +0 -1
- package/dist/17f00e48d38.library.js +0 -1
- package/dist/17f00e48d38.preview.js +0 -1
- package/dist/17f00e48d38.screenshoot.js +0 -1
- package/dist/1ea1c6cd21d25176810c.png +0 -1
- package/dist/292d42404e1b03398f61.png +0 -1
- package/dist/312d376370831b7bea83.png +0 -1
- package/dist/313d1bfc1cf776d1aefe.png +0 -1
- package/dist/4aa58bb7a66bb44975aa.png +0 -1
- package/dist/56ce063bc6c81adb7322.png +0 -1
- package/dist/6a411166ef5cc79e0714.png +0 -1
- package/dist/6faf403782fefacc1649.png +0 -1
- package/dist/79dca33c68fab79c067f.png +0 -1
- package/dist/82da1578fa84f9debaeb.png +0 -1
- package/dist/8b8e0f0824743974b282.png +0 -1
- package/dist/8d551390d81e39130a3c.png +0 -1
- package/dist/9fc61b9479877ebdb6c7.png +0 -1
- package/dist/a165d31dcb3dc90f1057.png +0 -1
- package/dist/a98d4a5698812c4426b3.png +0 -1
- package/dist/c41606bf9d1b604e46d5.png +0 -1
- package/dist/ce1f7450ce6c1aacd330.png +0 -1
- package/dist/cf8c01e88f4770a6e3e5.png +0 -1
- package/dist/dfbcfeab1d5622a737e2.png +0 -1
- package/dist/e4893ed8c2f7b8329919.png +0 -1
- package/dist/ec2ab4eb4ef73d186186.png +0 -1
package/dist/132.js
CHANGED
|
@@ -161,8 +161,9 @@ class ChatButton extends common/* Com */.up {
|
|
|
161
161
|
let accountSetting = this.props.plugin.chatbox;
|
|
162
162
|
if (new util/* default.Date */.Z.Date().getTime() - this.props.store.matchClosePreviewAt() < Ms30Mins) return;
|
|
163
163
|
let greeting = util/* default.get */.Z.get(accountSetting, 'greeting', {});
|
|
164
|
+
let text = this.props.t.i18n(util/* default.get */.Z.get(greeting, 'greeting', {})) || greeting.message;
|
|
164
165
|
|
|
165
|
-
if (!
|
|
166
|
+
if (!text || !greeting.enabled) {
|
|
166
167
|
this.setState({
|
|
167
168
|
previewEvent: {}
|
|
168
169
|
});
|
|
@@ -224,6 +225,13 @@ class ChatButton extends common/* Com */.up {
|
|
|
224
225
|
position = util/* default.get */.Z.get(accountSetting, 'mobile_button.position') || position;
|
|
225
226
|
}
|
|
226
227
|
|
|
228
|
+
if (accountSetting && accountSetting.hide_agent_profile) {
|
|
229
|
+
agent = Object.assign({}, account, {
|
|
230
|
+
avatar_url: account.logo_url || __webpack_require__(9895),
|
|
231
|
+
fullname: account.name || this.props.t('agent')
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
227
235
|
let cls = 'widget-preview widget-preview--' + position;
|
|
228
236
|
if (!this.state.displayPreview) cls += ' widget-preview--hidden';
|
|
229
237
|
var tags = this.renderMessagePreview(this.state.previewEvent, this.props.t('sent_you_a_message'));
|
|
@@ -257,21 +265,17 @@ class ChatButton extends common/* Com */.up {
|
|
|
257
265
|
}
|
|
258
266
|
|
|
259
267
|
onProfileReady() {
|
|
260
|
-
if (this.
|
|
268
|
+
if (this._buttonLoaded) this.setState({
|
|
261
269
|
opacity: 1
|
|
262
270
|
});
|
|
263
|
-
this.
|
|
264
|
-
profileLoaded: true
|
|
265
|
-
});
|
|
271
|
+
this._profileLoaded = true;
|
|
266
272
|
}
|
|
267
273
|
|
|
268
274
|
onButtonReady() {
|
|
269
|
-
if (this.
|
|
275
|
+
if (this._profileLoaded) this.setState({
|
|
270
276
|
opacity: 1
|
|
271
277
|
});
|
|
272
|
-
this.
|
|
273
|
-
buttonLoaded: true
|
|
274
|
-
});
|
|
278
|
+
this._buttonLoaded = true;
|
|
275
279
|
}
|
|
276
280
|
|
|
277
281
|
renderButton() {
|
|
@@ -461,6 +465,26 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
461
465
|
|
|
462
466
|
render() {
|
|
463
467
|
let accountSetting = this.props.plugin.chatbox;
|
|
468
|
+
let acc = this.props.store.matchAccount();
|
|
469
|
+
var tooltippos = this.props.tooltipPos || 'bottom';
|
|
470
|
+
var mode = this.props.mode || 'primary';
|
|
471
|
+
|
|
472
|
+
if (accountSetting && accountSetting.hide_agent_profile) {
|
|
473
|
+
return (0,preact_module.h)("div", {
|
|
474
|
+
class: `group-avatar group-avatar--${mode}`
|
|
475
|
+
}, (0,preact_module.h)("div", {
|
|
476
|
+
class: "d-inline-block pos-relative",
|
|
477
|
+
"data-tooltip": acc.name,
|
|
478
|
+
"data-tooltip-position": tooltippos
|
|
479
|
+
}, (0,preact_module.h)("img", {
|
|
480
|
+
width: 35,
|
|
481
|
+
height: 35,
|
|
482
|
+
alt: "agent avatar left",
|
|
483
|
+
class: "avatar group-avatar--agent-left",
|
|
484
|
+
src: this.props.store.replaceFileUrl(acc.logo_url) || __webpack_require__(9895)
|
|
485
|
+
})));
|
|
486
|
+
}
|
|
487
|
+
|
|
464
488
|
let agentM = this.props.store.matchAgent('*');
|
|
465
489
|
var agents = util/* default.map */.Z.map(this.props.agent_ids, id => agentM[id]);
|
|
466
490
|
|
|
@@ -476,9 +500,6 @@ class AgentsAvatar extends common/* Com */.up {
|
|
|
476
500
|
}
|
|
477
501
|
|
|
478
502
|
agents = util/* default.filter */.Z.filter(agents, ag => !!ag);
|
|
479
|
-
let acc = this.props.store.matchAccount();
|
|
480
|
-
var tooltippos = this.props.tooltipPos || 'bottom';
|
|
481
|
-
var mode = this.props.mode || 'primary';
|
|
482
503
|
|
|
483
504
|
if (agents.length === 0) {
|
|
484
505
|
return (0,preact_module.h)("div", {
|
|
@@ -839,6 +860,12 @@ class MessageInput extends common/* Com */.up {
|
|
|
839
860
|
}, 5);
|
|
840
861
|
}
|
|
841
862
|
|
|
863
|
+
blur() {
|
|
864
|
+
const $input = this.refMessageInput.current;
|
|
865
|
+
if (!$input) return;
|
|
866
|
+
$input.blur();
|
|
867
|
+
}
|
|
868
|
+
|
|
842
869
|
render() {
|
|
843
870
|
var buttons = (0,preact_module.h)("div", {
|
|
844
871
|
class: "d-flex flex-row align-self-end"
|
|
@@ -1295,7 +1322,7 @@ class Buttons extends common/* Com */.up {
|
|
|
1295
1322
|
href: 'tel:' + button.phone_number,
|
|
1296
1323
|
key: index,
|
|
1297
1324
|
title: button.title
|
|
1298
|
-
}, button.title);
|
|
1325
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
1299
1326
|
}
|
|
1300
1327
|
|
|
1301
1328
|
if (button.type === 'url_button') {
|
|
@@ -1305,7 +1332,7 @@ class Buttons extends common/* Com */.up {
|
|
|
1305
1332
|
target: "_blank",
|
|
1306
1333
|
key: index,
|
|
1307
1334
|
title: button.title
|
|
1308
|
-
}, button.title || button.url);
|
|
1335
|
+
}, this.props.t.i18n(button.i18n_title) || button.title || button.url);
|
|
1309
1336
|
}
|
|
1310
1337
|
|
|
1311
1338
|
if (button.type === 'postback_button') {
|
|
@@ -1313,7 +1340,7 @@ class Buttons extends common/* Com */.up {
|
|
|
1313
1340
|
class: "url-button-attachment",
|
|
1314
1341
|
href: "javascript:;",
|
|
1315
1342
|
onClick: _ => this.props.onSelect(button)
|
|
1316
|
-
}, button.title);
|
|
1343
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
1317
1344
|
}
|
|
1318
1345
|
|
|
1319
1346
|
if (button.type === 'widget_ask_desktop_notify_button') return null;
|
|
@@ -1347,7 +1374,8 @@ class ButtonAttachments extends common/* Com */.up {
|
|
|
1347
1374
|
});
|
|
1348
1375
|
return (0,preact_module.h)(Buttons, {
|
|
1349
1376
|
store: this.props.store,
|
|
1350
|
-
buttons: buttons
|
|
1377
|
+
buttons: buttons,
|
|
1378
|
+
t: this.props.t
|
|
1351
1379
|
});
|
|
1352
1380
|
}
|
|
1353
1381
|
|
|
@@ -1956,7 +1984,10 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1956
1984
|
this.setState({
|
|
1957
1985
|
focusing: eleindex
|
|
1958
1986
|
});
|
|
1959
|
-
this.galleryRef.current.
|
|
1987
|
+
this.galleryRef.current.scrollTo({
|
|
1988
|
+
left: 220 * eleindex,
|
|
1989
|
+
behavior: 'smooth'
|
|
1990
|
+
});
|
|
1960
1991
|
}
|
|
1961
1992
|
|
|
1962
1993
|
render() {
|
|
@@ -1967,21 +1998,26 @@ class GenericTemplateAttachments extends common/* Com */.up {
|
|
|
1967
1998
|
if (generics.length === 0) return null;
|
|
1968
1999
|
var $generics = util/* default.map */.Z.map(generics, (gen, index) => {
|
|
1969
2000
|
var $eles = util/* default.map */.Z.map(gen.elements, ele => {
|
|
1970
|
-
let
|
|
2001
|
+
let title = this.props.t.i18n(ele.i18n_title) || ele.title;
|
|
2002
|
+
let subtitle = this.props.t.i18n(ele.i18n_subtitle) || ele.subtitle;
|
|
2003
|
+
let $title = title ? (0,preact_module.h)("div", {
|
|
1971
2004
|
class: "generic-attachment--element-title"
|
|
1972
|
-
},
|
|
1973
|
-
let $subtitle =
|
|
2005
|
+
}, title) : null;
|
|
2006
|
+
let $subtitle = subtitle ? (0,preact_module.h)("div", {
|
|
1974
2007
|
class: "generic-attachment--element-subtitle"
|
|
1975
|
-
},
|
|
2008
|
+
}, subtitle) : null;
|
|
1976
2009
|
return (0,preact_module.h)("div", {
|
|
1977
2010
|
class: "generic-attachment--element swiper-slide"
|
|
1978
2011
|
}, (0,preact_module.h)("div", null, (0,preact_module.h)("img", {
|
|
1979
2012
|
alt: "generic attachment element",
|
|
1980
2013
|
class: "generic-attachment--element-img",
|
|
1981
2014
|
src: this.props.store.replaceFileUrl(ele.image_url)
|
|
1982
|
-
})),
|
|
2015
|
+
})), (0,preact_module.h)("div", {
|
|
2016
|
+
class: "generic-attachment--element-content"
|
|
2017
|
+
}, $title, $subtitle), (0,preact_module.h)(Buttons, {
|
|
1983
2018
|
buttons: ele.buttons,
|
|
1984
|
-
onSelect: button => this.props.onSelect(button)
|
|
2019
|
+
onSelect: button => this.props.onSelect(button),
|
|
2020
|
+
t: this.props.t
|
|
1985
2021
|
}));
|
|
1986
2022
|
});
|
|
1987
2023
|
let elements = util/* default.get */.Z.get(attachments, '0.elements', []);
|
|
@@ -2031,17 +2067,53 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
2031
2067
|
let acc = this.props.store.matchAccount();
|
|
2032
2068
|
let $products = util/* default.map */.Z.map(products, (att, index) => {
|
|
2033
2069
|
let product = att.product;
|
|
2034
|
-
let $
|
|
2070
|
+
let $detailbtns = [];
|
|
2035
2071
|
let url = product.url || product.mobile_url;
|
|
2036
2072
|
if (this.props.store.isMobile()) url = product.mobile_url || product.url;
|
|
2037
|
-
if (url)
|
|
2073
|
+
if (url && util/* default.size */.Z.size(product.buttons) == 0) $detailbtns.push((0,preact_module.h)("a", {
|
|
2038
2074
|
class: "product_attachment__btn",
|
|
2039
2075
|
href: url,
|
|
2040
2076
|
target: "_blank"
|
|
2041
2077
|
}, this.props.t('detail'), (0,preact_module.h)("img", {
|
|
2042
2078
|
src: __webpack_require__(8453),
|
|
2043
2079
|
class: "product_attachment__btn_external_link"
|
|
2044
|
-
}));
|
|
2080
|
+
})));
|
|
2081
|
+
console.log('P', product);
|
|
2082
|
+
|
|
2083
|
+
if (util/* default.size */.Z.size(product.buttons) > 0) {
|
|
2084
|
+
$detailbtns = $detailbtns.concat(util/* default.map */.Z.map(product.buttons, (button, index) => {
|
|
2085
|
+
if (button.type === 'call_button') {
|
|
2086
|
+
return (0,preact_module.h)("a", {
|
|
2087
|
+
class: "product_attachment__btn",
|
|
2088
|
+
href: 'tel:' + button.phone_number,
|
|
2089
|
+
key: index,
|
|
2090
|
+
title: button.title
|
|
2091
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
if (button.type === 'url_button') {
|
|
2095
|
+
return (0,preact_module.h)("a", {
|
|
2096
|
+
class: "product_attachment__btn",
|
|
2097
|
+
href: button.url,
|
|
2098
|
+
target: "_blank",
|
|
2099
|
+
key: index,
|
|
2100
|
+
title: button.title
|
|
2101
|
+
}, this.props.t.i18n(button.i18n_title) || button.title || this.props.t('detail'), ' ', (0,preact_module.h)("img", {
|
|
2102
|
+
src: __webpack_require__(8453),
|
|
2103
|
+
class: "product_attachment__btn_external_link"
|
|
2104
|
+
}));
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
if (button.type === 'postback_button') {
|
|
2108
|
+
return (0,preact_module.h)("a", {
|
|
2109
|
+
class: "product_attachment__btn",
|
|
2110
|
+
href: "javascript:;",
|
|
2111
|
+
onClick: _ => this.props.onPostback(button)
|
|
2112
|
+
}, this.props.t.i18n(button.i18n_title) || button.title);
|
|
2113
|
+
}
|
|
2114
|
+
}));
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2045
2117
|
let $title = (0,preact_module.h)("a", {
|
|
2046
2118
|
href: url,
|
|
2047
2119
|
class: "product_attachment__title",
|
|
@@ -2070,7 +2142,7 @@ class ProductAttachments extends common/* Com */.up {
|
|
|
2070
2142
|
src: this.props.store.replaceFileUrl(product.image)
|
|
2071
2143
|
}))), $title, $subtitle, $price, (0,preact_module.h)("div", {
|
|
2072
2144
|
class: "product_attachment__btns"
|
|
2073
|
-
}, $
|
|
2145
|
+
}, $detailbtns));
|
|
2074
2146
|
});
|
|
2075
2147
|
return $products;
|
|
2076
2148
|
}
|
|
@@ -2226,8 +2298,7 @@ img { max-width: 100%; display: block; margin: 10px auto; }
|
|
|
2226
2298
|
* { white-space: normal }
|
|
2227
2299
|
ul > li { margin-bottom: 5px }
|
|
2228
2300
|
ul:last-child { margin-bottom: 0 }
|
|
2229
|
-
p
|
|
2230
|
-
p:last-child { margin-bottom: 0;}
|
|
2301
|
+
p { margin-bottom: 0; margin-top: 0;}
|
|
2231
2302
|
</style>
|
|
2232
2303
|
<div>${html}</div>`;
|
|
2233
2304
|
let links = this.shadowRoot.querySelectorAll('a');
|
|
@@ -2271,6 +2342,11 @@ class TextMessage extends common/* Com */.up {
|
|
|
2271
2342
|
render() {
|
|
2272
2343
|
var format = util/* default.get */.Z.get(this.props.ev, 'data.message.format', 'plaintext');
|
|
2273
2344
|
if (format === 'markdown') return this.renderMarkdown();
|
|
2345
|
+
if (format === 'delta') return this.renderDelta();
|
|
2346
|
+
return this.renderPlainText();
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
renderPlainText() {
|
|
2274
2350
|
var text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
|
|
2275
2351
|
text = util/* default.trim */.Z.trim(text);
|
|
2276
2352
|
if (util/* default.size */.Z.size(text) === 0) return null;
|
|
@@ -2316,8 +2392,86 @@ class TextMessage extends common/* Com */.up {
|
|
|
2316
2392
|
}, tags);
|
|
2317
2393
|
}
|
|
2318
2394
|
|
|
2319
|
-
|
|
2320
|
-
|
|
2395
|
+
renderDelta() {
|
|
2396
|
+
let deltas = util/* default.get */.Z.get(this.props.ev, 'data.message.quill_delta') || util/* default.get */.Z.get(this.props.ev, 'data.message.text');
|
|
2397
|
+
let quilldeltas = util/* default.parseJSON */.Z.parseJSON(deltas) || {};
|
|
2398
|
+
quilldeltas = trimQuillDelta(quilldeltas);
|
|
2399
|
+
if (!quilldeltas || util/* default.size */.Z.size(quilldeltas.ops) === 0) return null;
|
|
2400
|
+
let $deltas = util/* default.map */.Z.map(quilldeltas.ops, delta => {
|
|
2401
|
+
let html = '';
|
|
2402
|
+
let insert = delta.insert;
|
|
2403
|
+
let attributes = delta.attributes;
|
|
2404
|
+
|
|
2405
|
+
if (insert.dynamicField) {
|
|
2406
|
+
return util/* default.get */.Z.get(insert, 'dynamicField.text', '');
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
if (insert.mention) {
|
|
2410
|
+
if (insert.mention.id == '*' || insert.mention.id == 'all') {
|
|
2411
|
+
return (0,preact_module.h)("span", {
|
|
2412
|
+
class: "mention"
|
|
2413
|
+
}, "@", this.$t('all'));
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
let ag = store.matchAgent(insert.mention.id);
|
|
2417
|
+
let name = util/* default.getAgentDisplayName */.Z.getAgentDisplayName(ag, insert.mention.fullname);
|
|
2418
|
+
return (0,preact_module.h)("span", {
|
|
2419
|
+
class: "mention",
|
|
2420
|
+
"data-agent-id": ag.id,
|
|
2421
|
+
"data-agent-fullname": name
|
|
2422
|
+
}, "@", name);
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
if (insert.emoji) return (0,preact_module.h)(Emoji, {
|
|
2426
|
+
emojiCode: `:${insert.emoji}:`
|
|
2427
|
+
});
|
|
2428
|
+
|
|
2429
|
+
if (typeof insert === 'string') {
|
|
2430
|
+
let $tags = util/* default.extractText */.Z.extractText(insert).map((tag, i) => {
|
|
2431
|
+
if (tag.type === 'link') {
|
|
2432
|
+
return (0,preact_module.h)("a", {
|
|
2433
|
+
href: absLink(tag.text),
|
|
2434
|
+
target: "_blank"
|
|
2435
|
+
}, tag.text);
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
return tag.text;
|
|
2439
|
+
});
|
|
2440
|
+
|
|
2441
|
+
if (attributes) {
|
|
2442
|
+
if (attributes.italic && attributes.bold) return (0,preact_module.h)("span", {
|
|
2443
|
+
style: "font-weight: bold !important; font-style: italic !important"
|
|
2444
|
+
}, $tags);
|
|
2445
|
+
if (attributes.italic) return (0,preact_module.h)("span", {
|
|
2446
|
+
style: "font-style: italic !important"
|
|
2447
|
+
}, $tags);
|
|
2448
|
+
if (attributes.bold) return (0,preact_module.h)("span", {
|
|
2449
|
+
style: "font-weight: bold !important"
|
|
2450
|
+
}, $tags);
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
return (0,preact_module.h)("span", null, $tags);
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
return null;
|
|
2457
|
+
});
|
|
2458
|
+
let byType = util/* default.get */.Z.get(this.ev, 'by.type');
|
|
2459
|
+
if (byType !== 'user') byType = 'agent';
|
|
2460
|
+
if (util/* default.size */.Z.size($deltas) === 0) return null;
|
|
2461
|
+
|
|
2462
|
+
if (byType === 'agent') {
|
|
2463
|
+
return (0,preact_module.h)("div", {
|
|
2464
|
+
class: "message-agent message-text--agent"
|
|
2465
|
+
}, $deltas);
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
return (0,preact_module.h)("div", {
|
|
2469
|
+
class: "message-user message-text--user"
|
|
2470
|
+
}, $deltas);
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
renderMarkdown(text) {
|
|
2474
|
+
if (!text) text = util/* default.get */.Z.get(this.props.ev, 'data.message.text');
|
|
2321
2475
|
if (util/* default.size */.Z.size(text) === 0) return null;
|
|
2322
2476
|
let byType = util/* default.get */.Z.get(this.props.ev, 'by.type');
|
|
2323
2477
|
text = util/* default.trim */.Z.trim(text);
|
|
@@ -2341,6 +2495,81 @@ class TextMessage extends common/* Com */.up {
|
|
|
2341
2495
|
}
|
|
2342
2496
|
|
|
2343
2497
|
}
|
|
2498
|
+
|
|
2499
|
+
function deltaToMarkdown(deltas) {
|
|
2500
|
+
let output = '';
|
|
2501
|
+
sb.each(deltas, (delta, idx) => {
|
|
2502
|
+
let text = '';
|
|
2503
|
+
let insert = delta.insert;
|
|
2504
|
+
let attributes = delta.attributes;
|
|
2505
|
+
if (insert.emoji) text = emojiCodes[insert.emoji] || '';
|
|
2506
|
+
|
|
2507
|
+
if (attributes) {
|
|
2508
|
+
if (attributes.italic && attributes.bold) text = `*__${insert}__*`;else if (attributes.italic) text = `*${insert}*`;else if (attributes.bold) text = `**${insert}**`;else text = insert;
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
if (insert.dynamicField) text = `${sb.get(insert, 'dynamicField.text', '')}`;
|
|
2512
|
+
|
|
2513
|
+
if (!insert.emoji && !attributes && !insert.dynamicField) {
|
|
2514
|
+
text = insert || '';
|
|
2515
|
+
text = text.replace(/\n/g, '<br/>');
|
|
2516
|
+
}
|
|
2517
|
+
|
|
2518
|
+
output += text;
|
|
2519
|
+
});
|
|
2520
|
+
return output;
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
const emojiCodes = {
|
|
2524
|
+
like: '👍',
|
|
2525
|
+
unlike: '👎',
|
|
2526
|
+
angry: '😠',
|
|
2527
|
+
confused: '😕',
|
|
2528
|
+
crying: '😢',
|
|
2529
|
+
grinning: '😀',
|
|
2530
|
+
'heart-eyes': '😍',
|
|
2531
|
+
neutral: '😐',
|
|
2532
|
+
sleepy: '😪',
|
|
2533
|
+
sad: '😞',
|
|
2534
|
+
smiling: '😄',
|
|
2535
|
+
'tongue-out': '😛',
|
|
2536
|
+
tired: '😩',
|
|
2537
|
+
surprised: '😮',
|
|
2538
|
+
wink: '😉'
|
|
2539
|
+
};
|
|
2540
|
+
|
|
2541
|
+
function trimQuillDelta(delta) {
|
|
2542
|
+
if (!delta) return delta;
|
|
2543
|
+
if (!delta.ops || !delta.ops.length) return delta;
|
|
2544
|
+
let last = delta.ops[delta.ops.length - 1];
|
|
2545
|
+
if (typeof last.insert != 'string') return delta;
|
|
2546
|
+
let insert = last.insert.trim();
|
|
2547
|
+
|
|
2548
|
+
if (insert) {
|
|
2549
|
+
if (last.insert != insert) {
|
|
2550
|
+
let newops = delta.ops.slice();
|
|
2551
|
+
let last = newops.pop();
|
|
2552
|
+
last.insert = insert;
|
|
2553
|
+
newops.push(last);
|
|
2554
|
+
return {
|
|
2555
|
+
ops: newops
|
|
2556
|
+
};
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
return delta;
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
let newops = delta.ops.slice();
|
|
2563
|
+
newops.pop();
|
|
2564
|
+
return trimQuillDelta({
|
|
2565
|
+
ops: newops
|
|
2566
|
+
});
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
function absLink(url) {
|
|
2570
|
+
if (!url.startsWith('http://') && !url.startsWith('https://') && !url.startsWith('//')) return 'http://' + url;
|
|
2571
|
+
return url;
|
|
2572
|
+
}
|
|
2344
2573
|
;// CONCATENATED MODULE: ./src/chatbox/time.js
|
|
2345
2574
|
|
|
2346
2575
|
var g_pub = new util/* default.Pubsub */.Z.Pubsub();
|
|
@@ -2624,9 +2853,21 @@ class Event extends common/* Com */.up {
|
|
|
2624
2853
|
|
|
2625
2854
|
var uri = acc.logo_url || __webpack_require__(9895);
|
|
2626
2855
|
|
|
2856
|
+
if (util/* default.get */.Z.get(this.props, 'chatbox.hide_agent_profile')) {
|
|
2857
|
+
return (0,preact_module.h)("div", {
|
|
2858
|
+
class: "message-sender"
|
|
2859
|
+
}, (0,preact_module.h)("img", {
|
|
2860
|
+
alt: "sender",
|
|
2861
|
+
class: "message-sender-avatar",
|
|
2862
|
+
src: this.props.store.replaceFileUrl(uri)
|
|
2863
|
+
}), (0,preact_module.h)("p", {
|
|
2864
|
+
class: "message-sender-name"
|
|
2865
|
+
}, acc.name));
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2627
2868
|
let agentM = this.props.store.matchAgent('*');
|
|
2628
2869
|
|
|
2629
|
-
if (byid !== 'system'
|
|
2870
|
+
if (byid !== 'system' && bytype !== 'dummy' && bytype !== 'workflow') {
|
|
2630
2871
|
uri = util/* default.get */.Z.get(agentM[byid], 'avatar_url') || acc.logo_url || __webpack_require__(4761);
|
|
2631
2872
|
}
|
|
2632
2873
|
|
|
@@ -2679,7 +2920,8 @@ class Event extends common/* Com */.up {
|
|
|
2679
2920
|
ev: ev
|
|
2680
2921
|
}), (0,preact_module.h)(ButtonAttachments, {
|
|
2681
2922
|
store: this.props.store,
|
|
2682
|
-
ev: ev
|
|
2923
|
+
ev: ev,
|
|
2924
|
+
t: this.props.t
|
|
2683
2925
|
}), (0,preact_module.h)(FormAttachments, {
|
|
2684
2926
|
store: this.props.store,
|
|
2685
2927
|
onSubmit: this.props.onFormSubmit,
|
|
@@ -2693,9 +2935,11 @@ class Event extends common/* Com */.up {
|
|
|
2693
2935
|
}), (0,preact_module.h)(GenericTemplateAttachments, {
|
|
2694
2936
|
store: this.props.store,
|
|
2695
2937
|
ev: ev,
|
|
2696
|
-
onSelect: e => this.choosePostbackBtn(e)
|
|
2938
|
+
onSelect: e => this.choosePostbackBtn(e),
|
|
2939
|
+
t: this.props.t
|
|
2697
2940
|
}), (0,preact_module.h)(ProductAttachments, {
|
|
2698
2941
|
t: this.props.t,
|
|
2942
|
+
onPostback: e => this.choosePostbackBtn(e),
|
|
2699
2943
|
store: this.props.store,
|
|
2700
2944
|
ev: ev
|
|
2701
2945
|
}), (0,preact_module.h)(OrderAttachments_ProductAttachments, {
|
|
@@ -2767,7 +3011,8 @@ class Event extends common/* Com */.up {
|
|
|
2767
3011
|
ev: ev
|
|
2768
3012
|
}), (0,preact_module.h)(ButtonAttachments, {
|
|
2769
3013
|
store: this.props.store,
|
|
2770
|
-
ev: ev
|
|
3014
|
+
ev: ev,
|
|
3015
|
+
t: this.props.t
|
|
2771
3016
|
}), (0,preact_module.h)(FormAttachments, {
|
|
2772
3017
|
store: this.props.store,
|
|
2773
3018
|
onSubmit: this.props.onFormSubmit,
|
|
@@ -2805,11 +3050,10 @@ class Event extends common/* Com */.up {
|
|
|
2805
3050
|
getSenderName(ev) {
|
|
2806
3051
|
let bytype = util/* default.get */.Z.get(ev, 'by.type');
|
|
2807
3052
|
let byid = util/* default.get */.Z.get(ev, 'by.display_id', util/* default.get */.Z.get(ev, 'by.id'));
|
|
2808
|
-
if (
|
|
2809
|
-
let user = this.props.store.matchUser();
|
|
3053
|
+
if (bytype === 'user') return util/* default.getUserDisplayName */.Z.getUserDisplayName(this.props.store.matchUser());
|
|
2810
3054
|
let acc = this.props.store.matchAccount();
|
|
2811
|
-
if (bytype === 'user') return util/* default.getUserDisplayName */.Z.getUserDisplayName(user);
|
|
2812
3055
|
if (bytype === 'agent') return util/* default.getAgentDisplayName */.Z.getAgentDisplayName(acc, this.props.store.matchAgent(byid));
|
|
3056
|
+
if (byid === 'system' || bytype === 'dummy' || bytype === 'workflow') return acc.name || 'system';
|
|
2813
3057
|
return '';
|
|
2814
3058
|
}
|
|
2815
3059
|
|
|
@@ -2916,6 +3160,7 @@ class Events extends common/* Com */.up {
|
|
|
2916
3160
|
}));
|
|
2917
3161
|
processEvents(convo, events);
|
|
2918
3162
|
let $events = util/* default.map */.Z.map(events, ev => (0,preact_module.h)(Event, {
|
|
3163
|
+
chatbox: this.props.chatbox,
|
|
2919
3164
|
onLink: this.props.onLink,
|
|
2920
3165
|
store: this.props.store,
|
|
2921
3166
|
onFormSubmit: this.props.onFormSubmit,
|
|
@@ -3149,6 +3394,8 @@ class Typing extends common/* Com */.up {
|
|
|
3149
3394
|
return;
|
|
3150
3395
|
}
|
|
3151
3396
|
|
|
3397
|
+
let ag = this.props.store.matchAgent(ev.by.id) || {};
|
|
3398
|
+
if (ag.type == 'agent') return;
|
|
3152
3399
|
if (util/* default.get */.Z.get(ev, 'type') !== 'conversation_typing') return;
|
|
3153
3400
|
this.setState({
|
|
3154
3401
|
ev: ev,
|
|
@@ -3161,7 +3408,7 @@ class Typing extends common/* Com */.up {
|
|
|
3161
3408
|
this.setState({
|
|
3162
3409
|
isShow: false
|
|
3163
3410
|
});
|
|
3164
|
-
},
|
|
3411
|
+
}, 5000);
|
|
3165
3412
|
});
|
|
3166
3413
|
}
|
|
3167
3414
|
|
|
@@ -4061,6 +4308,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4061
4308
|
loading: true,
|
|
4062
4309
|
order: {},
|
|
4063
4310
|
err: {},
|
|
4311
|
+
shipping_address: 'new',
|
|
4064
4312
|
selectedProvince: null,
|
|
4065
4313
|
selectedDistrict: null,
|
|
4066
4314
|
selectedWard: null,
|
|
@@ -4353,16 +4601,17 @@ class order_Order extends common/* Com */.up {
|
|
|
4353
4601
|
|
|
4354
4602
|
order_defineProperty(this, "onCancel", () => {
|
|
4355
4603
|
if (this.props.onResponse) this.props.onResponse('rejected');
|
|
4356
|
-
this.close();
|
|
4357
|
-
});
|
|
4358
4604
|
|
|
4359
|
-
order_defineProperty(this, "close", () => {
|
|
4360
4605
|
if (this.props.cid && !this.state.order.user_confirmation) {
|
|
4361
4606
|
let order = util/* default.cloneDeep */.Z.cloneDeep(this.state.order);
|
|
4362
4607
|
order.user_confirmation = 'rejected';
|
|
4363
4608
|
this.props.store.updateOrder(order);
|
|
4364
4609
|
}
|
|
4365
4610
|
|
|
4611
|
+
this.close();
|
|
4612
|
+
});
|
|
4613
|
+
|
|
4614
|
+
order_defineProperty(this, "close", () => {
|
|
4366
4615
|
if (this.props.onClose) this.props.onClose();
|
|
4367
4616
|
});
|
|
4368
4617
|
|
|
@@ -4432,7 +4681,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4432
4681
|
return null;
|
|
4433
4682
|
let editmode = false;
|
|
4434
4683
|
|
|
4435
|
-
if (!order.status || order.status == '
|
|
4684
|
+
if (!order.status || order.status == 'open') {
|
|
4436
4685
|
editmode = !order.user_confirmation;
|
|
4437
4686
|
}
|
|
4438
4687
|
|
|
@@ -4523,7 +4772,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4523
4772
|
renderDesktopShipping(order) {
|
|
4524
4773
|
let editmode = false;
|
|
4525
4774
|
|
|
4526
|
-
if (!order.status || order.status == '
|
|
4775
|
+
if (!order.status || order.status == 'open') {
|
|
4527
4776
|
editmode = !order.user_confirmation;
|
|
4528
4777
|
}
|
|
4529
4778
|
|
|
@@ -4824,7 +5073,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4824
5073
|
}, (0,preact_module.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", null, util/* default.get */.Z.get(order, 'shipping.fee', 0), " d"));
|
|
4825
5074
|
let editmode = false;
|
|
4826
5075
|
|
|
4827
|
-
if (!order.status || order.status == '
|
|
5076
|
+
if (!order.status || order.status == 'open') {
|
|
4828
5077
|
editmode = !order.user_confirmation;
|
|
4829
5078
|
}
|
|
4830
5079
|
|
|
@@ -4860,7 +5109,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4860
5109
|
}
|
|
4861
5110
|
|
|
4862
5111
|
renderStatusBadge(order) {
|
|
4863
|
-
let status = order.status || '
|
|
5112
|
+
let status = order.status || 'open';
|
|
4864
5113
|
return (0,preact_module.h)("div", {
|
|
4865
5114
|
style: "float: right !important;",
|
|
4866
5115
|
class: 'order_status order_status__' + status
|
|
@@ -4868,7 +5117,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4868
5117
|
}
|
|
4869
5118
|
|
|
4870
5119
|
renderShippingInfo(order) {
|
|
4871
|
-
if (order.status != '
|
|
5120
|
+
if (order.status != 'open' || order.user_confirmation) {}
|
|
4872
5121
|
|
|
4873
5122
|
let shipping_provider = util/* default.get */.Z.get(order, 'shipping.shipping_provider');
|
|
4874
5123
|
if (!shipping_provider) return null;
|
|
@@ -4968,7 +5217,7 @@ class order_Order extends common/* Com */.up {
|
|
|
4968
5217
|
let $products = null;
|
|
4969
5218
|
let editmode = false;
|
|
4970
5219
|
|
|
4971
|
-
if (!order.status || order.status == '
|
|
5220
|
+
if (!order.status || order.status == 'open') {
|
|
4972
5221
|
editmode = !order.user_confirmation;
|
|
4973
5222
|
}
|
|
4974
5223
|
|
|
@@ -5072,7 +5321,7 @@ class order_Order extends common/* Com */.up {
|
|
|
5072
5321
|
onClick: this.onCancel
|
|
5073
5322
|
}, this.props.t('cancel_order'));
|
|
5074
5323
|
|
|
5075
|
-
if (order.user_confirmation || order.status != '
|
|
5324
|
+
if (order.user_confirmation || order.status != 'open') {
|
|
5076
5325
|
$status = null;
|
|
5077
5326
|
if (this.props.cid) $close = (0,preact_module.h)("div", {
|
|
5078
5327
|
class: "order_btn order__btn__light mt-3",
|
|
@@ -5104,7 +5353,7 @@ class order_Order extends common/* Com */.up {
|
|
|
5104
5353
|
let $actions = null;
|
|
5105
5354
|
let editmode = false;
|
|
5106
5355
|
|
|
5107
|
-
if (!order.status || order.status == '
|
|
5356
|
+
if (!order.status || order.status == 'open') {
|
|
5108
5357
|
editmode = !order.user_confirmation;
|
|
5109
5358
|
}
|
|
5110
5359
|
|
|
@@ -5512,6 +5761,48 @@ class Widget extends common/* Com */.up {
|
|
|
5512
5761
|
constructor(props) {
|
|
5513
5762
|
super(props);
|
|
5514
5763
|
|
|
5764
|
+
Widget_defineProperty(this, "msgInput", (0,preact_module/* createRef */.Vf)());
|
|
5765
|
+
|
|
5766
|
+
Widget_defineProperty(this, "sendMessage", async message => {
|
|
5767
|
+
let hasPostback = util/* default.find */.Z.find(message.attachments, att => att.type === 'postback');
|
|
5768
|
+
|
|
5769
|
+
if (this.isFormRequired() && hasPostback) {
|
|
5770
|
+
this.onStartConvoClick();
|
|
5771
|
+
this.fillQuickReplyToQuestion(message);
|
|
5772
|
+
return;
|
|
5773
|
+
}
|
|
5774
|
+
|
|
5775
|
+
let text = message.text;
|
|
5776
|
+
|
|
5777
|
+
if (!this.props.cid) {
|
|
5778
|
+
this.creating = true;
|
|
5779
|
+
const {
|
|
5780
|
+
convo,
|
|
5781
|
+
error
|
|
5782
|
+
} = await this.props.store.startConvo({
|
|
5783
|
+
locale: this.props.t.locale(),
|
|
5784
|
+
message: text,
|
|
5785
|
+
initial_by: this.props.store.matchUser().id
|
|
5786
|
+
});
|
|
5787
|
+
|
|
5788
|
+
if (error) {}
|
|
5789
|
+
|
|
5790
|
+
this.creating = false;
|
|
5791
|
+
this.props.store.sendConvoEvent(convo.id, 'message_sent', {
|
|
5792
|
+
message
|
|
5793
|
+
});
|
|
5794
|
+
this.props.onGo({
|
|
5795
|
+
view: 'chat',
|
|
5796
|
+
cid: convo.id
|
|
5797
|
+
});
|
|
5798
|
+
return;
|
|
5799
|
+
}
|
|
5800
|
+
|
|
5801
|
+
this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
5802
|
+
message
|
|
5803
|
+
});
|
|
5804
|
+
});
|
|
5805
|
+
|
|
5515
5806
|
Widget_defineProperty(this, "onLink", (e, url) => {
|
|
5516
5807
|
if (!url) return e.preventDefault();
|
|
5517
5808
|
let noschemeurl = url.replace(/(^\w+:|^)\/\//, '');
|
|
@@ -5542,7 +5833,8 @@ class Widget extends common/* Com */.up {
|
|
|
5542
5833
|
clickedJoin: false,
|
|
5543
5834
|
formData: {},
|
|
5544
5835
|
showOrder: false,
|
|
5545
|
-
order_id: ''
|
|
5836
|
+
order_id: '',
|
|
5837
|
+
quickReplyMessage: {}
|
|
5546
5838
|
});
|
|
5547
5839
|
this.props.store.onUpdate(this, _ => this.forceUpdate());
|
|
5548
5840
|
}
|
|
@@ -5560,7 +5852,8 @@ class Widget extends common/* Com */.up {
|
|
|
5560
5852
|
if (prevProp.cid !== this.props.cid) {
|
|
5561
5853
|
this.closeOrder();
|
|
5562
5854
|
this.setState({
|
|
5563
|
-
clickedJoin: false
|
|
5855
|
+
clickedJoin: false,
|
|
5856
|
+
quickReplyMessage: {}
|
|
5564
5857
|
});
|
|
5565
5858
|
setTimeout(() => {
|
|
5566
5859
|
this.events && this.events.focus();
|
|
@@ -5572,6 +5865,13 @@ class Widget extends common/* Com */.up {
|
|
|
5572
5865
|
}
|
|
5573
5866
|
|
|
5574
5867
|
shouldShowForm() {
|
|
5868
|
+
let form;
|
|
5869
|
+
let accountSetting = this.props.plugin.chatbox || {};
|
|
5870
|
+
let acc = this.props.store.matchAccount() || {};
|
|
5871
|
+
if (util/* default.get */.Z.get(accountSetting, 'prechat_form.enabled')) form = accountSetting.prechat_form;
|
|
5872
|
+
let offlineEnabled = util/* default.get */.Z.get(accountSetting, 'offline_form.enabled');
|
|
5873
|
+
if (this.isOffline(acc, accountSetting) && offlineEnabled) form = accountSetting.offline_form;
|
|
5874
|
+
if (!this.hasSentMessage(this.props.cid) && form && (util/* default.size */.Z.size(form.groups) || form.group_required)) return true;
|
|
5575
5875
|
let formRequired = this.isFormRequired();
|
|
5576
5876
|
return formRequired && !this.props.cid || formRequired && this.props.cid && this.state.clickedJoin;
|
|
5577
5877
|
}
|
|
@@ -5644,17 +5944,23 @@ class Widget extends common/* Com */.up {
|
|
|
5644
5944
|
if (hasError) return this.forceUpdate();
|
|
5645
5945
|
let data = util/* default.cloneDeep */.Z.cloneDeep(this.state.formData);
|
|
5646
5946
|
let user = util/* default.cloneDeep */.Z.cloneDeep(this.props.store.matchUser());
|
|
5947
|
+
let is_lead = false;
|
|
5647
5948
|
util/* default.map */.Z.map(data, (field, key) => {
|
|
5648
5949
|
if (!key.startsWith('attr:')) return;
|
|
5649
5950
|
var attr = {
|
|
5650
5951
|
key: key.substr(5)
|
|
5651
5952
|
};
|
|
5953
|
+
is_lead = is_lead || key == 'emails' || key == 'phones';
|
|
5652
5954
|
if (field.type === 'number') attr.number = parseInt(field.value);
|
|
5653
5955
|
if (field.type === 'datetime') attr.datetime = new util/* default.Date */.Z.Date(field.value).toISOString();
|
|
5654
5956
|
if (field.type === 'list') attr.list = field.value;
|
|
5655
5957
|
if (field.type === 'text' || field.type === 'boolean') attr[field.type] = field.value;
|
|
5656
5958
|
util/* default.setUserAttr */.Z.setUserAttr(user, attr);
|
|
5657
5959
|
});
|
|
5960
|
+
if (is_lead) util/* default.setUserAttr */.Z.setUserAttr(user, {
|
|
5961
|
+
key: 'lead_source',
|
|
5962
|
+
text: 'widget'
|
|
5963
|
+
});
|
|
5658
5964
|
let firstmsg = util/* default.get */.Z.get(data, 'question.value');
|
|
5659
5965
|
let groupid = util/* default.get */.Z.get(data, 'group.value', '');
|
|
5660
5966
|
|
|
@@ -5670,9 +5976,13 @@ class Widget extends common/* Com */.up {
|
|
|
5670
5976
|
fields: [{
|
|
5671
5977
|
key: 'to_agent_group',
|
|
5672
5978
|
value: util/* default.stringify */.Z.stringify(groupid)
|
|
5673
|
-
}]
|
|
5979
|
+
}],
|
|
5980
|
+
attachments: this.state.quickReplyMessage.attachments
|
|
5674
5981
|
}
|
|
5675
5982
|
});
|
|
5983
|
+
this.setState({
|
|
5984
|
+
quickReplyMessage: {}
|
|
5985
|
+
});
|
|
5676
5986
|
if (form.end_conversation_after_submit) await this.props.store.endConvo(this.props.cid);
|
|
5677
5987
|
return;
|
|
5678
5988
|
}
|
|
@@ -5693,11 +6003,11 @@ class Widget extends common/* Com */.up {
|
|
|
5693
6003
|
this.setState({
|
|
5694
6004
|
creatingError: null
|
|
5695
6005
|
});
|
|
6006
|
+
await this.props.store.setUser(user);
|
|
5696
6007
|
const {
|
|
5697
6008
|
error,
|
|
5698
6009
|
convo
|
|
5699
6010
|
} = await this.props.store.startConvo(req);
|
|
5700
|
-
this.props.store.setUser(user);
|
|
5701
6011
|
|
|
5702
6012
|
if (error) {
|
|
5703
6013
|
this.setState({
|
|
@@ -5718,7 +6028,8 @@ class Widget extends common/* Com */.up {
|
|
|
5718
6028
|
});
|
|
5719
6029
|
this.setState({
|
|
5720
6030
|
creating: false,
|
|
5721
|
-
clickedJoin: false
|
|
6031
|
+
clickedJoin: false,
|
|
6032
|
+
quickReplyMessage: {}
|
|
5722
6033
|
});
|
|
5723
6034
|
if (!this.props.store.isMobile()) this.focusInput();
|
|
5724
6035
|
}
|
|
@@ -5729,7 +6040,8 @@ class Widget extends common/* Com */.up {
|
|
|
5729
6040
|
key: 'question',
|
|
5730
6041
|
is_required: true,
|
|
5731
6042
|
label: this.props.t.i18n(util/* default.get */.Z.get(form, `i18n_question_label`, {})) || form.question_label,
|
|
5732
|
-
type: 'text'
|
|
6043
|
+
type: 'text',
|
|
6044
|
+
value: this.state.quickReplyMessage.text
|
|
5733
6045
|
};
|
|
5734
6046
|
this.setState({
|
|
5735
6047
|
formData
|
|
@@ -5782,6 +6094,7 @@ class Widget extends common/* Com */.up {
|
|
|
5782
6094
|
renderFields() {
|
|
5783
6095
|
if (util/* default.size */.Z.size(this.state.formData) === 0) return null;
|
|
5784
6096
|
let $fields = util/* default.map */.Z.map(this.state.formData, (field, key) => {
|
|
6097
|
+
if (this.state.quickReplyMessage.text && key === 'question') return null;
|
|
5785
6098
|
let $field = null;
|
|
5786
6099
|
var errclass = field.error ? 'input--error' : '';
|
|
5787
6100
|
|
|
@@ -5998,7 +6311,7 @@ class Widget extends common/* Com */.up {
|
|
|
5998
6311
|
|
|
5999
6312
|
blur() {
|
|
6000
6313
|
if (this.props.store.isPreview) return;
|
|
6001
|
-
var $input = this.msgInput;
|
|
6314
|
+
var $input = this.msgInput.current;
|
|
6002
6315
|
if (!$input) return;
|
|
6003
6316
|
setTimeout(() => $input && $input.blur());
|
|
6004
6317
|
setTimeout(() => $input && $input.blur(), 300);
|
|
@@ -6022,7 +6335,7 @@ class Widget extends common/* Com */.up {
|
|
|
6022
6335
|
return;
|
|
6023
6336
|
}
|
|
6024
6337
|
|
|
6025
|
-
var $input = this.msgInput;
|
|
6338
|
+
var $input = this.msgInput.current;
|
|
6026
6339
|
if (!$input) return;
|
|
6027
6340
|
setTimeout(() => $input.focus());
|
|
6028
6341
|
setTimeout(() => $input.focus(), 300);
|
|
@@ -6038,35 +6351,16 @@ class Widget extends common/* Com */.up {
|
|
|
6038
6351
|
this.focusInput();
|
|
6039
6352
|
}
|
|
6040
6353
|
|
|
6041
|
-
|
|
6042
|
-
let
|
|
6043
|
-
|
|
6044
|
-
if (!this.props.cid) {
|
|
6045
|
-
this.creating = true;
|
|
6046
|
-
const {
|
|
6047
|
-
convo,
|
|
6048
|
-
error
|
|
6049
|
-
} = await this.props.store.startConvo({
|
|
6050
|
-
locale: this.props.t.locale(),
|
|
6051
|
-
message: text,
|
|
6052
|
-
initial_by: this.props.store.matchUser().id
|
|
6053
|
-
});
|
|
6054
|
-
|
|
6055
|
-
if (error) {}
|
|
6354
|
+
fillQuickReplyToQuestion(message) {
|
|
6355
|
+
let formData = this.state.formData;
|
|
6056
6356
|
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
message
|
|
6060
|
-
});
|
|
6061
|
-
this.props.onGo({
|
|
6062
|
-
view: 'chat',
|
|
6063
|
-
cid: convo.id
|
|
6064
|
-
});
|
|
6065
|
-
return;
|
|
6357
|
+
if (formData) {
|
|
6358
|
+
util/* default.set */.Z.set(formData, 'question.value', message.text);
|
|
6066
6359
|
}
|
|
6067
6360
|
|
|
6068
|
-
this.
|
|
6069
|
-
|
|
6361
|
+
this.setState({
|
|
6362
|
+
formData,
|
|
6363
|
+
quickReplyMessage: message
|
|
6070
6364
|
});
|
|
6071
6365
|
}
|
|
6072
6366
|
|
|
@@ -6077,9 +6371,9 @@ class Widget extends common/* Com */.up {
|
|
|
6077
6371
|
renderChat() {
|
|
6078
6372
|
let $input = (0,preact_module.h)(MessageInput, {
|
|
6079
6373
|
store: this.props.store,
|
|
6080
|
-
ref:
|
|
6374
|
+
ref: this.msgInput,
|
|
6081
6375
|
cid: this.props.cid,
|
|
6082
|
-
onSend:
|
|
6376
|
+
onSend: this.sendMessage,
|
|
6083
6377
|
t: this.props.t
|
|
6084
6378
|
});
|
|
6085
6379
|
let convo = this.props.store.matchConvo(this.props.cid) || {};
|
|
@@ -6102,6 +6396,7 @@ class Widget extends common/* Com */.up {
|
|
|
6102
6396
|
isShow: this.props.isShow,
|
|
6103
6397
|
onLink: this.onLink,
|
|
6104
6398
|
store: this.props.store,
|
|
6399
|
+
chatbox: this.props.plugin.chatbox || {},
|
|
6105
6400
|
onFormSubmit: e => this.onEventFormSubmit(e),
|
|
6106
6401
|
ref: ref => this.events = ref,
|
|
6107
6402
|
cid: this.props.cid,
|
|
@@ -6139,7 +6434,8 @@ class Widget extends common/* Com */.up {
|
|
|
6139
6434
|
cid: ''
|
|
6140
6435
|
});
|
|
6141
6436
|
this.setState({
|
|
6142
|
-
clickedJoin: true
|
|
6437
|
+
clickedJoin: true,
|
|
6438
|
+
quickReplyMessage: {}
|
|
6143
6439
|
});
|
|
6144
6440
|
}
|
|
6145
6441
|
|
|
@@ -6164,12 +6460,12 @@ class Widget extends common/* Com */.up {
|
|
|
6164
6460
|
let formData = this.fillForm(form);
|
|
6165
6461
|
let convo = this.props.store.matchConvo(this.props.cid) || {};
|
|
6166
6462
|
if (convo.state === 'ended') return true;
|
|
6167
|
-
if (this.userHasSent(this.props.cid)) return false;
|
|
6168
6463
|
if (convo.state && convo.state !== 'pending') delete formData.group;
|
|
6169
|
-
return !!util/* default.find */.Z.find(formData, field => field.value == null || field.value === '');
|
|
6464
|
+
return !!util/* default.find */.Z.find(formData, field => field.is_required && (field.value == null || field.value === ''));
|
|
6170
6465
|
}
|
|
6171
6466
|
|
|
6172
6467
|
renderConvoSummary(convo) {
|
|
6468
|
+
let accountSetting = this.props.plugin.chatbox || {};
|
|
6173
6469
|
let agentM = this.props.store.matchAgent('*');
|
|
6174
6470
|
let ags = util/* default.filter */.Z.filter(convo.members, m => {
|
|
6175
6471
|
return (m.type === 'agent' || m.type === 'bot') && m.membership === 'active';
|
|
@@ -6181,7 +6477,7 @@ class Widget extends common/* Com */.up {
|
|
|
6181
6477
|
fullname: 'Offline Agent'
|
|
6182
6478
|
});
|
|
6183
6479
|
var name = util/* default.each */.Z.each(agents, ag => ag.fullname).join(', ');
|
|
6184
|
-
if (!name) name = this.props.store.matchAccount().name;
|
|
6480
|
+
if (accountSetting.hide_agent_profile || !name) name = this.props.store.matchAccount().name;
|
|
6185
6481
|
if (!name) name = this.props.t('agent');
|
|
6186
6482
|
var $you = null;
|
|
6187
6483
|
|
|
@@ -6268,6 +6564,15 @@ class Widget extends common/* Com */.up {
|
|
|
6268
6564
|
return joined;
|
|
6269
6565
|
}
|
|
6270
6566
|
|
|
6567
|
+
hasSentMessage(cid) {
|
|
6568
|
+
let convo = this.props.store.matchConvo(cid) || {};
|
|
6569
|
+
let joined = util/* default.find */.Z.find(convo.members, mem => {
|
|
6570
|
+
if (mem.type === 'bot') return true;
|
|
6571
|
+
return mem.last_sent;
|
|
6572
|
+
});
|
|
6573
|
+
return joined;
|
|
6574
|
+
}
|
|
6575
|
+
|
|
6271
6576
|
isOffline(acc, accSetting) {
|
|
6272
6577
|
let enableWhen = util/* default.get */.Z.get(accSetting, 'offline_form.enable_when');
|
|
6273
6578
|
let isonline = true;
|
|
@@ -6523,6 +6828,14 @@ class Main extends common/* Com */.up {
|
|
|
6523
6828
|
}
|
|
6524
6829
|
|
|
6525
6830
|
p = p || {};
|
|
6831
|
+
|
|
6832
|
+
if (!p.view && !p.cid) {
|
|
6833
|
+
let convoM = this.props.store.matchConvo('*');
|
|
6834
|
+
let redconvo = util/* default.find */.Z.find(convoM, convo => !util/* default.isConvoSeen */.Z.isConvoSeen(convo, this.props.store.matchUser().id));
|
|
6835
|
+
p.cid = util/* default.get */.Z.get(redconvo, 'id', util/* default.get */.Z.get(convoM, '0.id'));
|
|
6836
|
+
p.view = 'chat';
|
|
6837
|
+
}
|
|
6838
|
+
|
|
6526
6839
|
if (this.props.store.isMobile()) modifyViewport();
|
|
6527
6840
|
this.setState({
|
|
6528
6841
|
widgetConvoId: p.cid,
|
|
@@ -6563,11 +6876,13 @@ class Main extends common/* Com */.up {
|
|
|
6563
6876
|
}
|
|
6564
6877
|
|
|
6565
6878
|
function restoreViewport() {
|
|
6879
|
+
if (document.body && document.body.classList) document.body.classList.remove('sbz_no_scroll');
|
|
6566
6880
|
let metatag = document.getElementById('subiz-meta-viewport');
|
|
6567
6881
|
if (metatag) metatag.remove();
|
|
6568
6882
|
}
|
|
6569
6883
|
|
|
6570
6884
|
function modifyViewport() {
|
|
6885
|
+
if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
|
|
6571
6886
|
let metatag = document.createElement('meta');
|
|
6572
6887
|
metatag.httpEquiv = 'X-UA-Compatible';
|
|
6573
6888
|
metatag.name = 'viewport';
|