@webitel/ui-sdk 24.6.45 → 24.6.47

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "24.6.45",
3
+ "version": "24.6.47",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -1,5 +1,6 @@
1
1
  import * as XLSX from 'xlsx';
2
2
  import { saveAs } from 'file-saver-es';
3
+ import { objSnakeToCamel } from '../../scripts/caseConverters.js';
3
4
 
4
5
  export default class XLSExport {
5
6
  filename = 'export';
@@ -18,8 +19,42 @@ export default class XLSExport {
18
19
  this.downloadProgress = { count: 0 };
19
20
  }
20
21
 
21
- save(data) {
22
- const ws = XLSX.utils.json_to_sheet(data);
22
+ // NOTE: if the value is an object with a name property, extract the name to display it in the EXEL file
23
+ extractNameFromObject(value) {
24
+ if (value && typeof value === 'object' && value.name) {
25
+ return value.name;
26
+ }
27
+ return value;
28
+ }
29
+
30
+ // NOTE: creates a new object that only includes the properties specified in the columns array
31
+ filterDataByColumns(data, columns) {
32
+ return data.map(item => {
33
+ let filteredItem = {};
34
+ columns.forEach(column => {
35
+ const value = item.hasOwnProperty(column) ? this.extractNameFromObject(item[column]) : ''; // '' needed to display column that has no data
36
+ filteredItem[column] = value;
37
+ });
38
+ return filteredItem;
39
+ });
40
+ }
41
+
42
+ // NOTE: calculates the width of the columns based on the data to display it in the EXEL file
43
+ calculateColumnWidths(data, columns) {
44
+ return columns.map(column => {
45
+ const maxLength = data.reduce((max, item) => {
46
+ const value = item[column] || '';
47
+ return Math.max(max, value.toString().length);
48
+ }, column.length);
49
+ return { wch: maxLength + 2 }; // Adding some padding
50
+ });
51
+ }
52
+
53
+ save(data, columns) {
54
+ const filteredData = this.filterDataByColumns(data, columns);
55
+ const ws = XLSX.utils.json_to_sheet(filteredData);
56
+ const columnWidths = this.calculateColumnWidths(filteredData, columns);
57
+ ws['!cols'] = columnWidths;
23
58
  const wb = XLSX.utils.book_new();
24
59
  XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
25
60
  const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });
@@ -27,10 +62,12 @@ export default class XLSExport {
27
62
  saveAs(blob, `${this.filename}.xlsx`);
28
63
  }
29
64
 
30
- async export(params) {
65
+ async fetchAndPrepareData(params) {
31
66
  let data = [];
32
67
  let isNext = false;
33
68
  let page = 1;
69
+ let columns = params._columns ||
70
+ (params?.fields ? objSnakeToCamel(params?.fields) : []);
34
71
 
35
72
  do {
36
73
  const { items, next } = await this.fetchMethod({
@@ -43,8 +80,12 @@ export default class XLSExport {
43
80
  isNext = next;
44
81
  page += 1;
45
82
  } while (isNext);
83
+ return { data, columns };
84
+ }
46
85
 
47
- this.save(data);
86
+ async export(params) {
87
+ const { data, columns } = await this.fetchAndPrepareData(params);
88
+ this.save(data, columns);
48
89
  this.resetProgress();
49
90
  }
50
91
  }
@@ -4,6 +4,7 @@ export default {
4
4
  data: () => ({
5
5
  XLSExport: null,
6
6
  }),
7
+
7
8
  computed: {
8
9
  isXLSLoading() {
9
10
  return !!this.XLSDownloadProgress;
@@ -12,7 +13,14 @@ export default {
12
13
  XLSDownloadProgress() {
13
14
  return this.XLSExport ? this.XLSExport.downloadProgress.count : 0;
14
15
  },
15
-
16
+ selectedIds() {
17
+ return this.dataList
18
+ .filter((item) => item._isSelected)
19
+ .map((item) => item.id);
20
+ },
21
+ isAnySelected() {
22
+ return !!this.selectedIds.length;
23
+ },
16
24
  },
17
25
  methods: {
18
26
  initXLSExport(fetchMethod, options) {
@@ -33,6 +41,5 @@ export default {
33
41
  throw err;
34
42
  }
35
43
  },
36
-
37
44
  },
38
45
  };
@@ -2,6 +2,7 @@ import { CallActions, ChatActions, JobState } from 'webitel-sdk';
2
2
  import i18n from '../../../locale/i18n.js';
3
3
  import BaseStoreModule from '../../../store/BaseStoreModules/BaseStoreModule.js';
4
4
  import endChatSound from '../assets/audio/end-chat.wav';
5
+ import endCallSound from '../assets/audio/end-call.mp3';
5
6
  import newChatSound from '../assets/audio/new-chat.wav';
6
7
  import newMessageSound from '../assets/audio/new-message.wav';
7
8
  import ringingSound from '../assets/audio/ringing.mp3';
@@ -19,10 +20,11 @@ const getNotificationSound = (action) => {
19
20
  case ChatActions.Close:
20
21
  return new Audio(endChatSound);
21
22
  case CallActions.Ringing:
22
-
23
23
  const audio = new Audio(ringingSound);
24
24
  audio.loop = true;
25
25
  return audio;
26
+ case CallActions.Hangup:
27
+ return new Audio(endCallSound);
26
28
  default:
27
29
  return false;
28
30
  }
@@ -120,6 +122,10 @@ export default class NotificationsStoreModule extends BaseStoreModule {
120
122
  if (context.getters.IS_SOUND_ALLOWED
121
123
  && !localStorage.getItem('wtIsPlaying')
122
124
  ) {
125
+ if (action === CallActions.Hangup
126
+ && !localStorage.getItem('settings/callEndSound'))
127
+ return;
128
+
123
129
  const audio = sound instanceof Audio ? sound : new Audio(sound);
124
130
  audio.addEventListener('ended', () => {
125
131
  context.dispatch('STOP_SOUND');