versacall-dashboards-library-react 2.0.39 → 2.0.40

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 (102) hide show
  1. package/package.json +2 -2
  2. package/dist/components/DashboardsCell/DashboardsCell.js +0 -267
  3. package/dist/components/DashboardsCell/index.js +0 -15
  4. package/dist/components/DashboardsCellContent/DashboardsCellContent.js +0 -438
  5. package/dist/components/DashboardsCellContent/index.js +0 -15
  6. package/dist/components/DashboardsCellFindAndReplace/DashboardsCellFindAndReplace.js +0 -190
  7. package/dist/components/DashboardsCellFindAndReplace/index.js +0 -15
  8. package/dist/components/DashboardsCellGlobalActions/DashboardsCellGlobalActions.js +0 -218
  9. package/dist/components/DashboardsCellGlobalActions/index.js +0 -15
  10. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditions.js +0 -1043
  11. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditionsNestable.js +0 -927
  12. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditionsOld.js +0 -816
  13. package/dist/components/DashboardsCellGlobalConditions/index.js +0 -15
  14. package/dist/components/DashboardsCellGlobalStyles/DashboardsCellGlobalStyles.js +0 -394
  15. package/dist/components/DashboardsCellGlobalStyles/index.js +0 -15
  16. package/dist/components/DashboardsCellMergeUnmerge/DashboardsCellMergeUnmerge.js +0 -152
  17. package/dist/components/DashboardsCellMergeUnmerge/index.js +0 -15
  18. package/dist/components/DashboardsCellPosition/DashboardsCellPosition.js +0 -85
  19. package/dist/components/DashboardsCellPosition/index.js +0 -15
  20. package/dist/components/DashboardsCellSize/DashboardsCellSize.js +0 -89
  21. package/dist/components/DashboardsCellSize/index.js +0 -15
  22. package/dist/components/DashboardsCellStyle/DashboardsCellStyle.js +0 -83
  23. package/dist/components/DashboardsCellStyle/index.js +0 -15
  24. package/dist/components/DashboardsCellStyleAlignItems/DashboardsCellStyleAlignItems.js +0 -152
  25. package/dist/components/DashboardsCellStyleAlignItems/index.js +0 -15
  26. package/dist/components/DashboardsCellStyleBackgroundColor/DashboardsCellStyleBackgroundColor.js +0 -198
  27. package/dist/components/DashboardsCellStyleBackgroundColor/index.js +0 -15
  28. package/dist/components/DashboardsCellStyleClear/DashboardsCellStyleClear.js +0 -50
  29. package/dist/components/DashboardsCellStyleClear/index.js +0 -15
  30. package/dist/components/DashboardsCellStyleColor/DashboardsCellStyleColor.js +0 -198
  31. package/dist/components/DashboardsCellStyleColor/index.js +0 -15
  32. package/dist/components/DashboardsCellStyleDisplay/DashboardsCellStyleDisplay.js +0 -65
  33. package/dist/components/DashboardsCellStyleDisplay/index.js +0 -15
  34. package/dist/components/DashboardsCellStyleFontFamily/DashboardsCellStyleFontFamily.js +0 -64
  35. package/dist/components/DashboardsCellStyleFontFamily/index.js +0 -15
  36. package/dist/components/DashboardsCellStyleFontSize/DashboardsCellStyleFontSize.js +0 -89
  37. package/dist/components/DashboardsCellStyleFontSize/index.js +0 -15
  38. package/dist/components/DashboardsCellStyleJustifyContent/DashboardsCellStyleJustifyContent.js +0 -152
  39. package/dist/components/DashboardsCellStyleJustifyContent/index.js +0 -15
  40. package/dist/components/DashboardsCellStyleObjectFit/DashboardsCellStyleObjectFit.js +0 -81
  41. package/dist/components/DashboardsCellStyleObjectFit/index.js +0 -15
  42. package/dist/components/DashboardsCellStylePadding/DashboardsCellStylePadding.js +0 -105
  43. package/dist/components/DashboardsCellStylePadding/index.js +0 -15
  44. package/dist/components/DashboardsCellStyleWeightStyleDecoration/DashboardsCellStyleWeightStyleDecoration.js +0 -154
  45. package/dist/components/DashboardsCellStyleWeightStyleDecoration/index.js +0 -15
  46. package/dist/components/DashboardsCopyAndPaste/DashboardsCopyAndPaste.js +0 -112
  47. package/dist/components/DashboardsCopyAndPaste/index.js +0 -15
  48. package/dist/components/DashboardsEditor/DashboardsEditor.js +0 -415
  49. package/dist/components/DashboardsEditor/index.js +0 -15
  50. package/dist/components/DashboardsGlobalStylesPicker/DashboardsGlobalStylesPicker.js +0 -90
  51. package/dist/components/DashboardsGlobalStylesPicker/index.js +0 -15
  52. package/dist/components/DashboardsGrid/DashboardsGrid.js +0 -139
  53. package/dist/components/DashboardsGrid/index.js +0 -15
  54. package/dist/components/DashboardsMainFreehand/DashboardsMainFreehand.js +0 -466
  55. package/dist/components/DashboardsMainFreehand/index.js +0 -15
  56. package/dist/components/DashboardsMainMessaging/DashboardsMainMessaging.js +0 -628
  57. package/dist/components/DashboardsMainMessaging/index.js +0 -15
  58. package/dist/components/DashboardsMainTable/DashboardsMainTable.js +0 -626
  59. package/dist/components/DashboardsMainTable/index.js +0 -15
  60. package/dist/components/DashboardsPreview/DashboardsPreview.js +0 -113
  61. package/dist/components/DashboardsPreview/index.js +0 -15
  62. package/dist/components/DashboardsRatio/DashboardsRatio.js +0 -288
  63. package/dist/components/DashboardsRatio/DashboardsRatioOld.js +0 -211
  64. package/dist/components/DashboardsRatio/index.js +0 -15
  65. package/dist/components/DashboardsStatusBar/DashboardsStatusBar.css +0 -1
  66. package/dist/components/DashboardsStatusBar/DashboardsStatusBar.js +0 -137
  67. package/dist/components/DashboardsStatusBar/index.js +0 -15
  68. package/dist/components/DashboardsUndoRedo/DashboardsUndoRedo.js +0 -144
  69. package/dist/components/DashboardsUndoRedo/index.js +0 -15
  70. package/dist/components/DashboardsViewer/DashboardsViewer.js +0 -74
  71. package/dist/components/DashboardsViewer/index.js +0 -15
  72. package/dist/components/DashboardsWidthHeight/DashboardsWidthHeight.js +0 -98
  73. package/dist/components/DashboardsWidthHeight/index.js +0 -15
  74. package/dist/components/WidgetParameters/WidgetParameters.js +0 -383
  75. package/dist/components/WidgetParameters/index.js +0 -15
  76. package/dist/components/index.js +0 -287
  77. package/dist/constants/defaultFreehandCell.js +0 -23
  78. package/dist/constants/defaultFreehandDashboard.js +0 -23
  79. package/dist/constants/defaultMessagingDashboard.js +0 -53
  80. package/dist/constants/defaultStyle.js +0 -11
  81. package/dist/constants/defaultTableCell.js +0 -27
  82. package/dist/constants/defaultTableDashboard.js +0 -25
  83. package/dist/constants/index.js +0 -55
  84. package/dist/functions/addTranslations.js +0 -28
  85. package/dist/functions/calculateDashboardVariables.js +0 -146
  86. package/dist/functions/convertColorObject.js +0 -10
  87. package/dist/functions/convertColorString.js +0 -26
  88. package/dist/functions/convertPercentToInt.js +0 -10
  89. package/dist/functions/convertSecondsToElapsedTime.js +0 -37
  90. package/dist/functions/generateFreehandCell.js +0 -24
  91. package/dist/functions/generateFreehandDashboard.js +0 -19
  92. package/dist/functions/generateMessagingDashboard.js +0 -14
  93. package/dist/functions/generateSelected.js +0 -18
  94. package/dist/functions/generateTableCell.js +0 -18
  95. package/dist/functions/generateTableDashboard.js +0 -37
  96. package/dist/functions/index.js +0 -119
  97. package/dist/functions/mergeSelected.js +0 -22
  98. package/dist/functions/sortCells.js +0 -26
  99. package/dist/images/BackgroundTransparency.png +0 -0
  100. package/dist/index.js +0 -44
  101. package/dist/translations/en.json +0 -11
  102. package/dist/translations/es.json +0 -3
@@ -1,816 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _styles = require("@material-ui/core/styles");
13
-
14
- var _CardActionArea = _interopRequireDefault(require("@material-ui/core/CardActionArea"));
15
-
16
- var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
17
-
18
- var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
19
-
20
- var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));
21
-
22
- var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
23
-
24
- var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));
25
-
26
- var _Paper = _interopRequireDefault(require("@material-ui/core/Paper"));
27
-
28
- var _Grid = _interopRequireDefault(require("@material-ui/core/Grid"));
29
-
30
- var _Tabs = _interopRequireDefault(require("@material-ui/core/Tabs"));
31
-
32
- var _Tab = _interopRequireDefault(require("@material-ui/core/Tab"));
33
-
34
- var _Fab = _interopRequireDefault(require("@material-ui/core/Fab"));
35
-
36
- var _SettingsOutlined = _interopRequireDefault(require("@material-ui/icons/SettingsOutlined"));
37
-
38
- var _ArrowDownward = _interopRequireDefault(require("@material-ui/icons/ArrowDownward"));
39
-
40
- var _ArrowUpward = _interopRequireDefault(require("@material-ui/icons/ArrowUpward"));
41
-
42
- var _FileCopy = _interopRequireDefault(require("@material-ui/icons/FileCopy"));
43
-
44
- var _Settings = _interopRequireDefault(require("@material-ui/icons/Settings"));
45
-
46
- var _Delete = _interopRequireDefault(require("@material-ui/icons/Delete"));
47
-
48
- var _Add = _interopRequireDefault(require("@material-ui/icons/Add"));
49
-
50
- var _reactIntl = require("react-intl");
51
-
52
- var _versacallCoreLibraryReact = require("versacall-core-library-react");
53
-
54
- var _DashboardsCellGlobalStyles = _interopRequireDefault(require("../DashboardsCellGlobalStyles"));
55
-
56
- var _DashboardsCellContent = _interopRequireDefault(require("../DashboardsCellContent"));
57
-
58
- var _DashboardsCellStyle = _interopRequireDefault(require("../DashboardsCellStyle"));
59
-
60
- var _DashboardsPreview = _interopRequireDefault(require("../DashboardsPreview"));
61
-
62
- var _DashboardsCell = _interopRequireDefault(require("../DashboardsCell"));
63
-
64
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
65
-
66
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
67
-
68
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
69
-
70
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
71
-
72
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
73
-
74
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
75
-
76
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
77
-
78
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
79
-
80
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
81
-
82
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
83
-
84
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
85
-
86
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
87
-
88
- var muiStyles = () => ({
89
- dialog: {
90
- backgroundColor: '#eff4f8'
91
- }
92
- });
93
-
94
- var style = {
95
- root: {
96
- position: 'relative',
97
- display: 'flex',
98
- flexFlow: 'column',
99
- height: '76vh',
100
- padding: 16,
101
- paddingBottom: 0,
102
- // backgroundColor: '#e6e6e6',
103
- overflow: 'hidden'
104
- },
105
- fullHeight: {
106
- height: '100%',
107
- overflow: 'hidden'
108
- },
109
- paper: {
110
- display: 'block',
111
- boxSizing: 'border-box',
112
- padding: 16,
113
- overflow: 'hidden'
114
- },
115
- block: {
116
- display: 'block',
117
- boxSizing: 'border-box'
118
- },
119
- scrollHolder: {
120
- position: 'relative',
121
- height: '100%'
122
- },
123
- scroll: {
124
- position: 'absolute',
125
- width: '100%',
126
- height: '100%',
127
- overflow: 'auto',
128
- overflowY: 'scroll'
129
- },
130
- fab: {
131
- position: 'absolute',
132
- right: 22,
133
- bottom: 4
134
- },
135
- styleBox: {
136
- borderStyle: 'solid',
137
- borderWidth: 1,
138
- borderColor: 'rgba(0, 0, 0, 0.23',
139
- borderRadius: 4,
140
- padding: 16,
141
- marginBottom: 16,
142
- marginTop: 16
143
- },
144
- button: {
145
- textAlign: 'center',
146
- textTransform: 'uppercase',
147
- color: 'rgba(0, 0, 0, 0.87)',
148
- padding: '12px 24px',
149
- border: '1px solid rgba(0, 0, 0, 0.23)',
150
- fontSize: '0.9375rem',
151
- borderRadius: '4px'
152
- },
153
- information: {
154
- padding: 16,
155
- textTransform: 'uppercase'
156
- }
157
- };
158
- var operatorOptions = [{
159
- value: '===',
160
- label: '='
161
- }, {
162
- value: '>',
163
- label: '>'
164
- }, {
165
- value: '<',
166
- label: '<'
167
- }, {
168
- value: '!==',
169
- label: "".concat(String.fromCharCode(0x2260))
170
- }, {
171
- value: '>=',
172
- label: "".concat(String.fromCharCode(0x2265))
173
- }, {
174
- value: '<=',
175
- label: "".concat(String.fromCharCode(0x2264))
176
- }];
177
-
178
- var tabStyle = active => ({
179
- border: active ? '2px solid #008bcc' : '',
180
- borderRadius: '3px'
181
- });
182
-
183
- var contentPreviewCustomCell = ({
184
- row
185
- }) => /*#__PURE__*/_react.default.createElement("div", {
186
- style: {
187
- width: 120
188
- }
189
- }, /*#__PURE__*/_react.default.createElement(_DashboardsPreview.default, {
190
- width: "120px",
191
- height: "100px",
192
- padding: "10px"
193
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCell.default, {
194
- cell: {
195
- content: row.content,
196
- custom: {
197
- viewWidth: 120,
198
- viewHeight: 100,
199
- style: {}
200
- }
201
- }
202
- })));
203
-
204
- var conditionCustomCell = ({
205
- row
206
- }) => {
207
- var newCondition = row.condition;
208
-
209
- if (newCondition.split(' ').length === 3) {
210
- operatorOptions.forEach(option => {
211
- newCondition = newCondition.replace(new RegExp(option.value, 'g'), option.label);
212
- });
213
- }
214
-
215
- return newCondition;
216
- };
217
-
218
- class DashboardsCellGlobalConditions extends _react.Component {
219
- constructor(props) {
220
- super(props);
221
- this.state = {
222
- open: false,
223
- tabIndex: 0,
224
- conditionIndex: null,
225
- advanced: false,
226
- typeCondition: '',
227
- styleColumns: [{
228
- id: 'condition',
229
- style: {
230
- paddingRight: 0
231
- },
232
- label: props.intl.formatMessage({
233
- id: '__condition'
234
- }),
235
- customCell: custom => conditionCustomCell(custom)
236
- }, {
237
- id: 'preview',
238
- style: {
239
- paddingRight: 0
240
- },
241
- label: props.intl.formatMessage({
242
- id: '__preview'
243
- }),
244
- customCell: custom => this.stylePreviewCustomCell(custom)
245
- }, {
246
- id: 'actions',
247
- style: {
248
- textAlign: 'right'
249
- },
250
- label: props.intl.formatMessage({
251
- id: '__actions'
252
- }),
253
- customCell: custom => this.actionsCustomCell(custom)
254
- }],
255
- conditionColumns: [{
256
- id: 'condition',
257
- style: {
258
- paddingRight: 0
259
- },
260
- label: props.intl.formatMessage({
261
- id: '__condition'
262
- }),
263
- customCell: custom => conditionCustomCell(custom)
264
- }, {
265
- id: 'type',
266
- style: {
267
- paddingRight: 0
268
- },
269
- label: props.intl.formatMessage({
270
- id: '__type'
271
- }),
272
- customCell: custom => this.contentTypeCustomCell(custom)
273
- }, {
274
- id: 'preview',
275
- style: {
276
- paddingRight: 0
277
- },
278
- label: props.intl.formatMessage({
279
- id: '__preview'
280
- }),
281
- customCell: custom => contentPreviewCustomCell(custom)
282
- }, {
283
- id: 'actions',
284
- style: {
285
- textAlign: 'right'
286
- },
287
- label: props.intl.formatMessage({
288
- id: '__actions'
289
- }),
290
- customCell: custom => this.actionsCustomCell(custom)
291
- }]
292
- };
293
- }
294
-
295
- stylePreviewCustomCell({
296
- row
297
- }) {
298
- var _this = this;
299
-
300
- var newCell = JSON.parse(JSON.stringify(row));
301
- newCell.custom = {
302
- viewWidth: 120,
303
- viewHeight: 120,
304
- style: {}
305
- };
306
-
307
- if (this.props.styles.length > 0 && row.styleIds.length > 0) {
308
- var _loop = function _loop(i) {
309
- var findStyle = _this.props.styles.find(searchStyle => searchStyle.id === newCell.styleIds[i]);
310
-
311
- if (findStyle) {
312
- newCell.custom.style = _objectSpread(_objectSpread({}, newCell.custom.style), findStyle.options);
313
- }
314
- };
315
-
316
- for (var i = 0; i < newCell.styleIds.length; i++) {
317
- _loop(i);
318
- }
319
- }
320
-
321
- newCell.custom.style = _objectSpread(_objectSpread({}, newCell.custom.style), newCell.style);
322
- return /*#__PURE__*/_react.default.createElement("div", {
323
- style: {
324
- width: 120
325
- }
326
- }, /*#__PURE__*/_react.default.createElement(_DashboardsPreview.default, {
327
- width: "120px",
328
- height: "100px",
329
- padding: "10px"
330
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCell.default, {
331
- cell: {
332
- content: {
333
- type: 'text',
334
- text: 'Hello'
335
- },
336
- custom: newCell.custom
337
- }
338
- })));
339
- }
340
-
341
- contentTypeCustomCell({
342
- row
343
- }) {
344
- return /*#__PURE__*/_react.default.createElement("span", null, this.props.intl.formatMessage({
345
- id: "__".concat(row.content.type)
346
- }));
347
- }
348
-
349
- actionsCustomCell({
350
- row
351
- }) {
352
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, row.index !== '0' && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
353
- onClick: e => {
354
- e.stopPropagation();
355
- this.moveCondition(row.index, -1);
356
- }
357
- }, /*#__PURE__*/_react.default.createElement(_ArrowUpward.default, null)), row.index !== String(this.props.value[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].length - 1) && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
358
- onClick: e => {
359
- e.stopPropagation();
360
- this.moveCondition(row.index, 1);
361
- }
362
- }, /*#__PURE__*/_react.default.createElement(_ArrowDownward.default, null)), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
363
- onClick: e => {
364
- e.stopPropagation();
365
- this.copyCondition(row);
366
- }
367
- }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
368
- title: this.props.intl.formatMessage({
369
- id: '__copy'
370
- })
371
- }, /*#__PURE__*/_react.default.createElement(_FileCopy.default, null))), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
372
- onClick: e => {
373
- e.stopPropagation();
374
- this.deleteCondition(row.index);
375
- }
376
- }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
377
- title: this.props.intl.formatMessage({
378
- id: '__delete'
379
- })
380
- }, /*#__PURE__*/_react.default.createElement(_Delete.default, null))));
381
- }
382
-
383
- updateCondition(change) {
384
- var conditions = JSON.parse(JSON.stringify(this.props.value["".concat(this.state.typeCondition, "Conditions")]));
385
-
386
- if (this.state.advanced) {
387
- conditions[this.state.conditionIndex].condition = change.value;
388
- } else {
389
- var split = conditions[this.state.conditionIndex].condition.split(/[ ,]+/);
390
-
391
- switch (change.stringIndex) {
392
- case 0:
393
- conditions[this.state.conditionIndex].condition = "".concat(change.value, " ").concat(split[1], " ").concat(split[2]);
394
- break;
395
-
396
- case 1:
397
- conditions[this.state.conditionIndex].condition = "".concat(split[0], " ").concat(change.value, " ").concat(split[2]);
398
- break;
399
-
400
- case 2:
401
- conditions[this.state.conditionIndex].condition = "".concat(split[0], " ").concat(split[1], " ").concat(change.value);
402
- break;
403
-
404
- default:
405
- conditions[this.state.conditionIndex].condition = '1 > 0';
406
- break;
407
- }
408
- }
409
-
410
- this.props.updateValue({
411
- ["".concat(this.state.typeCondition, "Conditions")]: conditions
412
- });
413
- }
414
-
415
- updateStyleIds(value) {
416
- var styleConditions = JSON.parse(JSON.stringify(this.props.value.styleConditions));
417
- styleConditions[this.state.conditionIndex].styleIds = value.styleIds;
418
- this.props.updateValue({
419
- styleConditions: styleConditions
420
- });
421
- }
422
-
423
- updateStyle(value) {
424
- var styleConditions = JSON.parse(JSON.stringify(this.props.value.styleConditions));
425
-
426
- if (Object.keys(value.style).length > 0) {
427
- styleConditions[this.state.conditionIndex].style = _objectSpread(_objectSpread({}, styleConditions[this.state.conditionIndex].style), value.style);
428
- Object.keys(styleConditions[this.state.conditionIndex].style).forEach(key => {
429
- if (styleConditions[this.state.conditionIndex].style[key] === 'delete') {
430
- delete styleConditions[this.state.conditionIndex].style[key];
431
- }
432
- });
433
- } else {
434
- styleConditions[this.state.conditionIndex].style = {};
435
- }
436
-
437
- this.props.updateValue({
438
- styleConditions: styleConditions
439
- });
440
- }
441
-
442
- updateContent(value) {
443
- var contentConditions = JSON.parse(JSON.stringify(this.props.value.contentConditions));
444
- contentConditions[this.state.conditionIndex].content = value.content;
445
- this.props.updateValue({
446
- contentConditions: contentConditions
447
- });
448
- }
449
-
450
- addCondition() {
451
- var conditions = JSON.parse(JSON.stringify(this.props.value));
452
- var typeCondition = '';
453
- var index = null;
454
-
455
- if (this.state.tabIndex === 0) {
456
- conditions.styleConditions.push({
457
- condition: '1 > 0',
458
- style: {},
459
- styleIds: []
460
- });
461
- index = conditions.styleConditions.length - 1;
462
- typeCondition = 'style';
463
- } else {
464
- conditions.contentConditions.push({
465
- condition: '1 > 0',
466
- content: {
467
- type: 'text',
468
- text: ''
469
- }
470
- });
471
- index = conditions.contentConditions.length - 1;
472
- typeCondition = 'content';
473
- }
474
-
475
- this.props.updateValue({
476
- styleConditions: conditions.styleConditions,
477
- contentConditions: conditions.contentConditions
478
- });
479
- this.setState({
480
- conditionIndex: "".concat(index),
481
- advanced: false,
482
- typeCondition: typeCondition
483
- });
484
- }
485
-
486
- copyCondition(condition) {
487
- var conditions = JSON.parse(JSON.stringify(this.props.value));
488
- var newCondition = JSON.parse(JSON.stringify(condition));
489
- delete newCondition.index;
490
- conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].push(newCondition);
491
- this.props.updateValue({
492
- styleConditions: conditions.styleConditions,
493
- contentConditions: conditions.contentConditions
494
- });
495
- this.setState(prevState => ({
496
- conditionIndex: "".concat(conditions[prevState.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].length),
497
- advanced: false
498
- }));
499
- }
500
-
501
- deleteCondition(index) {
502
- var conditions = JSON.parse(JSON.stringify(this.props.value));
503
- conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].splice(Number(index), 1);
504
- this.props.updateValue({
505
- styleConditions: conditions.styleConditions,
506
- contentConditions: conditions.contentConditions
507
- });
508
- this.setState({
509
- conditionIndex: null,
510
- advanced: false
511
- });
512
- }
513
-
514
- moveCondition(index, direction) {
515
- var conditions = JSON.parse(JSON.stringify(this.props.value));
516
-
517
- var _conditions$splice = conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].splice(Number(index), 1),
518
- _conditions$splice2 = _slicedToArray(_conditions$splice, 1),
519
- removed = _conditions$splice2[0];
520
-
521
- conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].splice(Number(index) + direction, 0, removed);
522
- this.props.updateValue({
523
- styleConditions: conditions.styleConditions,
524
- contentConditions: conditions.contentConditions
525
- });
526
- this.setState({
527
- conditionIndex: null,
528
- advanced: false
529
- });
530
- }
531
-
532
- render() {
533
- var _this$props = this.props,
534
- classes = _this$props.classes,
535
- intl = _this$props.intl,
536
- value = _this$props.value,
537
- images = _this$props.images,
538
- styles = _this$props.styles,
539
- widgets = _this$props.widgets,
540
- variables = _this$props.variables;
541
- var _this$state = this.state,
542
- open = _this$state.open,
543
- tabIndex = _this$state.tabIndex,
544
- conditionIndex = _this$state.conditionIndex,
545
- advanced = _this$state.advanced,
546
- styleColumns = _this$state.styleColumns,
547
- conditionColumns = _this$state.conditionColumns;
548
- var currentCondition = null;
549
-
550
- if (conditionIndex) {
551
- currentCondition = tabIndex === 0 ? value.styleConditions[conditionIndex] : value.contentConditions[conditionIndex];
552
- }
553
-
554
- var totalConditions = value.styleConditions.length + value.contentConditions.length;
555
- return /*#__PURE__*/_react.default.createElement(_Grid.default, {
556
- xs: 6,
557
- item: true
558
- }, /*#__PURE__*/_react.default.createElement(_CardActionArea.default, {
559
- onClick: () => this.setState({
560
- open: true
561
- })
562
- }, /*#__PURE__*/_react.default.createElement("div", {
563
- style: style.button
564
- }, "".concat(intl.formatMessage({
565
- id: '__conditions'
566
- })).concat(totalConditions > 0 ? " (".concat(totalConditions, ")") : '')), totalConditions > 0 && /*#__PURE__*/_react.default.createElement("div", {
567
- style: style.information
568
- }, value.styleConditions.length > 0 && /*#__PURE__*/_react.default.createElement("div", null, "".concat(intl.formatMessage({
569
- id: '__style'
570
- }), ": ").concat(value.styleConditions.length)), value.contentConditions.length > 0 && /*#__PURE__*/_react.default.createElement("div", null, "".concat(intl.formatMessage({
571
- id: '__content'
572
- }), ": ").concat(value.contentConditions.length)))), open && /*#__PURE__*/_react.default.createElement(_Dialog.default, {
573
- maxWidth: "lg",
574
- onClose: () => this.setState({
575
- open: false,
576
- conditionIndex: null,
577
- advanced: false
578
- }),
579
- fullWidth: true,
580
- open: true,
581
- classes: {
582
- paper: classes.dialog
583
- }
584
- }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreToolbar, {
585
- title: intl.formatMessage({
586
- id: '__conditions_editor'
587
- }),
588
- handleClose: () => this.setState({
589
- open: false,
590
- conditionIndex: null,
591
- advanced: false
592
- })
593
- }, /*#__PURE__*/_react.default.createElement(_Button.default, {
594
- variant: "outlined",
595
- color: "primary",
596
- onClick: () => this.addCondition(),
597
- style: {
598
- marginRight: 10
599
- }
600
- }, /*#__PURE__*/_react.default.createElement(_Add.default, {
601
- className: classes.icon
602
- }), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
603
- id: "__add_condition"
604
- })), /*#__PURE__*/_react.default.createElement(_Tabs.default, {
605
- value: tabIndex,
606
- onChange: (event, index) => this.setState({
607
- tabIndex: index,
608
- conditionIndex: null,
609
- advanced: false
610
- }),
611
- centered: true
612
- }, /*#__PURE__*/_react.default.createElement(_Tab.default, {
613
- id: "style",
614
- label: "".concat(intl.formatMessage({
615
- id: '__style'
616
- }), " (").concat(value.styleConditions.length, ")"),
617
- style: tabStyle(tabIndex === 0)
618
- }), /*#__PURE__*/_react.default.createElement(_Tab.default, {
619
- id: "content",
620
- label: "".concat(intl.formatMessage({
621
- id: '__content'
622
- }), " (").concat(value.contentConditions.length, ")"),
623
- style: tabStyle(tabIndex === 1)
624
- }))), /*#__PURE__*/_react.default.createElement("div", {
625
- style: style.root
626
- }, /*#__PURE__*/_react.default.createElement(_Grid.default, {
627
- spacing: 16,
628
- style: style.fullHeight,
629
- container: true
630
- }, /*#__PURE__*/_react.default.createElement(_Grid.default, {
631
- xs: 7,
632
- item: true
633
- }, /*#__PURE__*/_react.default.createElement(_Paper.default, {
634
- style: _objectSpread(_objectSpread({}, style.paper), style.fullHeight)
635
- }, /*#__PURE__*/_react.default.createElement("div", {
636
- style: _objectSpread(_objectSpread({}, style.block), style.scrollHolder)
637
- }, /*#__PURE__*/_react.default.createElement("div", {
638
- style: style.scroll
639
- }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTable, {
640
- id: "index",
641
- activeRow: conditionIndex,
642
- columns: tabIndex === 0 ? styleColumns : conditionColumns,
643
- onRowClick: row => {
644
- var currentConditionCheck = tabIndex === 0 ? value.styleConditions[row.index] : value.contentConditions[row.index];
645
- this.setState({
646
- conditionIndex: row.index,
647
- advanced: currentConditionCheck.condition.split(' ').length !== 3,
648
- typeCondition: row.typeCondition
649
- });
650
- },
651
- data: tabIndex === 0 ? value.styleConditions.map((styleCondition, index) => _objectSpread(_objectSpread({}, styleCondition), {}, {
652
- index: "".concat(index),
653
- typeCondition: 'style'
654
- })) : value.contentConditions.map((contentCondition, index) => _objectSpread(_objectSpread({}, contentCondition), {}, {
655
- index: "".concat(index),
656
- typeCondition: 'content'
657
- })),
658
- hover: true
659
- }), /*#__PURE__*/_react.default.createElement("div", {
660
- style: {
661
- height: 66
662
- }
663
- })), /*#__PURE__*/_react.default.createElement(_Fab.default, {
664
- color: "primary",
665
- style: style.fab,
666
- onClick: () => this.addCondition()
667
- }, /*#__PURE__*/_react.default.createElement(_Add.default, null))))), /*#__PURE__*/_react.default.createElement(_Grid.default, {
668
- xs: 5,
669
- item: true
670
- }, /*#__PURE__*/_react.default.createElement(_Paper.default, {
671
- style: _objectSpread(_objectSpread({}, style.paper), style.fullHeight)
672
- }, /*#__PURE__*/_react.default.createElement("div", {
673
- style: _objectSpread(_objectSpread({}, style.block), style.scrollHolder)
674
- }, /*#__PURE__*/_react.default.createElement("div", {
675
- style: style.scroll
676
- }, /*#__PURE__*/_react.default.createElement("div", {
677
- style: {
678
- paddingTop: 6,
679
- paddingRight: 16
680
- }
681
- }, currentCondition && /*#__PURE__*/_react.default.createElement(_Grid.default, {
682
- spacing: 2,
683
- container: true
684
- }, !advanced && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Grid.default, {
685
- xs: 4,
686
- item: true
687
- }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
688
- id: "name",
689
- options: variables,
690
- label: intl.formatMessage({
691
- id: '__basic'
692
- }),
693
- fullWidth: true,
694
- value: currentCondition.condition.split(/[ ,]+/)[0],
695
- updateValue: e => this.updateCondition({
696
- value: e,
697
- stringIndex: 0
698
- }),
699
- selectOption: e => this.updateCondition({
700
- value: "~".concat(e.name),
701
- stringIndex: 0
702
- })
703
- })), /*#__PURE__*/_react.default.createElement(_Grid.default, {
704
- xs: 2,
705
- item: true
706
- }, /*#__PURE__*/_react.default.createElement(_TextField.default, {
707
- variant: "outlined",
708
- SelectProps: {
709
- native: true
710
- },
711
- value: currentCondition.condition.split(/[ ,]+/)[1],
712
- onChange: e => this.updateCondition({
713
- value: e.target.value,
714
- stringIndex: 1
715
- }),
716
- fullWidth: true,
717
- select: true
718
- }, operatorOptions.map(operatorOption => /*#__PURE__*/_react.default.createElement("option", {
719
- key: operatorOption.value,
720
- value: operatorOption.value
721
- }, operatorOption.label)))), /*#__PURE__*/_react.default.createElement(_Grid.default, {
722
- xs: 4,
723
- item: true
724
- }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
725
- id: "name",
726
- options: variables,
727
- label: intl.formatMessage({
728
- id: '__basic'
729
- }),
730
- fullWidth: true,
731
- value: currentCondition.condition.split(/[ ,]+/)[2],
732
- updateValue: e => this.updateCondition({
733
- value: e,
734
- stringIndex: 2
735
- }),
736
- selectOption: e => this.updateCondition({
737
- value: "~".concat(e.name),
738
- stringIndex: 2
739
- })
740
- }))), advanced && /*#__PURE__*/_react.default.createElement(_Grid.default, {
741
- xs: 10,
742
- item: true
743
- }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
744
- id: "name",
745
- options: variables,
746
- label: intl.formatMessage({
747
- id: '__advanced'
748
- }),
749
- fullWidth: true,
750
- value: currentCondition.condition,
751
- updateValue: e => this.updateCondition({
752
- value: e
753
- }),
754
- selectOption: e => this.updateCondition({
755
- value: "~".concat(e.name)
756
- })
757
- })), /*#__PURE__*/_react.default.createElement(_Grid.default, {
758
- align: "center",
759
- xs: 2,
760
- item: true
761
- }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
762
- style: {
763
- marginTop: 6
764
- },
765
- onClick: () => this.setState({
766
- advanced: !advanced
767
- })
768
- }, advanced ? /*#__PURE__*/_react.default.createElement(_Settings.default, null) : /*#__PURE__*/_react.default.createElement(_SettingsOutlined.default, null)))), tabIndex === 0 && currentCondition && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
769
- style: style.styleBox
770
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCellStyle.default, {
771
- style: currentCondition.style,
772
- updateStyle: content => this.updateStyle(content)
773
- })), /*#__PURE__*/_react.default.createElement(_Grid.default, {
774
- spacing: 16,
775
- container: true
776
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCellGlobalStyles.default, {
777
- styles: styles,
778
- value: currentCondition.styleIds,
779
- updateValue: content => this.updateStyleIds(content)
780
- }))), tabIndex === 1 && currentCondition && /*#__PURE__*/_react.default.createElement(_Grid.default, {
781
- spacing: 2,
782
- style: {
783
- marginTop: 8
784
- },
785
- container: true
786
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCellContent.default, {
787
- images: images,
788
- widgets: widgets,
789
- variables: variables,
790
- value: currentCondition.content,
791
- updateValue: content => this.updateContent(content)
792
- })))))))))));
793
- }
794
-
795
- }
796
-
797
- DashboardsCellGlobalConditions.propTypes = {
798
- classes: _propTypes.default.shape().isRequired,
799
- intl: _propTypes.default.shape().isRequired,
800
- value: _propTypes.default.shape().isRequired,
801
- updateValue: _propTypes.default.func.isRequired,
802
- images: _propTypes.default.arrayOf(_propTypes.default.shape()),
803
- styles: _propTypes.default.arrayOf(_propTypes.default.shape()),
804
- widgets: _propTypes.default.arrayOf(_propTypes.default.shape()),
805
- variables: _propTypes.default.arrayOf(_propTypes.default.shape())
806
- };
807
- DashboardsCellGlobalConditions.defaultProps = {
808
- images: [],
809
- styles: [],
810
- widgets: [],
811
- variables: []
812
- };
813
-
814
- var _default = (0, _reactIntl.injectIntl)((0, _styles.withStyles)(muiStyles)(DashboardsCellGlobalConditions));
815
-
816
- exports.default = _default;