@chat21/chat21-ionic 3.0.75 → 3.0.76-rc.2

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/deploy_amazon_beta.sh +1 -1
  3. package/package.json +1 -1
  4. package/src/app/app.component.ts +1 -1
  5. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +1 -1
  6. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.ts +22 -8
  7. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +9 -9
  8. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +9 -2
  9. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +5 -6
  10. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +12 -5
  11. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.scss +5 -13
  12. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +4 -9
  13. package/src/app/chatlib/conversation-detail/message/frame/frame.component.ts +8 -3
  14. package/src/app/chatlib/conversation-detail/message/image/image.component.ts +2 -2
  15. package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.ts +6 -1
  16. package/src/app/components/canned-response/canned-response.component.html +26 -0
  17. package/src/app/components/canned-response/canned-response.component.scss +141 -0
  18. package/src/app/components/canned-response/canned-response.component.spec.ts +24 -0
  19. package/src/app/components/canned-response/canned-response.component.ts +281 -0
  20. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +0 -2
  21. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +10 -9
  22. package/src/app/pages/conversation-detail/conversation-detail.module.ts +2 -0
  23. package/src/app/pages/conversation-detail/conversation-detail.page.html +42 -13
  24. package/src/app/pages/conversation-detail/conversation-detail.page.scss +16 -21
  25. package/src/app/pages/conversation-detail/conversation-detail.page.ts +111 -329
  26. package/src/app/pages/conversations-list/conversations-list.page.ts +28 -2
  27. package/src/app/pages/loader-preview/loader-preview.page.ts +8 -27
  28. package/src/app/services/canned-responses/canned-responses.service.ts +43 -7
  29. package/src/app/utils/scrollbar-theme.directive.ts +2 -1
  30. package/src/assets/i18n/ar.json +2 -0
  31. package/src/assets/i18n/az.json +2 -0
  32. package/src/assets/i18n/de.json +2 -0
  33. package/src/assets/i18n/en.json +2 -0
  34. package/src/assets/i18n/es.json +2 -0
  35. package/src/assets/i18n/fr.json +2 -0
  36. package/src/assets/i18n/it.json +2 -0
  37. package/src/assets/i18n/kk.json +2 -0
  38. package/src/assets/i18n/pt.json +2 -0
  39. package/src/assets/i18n/ru.json +2 -0
  40. package/src/assets/i18n/sr.json +2 -0
  41. package/src/assets/i18n/sv.json +2 -0
  42. package/src/assets/i18n/tr.json +2 -0
  43. package/src/assets/i18n/uk.json +2 -0
  44. package/src/assets/i18n/uz.json +2 -0
  45. package/src/chat-config-pre.json +1 -1
  46. package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +14 -4
  47. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +1 -1
  48. package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +22 -0
  49. package/src/chat21-core/utils/constants.ts +3 -1
  50. package/src/chat21-core/utils/utils.ts +14 -0
  51. package/src/global.scss +3 -113
@@ -22,6 +22,7 @@ import {
22
22
  IonContent,
23
23
  IonTextarea,
24
24
  IonButton,
25
+ IonInput,
25
26
  } from '@ionic/angular'
26
27
 
27
28
  // models
@@ -44,7 +45,7 @@ import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/a
44
45
  import { ConversationHandlerService } from 'src/chat21-core/providers/abstract/conversation-handler.service'
45
46
  import { ContactsService } from 'src/app/services/contacts/contacts.service'
46
47
  import { CannedResponsesService } from '../../services/canned-responses/canned-responses.service'
47
- import { compareValues, htmlEntities } from '../../../chat21-core/utils/utils'
48
+ import { compareValues, getDateDifference, htmlEntities } from '../../../chat21-core/utils/utils'
48
49
  import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service'
49
50
  import { PresenceService } from 'src/chat21-core/providers/abstract/presence.service'
50
51
  import { CreateCannedResponsePage } from 'src/app/pages/create-canned-response/create-canned-response.page'
@@ -100,7 +101,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
100
101
 
101
102
  private unsubscribe$: Subject<any> = new Subject<any>()
102
103
  private subscriptions: Array<any>
103
- public tenant: string
104
+ public tenant: string;
104
105
  public loggedUser: UserModel
105
106
  public conversationWith: string
106
107
  public conversationWithFullname: string
@@ -128,10 +129,9 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
128
129
  public showIonContent = false
129
130
  public conv_type: string
130
131
 
131
- public tagsCanned: any = []
132
- public tagsCannedCount: number
133
- public tagsCannedFilter: any = []
134
- public HIDE_CANNED_RESPONSES: boolean = false
132
+ public messageStr: string;
133
+ public tagsCannedFilter: Array<any>= [];
134
+ public HIDE_CANNED_RESPONSES: boolean = true
135
135
 
136
136
  public window: any = window
137
137
  public styleMap: Map<string, string> = new Map()
@@ -140,7 +140,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
140
140
  MESSAGE_TYPE_MINE = MESSAGE_TYPE_MINE
141
141
  MESSAGE_TYPE_OTHERS = MESSAGE_TYPE_OTHERS
142
142
 
143
- arrowkeyLocation = -1
143
+
144
144
  public_Key: any;
145
145
  areVisibleCAR: boolean;
146
146
  supportMode: boolean;
@@ -227,6 +227,8 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
227
227
 
228
228
  this.events.publish('supportconvid:haschanged', this.conversationWith)
229
229
  })
230
+
231
+
230
232
  }
231
233
 
232
234
  // -----------------------------------------------------------
@@ -481,7 +483,6 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
481
483
  this.logger.log('[CONVS-DETAIL] - initialize -> conversationWith: ', this.conversationWith, ' -> conversationWithFullname: ', this.conversationWithFullname)
482
484
  this.subscriptions = []
483
485
  this.setHeightTextArea()
484
- this.tagsCanned = [] // list of canned
485
486
 
486
487
  this.messages = [] // list messages of conversation
487
488
  this.isFileSelected = false // indicates if a file has been selected (image to upload)
@@ -634,6 +635,8 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
634
635
  'INFO_SUPPORT_CHAT_REOPENED',
635
636
  'INFO_SUPPORT_CHAT_CLOSED',
636
637
  'INFO_A_NEW_SUPPORT_REQUEST_HAS_BEEN_ASSIGNED_TO_YOU',
638
+ 'INFO_SUPPORT_LEAD_UPDATED',
639
+ 'INFO_SUPPORT_MEMBER_LEFT_GROUP',
637
640
  'LABEL_TODAY',
638
641
  'LABEL_TOMORROW',
639
642
  'LABEL_LAST_ACCESS',
@@ -758,6 +761,8 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
758
761
  conv.conversation_with_fullname,
759
762
  conv.channel_type,
760
763
  )
764
+ let duration = getDateDifference(conv.timestamp, Date.now())
765
+ duration.days > 10? this.disableTextarea = true: this.disableTextarea = false
761
766
  }
762
767
  })
763
768
  }
@@ -768,11 +773,14 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
768
773
  this.logger.debug('[CONV-COMP] setHeaderContent getConversationDetail: archivedConversationsHandlerService', this.conversationWith, this.conv_type)
769
774
  this.archivedConversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
770
775
  if (conv) {
776
+
771
777
  this.conversationAvatar = setConversationAvatar(
772
778
  conv.conversation_with,
773
779
  conv.conversation_with_fullname,
774
780
  conv.channel_type,
775
781
  )
782
+ let duration = getDateDifference(conv.timestamp, Date.now())
783
+ duration.days > 10? this.disableTextarea = true: this.disableTextarea = false
776
784
  }
777
785
  if(!conv){
778
786
  this.conversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
@@ -797,10 +805,10 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
797
805
  // this.logger.log('[CONVS-DETAIL] - setHeaderContent > conversationAvatar: ', this.conversationAvatar);
798
806
  }
799
807
 
808
+
809
+
800
810
  returnSendMessage(e: any) {
801
811
  this.logger.log('[CONVS-DETAIL] - returnSendMessage event', e, ' - conversationWith', this.conversationWith)
802
-
803
- this.logger.log('[CONVS-DETAIL] - returnSendMessage event message', e.message)
804
812
  try {
805
813
  let message = ''
806
814
  if (e.message) {
@@ -822,12 +830,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
822
830
  * @param metadata
823
831
  * @param additional_attributes
824
832
  */
825
- sendMessage(
826
- msg: string,
827
- type: string,
828
- metadata?: any,
829
- additional_attributes?: any,
830
- ) {
833
+ sendMessage(msg: string, type: string, metadata?: any, additional_attributes?: any) {
831
834
  this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - MSG: ', msg)
832
835
  this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - type: ', type)
833
836
  this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - metadata: ', metadata)
@@ -866,18 +869,6 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
866
869
  }
867
870
  }
868
871
 
869
- // else if (type === 'image') {
870
- // if (msg) {
871
- // // msg = msg + '<br>' + 'File: ' + metadata.src;
872
- // msg = metadata.name + '\n' + msg
873
-
874
- // } else {
875
-
876
- // msg = metadata.name
877
- // }
878
-
879
- // }
880
-
881
872
  metadata ? (metadata = metadata) : (metadata = '')
882
873
  this.logger.log('[CONVS-DETAIL] - SEND MESSAGE msg: ', msg, ' - messages: ', this.messages, ' - loggedUser: ', this.loggedUser)
883
874
 
@@ -1032,7 +1023,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1032
1023
  this.conversationAvatar = setConversationAvatar(
1033
1024
  this.conversationWith,
1034
1025
  this.conversationWithFullname,
1035
- this.conversationAvatar.channel_type
1026
+ this.channelType
1036
1027
  )
1037
1028
 
1038
1029
  }
@@ -1158,7 +1149,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1158
1149
  this.logger.log('[CONVS-DETAIL] - returnChangeTextArea - canned responses pos of / (using lastIndexOf) ', pos)
1159
1150
 
1160
1151
  if (pos === -1) {
1161
- this.tagsCannedFilter = []
1152
+ // this.tagsCannedFilter = []
1162
1153
  this.HIDE_CANNED_RESPONSES = true
1163
1154
  }
1164
1155
  // test
@@ -1180,64 +1171,47 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1180
1171
  // --------------------------------------------
1181
1172
  // Load canned responses
1182
1173
  // --------------------------------------------
1183
- this.loadTagsCanned(strSearch, this.conversationWith)
1184
-
1174
+ this.HIDE_CANNED_RESPONSES = false
1175
+ this.messageStr = strSearch
1185
1176
  // ------------------------------------------------------------------------------------------------------------------------------------------
1186
1177
  // Hide / display Canned when the SLASH has POSITION POS 0 and checking if there is a space after the SLASH (in this case it will be hidden)
1187
1178
  // ------------------------------------------------------------------------------------------------------------------------------------------
1188
1179
 
1189
- var after_slash = message.substring(
1190
- message.lastIndexOf('/') + 1,
1191
- message.length,
1192
- )
1193
- if (
1194
- pos === 0 &&
1195
- after_slash.length === 1 &&
1196
- after_slash.trim() === ''
1197
- ) {
1180
+ var after_slash = message.substring( message.lastIndexOf('/') + 1, message.length)
1181
+ if (pos === 0 && after_slash.length === 1 && after_slash.trim() === '' ) {
1198
1182
  this.logger.log('[CONVS-DETAIL] - returnChangeTextArea after_slash --> there is a white space after ')
1199
1183
  this.HIDE_CANNED_RESPONSES = true
1200
- this.tagsCannedFilter = []
1184
+ // this.tagsCannedFilter = []
1201
1185
  } else if (pos === 0 && after_slash.length === 0) {
1202
1186
  this.logger.log('[CONVS-DETAIL] - returnChangeTextArea after_slash --> there is NOT a white space after')
1203
1187
  this.HIDE_CANNED_RESPONSES = false
1204
1188
  }
1205
1189
 
1206
1190
  if (pos > 0) {
1207
- // ------------------------------------------------------------------------------------------------------------------------------------------
1208
- // Hide / display Canned when the SLASH has POSITION POS > and checking if there is a space after the SLASH (in this case they it be hidden)
1209
- // and if there is not a space before the SLASH (in this it will be hidden)
1210
- // ------------------------------------------------------------------------------------------------------------------------------------------
1211
-
1212
- let beforeSlash = message.substr(pos - 1)
1213
- let afterSlash = message.substr(pos + 1)
1214
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea * POS ', pos)
1215
-
1216
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash', beforeSlash)
1217
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash', afterSlash)
1218
- var afterSlashParts = afterSlash.split('/')
1219
- var beforeSlashParts = beforeSlash.split('/')
1220
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash parts', afterSlashParts)
1221
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash parts', beforeSlashParts)
1222
-
1223
- if (beforeSlashParts.length === 2) {
1224
- if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0] === '') {
1191
+ // // ------------------------------------------------------------------------------------------------------------------------------------------
1192
+ // // Hide / display Canned when the SLASH has POSITION POS > and checking if there is a space after the SLASH (in this case they it be hidden)
1193
+ // // and if there is not a space before the SLASH (in this it will be hidden)
1194
+ // // ------------------------------------------------------------------------------------------------------------------------------------------
1195
+
1196
+ let beforeSlash = message.substr(0, pos)
1197
+ let afterSlash = message.substr(pos + 1)
1198
+ this.logger.log('[CONVS-DETAIL] - returnChangeTextArea * POS ', pos)
1199
+
1200
+ this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash', beforeSlash)
1201
+ this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash', afterSlash)
1202
+
1203
+
1204
+ if(beforeSlash[beforeSlash.length-1].indexOf(' ') >= 0 && afterSlash[0] === ''){
1225
1205
  this.HIDE_CANNED_RESPONSES = false
1226
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash there is a white space After Not')
1227
- // if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0].indexOf(' ') >= 0)
1228
- } else if (beforeSlashParts[0].indexOf(' ') < 0 && afterSlashParts[0] === '') {
1206
+ } else if(beforeSlash[beforeSlash.length-1].indexOf(' ') < 0 && afterSlash[0] === '' ){
1229
1207
  this.HIDE_CANNED_RESPONSES = true
1230
- this.tagsCannedFilter = []
1231
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After Not')
1232
- } else if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0] === ' ') {
1233
- this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After YES')
1208
+ } else if(beforeSlash[beforeSlash.length-1].indexOf(' ') >= 0 && afterSlash[0] === ' '){
1234
1209
  this.HIDE_CANNED_RESPONSES = true
1235
- this.tagsCannedFilter = []
1210
+ // this.tagsCannedFilter = []
1236
1211
  }
1237
1212
  }
1238
- }
1239
1213
  } else {
1240
- this.tagsCannedFilter = []
1214
+ // this.tagsCannedFilter = []
1241
1215
  }
1242
1216
  }
1243
1217
  }, 300)
@@ -1248,140 +1222,12 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1248
1222
  }
1249
1223
  }
1250
1224
 
1251
- // ----------------------------------------------------------
1252
- // @ CANNED RESPONSES methods
1253
- // ----------------------------------------------------------
1254
- loadTagsCanned(strSearch, conversationWith) {
1255
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned strSearch ', strSearch)
1256
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned groupDetail ', this.groupDetail)
1257
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned conversationWith ', conversationWith)
1258
-
1259
- const conversationWith_segments = conversationWith.split('-')
1260
- // Removes the last element of the array if is = to the separator
1261
- if (conversationWith_segments[conversationWith_segments.length - 1] === '') {
1262
- conversationWith_segments.pop()
1263
- }
1264
-
1265
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned conversationWith_segments ', conversationWith_segments)
1266
- let projectId = ''
1267
-
1268
- if (conversationWith_segments.length === 4) {
1269
- projectId = conversationWith_segments[2]
1270
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned projectId ', projectId)
1271
- this.getAndShowCannedResponses(strSearch, projectId)
1272
- } else {
1273
- this.getProjectIdByConversationWith(strSearch, this.conversationWith)
1274
- }
1275
- }
1276
-
1277
- getProjectIdByConversationWith(strSearch, conversationWith: string) {
1278
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1279
-
1280
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe((res) => {
1281
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES', res)
1282
- if (res) {
1283
- const projectId = res.id_project
1284
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT projectId ', projectId)
1285
- if (projectId) {
1286
- this.getAndShowCannedResponses(strSearch, projectId)
1287
- }
1288
- }
1289
- }, (error) => {
1290
- this.logger.error('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
1291
- }, () => {
1292
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT * COMPLETE *')
1293
- })
1294
- }
1295
-
1296
- getAndShowCannedResponses(strSearch, projectId) {
1297
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1298
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned tagsCanned.length', this.tagsCanned.length)
1299
- //if(this.tagsCanned.length <= 0 ){
1300
- this.tagsCanned = []
1301
- this.cannedResponsesService.getCannedResponses(tiledeskToken, projectId).subscribe((res) => {
1302
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses RES', res)
1303
-
1304
- this.tagsCanned = res
1305
- this.tagsCannedCount = res.length
1306
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses tagsCannedCount', this.tagsCannedCount)
1307
- if (this.HIDE_CANNED_RESPONSES === false) {
1308
- this.showTagsCanned(strSearch)
1309
- }
1310
- }, (error) => {
1311
- this.logger.error('[CONVS-DETAIL] - loadTagsCanned getCannedResponses - ERROR ', error)
1312
- }, () => {
1313
- this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses * COMPLETE *')
1314
- })
1315
- }
1316
-
1317
- showTagsCanned(strSearch) {
1318
- this.logger.log('[CONVS-DETAIL] - showTagsCanned strSearch ', strSearch)
1319
- this.tagsCannedFilter = []
1320
- var tagsCannedClone = JSON.parse(JSON.stringify(this.tagsCanned))
1321
- this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedClone ', tagsCannedClone)
1322
- //this.logger.log("that.contacts lenght:: ", strSearch);
1323
- this.tagsCannedFilter = this.filterItems(tagsCannedClone, strSearch)
1324
- this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedFilter ', this.tagsCannedFilter)
1325
-
1326
- this.tagsCannedFilter.sort(compareValues('title', 'asc'))
1327
- var strReplace = strSearch
1328
- if (strSearch.length > 0) {
1329
- strReplace = "<b class='highlight-search-string'>" + strSearch + '</b>'
1330
- }
1331
- for (var i = 0; i < this.tagsCannedFilter.length; i++) {
1332
- let text = htmlEntities(this.tagsCannedFilter[i].text);
1333
- // const textCanned = "<div class='cannedText'>" + this.replacePlaceholderInCanned(this.tagsCannedFilter[i].text) + '</div>'
1334
- const textCanned = "<div class='cannedText'>" + this.replacePlaceholderInCanned(text) + '</div>'
1335
- let title = htmlEntities(this.tagsCannedFilter[i].title)
1336
- // this.tagsCannedFilter[i].title = "<div class='cannedContent'><div class='cannedTitle'>" + this.tagsCannedFilter[i].title.toString().replace(strSearch, strReplace.trim()) + '</div>' + textCanned + '</div>'
1337
- this.tagsCannedFilter[i].title = "<div class='cannedContent'><div class='cannedTitle'>" + title.toString().replace(strSearch, strReplace.trim()) + '</div>' + textCanned + '</div>'
1338
-
1339
- }
1340
- if (this.tagsCannedCount === 0) {
1341
- // const button = this.renderer.createElement('button');
1342
- // const buttonText = this.renderer.createText('Click me');
1343
- // this.renderer.appendChild(button, buttonText);
1344
- // console.log('[CONVS-DETAIL] - this.el.nativeElement ', this.el.nativeElement)
1345
- // this.renderer.listen(button, 'click', () => { alert('hi'); });
1346
- // let nocanned = {}
1347
- // if (this.USER_ROLE !== 'agent') {
1348
- const nocanned = {
1349
- // "<div class='cannedContent'><div class='cannedTitle nocannedTitle #noCannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div><div class='cannedText'>" + this.translationMap.get('TO_CREATE_THEM_GO_TO_THE_PROJECT') + '</div></div>'
1350
- // <div class='cannedText no-canned-available-text'>" + this.translationMap.get('AddNewCannedResponse') + '</div>
1351
- title:
1352
- "<div class='cannedContent'><div class='cannedTitle nocannedTitle #noCannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div></div>",
1353
- text: 'There are no canned responses available',
1354
- }
1355
- // } else if (this.USER_ROLE === 'agent') {
1356
- // nocanned = {
1357
- // // "<div class='cannedContent'><div class='cannedTitle nocannedTitle #noCannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div><div class='cannedText'>" + this.translationMap.get('TO_CREATE_THEM_GO_TO_THE_PROJECT') + '</div></div>'
1358
- // title:
1359
- // "<div class='cannedContent'><div class='cannedTitle nocannedTitle #noCannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div></div>",
1360
- // text: 'There are no canned responses available',
1361
- // }
1362
- // }
1363
- this.tagsCannedFilter.push(nocanned)
1364
- }
1365
- }
1225
+
1366
1226
 
1367
1227
  toggleSidebar() {
1368
1228
  // console.log('[CONVS-DETAIL] has clicked test')
1369
1229
  }
1370
1230
 
1371
- filterItems(items, searchTerm) {
1372
- this.logger.log('[CONVS-DETAIL] filterItems tagsCannedClone ', items, ' searchTerm: ', searchTerm)
1373
- //this.logger.log("filterItems::: ",searchTerm);
1374
- return items.filter((item) => {
1375
- //this.logger.log("filterItems::: ", item.title.toString().toLowerCase());
1376
- this.logger.log('[CONVS-DETAIL] filtered tagsCannedClone item ', item)
1377
- return (
1378
- item.title
1379
- .toString()
1380
- .toLowerCase()
1381
- .indexOf(searchTerm.toString().toLowerCase()) > -1
1382
- )
1383
- })
1384
- }
1385
1231
 
1386
1232
  replacePlaceholderInCanned(str) {
1387
1233
  this.logger.log('[CONVS-DETAIL] - replacePlaceholderInCanned str ', str)
@@ -1392,50 +1238,48 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1392
1238
  return str
1393
1239
  }
1394
1240
 
1395
- replaceTagInMessage(canned, event) {
1396
- if (this.tagsCannedCount > 0) {
1397
- // console.log('[CONVS-DETAIL] replaceTagInMessage event ', event)
1398
- // console.log('[CONVS-DETAIL] replaceTagInMessage canned ', canned)
1399
- // console.log('[CONVS-DETAIL] replaceTagInMessage canned title', canned.title)
1400
- // console.log('[CONVS-DETAIL] replaceTagInMessage canned contains nocannedTitle', canned.title.includes('nocannedTitle'))
1241
+ onLoadedCannedResponses(event){
1242
+ this.logger.log('[CONVS-DETAIL] onLoadedCannedResponses --> ',event)
1243
+ if(event && event.length > 0 ){
1244
+ this.tagsCannedFilter = event
1245
+ }
1246
+ }
1401
1247
 
1402
- const elTextArea = this.rowTextArea['el']
1403
- const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
1248
+ replaceTagInMessage(canned, event?) {
1249
+ const elTextArea = this.rowTextArea['el']
1250
+ const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
1251
+ // console.log('[CONVS-DETAIL] replaceTagInMessage textArea ', textArea)
1252
+ // console.log('[CONVS-DETAIL] replaceTagInMessage textArea value', textArea.value,)
1404
1253
 
1405
- // console.log('[CONVS-DETAIL] replaceTagInMessage textArea ', textArea)
1406
- // console.log('[CONVS-DETAIL] replaceTagInMessage textArea value', textArea.value,)
1254
+ // var lastChar = textArea.value.substr(-1); // Selects the last character
1255
+ // if (lastChar === '/') {
1256
+ // textArea.value = textArea.value.substring(0, textArea.value.length() - 1);
1257
+ // }
1258
+ // this.insertAtCursor(this.textArea, textArea.value)
1259
+
1260
+ this.logger.log('[CONVS-DETAIL] replaceTagInMessage canned text ', canned.text)
1261
+
1262
+ // replace text
1263
+ var strTEMP = textArea.value.replace(/\/$/ig, canned.text)
1264
+ strTEMP = this.replacePlaceholderInCanned(strTEMP)
1265
+ this.logger.log('[CONVS-DETAIL] replaceTagInMessage strSearch ', strTEMP)
1266
+ // strTEMP = this.replacePlaceholderInCanned(strTEMP);
1267
+ // textArea.value = '';
1268
+ // that.messageString = strTEMP;
1269
+ textArea.value = strTEMP
1270
+ setTimeout(() => {
1271
+ // textArea.focus();
1272
+ textArea.setFocus()
1273
+ // this.resizeTextArea()
1274
+ }, 200)
1275
+
1276
+ }
1407
1277
 
1408
- // var lastChar = textArea.value.substr(-1); // Selects the last character
1409
- // if (lastChar === '/') {
1410
- // textArea.value = textArea.value.substring(0, textArea.value.length() - 1);
1411
- // }
1412
- // this.insertAtCursor(this.textArea, textArea.value)
1413
-
1414
- this.arrowkeyLocation = -1
1415
- this.tagsCannedFilter = []
1416
- this.logger.log('[CONVS-DETAIL] replaceTagInMessage canned text ', canned.text)
1417
-
1418
- // replace text
1419
- var pos = textArea.value.lastIndexOf('/')
1420
- var strSearch = textArea.value.substr(pos)
1421
- this.logger.log('[CONVS-DETAIL] replaceTagInMessage strSearch ', strSearch)
1422
-
1423
- var strTEMP = textArea.value.replace(strSearch, canned.text)
1424
- strTEMP = this.replacePlaceholderInCanned(strTEMP)
1425
- this.logger.log('[CONVS-DETAIL] replaceTagInMessage strSearch ', strTEMP)
1426
- // strTEMP = this.replacePlaceholderInCanned(strTEMP);
1427
- // textArea.value = '';
1428
- // that.messageString = strTEMP;
1429
- textArea.value = strTEMP
1430
- setTimeout(() => {
1431
- // textArea.focus();
1432
- textArea.setFocus()
1433
- this.resizeTextArea()
1434
- }, 200)
1435
- }
1436
- else {
1437
- this.logger.log('[CONVS-DETAIL] THERE IS NOT CANNED ', canned.text)
1438
- }
1278
+
1279
+ closeListCannedResponse(){
1280
+ this.logger.log('[CONVS-DETAIL] close list canned . . . ')
1281
+ this.HIDE_CANNED_RESPONSES = true
1282
+ this.tagsCannedFilter = []
1439
1283
  }
1440
1284
 
1441
1285
  async presentCreateCannedResponseModal(): Promise<any> {
@@ -1458,27 +1302,22 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1458
1302
  return await modal.present()
1459
1303
  }
1460
1304
 
1461
- hasClickedOpenCannedResponses($event) {
1462
- this.logger.log('[CONVS-DETAIL] - hasClickedOpenCannedResponses ', $event)
1305
+ onClickOpenCannedResponses($event) {
1306
+ this.logger.log('[CONVS-DETAIL] - onClickOpenCannedResponses ', $event)
1463
1307
  const elTextArea = this.rowTextArea['el']
1464
1308
  const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
1465
-
1466
- this.logger.log('[CONVS-DETAIL] hasClickedOpenCannedResponses textArea ', textArea)
1467
- // console.log("[CONVS-DETAIL] hasClickedOpenCannedResponses textArea value", textArea.value)
1468
- var lastChar = textArea.value[textArea.value.length - 1]
1469
- // console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses lastChar', lastChar)
1470
- if (lastChar !== '/') {
1471
- this.insertAtCursor(textArea, '/')
1309
+ if($event && elTextArea){
1310
+ this.logger.log('[CONVS-DETAIL] onClickOpenCannedResponses textArea ', textArea)
1311
+ // console.log("[CONVS-DETAIL] onClickOpenCannedResponses textArea value", textArea.value)
1312
+ var lastChar = textArea.value[textArea.value.length - 1]
1313
+ // console.log('[CONVS-DETAIL] onClickOpenCannedResponses lastChar', lastChar)
1314
+ if (lastChar !== '/') {
1315
+ this.insertAtCursor(textArea, '/')
1316
+ }
1317
+ this.setCaretPosition(textArea)
1318
+ }else{
1319
+ this.HIDE_CANNED_RESPONSES = true
1472
1320
  }
1473
- // console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses textArea.value', textArea.value)
1474
- // setTimeout(() => {
1475
- // // if (textArea.value === '/') {
1476
- // // textArea.focus();
1477
- // textArea.setFocus();
1478
- // // }
1479
- // }, 1500);
1480
-
1481
- this.setCaretPosition(textArea)
1482
1321
  }
1483
1322
 
1484
1323
  setCaretPosition(ctrl) {
@@ -1530,40 +1369,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1530
1369
  }
1531
1370
  }
1532
1371
 
1533
- @HostListener('document:keydown', ['$event'])
1534
- handleKeyboardEvent(event: KeyboardEvent) {
1535
- // this.logger.log("CONVERSATION-DETAIL handleKeyboardEvent event.key ", event.key);
1536
-
1537
- if (this.tagsCannedFilter.length > 0) {
1538
- if (event.key === 'ArrowDown') {
1539
- this.arrowkeyLocation++
1540
- if (this.arrowkeyLocation === this.tagsCannedFilter.length) {
1541
- this.arrowkeyLocation--
1542
- }
1543
- // this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
1544
- } else if (event.key === 'ArrowUp') {
1545
- if (this.arrowkeyLocation > 0) {
1546
- this.arrowkeyLocation--
1547
- } else if (this.arrowkeyLocation < 0) {
1548
- this.arrowkeyLocation++
1549
- }
1550
- // this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
1551
- }
1552
-
1553
- if (event.key === 'Enter') {
1554
- const canned_selected = this.tagsCannedFilter[this.arrowkeyLocation]
1555
- this.logger.log(
1556
- '[CONVS-DETAIL] replaceTagInMessage canned_selected ',
1557
- canned_selected,
1558
- )
1559
- if (canned_selected) {
1560
- this.replaceTagInMessage(canned_selected, 'enter')
1561
- // event.preventDefault();
1562
- // return false;
1563
- }
1564
- }
1565
- }
1566
- }
1372
+
1567
1373
  // ----------------------------------------------------------
1568
1374
  // ./end CANNED RESPONSES methods
1569
1375
  // ----------------------------------------------------------
@@ -1593,11 +1399,11 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1593
1399
  }, 1000)
1594
1400
  }
1595
1401
 
1596
- returnOnBeforeMessageRender(event) {
1402
+ onBeforeMessageRenderFN(event) {
1597
1403
  //this.onBeforeMessageRender.emit(event)
1598
1404
  }
1599
1405
 
1600
- returnOnAfterMessageRender(event) {
1406
+ onAfterMessageRenderFN(event) {
1601
1407
  // this.onAfterMessageRender.emit(event)
1602
1408
  }
1603
1409
 
@@ -1607,7 +1413,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1607
1413
 
1608
1414
  returnOnScrollContent(event: boolean) { }
1609
1415
 
1610
- returnOnAttachmentButtonClicked(event: any) {
1416
+ onAttachmentButtonClickedFN(event: any) {
1611
1417
  this.logger.debug('[CONV-COMP] eventbutton', event)
1612
1418
  if (!event || !event.target.type) {
1613
1419
  return
@@ -1640,9 +1446,9 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1640
1446
  }
1641
1447
  }
1642
1448
 
1643
- onImageRenderedFN(event) {
1449
+ onElementRenderedFN(event) {
1644
1450
  const imageRendered = event
1645
- if (this.showButtonToBottom) {
1451
+ if (event.status && this.ionContentChatArea) {
1646
1452
  this.scrollBottom(0)
1647
1453
  }
1648
1454
  }
@@ -1845,41 +1651,25 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1845
1651
 
1846
1652
  this.logger.log('[CONVS-DETAIL] ----> FILE - DROP ev ', ev)
1847
1653
  const fileList = ev.dataTransfer.files
1848
- this.logger.log(
1849
- '[CONVS-DETAIL] ----> FILE - DROP ev.dataTransfer.files ',
1850
- fileList,
1851
- )
1654
+ this.logger.log('[CONVS-DETAIL] ----> FILE - DROP ev.dataTransfer.files ',fileList)
1852
1655
  this.isHovering = false
1853
- this.logger.log(
1854
- '[CONVS-DETAIL] ----> FILE - DROP isHovering ',
1855
- this.isHovering,
1856
- )
1656
+ this.logger.log('[CONVS-DETAIL] ----> FILE - DROP isHovering ',this.isHovering)
1857
1657
  if (fileList.length > 0) {
1858
1658
  const file: File = fileList[0]
1859
1659
  this.logger.log('[CONVS-DETAIL] ----> FILE - DROP file ', file)
1860
1660
 
1861
1661
  var mimeType = fileList[0].type
1862
- this.logger.log(
1863
- '[CONVS-DETAIL] ----> FILE - DROP mimeType files ',
1864
- mimeType,
1865
- )
1662
+ this.logger.log('[CONVS-DETAIL] ----> FILE - DROP mimeType files ', mimeType)
1866
1663
 
1867
1664
  // if (mimeType.startsWith("image") || mimeType.startsWith("application")) {
1868
1665
  // this.logger.log('[CONVS-DETAIL] ----> FILE - DROP mimeType files: ', this.appConfigProvider.getConfig().fileUploadAccept);
1869
1666
  // this.checkAcceptedFile(mimeType);
1870
1667
  const isAccepted = this.checkAcceptedFile(mimeType)
1871
- this.logger.log(
1872
- '[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile FILE - DROP',
1873
- isAccepted,
1874
- )
1668
+ this.logger.log('[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile FILE - DROP',isAccepted)
1875
1669
  if (isAccepted === true) {
1876
1670
  this.handleDropEvent(ev)
1877
1671
  } else {
1878
- this.logger.log(
1879
- '[CONVS-DETAIL] ----> FILE - DROP mimeType files ',
1880
- mimeType,
1881
- 'NOT SUPPORTED FILE TYPE',
1882
- )
1672
+ this.logger.log( '[CONVS-DETAIL] ----> FILE - DROP mimeType files ', mimeType,'NOT SUPPORTED FILE TYPE')
1883
1673
  this.presentToastOnlyImageFilesAreAllowedToDrag()
1884
1674
  }
1885
1675
  }
@@ -1896,10 +1686,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1896
1686
  ev.stopPropagation()
1897
1687
  this.logger.log('[CONVS-DETAIL] ----> FILE - (dragover) allowDrop ev ', ev)
1898
1688
  this.isHovering = true
1899
- this.logger.log(
1900
- '[CONVS-DETAIL] ----> FILE - (dragover) allowDrop isHovering ',
1901
- this.isHovering,
1902
- )
1689
+ this.logger.log('[CONVS-DETAIL] ----> FILE - (dragover) allowDrop isHovering ',this.isHovering)
1903
1690
  }
1904
1691
 
1905
1692
  // DRAG LEAVE (WHEN LEAVE FROM THE DROP ZONE)
@@ -1908,17 +1695,12 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1908
1695
  ev.stopPropagation()
1909
1696
  this.logger.log('[CONVS-DETAIL] ----> FILE - (dragleave) drag ev ', ev)
1910
1697
  this.isHovering = false
1911
- this.logger.log(
1912
- '[CONVS-DETAIL] ----> FILE - FILE - (dragleave) drag his.isHovering ',
1913
- this.isHovering,
1914
- )
1698
+ this.logger.log('[CONVS-DETAIL] ----> FILE - FILE - (dragleave) drag his.isHovering ',this.isHovering)
1915
1699
  }
1916
1700
 
1917
1701
  async presentToastOnlyImageFilesAreAllowedToDrag() {
1918
1702
  const toast = await this.toastController.create({
1919
- message: this.translationMap.get(
1920
- 'FAILED_TO_UPLOAD_THE_FORMAT_IS_NOT_SUPPORTED',
1921
- ),
1703
+ message: this.translationMap.get('FAILED_TO_UPLOAD_THE_FORMAT_IS_NOT_SUPPORTED'),
1922
1704
  duration: 5000,
1923
1705
  color: 'danger',
1924
1706
  cssClass: 'toast-custom-class',