versacall-dashboards-library-react 2.0.44 → 2.0.45

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 (34) hide show
  1. package/dist/components/DashboardsCell/DashboardsCell.js +48 -26
  2. package/dist/components/DashboardsCellContent/DashboardsCellContent.js +40 -31
  3. package/dist/components/DashboardsCellFindAndReplace/DashboardsCellFindAndReplace.js +2 -2
  4. package/dist/components/DashboardsCellGlobalActions/DashboardsCellGlobalActions.js +4 -6
  5. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditions.js +337 -296
  6. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditionsNestable.js +59 -39
  7. package/dist/components/DashboardsCellGlobalConditions/DashboardsCellGlobalConditionsOld.js +57 -39
  8. package/dist/components/DashboardsCellGlobalStyles/DashboardsCellGlobalStyles.js +52 -32
  9. package/dist/components/DashboardsCellStyleAlignItems/DashboardsCellStyleAlignItems.js +3 -7
  10. package/dist/components/DashboardsCellStyleBackgroundColor/DashboardsCellStyleBackgroundColor.js +9 -11
  11. package/dist/components/DashboardsCellStyleColor/DashboardsCellStyleColor.js +9 -11
  12. package/dist/components/DashboardsCellStyleDisplay/DashboardsCellStyleDisplay.js +4 -4
  13. package/dist/components/DashboardsCellStyleFontSize/DashboardsCellStyleFontSize.js +1 -1
  14. package/dist/components/DashboardsCellStyleJustifyContent/DashboardsCellStyleJustifyContent.js +3 -7
  15. package/dist/components/DashboardsCellStyleWeightStyleDecoration/DashboardsCellStyleWeightStyleDecoration.js +3 -7
  16. package/dist/components/DashboardsCopyAndPaste/DashboardsCopyAndPaste.js +3 -6
  17. package/dist/components/DashboardsEditor/DashboardsEditor.js +32 -27
  18. package/dist/components/DashboardsGlobalStylesPicker/DashboardsGlobalStylesPicker.js +3 -7
  19. package/dist/components/DashboardsGrid/DashboardsGrid.js +5 -9
  20. package/dist/components/DashboardsMainFreehand/DashboardsMainFreehand.js +39 -28
  21. package/dist/components/DashboardsMainMessaging/DashboardsMainMessaging.js +45 -32
  22. package/dist/components/DashboardsMainTable/DashboardsMainTable.js +41 -26
  23. package/dist/components/DashboardsPreview/DashboardsPreview.js +4 -8
  24. package/dist/components/DashboardsRatio/DashboardsRatio.js +20 -16
  25. package/dist/components/DashboardsRatio/DashboardsRatioOld.js +23 -22
  26. package/dist/components/DashboardsStatusBar/DashboardsStatusBar.js +6 -9
  27. package/dist/components/DashboardsViewer/DashboardsViewer.js +1 -1
  28. package/dist/components/WidgetParameters/WidgetParameters.js +27 -24
  29. package/dist/functions/addTranslations.js +11 -8
  30. package/dist/functions/calculateDashboardVariables.js +12 -15
  31. package/dist/functions/convertColorObject.js +1 -1
  32. package/dist/functions/convertSecondsToElapsedTime.js +5 -5
  33. package/dist/translations/en.json +1 -3
  34. package/package.json +5 -4
@@ -5,31 +5,32 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _versacallCoreLibraryReact = require("versacall-core-library-react");
9
- var _reactBeautifulDnd = require("react-beautiful-dnd");
10
- var _FormControlLabel = _interopRequireDefault(require("@material-ui/core/FormControlLabel"));
11
- var _reactIntl = require("react-intl");
12
- var _CallSplit = _interopRequireDefault(require("@material-ui/icons/CallSplit"));
13
- var _FileCopy = _interopRequireDefault(require("@material-ui/icons/FileCopy"));
14
- var _MoreVert = _interopRequireDefault(require("@material-ui/icons/MoreVert"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
9
  var _styles = require("@material-ui/core/styles");
16
- var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
17
- var _OpenWith = _interopRequireDefault(require("@material-ui/icons/OpenWith"));
18
- var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));
19
- var _Delete = _interopRequireDefault(require("@material-ui/icons/Delete"));
20
- var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
21
10
  var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
11
+ var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
12
+ var _FormControlLabel = _interopRequireDefault(require("@material-ui/core/FormControlLabel"));
22
13
  var _Switch = _interopRequireDefault(require("@material-ui/core/Switch"));
14
+ var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));
15
+ var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
23
16
  var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));
24
- var _Add = _interopRequireDefault(require("@material-ui/icons/Add"));
25
17
  var _Paper = _interopRequireDefault(require("@material-ui/core/Paper"));
26
- var _Menu = _interopRequireDefault(require("@material-ui/core/Menu"));
27
18
  var _Grid = _interopRequireDefault(require("@material-ui/core/Grid"));
28
19
  var _Tabs = _interopRequireDefault(require("@material-ui/core/Tabs"));
29
20
  var _Tab = _interopRequireDefault(require("@material-ui/core/Tab"));
30
- var _propTypes = _interopRequireDefault(require("prop-types"));
31
- var _ArrowDropDown = _interopRequireDefault(require("@material-ui/icons/ArrowDropDown"));
32
- var _InputAdornment = _interopRequireDefault(require("@material-ui/core/InputAdornment"));
21
+ var _Menu = _interopRequireDefault(require("@material-ui/core/Menu"));
22
+ var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
23
+ var _ArrowDownward = _interopRequireDefault(require("@material-ui/icons/ArrowDownward"));
24
+ var _ArrowUpward = _interopRequireDefault(require("@material-ui/icons/ArrowUpward"));
25
+ var _FileCopy = _interopRequireDefault(require("@material-ui/icons/FileCopy"));
26
+ var _Delete = _interopRequireDefault(require("@material-ui/icons/Delete"));
27
+ var _Add = _interopRequireDefault(require("@material-ui/icons/Add"));
28
+ var _MoreVert = _interopRequireDefault(require("@material-ui/icons/MoreVert"));
29
+ var _OpenWith = _interopRequireDefault(require("@material-ui/icons/OpenWith"));
30
+ var _CallSplit = _interopRequireDefault(require("@material-ui/icons/CallSplit"));
31
+ var _reactBeautifulDnd = require("react-beautiful-dnd");
32
+ var _reactIntl = require("react-intl");
33
+ var _versacallCoreLibraryReact = require("versacall-core-library-react");
33
34
  var _DashboardsCellGlobalStyles = _interopRequireDefault(require("../DashboardsCellGlobalStyles"));
34
35
  var _DashboardsCellContent = _interopRequireDefault(require("../DashboardsCellContent"));
35
36
  var _DashboardsCellStyle = _interopRequireDefault(require("../DashboardsCellStyle"));
@@ -39,11 +40,26 @@ require("react-nestable-fork/dist/Nestable/Nestable.css");
39
40
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
40
41
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
41
42
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
42
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
43
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
44
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
45
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
46
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
43
+ // Constants
44
+ const OPERATOR_OPTIONS = [{
45
+ value: '===',
46
+ label: '='
47
+ }, {
48
+ value: '>',
49
+ label: '>'
50
+ }, {
51
+ value: '<',
52
+ label: '<'
53
+ }, {
54
+ value: '!==',
55
+ label: `${String.fromCharCode(0x2260)}`
56
+ }, {
57
+ value: '>=',
58
+ label: `${String.fromCharCode(0x2265)}`
59
+ }, {
60
+ value: '<=',
61
+ label: `${String.fromCharCode(0x2264)}`
62
+ }];
47
63
  const muiStyles = () => ({
48
64
  dialog: {
49
65
  backgroundColor: '#eff4f8'
@@ -133,27 +149,6 @@ const style = {
133
149
  textTransform: 'uppercase'
134
150
  }
135
151
  };
136
-
137
- // Constants
138
- const OPERATOR_OPTIONS = [{
139
- value: '===',
140
- label: '='
141
- }, {
142
- value: '>',
143
- label: '>'
144
- }, {
145
- value: '<',
146
- label: '<'
147
- }, {
148
- value: '!==',
149
- label: "".concat(String.fromCharCode(0x2260))
150
- }, {
151
- value: '>=',
152
- label: "".concat(String.fromCharCode(0x2265))
153
- }, {
154
- value: '<=',
155
- label: "".concat(String.fromCharCode(0x2264))
156
- }];
157
152
  const formatCondition = original => {
158
153
  let formatted = original;
159
154
  formatted = formatted.replace('===', '=');
@@ -191,10 +186,11 @@ const contentPreviewCustomCell = _ref => {
191
186
  }
192
187
  })));
193
188
  };
194
- const getItemStyle = (isDragging, draggableStyle) => _objectSpread({
189
+ const getItemStyle = (isDragging, draggableStyle) => ({
195
190
  userSelect: 'none',
196
- marginBottom: 10
197
- }, draggableStyle);
191
+ marginBottom: 10,
192
+ ...draggableStyle
193
+ });
198
194
  const getListStyle = () => ({
199
195
  // Empty object for now, can be extended if needed
200
196
  });
@@ -225,43 +221,120 @@ class DashboardsCellGlobalConditions extends _react.Component {
225
221
  conditionIndex: null,
226
222
  menuIndex: null,
227
223
  menuAnchorEl: null,
228
- advanced: false,
229
- conditionMenuAdvanced: null,
230
- conditionMenuOne: null,
231
- conditionMenuTwo: null
224
+ advanced: false
232
225
  };
233
226
  }
234
- onDragEnd(result) {
235
- const {
236
- value
237
- } = this.props;
227
+ stylePreviewCustomCell = _ref2 => {
228
+ let {
229
+ row
230
+ } = _ref2;
231
+ const newCell = {
232
+ ...row
233
+ };
234
+ newCell.custom = {
235
+ viewWidth: 120,
236
+ viewHeight: 120,
237
+ style: {}
238
+ };
239
+ if (this.props.styles.length > 0 && row.styleIds && row.styleIds.length > 0) {
240
+ for (let i = 0; i < newCell.styleIds.length; i++) {
241
+ const findStyle = this.props.styles.find(searchStyle => searchStyle.id === newCell.styleIds[i]);
242
+ if (findStyle) {
243
+ newCell.custom.style = {
244
+ ...newCell.custom.style,
245
+ ...findStyle.options
246
+ };
247
+ }
248
+ }
249
+ }
250
+ newCell.custom.style = {
251
+ ...newCell.custom.style,
252
+ ...newCell.style
253
+ };
254
+ return /*#__PURE__*/_react.default.createElement("div", {
255
+ style: {
256
+ width: 120
257
+ }
258
+ }, /*#__PURE__*/_react.default.createElement(_DashboardsPreview.default, {
259
+ width: "120px",
260
+ height: "100px",
261
+ padding: "10px"
262
+ }, /*#__PURE__*/_react.default.createElement(_DashboardsCell.default, {
263
+ cell: {
264
+ content: {
265
+ type: 'text',
266
+ text: 'Hello'
267
+ },
268
+ custom: newCell.custom
269
+ }
270
+ })));
271
+ };
272
+ contentTypeCustomCell = _ref3 => {
273
+ let {
274
+ row
275
+ } = _ref3;
276
+ return /*#__PURE__*/_react.default.createElement("span", null, this.props.intl.formatMessage({
277
+ id: `__${row.content.type}`
278
+ }));
279
+ };
280
+ actionsCustomCell = _ref4 => {
281
+ let {
282
+ row
283
+ } = _ref4;
238
284
  const {
239
285
  tabIndex
240
286
  } = this.state;
241
- if (!result.destination) {
242
- return;
243
- }
244
- const items = reorder(tabIndex === 0 ? value.styleConditions : value.contentConditions, result.source.index, result.destination.index);
245
- const newConditions = _objectSpread({}, value);
246
- if (tabIndex === 0) {
247
- newConditions.styleConditions = items;
248
- } else {
249
- newConditions.contentConditions = items;
250
- }
251
- this.props.updateValue({
252
- styleConditions: newConditions.styleConditions,
253
- contentConditions: newConditions.contentConditions
254
- });
255
- this.setState({
256
- conditionIndex: result.destination.index
257
- });
258
- }
259
- updateCondition(change) {
287
+ const conditions = tabIndex === 0 ? this.props.value.styleConditions : this.props.value.contentConditions;
288
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, row.index !== 0 && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
289
+ onClick: e => {
290
+ e.stopPropagation();
291
+ this.moveCondition(row.index, -1);
292
+ },
293
+ "aria-label": this.props.intl.formatMessage({
294
+ id: '__move_up'
295
+ })
296
+ }, /*#__PURE__*/_react.default.createElement(_ArrowUpward.default, null)), row.index !== String(conditions.length - 1) && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
297
+ onClick: e => {
298
+ e.stopPropagation();
299
+ this.moveCondition(row.index, 1);
300
+ },
301
+ "aria-label": this.props.intl.formatMessage({
302
+ id: '__move_down'
303
+ })
304
+ }, /*#__PURE__*/_react.default.createElement(_ArrowDownward.default, null)), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
305
+ onClick: e => {
306
+ e.stopPropagation();
307
+ this.copyCondition(row);
308
+ },
309
+ "aria-label": this.props.intl.formatMessage({
310
+ id: '__copy'
311
+ })
312
+ }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
313
+ title: this.props.intl.formatMessage({
314
+ id: '__copy'
315
+ })
316
+ }, /*#__PURE__*/_react.default.createElement(_FileCopy.default, null))), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
317
+ onClick: e => {
318
+ e.stopPropagation();
319
+ this.deleteCondition(row.index);
320
+ },
321
+ "aria-label": this.props.intl.formatMessage({
322
+ id: '__delete'
323
+ })
324
+ }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
325
+ title: this.props.intl.formatMessage({
326
+ id: '__delete'
327
+ })
328
+ }, /*#__PURE__*/_react.default.createElement(_Delete.default, null))));
329
+ };
330
+ updateCondition = change => {
260
331
  const {
261
332
  conditionIndex,
262
333
  tabIndex
263
334
  } = this.state;
264
- const updatedValue = _objectSpread({}, this.props.value);
335
+ const updatedValue = {
336
+ ...this.props.value
337
+ };
265
338
  const conditions = tabIndex === 1 ? updatedValue.contentConditions : updatedValue.styleConditions;
266
339
  if (this.state.advanced) {
267
340
  conditions[conditionIndex].condition = change.value;
@@ -272,16 +345,16 @@ class DashboardsCellGlobalConditions extends _react.Component {
272
345
  const segment3 = split.length > 2 ? split[2] : '0';
273
346
  switch (change.stringIndex) {
274
347
  case 0:
275
- conditions[conditionIndex].condition = "".concat(change.value, " ").concat(segment2, " ").concat(segment3);
348
+ conditions[conditionIndex].condition = `${change.value} ${segment2} ${segment3}`;
276
349
  break;
277
350
  case 1:
278
- conditions[conditionIndex].condition = "".concat(segment1, " ").concat(change.value, " ").concat(segment3);
351
+ conditions[conditionIndex].condition = `${segment1} ${change.value} ${segment3}`;
279
352
  break;
280
353
  case 2:
281
- conditions[conditionIndex].condition = "".concat(segment1, " ").concat(segment2, " ").concat(change.value);
354
+ conditions[conditionIndex].condition = `${segment1} ${segment2} ${change.value}`;
282
355
  break;
283
356
  default:
284
- conditions[conditionIndex].condition = "".concat(segment1, " ").concat(segment2, " ").concat(segment3);
357
+ conditions[conditionIndex].condition = `${segment1} ${segment2} ${segment3}`;
285
358
  break;
286
359
  }
287
360
  }
@@ -289,18 +362,21 @@ class DashboardsCellGlobalConditions extends _react.Component {
289
362
  styleConditions: updatedValue.styleConditions,
290
363
  contentConditions: updatedValue.contentConditions
291
364
  });
292
- }
293
- updateStyleIds(value) {
365
+ };
366
+ updateStyleIds = value => {
294
367
  const styleConditions = [...this.props.value.styleConditions];
295
368
  styleConditions[this.state.conditionIndex].styleIds = value.styleIds;
296
369
  this.props.updateValue({
297
- styleConditions: styleConditions
370
+ styleConditions
298
371
  });
299
- }
300
- updateStyle(value) {
372
+ };
373
+ updateStyle = value => {
301
374
  const styleConditions = [...this.props.value.styleConditions];
302
375
  if (Object.keys(value.style).length > 0) {
303
- styleConditions[this.state.conditionIndex].style = _objectSpread(_objectSpread({}, styleConditions[this.state.conditionIndex].style), value.style);
376
+ styleConditions[this.state.conditionIndex].style = {
377
+ ...styleConditions[this.state.conditionIndex].style,
378
+ ...value.style
379
+ };
304
380
  Object.keys(styleConditions[this.state.conditionIndex].style).forEach(key => {
305
381
  if (styleConditions[this.state.conditionIndex].style[key] === 'delete') {
306
382
  delete styleConditions[this.state.conditionIndex].style[key];
@@ -310,18 +386,20 @@ class DashboardsCellGlobalConditions extends _react.Component {
310
386
  styleConditions[this.state.conditionIndex].style = {};
311
387
  }
312
388
  this.props.updateValue({
313
- styleConditions: styleConditions
389
+ styleConditions
314
390
  });
315
- }
316
- updateContent(value) {
391
+ };
392
+ updateContent = value => {
317
393
  const contentConditions = [...this.props.value.contentConditions];
318
394
  contentConditions[this.state.conditionIndex].content = value.content;
319
395
  this.props.updateValue({
320
- contentConditions: contentConditions
396
+ contentConditions
321
397
  });
322
- }
323
- addCondition() {
324
- const conditions = _objectSpread({}, this.props.value);
398
+ };
399
+ addCondition = () => {
400
+ const conditions = {
401
+ ...this.props.value
402
+ };
325
403
  let index = null;
326
404
  if (this.state.tabIndex === 0) {
327
405
  conditions.styleConditions.push({
@@ -348,10 +426,14 @@ class DashboardsCellGlobalConditions extends _react.Component {
348
426
  conditionIndex: index,
349
427
  advanced: false
350
428
  });
351
- }
352
- copyCondition(condition) {
353
- const newValue = _objectSpread({}, this.props.value);
354
- const newCondition = _objectSpread({}, condition);
429
+ };
430
+ copyCondition = condition => {
431
+ const newValue = {
432
+ ...this.props.value
433
+ };
434
+ const newCondition = {
435
+ ...condition
436
+ };
355
437
  delete newCondition.index;
356
438
  const conditions = newValue[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'];
357
439
  conditions.push(newCondition);
@@ -360,12 +442,12 @@ class DashboardsCellGlobalConditions extends _react.Component {
360
442
  styleConditions: newValue.styleConditions,
361
443
  contentConditions: newValue.contentConditions
362
444
  });
363
- this.setState(() => ({
445
+ this.setState(prevState => ({
364
446
  conditionIndex: conditions.length - 1,
365
- advanced: advanced
447
+ advanced
366
448
  }));
367
- }
368
- duplicateCondition(index) {
449
+ };
450
+ duplicateCondition = index => {
369
451
  const {
370
452
  value
371
453
  } = this.props;
@@ -374,9 +456,11 @@ class DashboardsCellGlobalConditions extends _react.Component {
374
456
  } = this.state;
375
457
  const condition = value[tabIndex === 0 ? 'styleConditions' : 'contentConditions'][index];
376
458
  this.copyCondition(condition);
377
- }
378
- deleteCondition(index) {
379
- const conditions = _objectSpread({}, this.props.value);
459
+ };
460
+ deleteCondition = index => {
461
+ const conditions = {
462
+ ...this.props.value
463
+ };
380
464
  conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'].splice(Number(index), 1);
381
465
  this.props.updateValue({
382
466
  styleConditions: conditions.styleConditions,
@@ -386,9 +470,11 @@ class DashboardsCellGlobalConditions extends _react.Component {
386
470
  conditionIndex: null,
387
471
  advanced: false
388
472
  });
389
- }
390
- moveCondition(index, direction) {
391
- const conditions = _objectSpread({}, this.props.value);
473
+ };
474
+ moveCondition = (index, direction) => {
475
+ const conditions = {
476
+ ...this.props.value
477
+ };
392
478
  const conditionArray = conditions[this.state.tabIndex === 0 ? 'styleConditions' : 'contentConditions'];
393
479
  const [removed] = conditionArray.splice(Number(index), 1);
394
480
  conditionArray.splice(Number(index) + direction, 0, removed);
@@ -400,45 +486,35 @@ class DashboardsCellGlobalConditions extends _react.Component {
400
486
  conditionIndex: null,
401
487
  advanced: false
402
488
  });
403
- }
404
- stylePreviewCustomCell(_ref2) {
405
- let {
406
- row
407
- } = _ref2;
408
- const newCell = _objectSpread({}, row);
409
- newCell.custom = {
410
- viewWidth: 120,
411
- viewHeight: 120,
412
- style: {}
489
+ };
490
+ onDragEnd = result => {
491
+ const {
492
+ value
493
+ } = this.props;
494
+ const {
495
+ tabIndex
496
+ } = this.state;
497
+ if (!result.destination) {
498
+ return;
499
+ }
500
+ const items = reorder(tabIndex === 0 ? value.styleConditions : value.contentConditions, result.source.index, result.destination.index);
501
+ const newConditions = {
502
+ ...value
413
503
  };
414
- if (this.props.styles.length > 0 && row.styleIds && row.styleIds.length > 0) {
415
- for (let i = 0; i < newCell.styleIds.length; i++) {
416
- const findStyle = this.props.styles.find(searchStyle => searchStyle.id === newCell.styleIds[i]);
417
- if (findStyle) {
418
- newCell.custom.style = _objectSpread(_objectSpread({}, newCell.custom.style), findStyle.options);
419
- }
420
- }
504
+ if (tabIndex === 0) {
505
+ newConditions.styleConditions = items;
506
+ } else {
507
+ newConditions.contentConditions = items;
421
508
  }
422
- newCell.custom.style = _objectSpread(_objectSpread({}, newCell.custom.style), newCell.style);
423
- return /*#__PURE__*/_react.default.createElement("div", {
424
- style: {
425
- width: 120
426
- }
427
- }, /*#__PURE__*/_react.default.createElement(_DashboardsPreview.default, {
428
- width: "120px",
429
- height: "100px",
430
- padding: "10px"
431
- }, /*#__PURE__*/_react.default.createElement(_DashboardsCell.default, {
432
- cell: {
433
- content: {
434
- type: 'text',
435
- text: 'Hello'
436
- },
437
- custom: newCell.custom
438
- }
439
- })));
440
- }
441
- selectCondition(index) {
509
+ this.props.updateValue({
510
+ styleConditions: newConditions.styleConditions,
511
+ contentConditions: newConditions.contentConditions
512
+ });
513
+ this.setState({
514
+ conditionIndex: result.destination.index
515
+ });
516
+ };
517
+ selectCondition = index => {
442
518
  const {
443
519
  value
444
520
  } = this.props;
@@ -450,10 +526,10 @@ class DashboardsCellGlobalConditions extends _react.Component {
450
526
  const advanced = determineIfAdvanced(condition.condition);
451
527
  this.setState({
452
528
  conditionIndex: index,
453
- advanced: advanced
529
+ advanced
454
530
  });
455
- }
456
- renderConditionCard(obj) {
531
+ };
532
+ renderConditionCard = obj => {
457
533
  const {
458
534
  item,
459
535
  handler
@@ -479,14 +555,7 @@ class DashboardsCellGlobalConditions extends _react.Component {
479
555
  "aria-selected": item.index === conditionIndex,
480
556
  style: divStyle,
481
557
  className: classes.selectable,
482
- onClick: () => this.selectCondition(item.index),
483
- onKeyDown: event => {
484
- if (event.key === 'Enter' || event.key === ' ') {
485
- event.preventDefault();
486
- this.selectCondition(item.index);
487
- }
488
- },
489
- tabIndex: 0
558
+ onClick: () => this.selectCondition(item.index)
490
559
  }, /*#__PURE__*/_react.default.createElement("span", {
491
560
  style: {
492
561
  marginRight: 20,
@@ -503,7 +572,7 @@ class DashboardsCellGlobalConditions extends _react.Component {
503
572
  marginRight: 10
504
573
  }
505
574
  }, intl.formatMessage({
506
- id: "__".concat(item.content.type)
575
+ id: `__${item.content.type}`
507
576
  })), contentPreviewCustomCell({
508
577
  row: item
509
578
  })), handler, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
@@ -518,7 +587,7 @@ class DashboardsCellGlobalConditions extends _react.Component {
518
587
  id: '__more_options'
519
588
  })
520
589
  }, /*#__PURE__*/_react.default.createElement(_MoreVert.default, null)));
521
- }
590
+ };
522
591
  render() {
523
592
  const {
524
593
  classes,
@@ -536,10 +605,7 @@ class DashboardsCellGlobalConditions extends _react.Component {
536
605
  conditionIndex,
537
606
  menuIndex,
538
607
  menuAnchorEl,
539
- advanced,
540
- conditionMenuAdvanced,
541
- conditionMenuOne,
542
- conditionMenuTwo
608
+ advanced
543
609
  } = this.state;
544
610
  let currentCondition = null;
545
611
  if (conditionIndex !== null) {
@@ -549,17 +615,19 @@ class DashboardsCellGlobalConditions extends _react.Component {
549
615
  const nestItems = [];
550
616
  if (tabIndex === 0) {
551
617
  value.styleConditions.forEach((condition, index) => {
552
- nestItems.push(_objectSpread(_objectSpread({}, condition), {}, {
553
- index: index,
618
+ nestItems.push({
619
+ ...condition,
620
+ index,
554
621
  id: String(index)
555
- }));
622
+ });
556
623
  });
557
624
  } else {
558
625
  value.contentConditions.forEach((condition, index) => {
559
- nestItems.push(_objectSpread(_objectSpread({}, condition), {}, {
560
- index: index,
626
+ nestItems.push({
627
+ ...condition,
628
+ index,
561
629
  id: String(index)
562
- }));
630
+ });
563
631
  });
564
632
  }
565
633
  return /*#__PURE__*/_react.default.createElement(_Grid.default, {
@@ -579,9 +647,9 @@ class DashboardsCellGlobalConditions extends _react.Component {
579
647
  style: {
580
648
  marginRight: 10
581
649
  }
582
- }), "".concat(intl.formatMessage({
650
+ }), `${intl.formatMessage({
583
651
  id: '__conditions'
584
- })).concat(totalConditions > 0 ? " (".concat(totalConditions, ")") : '')), open && /*#__PURE__*/_react.default.createElement(_Dialog.default, {
652
+ })}${totalConditions > 0 ? ` (${totalConditions})` : ''}`), open && /*#__PURE__*/_react.default.createElement(_Dialog.default, {
585
653
  maxWidth: "xl",
586
654
  onClose: () => this.setState({
587
655
  open: false,
@@ -605,7 +673,7 @@ class DashboardsCellGlobalConditions extends _react.Component {
605
673
  }, /*#__PURE__*/_react.default.createElement(_Button.default, {
606
674
  variant: "outlined",
607
675
  color: "primary",
608
- onClick: () => this.addCondition(),
676
+ onClick: this.addCondition,
609
677
  style: {
610
678
  marginRight: 10
611
679
  }
@@ -623,15 +691,15 @@ class DashboardsCellGlobalConditions extends _react.Component {
623
691
  centered: true
624
692
  }, /*#__PURE__*/_react.default.createElement(_Tab.default, {
625
693
  id: "style",
626
- label: "".concat(intl.formatMessage({
694
+ label: `${intl.formatMessage({
627
695
  id: '__style'
628
- }), " (").concat(value.styleConditions.length, ")"),
696
+ })} (${value.styleConditions.length})`,
629
697
  style: tabStyle(tabIndex === 0)
630
698
  }), /*#__PURE__*/_react.default.createElement(_Tab.default, {
631
699
  id: "content",
632
- label: "".concat(intl.formatMessage({
700
+ label: `${intl.formatMessage({
633
701
  id: '__content'
634
- }), " (").concat(value.contentConditions.length, ")"),
702
+ })} (${value.contentConditions.length})`,
635
703
  style: tabStyle(tabIndex === 1)
636
704
  }))), /*#__PURE__*/_react.default.createElement("div", {
637
705
  style: style.root
@@ -643,9 +711,15 @@ class DashboardsCellGlobalConditions extends _react.Component {
643
711
  xs: 7,
644
712
  item: true
645
713
  }, /*#__PURE__*/_react.default.createElement("div", {
646
- style: _objectSpread(_objectSpread({}, style.paper), style.fullHeight)
714
+ style: {
715
+ ...style.paper,
716
+ ...style.fullHeight
717
+ }
647
718
  }, /*#__PURE__*/_react.default.createElement("div", {
648
- style: _objectSpread(_objectSpread({}, style.block), style.scrollHolder)
719
+ style: {
720
+ ...style.block,
721
+ ...style.scrollHolder
722
+ }
649
723
  }, /*#__PURE__*/_react.default.createElement("div", {
650
724
  style: style.scroll,
651
725
  className: _versacallCoreLibraryReact.ScrollbarStyles.scroll
@@ -665,7 +739,7 @@ class DashboardsCellGlobalConditions extends _react.Component {
665
739
  }, dragProvided.draggableProps, {
666
740
  style: getItemStyle(dragSnapshot.isDragging, dragProvided.draggableProps.style)
667
741
  }), this.renderConditionCard({
668
- item: item,
742
+ item,
669
743
  handler: /*#__PURE__*/_react.default.createElement("div", dragProvided.dragHandleProps, /*#__PURE__*/_react.default.createElement(_OpenWith.default, {
670
744
  className: classes.anchor
671
745
  }))
@@ -673,9 +747,15 @@ class DashboardsCellGlobalConditions extends _react.Component {
673
747
  xs: 5,
674
748
  item: true
675
749
  }, /*#__PURE__*/_react.default.createElement("div", {
676
- style: _objectSpread(_objectSpread({}, style.paper), style.fullHeight)
750
+ style: {
751
+ ...style.paper,
752
+ ...style.fullHeight
753
+ }
677
754
  }, /*#__PURE__*/_react.default.createElement("div", {
678
- style: _objectSpread(_objectSpread({}, style.block), style.scrollHolder)
755
+ style: {
756
+ ...style.block,
757
+ ...style.scrollHolder
758
+ }
679
759
  }, currentCondition && /*#__PURE__*/_react.default.createElement(_Paper.default, {
680
760
  style: style.scroll,
681
761
  className: _versacallCoreLibraryReact.ScrollbarStyles.scroll
@@ -693,86 +773,23 @@ class DashboardsCellGlobalConditions extends _react.Component {
693
773
  paddingTop: 26,
694
774
  textAlign: 'center'
695
775
  }
696
- }, "IF"), advanced ? /*#__PURE__*/_react.default.createElement(_Grid.default, {
697
- xs: 9,
698
- item: true
699
- }, /*#__PURE__*/_react.default.createElement(_TextField.default, {
700
- id: "advanced-condition",
701
- variant: "outlined",
702
- fullWidth: true,
703
- label: intl.formatMessage({
704
- id: '__advanced'
705
- }),
706
- value: currentCondition.condition,
707
- onChange: event => this.updateCondition({
708
- value: event.target.value
709
- }),
710
- InputProps: {
711
- endAdornment: /*#__PURE__*/_react.default.createElement(_InputAdornment.default, {
712
- position: "end"
713
- }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
714
- onClick: event => {
715
- this.setState({
716
- conditionMenuAdvanced: event.currentTarget
717
- });
718
- }
719
- }, /*#__PURE__*/_react.default.createElement(_ArrowDropDown.default, null)))
720
- }
721
- }), /*#__PURE__*/_react.default.createElement(_Menu.default, {
722
- open: !!conditionMenuAdvanced,
723
- anchorEl: conditionMenuAdvanced,
724
- onClose: () => this.setState({
725
- conditionMenuAdvanced: null
726
- })
727
- }, variables.map((variable, index) => /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
728
- key: String([index]),
729
- onClick: () => {
730
- this.updateCondition({
731
- value: "~".concat(variable.name)
732
- });
733
- this.setState({
734
- conditionMenuAdvanced: null
735
- });
736
- }
737
- }, "~".concat(variable.name))))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Grid.default, {
776
+ }, "IF"), !advanced && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Grid.default, {
738
777
  xs: 4,
739
778
  item: true
740
- }, /*#__PURE__*/_react.default.createElement(_TextField.default, {
741
- variant: "outlined",
779
+ }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
780
+ id: "condition-variable",
781
+ options: variables,
782
+ fullWidth: true,
742
783
  value: currentCondition.condition.split(/[ ,]+/)[0],
743
- onChange: event => this.updateCondition({
744
- value: event.target.value,
784
+ updateValue: e => this.updateCondition({
785
+ value: e,
745
786
  stringIndex: 0
746
787
  }),
747
- InputProps: {
748
- endAdornment: /*#__PURE__*/_react.default.createElement(_InputAdornment.default, {
749
- position: "end"
750
- }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
751
- onClick: event => {
752
- this.setState({
753
- conditionMenuOne: event.currentTarget
754
- });
755
- }
756
- }, /*#__PURE__*/_react.default.createElement(_ArrowDropDown.default, null)))
757
- }
758
- }), /*#__PURE__*/_react.default.createElement(_Menu.default, {
759
- open: !!conditionMenuOne,
760
- anchorEl: conditionMenuOne,
761
- onClose: () => this.setState({
762
- conditionMenuOne: null
788
+ selectOption: e => this.updateCondition({
789
+ value: `~${e.name}`,
790
+ stringIndex: 0
763
791
  })
764
- }, variables.map((variable, index) => /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
765
- key: String([index]),
766
- onClick: () => {
767
- this.updateCondition({
768
- value: "~".concat(variable.name),
769
- stringIndex: 0
770
- });
771
- this.setState({
772
- conditionMenuOne: null
773
- });
774
- }
775
- }, "~".concat(variable.name))))), /*#__PURE__*/_react.default.createElement(_Grid.default, {
792
+ })), /*#__PURE__*/_react.default.createElement(_Grid.default, {
776
793
  xs: 2,
777
794
  item: true
778
795
  }, /*#__PURE__*/_react.default.createElement(_TextField.default, {
@@ -781,8 +798,8 @@ class DashboardsCellGlobalConditions extends _react.Component {
781
798
  native: true
782
799
  },
783
800
  value: currentCondition.condition.split(/[ ,]+/)[1],
784
- onChange: event => this.updateCondition({
785
- value: event.target.value,
801
+ onChange: e => this.updateCondition({
802
+ value: e.target.value,
786
803
  stringIndex: 1
787
804
  }),
788
805
  fullWidth: true,
@@ -793,42 +810,37 @@ class DashboardsCellGlobalConditions extends _react.Component {
793
810
  }, operatorOption.label)))), /*#__PURE__*/_react.default.createElement(_Grid.default, {
794
811
  xs: 3,
795
812
  item: true
796
- }, /*#__PURE__*/_react.default.createElement(_TextField.default, {
797
- variant: "outlined",
813
+ }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
814
+ id: "condition-value",
815
+ options: variables,
816
+ fullWidth: true,
798
817
  value: currentCondition.condition.split(/[ ,]+/)[2],
799
- onChange: event => this.updateCondition({
800
- value: event.target.value,
818
+ updateValue: e => this.updateCondition({
819
+ value: e,
801
820
  stringIndex: 2
802
821
  }),
803
- InputProps: {
804
- endAdornment: /*#__PURE__*/_react.default.createElement(_InputAdornment.default, {
805
- position: "end"
806
- }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
807
- onClick: event => {
808
- this.setState({
809
- conditionMenuTwo: event.currentTarget
810
- });
811
- }
812
- }, /*#__PURE__*/_react.default.createElement(_ArrowDropDown.default, null)))
813
- }
814
- }), /*#__PURE__*/_react.default.createElement(_Menu.default, {
815
- open: !!conditionMenuTwo,
816
- anchorEl: conditionMenuTwo,
817
- onClose: () => this.setState({
818
- conditionMenuTwo: null
822
+ selectOption: e => this.updateCondition({
823
+ value: `~${e.name}`,
824
+ stringIndex: 2
819
825
  })
820
- }, variables.map((variable, index) => /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
821
- key: String([index]),
822
- onClick: () => {
823
- this.updateCondition({
824
- value: "~".concat(variable.name),
825
- stringIndex: 2
826
- });
827
- this.setState({
828
- conditionMenuTwo: null
829
- });
830
- }
831
- }, "~".concat(variable.name)))))), /*#__PURE__*/_react.default.createElement(_Grid.default, {
826
+ }))), advanced && /*#__PURE__*/_react.default.createElement(_Grid.default, {
827
+ xs: 9,
828
+ item: true
829
+ }, /*#__PURE__*/_react.default.createElement(_versacallCoreLibraryReact.CoreTextField, {
830
+ id: "advanced-condition",
831
+ options: variables,
832
+ label: intl.formatMessage({
833
+ id: '__advanced'
834
+ }),
835
+ fullWidth: true,
836
+ value: currentCondition.condition,
837
+ updateValue: e => this.updateCondition({
838
+ value: e
839
+ }),
840
+ selectOption: e => this.updateCondition({
841
+ value: `~${e.name}`
842
+ })
843
+ })), /*#__PURE__*/_react.default.createElement(_Grid.default, {
832
844
  align: "center",
833
845
  xs: 2,
834
846
  item: true
@@ -845,8 +857,8 @@ class DashboardsCellGlobalConditions extends _react.Component {
845
857
  control: /*#__PURE__*/_react.default.createElement(_Switch.default, {
846
858
  color: "primary",
847
859
  checked: advanced,
848
- onChange: event => this.setState({
849
- advanced: event.target.checked
860
+ onChange: e => this.setState({
861
+ advanced: e.target.checked
850
862
  })
851
863
  })
852
864
  }))), tabIndex === 0 && currentCondition && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
@@ -916,16 +928,45 @@ class DashboardsCellGlobalConditions extends _react.Component {
916
928
  }
917
929
  }
918
930
  DashboardsCellGlobalConditions.propTypes = {
919
- contentConditions: _propTypes.default.arrayOf(_propTypes.default.shape()).isRequired,
931
+ classes: _propTypes.default.shape({
932
+ dialog: _propTypes.default.string.isRequired,
933
+ icon: _propTypes.default.string.isRequired,
934
+ anchor: _propTypes.default.string.isRequired,
935
+ selectable: _propTypes.default.string.isRequired,
936
+ menuPaper: _propTypes.default.string.isRequired,
937
+ menuList: _propTypes.default.string.isRequired
938
+ }).isRequired,
939
+ intl: _propTypes.default.shape({
940
+ formatMessage: _propTypes.default.func.isRequired
941
+ }).isRequired,
942
+ value: _propTypes.default.shape({
943
+ styleConditions: _propTypes.default.arrayOf(_propTypes.default.shape({
944
+ condition: _propTypes.default.string.isRequired,
945
+ style: _propTypes.default.object,
946
+ styleIds: _propTypes.default.arrayOf(_propTypes.default.string)
947
+ })).isRequired,
948
+ contentConditions: _propTypes.default.arrayOf(_propTypes.default.shape({
949
+ condition: _propTypes.default.string.isRequired,
950
+ content: _propTypes.default.object
951
+ })).isRequired
952
+ }).isRequired,
920
953
  updateValue: _propTypes.default.func.isRequired,
921
- classes: _propTypes.default.shape().isRequired,
922
- value: _propTypes.default.shape().isRequired,
923
- intl: _propTypes.default.shape().isRequired,
924
- variables: _propTypes.default.arrayOf(_propTypes.default.shape()),
925
- widgets: _propTypes.default.arrayOf(_propTypes.default.shape()),
926
- images: _propTypes.default.arrayOf(_propTypes.default.shape()),
927
- styles: _propTypes.default.arrayOf(_propTypes.default.shape()),
928
- tags: _propTypes.default.shape()
954
+ images: _propTypes.default.arrayOf(_propTypes.default.shape({
955
+ id: _propTypes.default.string.isRequired,
956
+ fileName: _propTypes.default.string.isRequired
957
+ })),
958
+ styles: _propTypes.default.arrayOf(_propTypes.default.shape({
959
+ id: _propTypes.default.string.isRequired,
960
+ options: _propTypes.default.object
961
+ })),
962
+ tags: _propTypes.default.object,
963
+ widgets: _propTypes.default.arrayOf(_propTypes.default.shape({
964
+ id: _propTypes.default.string.isRequired,
965
+ name: _propTypes.default.string.isRequired
966
+ })),
967
+ variables: _propTypes.default.arrayOf(_propTypes.default.shape({
968
+ name: _propTypes.default.string.isRequired
969
+ }))
929
970
  };
930
971
  DashboardsCellGlobalConditions.defaultProps = {
931
972
  images: [],