cronapi-js 2.8.16 → 2.8.20

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/cronapi.js CHANGED
@@ -33,6 +33,14 @@ if (!window.fixedTimeZone) {
33
33
 
34
34
  this.cronapi = {};
35
35
 
36
+ this.cronapi.getRequestData = data => {
37
+ let result = data || {};
38
+ if (data.data && typeof data.data === 'object') {
39
+ result = data.data;
40
+ }
41
+ return result;
42
+ };
43
+
36
44
  this.cronapi.toDate = function(value) {
37
45
  return new Date(value);
38
46
  }
@@ -1251,13 +1259,6 @@ if (!window.fixedTimeZone) {
1251
1259
  return this.cronapi.$scope.vars[name];
1252
1260
  };
1253
1261
 
1254
- /**
1255
- * @category {{notificationCategory}}
1256
- * @categoryTags notification | notification
1257
- */
1258
- this.cronapi.notification = {};
1259
-
1260
-
1261
1262
  /**
1262
1263
  * @deprecated true
1263
1264
  * @type function
@@ -1277,196 +1278,6 @@ if (!window.fixedTimeZone) {
1277
1278
  this.cronapi.$scope.Notification({'message':message.toString() },type);
1278
1279
  };
1279
1280
 
1280
-
1281
- /**
1282
- * @type function
1283
- * @name {{screenNotifySimpleName}}
1284
- * @description {{screenNotifySimpleDescription}}
1285
- * @nameTags show | exibir | exibe | notification | notificação
1286
- * @param {ObjectType.STRING} status {{screenNotifySimpleParam0}}
1287
- * @param {ObjectType.STRING} message {{screenNotifySimpleParam1}}
1288
- * @param {ObjectType.STRING} animation {{screenNotifySimpleParam2}}
1289
- * @param {ObjectType.STRING} verticalPosition {{screenNotifySimpleParam3}}
1290
- * @param {ObjectType.STRING} horizontalPosition {{screenNotifySimpleParam4}}
1291
- * @param {ObjectType.STRING} autoHide {{screenNotifySimpleParam5}}
1292
- */
1293
- this.cronapi.notification.customNotify = function(/** @type {ObjectType.STRING} @description {{status}} @blockType util_dropdown @keys error|success|warning|info @values {{error}}|{{success}}|{{warning}}|{{info}} */ status, /** @type {ObjectType.STRING} */ message, /** @type {ObjectType.STRING} @description {{animation}} @blockType util_dropdown @keys fade|slide|zoom @values {{fade}}|{{slide}}|{{zoom}} */ animation, /** @type {ObjectType.STRING} @description {{verticalPosition}} @blockType util_dropdown @keys top|bottom @values {{top}}|{{bottom}} */ verticalPosition, /** @type {ObjectType.STRING} @description {{horizontalPosition}} @blockType util_dropdown @keys left|center|right @values {{left}}|{{center}}|{{right}} */ horizontalPosition, /** @type {ObjectType.STRING} @description {{autoHide}} @blockType util_dropdown @keys true|false @values {{yes}}|{{no}} */ autoHide) {
1294
-
1295
- let idCustomNotification = "customNotification" ;
1296
-
1297
- let dataNotification = {
1298
- stacking: "default",
1299
- autoHideAfter: 5000,
1300
- position: {
1301
- pinned: true
1302
- },
1303
- animation: {
1304
- open: {
1305
- effects: null
1306
- },
1307
- close: {
1308
- effects: null
1309
- }
1310
- }
1311
- };
1312
-
1313
- if (animation || verticalPosition || horizontalPosition || autoHide) {
1314
- customNotification(message, status, animation, verticalPosition, horizontalPosition, autoHide);
1315
- } else {
1316
- defaultNotification(message, status);
1317
- }
1318
-
1319
- async function defaultNotification(message, status) {
1320
-
1321
- let cronappConfig = {
1322
- id: "CronappNotification",
1323
- verticalPosition: "top",
1324
- horizontalPosition: "left",
1325
- animation: "slide",
1326
- autoHide: "false"
1327
- };
1328
-
1329
- setVerticalPosition(cronappConfig.verticalPosition);
1330
- setHorizontalPosition(cronappConfig.horizontalPosition);
1331
- setAnimation(cronappConfig.animation);
1332
- setAutoHide(cronappConfig.autoHide);
1333
-
1334
- if (!isNotificationInitialized(cronappConfig.id)) {
1335
- initializeNotification(cronappConfig.id, dataNotification);
1336
- }
1337
-
1338
- showNotification(cronappConfig.id, message, status);
1339
-
1340
- }
1341
-
1342
- async function customNotification(message, status, animation, verticalPosition, horizontalPosition, autoHide) {
1343
-
1344
- setVerticalPosition(verticalPosition);
1345
- setHorizontalPosition(horizontalPosition);
1346
- setAnimation(animation);
1347
- setAutoHide(autoHide);
1348
-
1349
- initializeNotification(idCustomNotification, dataNotification);
1350
- showNotification(idCustomNotification, message, status);
1351
-
1352
- }
1353
-
1354
- function setVerticalPosition(verticalPosition){
1355
- switch (verticalPosition) {
1356
- case "bottom":
1357
- dataNotification.position.bottom = 20;
1358
- idCustomNotification = idCustomNotification.concat('-bottom');
1359
- break;
1360
-
1361
- default:
1362
- dataNotification.position.top = 60;
1363
- idCustomNotification = idCustomNotification.concat('-top');
1364
-
1365
- }
1366
- }
1367
-
1368
- function setHorizontalPosition(horizontalPosition){
1369
- switch (horizontalPosition) {
1370
- case "right":
1371
- dataNotification.position.right = 20;
1372
- idCustomNotification = idCustomNotification.concat('-right');
1373
- break;
1374
-
1375
- case "center":
1376
- dataNotification.show = centerElementScreen;
1377
- idCustomNotification = idCustomNotification.concat('-center');
1378
- break;
1379
-
1380
- default:
1381
- dataNotification.position.left = 20;
1382
- idCustomNotification = idCustomNotification.concat('-left');
1383
-
1384
- }
1385
- }
1386
-
1387
- function centerElementScreen(e){
1388
- if (e.sender.getNotifications().length == 1) {
1389
- var element = e.element.parent(),
1390
- eWidth = element.width(),
1391
- wWidth = $(window).width()
1392
- var newLeft;
1393
-
1394
- newLeft = Math.floor(wWidth / 2 - eWidth / 2);
1395
-
1396
- e.element.parent().css({ left: newLeft });
1397
- }
1398
- }
1399
-
1400
- function setAnimation(animation){
1401
- switch (animation) {
1402
- case "slide":
1403
- if (dataNotification.show && dataNotification.position.bottom != null) {
1404
- dataNotification.animation.open.effects = "slideIn:up";
1405
- idCustomNotification = idCustomNotification.concat('-slideIn-up');
1406
-
1407
- } else if (dataNotification.show && dataNotification.position.top != null) {
1408
- dataNotification.animation.open.effects = "slideIn:down";
1409
- idCustomNotification = idCustomNotification.concat('-slideIn-dow');
1410
-
1411
- } else if (dataNotification.position.left != null) {
1412
- dataNotification.animation.open.effects = "slideIn:right";
1413
- idCustomNotification = idCustomNotification.concat('-slideIn-right');
1414
-
1415
- } else if (dataNotification.position.left == null) {
1416
- dataNotification.animation.open.effects = "slideIn:left";
1417
- idCustomNotification = idCustomNotification.concat('-slideIn-left');
1418
- }
1419
-
1420
- dataNotification.animation.close.effects = "slideOut";
1421
- break;
1422
-
1423
- case "zoom":
1424
- dataNotification.animation.open.effects = "zoomIn";
1425
- dataNotification.animation.close.effects = "zoomOut";
1426
- idCustomNotification = idCustomNotification.concat('-zoom');
1427
- break;
1428
-
1429
- default:
1430
- dataNotification.animation.open.effects = "fadeIn";
1431
- dataNotification.animation.close.effects = "fadeOut";
1432
- idCustomNotification = idCustomNotification.concat('-fade');
1433
- }
1434
- }
1435
-
1436
- function setAutoHide(autoHide){
1437
- if(autoHide == "false"){
1438
- dataNotification.autoHideAfter = 0;
1439
- idCustomNotification = idCustomNotification.concat('-autoHideAfter');
1440
- }
1441
- }
1442
-
1443
- async function initializeNotification(id, options) {
1444
- if (!hasHTMLElement(id)) {
1445
- let idNotification = $(`<span id="${id}"></span>`);
1446
- $('body').append(idNotification);
1447
-
1448
- await $(`#${id}`).kendoNotification(options);
1449
-
1450
- if(horizontalPosition == "center"){
1451
- centerElementScreen(e)
1452
- }
1453
- }
1454
- }
1455
-
1456
- function isNotificationInitialized(id) {
1457
- return $(`#${id}`).getKendoNotification();
1458
- }
1459
-
1460
- function showNotification(id, message, status) {
1461
- $(`#${id}`).getKendoNotification().show(message, status);
1462
- }
1463
-
1464
- function hasHTMLElement(id) {
1465
- return document.getElementById(id);
1466
- }
1467
-
1468
- };
1469
-
1470
1281
  /**
1471
1282
  * @type function
1472
1283
  * @name {{datasourceFromScreenName}}
@@ -1670,6 +1481,7 @@ if (!window.fixedTimeZone) {
1670
1481
  };
1671
1482
 
1672
1483
  /**
1484
+ * @deprecated true
1673
1485
  * @type function
1674
1486
  * @name {{datasourceFilterName}}
1675
1487
  * @nameTags filter|datasource
@@ -1687,6 +1499,51 @@ if (!window.fixedTimeZone) {
1687
1499
  }
1688
1500
  };
1689
1501
 
1502
+ /**
1503
+ * @type function
1504
+ * @name {{datasourceFilterName1}}
1505
+ * @nameTags filter|datasource
1506
+ * @description {{datasourceFilterDescription}}
1507
+ * @param {ObjectType.STRING} datasource {{datasourceFilterParam0}}
1508
+ * @param {ObjectType.STRING} condition {{datasourceFilterParam6}}
1509
+ * @param {ObjectType.LIST} filter {{datasourceFilterParam5}}
1510
+ * @multilayer true
1511
+ */
1512
+ this.cronapi.screen.doFilter = function(/** @type {ObjectType.OBJECT} @blockType datasource_from_screen*/ datasource, /** @type {ObjectType.String} @description {{datasourceFilterParam6}} @blockType util_dropdown @keys or|and @values {{datasourceFilterConditionOr}}|{{datasourceFilterConditionAnd}} */ condition,/** @type {ObjectType.LIST}*/ filter) {
1513
+
1514
+ let path = filter;
1515
+
1516
+ if(filter instanceof Array){
1517
+ path = filter.join(' ' + condition + ' ');
1518
+ }
1519
+
1520
+ if(getDatasource(datasource).isOData()){
1521
+ getDatasource(datasource).search(path);
1522
+ }
1523
+ else{
1524
+ getDatasource(datasource).filter('/' + path);
1525
+ }
1526
+ };
1527
+
1528
+ /**
1529
+ * @type function
1530
+ * @name {{datasourceFilterName2}}
1531
+ * @nameTags filter|datasource
1532
+ * @description {{datasourceFilterDescription}}
1533
+ * @param {ObjectType.STRING} field {{datasourceFilterParam2}}
1534
+ * @param {ObjectType.STRING} filterType {{datasourceFilterParam3}}
1535
+ * @param {ObjectType.STRING} filterValue {{datasourceFilterParam4}}
1536
+ * @returns {ObjectType.LIST}
1537
+ * @multilayer true
1538
+ */
1539
+ this.cronapi.screen.createFilter = function(/** @type {ObjectType.String} */ field, /** @type {ObjectType.String} @description {{datasourceFilterParam3}} @blockType util_dropdown @keys eq|ne|gt|lt|ge|le|substringof @values {{datasourceFilterOprEq}}|datasourceFilterOprNe|datasourceFilterOprGt|datasourceFilterOprLt|datasourceFilterOprGe|datasourceFilterOprLe|datasourceFilterOprSubStr */ filterType, /** @type {ObjectType.Object}*/ filterValue) {
1540
+ if(filterType === "substringof"){
1541
+ return "substringof('" + filterValue + "', tolower(" + field + "))";
1542
+ }
1543
+
1544
+ return field + " " + filterType + " " + objToOData(filterValue) + "";
1545
+ };
1546
+
1690
1547
  /**
1691
1548
  * @type function
1692
1549
  * @name {{changeView}}
@@ -1829,8 +1686,8 @@ if (!window.fixedTimeZone) {
1829
1686
  return null;
1830
1687
  };
1831
1688
 
1832
-
1833
1689
  /**
1690
+ * @deprecated true
1834
1691
  * @type function
1835
1692
  * @name {{confirmDialogName}}
1836
1693
  * @nameTags confirmDialog|Confirmar
@@ -1843,7 +1700,7 @@ if (!window.fixedTimeZone) {
1843
1700
  var value = confirm(msg);
1844
1701
  return value;
1845
1702
  };
1846
-
1703
+
1847
1704
  /**
1848
1705
  * @type function
1849
1706
  * @name {{createDefaultModalName}}
@@ -3205,6 +3062,12 @@ if (!window.fixedTimeZone) {
3205
3062
 
3206
3063
  this.cronapi.internal = {};
3207
3064
 
3065
+ this.cronapi.internal.skipIterationLoop = function() {
3066
+ return new Promise((resolve) => {
3067
+ resolve();
3068
+ });
3069
+ };
3070
+
3208
3071
  this.cronapi.internal.coverElement = function($element) {
3209
3072
 
3210
3073
  let cover = (id, obj) => {
@@ -3238,7 +3101,9 @@ if (!window.fixedTimeZone) {
3238
3101
  if ($firstInput && $firstInput.length) {
3239
3102
  let waitBecomeVisible = setInterval(()=> {
3240
3103
  if ($firstInput.is(':visible')) {
3241
- $firstInput.focus();
3104
+ if ($firstInput.data('role') !== 'dropdownlist') {
3105
+ $firstInput.focus();
3106
+ }
3242
3107
  clearInterval(waitBecomeVisible);
3243
3108
  }
3244
3109
  }, 100);
@@ -3665,6 +3530,8 @@ if (!window.fixedTimeZone) {
3665
3530
  let barCodeOneD = "UPC_A|UPC_E|EAN_8|EAN_13|CODE_39|CODE_128|ITF|RSS14|RSS_EXPANDED";
3666
3531
  let codeReader;
3667
3532
 
3533
+ navigator.mediaDevices.getUserMedia({audio: false, video: true}).then(stream => {
3534
+
3668
3535
  switch (scanOptions.formats) {
3669
3536
  case "AZTEC":
3670
3537
  codeReader = new ZXing.BrowserAztecCodeReader();
@@ -3686,43 +3553,84 @@ if (!window.fixedTimeZone) {
3686
3553
  codeReader = new ZXing.BrowserBarcodeReader();
3687
3554
  }
3688
3555
 
3689
- codeReader.listVideoInputDevices()
3556
+ codeReader.listVideoInputDevices()
3690
3557
  .then((videoInputDevices) => {
3691
3558
  selectedDeviceId = videoInputDevices[0].deviceId
3692
- var cameraContainer = '<div style="position: fixed; display: flex; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; background-color: \
3693
- rgb(0 0 0 / 72%); z-index: 9999999; cursor: pointer; justify-content: center; align-items: center;">\
3694
- <div style="position: absolute">\
3695
- <video id="video" style="width: 100%; max-width: 600px; border-radius: 5px;"></video>\
3696
- <button class="btn btn-danger button button-assertive" id="cronapiBarCodeCancel" style="position: absolute; right: 0; z-index: 999999999;">\
3697
- <span class="glyphicon glyphicon-remove icon ion-android-close"></span>\
3698
- <span class="sr-only">{{"Cancel" | translate}}</span>\
3699
- </button>\
3700
- </div>\
3701
- </div>';
3702
- var cronappVideoBarCode = $(cameraContainer);
3559
+ let cameraContainer = `<div style="position: fixed; display: flex; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; background-color:
3560
+ rgb(0 0 0 / 72%); z-index: 9999999; cursor: pointer; justify-content: center; align-items: center;">
3561
+ <div style="position: absolute">
3562
+ <div class="row" style="position: absolute; bottom 50px; z-index: 999999999;">
3563
+ <div class="col-xs-8">
3564
+ <select style="width: 100%; position: absolute; bottom: 10px; left: 0; z-index: 999999999;" id="videoSource"></select>
3565
+ </div>
3566
+ <div class="col-xs-2">
3567
+ <button class="btn btn-danger button button-dark" id="cronapiBarCodeChangeCam" >
3568
+ <span class="glyphicon glyphicon-remove icon ion ion-ios-reverse-camera"></span>
3569
+ <span class="sr-only">{{"ChangeCam" | translate}}</span>
3570
+ </button>
3571
+ </div>
3572
+ <div class="col-xs-2">
3573
+ <button class="btn btn-danger button button-assertive" id="cronapiBarCodeCancel" >
3574
+ <span class="glyphicon glyphicon-remove icon ion-android-close"></span>
3575
+ <span class="sr-only">{{"Cancel" | translate}}</span>
3576
+ </button>
3577
+ </div>
3578
+ </div>
3579
+ <video id="video" style="width: 100%; max-width: 600px; border-radius: 5px;"></video>
3580
+ </div>
3581
+ </div>`;
3582
+ let cronappVideoBarCode = $(cameraContainer);
3703
3583
  cronappVideoBarCode.prependTo("body");
3704
- cronappVideoBarCode.find('#cronapiBarCodeCancel').on('click', function() {
3584
+ videoInputDevices.map((device, index)=>{
3585
+ if (device.kind === 'videoinput') {
3586
+ let option = document.createElement('option');
3587
+ option.value = device.deviceId;
3588
+ option.text = device.label || 'Câmera ' + (index + 1);
3589
+ if (index === 0) {
3590
+ option.selected = true;
3591
+ }
3592
+ document.querySelector('select#videoSource').appendChild(option);
3593
+ }
3594
+ });
3595
+ cronappVideoBarCode.find('#cronapiBarCodeCancel').on('click', (() => {
3705
3596
  codeReader.reset();
3706
3597
  $(cronappVideoBarCode).remove();
3707
- fail();
3708
- }.bind(this));
3709
-
3598
+ }).bind(this));
3599
+ cronappVideoBarCode.find('#cronapiBarCodeChangeCam').on('click', (() => {
3600
+ let selectedIndex = $("#videoSource").prop("selectedIndex");
3601
+ let itemsInDropDownList = $("#videoSource option").length;
3602
+
3603
+ if (selectedIndex < (itemsInDropDownList - 1)) {
3604
+ $("#videoSource").prop("selectedIndex", selectedIndex + 1);
3605
+ } else {
3606
+ $("#videoSource").prop("selectedIndex", 0);
3607
+ }
3608
+ $("#videoSource").trigger('change');
3609
+ }).bind(this));
3610
+ cronappVideoBarCode.find('#videoSource').on('change', (() => {
3611
+ codeReader.decodeOnceFromVideoDevice($("#videoSource").val(), 'video').then((result) => {
3612
+ if (result) {
3613
+ success(result.text);
3614
+ $(cronappVideoBarCode).remove();
3615
+ codeReader.reset();
3616
+ }
3617
+ });
3618
+ }).bind(this));
3710
3619
  codeReader.decodeOnceFromVideoDevice(selectedDeviceId, 'video').then((result) => {
3711
3620
  if (result) {
3712
3621
  success(result.text);
3713
3622
  $(cronappVideoBarCode).remove();
3714
3623
  codeReader.reset();
3715
3624
  }
3716
- }).catch((err) => {
3717
- fail(err);
3718
- $(cronappVideoBarCode).remove();
3719
- codeReader.reset();
3720
3625
  });
3721
3626
 
3722
3627
  }).catch((err) => {
3723
3628
  fail(err);
3724
3629
  codeReader.reset();
3725
3630
  });
3631
+ }).catch(function(err) {
3632
+ fail(err);
3633
+ });
3726
3634
  }
3727
3635
 
3728
3636
  this.cronapi.internal.castBinaryStringToByteArray = function(binary_string) {
@@ -3972,8 +3880,10 @@ if (!window.fixedTimeZone) {
3972
3880
  'Content-Type': 'application/json',
3973
3881
  'X-AUTH-TOKEN': _u.token,
3974
3882
  }
3975
- }).success(function(data, status, headers, config) {
3883
+ }).then(function(data, status, headers, config) {
3884
+ headers = headers || data.headers;
3976
3885
  headers = headers();
3886
+ data = this.cronapi.getRequestData(data);
3977
3887
  var filename = headers['x-filename'] || 'download.bin';
3978
3888
  var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
3979
3889
  try
@@ -3984,7 +3894,7 @@ if (!window.fixedTimeZone) {
3984
3894
  console.log('Error downloading file');
3985
3895
  console.log(ex);
3986
3896
  }
3987
- }.bind(this)).error(function(data, status, headers, config) {
3897
+ }.bind(this)).catch(function(data, status, headers, config) {
3988
3898
  console.log('Error downloading file');
3989
3899
  }.bind(this));
3990
3900
  }
@@ -4032,9 +3942,10 @@ if (!window.fixedTimeZone) {
4032
3942
 
4033
3943
  }
4034
3944
  }
4035
- }).success(function(data, status, headers, config) {
3945
+ }).then(function(data, status, headers, config) {
3946
+ data = this.cronapi.getRequestData(data);
4036
3947
  this.cronapi.screen.changeValueOfField(field, data.jsonString);
4037
- }.bind(this)).error(function(data, status, headers, config) {
3948
+ }.bind(this)).catch(function(data, status, headers, config) {
4038
3949
  alert('Error uploading file');
4039
3950
  }.bind(this));
4040
3951
 
@@ -4466,8 +4377,13 @@ if (!window.fixedTimeZone) {
4466
4377
  let options = { destinationType: Number(destinationType) , sourceType : Number(pictureSourceType) , mediaType: Number(mediaType) , allowEdit: allowEdit};
4467
4378
  if(window.cordova && window.cordova.platformId && window.cordova.platformId !== 'browser') {
4468
4379
 
4469
- let resultWithData = (data) => {
4470
- if (data && !data.startsWith("data:image")) data = "data:image/jpeg;base64, " + data;
4380
+ let resultWithData = async (data) => {
4381
+ if (data.startsWith("file://")) {
4382
+ data = Ionic.WebView.convertFileSrc(data);
4383
+ }
4384
+ else if (data && !data.startsWith("data:image")) {
4385
+ data = "data:image/jpeg;base64, " + data;
4386
+ }
4471
4387
  !success || success(data);
4472
4388
  };
4473
4389
  navigator.camera.getPicture(this.cronapi.util.handleCallback(resultWithData), this.cronapi.util.handleCallback(error), options);
@@ -4914,26 +4830,6 @@ if (!window.fixedTimeZone) {
4914
4830
  this.cronapi.event = {};
4915
4831
 
4916
4832
 
4917
- /**
4918
- * @type function
4919
- * @name {itemContextMenu}
4920
- * @nameTags contextMenu | menu | contexto | context | item
4921
- * @description {contextMenuDescription}
4922
- * @param {ObjectType.STRING} text {{text}}
4923
- * @param {ObjectType.STRING} cssClass {{cssClass}}
4924
- * @param {ObjectType.STATEMENT} action {{kendoContextMenuActionItem}}
4925
- * @param {ObjectType.OBJECT} subItens {{kendoDatasource}}
4926
- * @returns {ObjectType.OBJECT}
4927
- */
4928
- this.cronapi.event.itemContextMenu = function (/** @type{ObjectType.STRING} */ text, /** @type{ObjectType.STRING} */ cssClass, /** @type {ObjectType.STATEMENT} @description {kendoContextMenuActionItem} */action, subItens) {
4929
-
4930
- let jsonItem = { text: text }
4931
- if (subItens) { jsonItem.items = (Array.isArray(subItens) ? subItens : [subItens]) };
4932
- if (!subItens) { jsonItem.select = action }
4933
- if (cssClass) { jsonItem.cssClass = cssClass };
4934
- return jsonItem;
4935
- };
4936
-
4937
4833
  /**
4938
4834
  * @type function
4939
4835
  * @name {{contextMenu}}
@@ -4984,16 +4880,16 @@ if (!window.fixedTimeZone) {
4984
4880
 
4985
4881
  /**
4986
4882
  * @type function
4987
- * @name {itemContextMenu}
4883
+ * @name {{itemContextMenu}}
4988
4884
  * @nameTags contextMenu | menu | contexto | context | item
4989
- * @description {contextMenuDescription}
4885
+ * @description {{contextMenuDescription}}
4990
4886
  * @param {ObjectType.STRING} text {{text}}
4991
4887
  * @param {ObjectType.STRING} cssClass {{cssClass}}
4992
- * @param {ObjectType.STATEMENT} action {{kendoContextMenuActionItem}}
4888
+ * @param {ObjectType.STATEMENT} action {{contextMenuItemActionDescription}}
4993
4889
  * @param {ObjectType.OBJECT} subItens {{kendoDatasource}}
4994
4890
  * @returns {ObjectType.OBJECT}
4995
4891
  */
4996
- this.cronapi.event.itemContextMenu = function (/** @type{ObjectType.STRING} */ text, /** @type{ObjectType.STRING} */ cssClass, /** @type {ObjectType.STATEMENT} @description {kendoContextMenuActionItem} */action, subItens) {
4892
+ this.cronapi.event.itemContextMenu = function (/** @type{ObjectType.STRING} */ text, /** @type{ObjectType.STRING} */ cssClass, /** @type {ObjectType.STATEMENT} */ action, subItens) {
4997
4893
 
4998
4894
  let jsonItem = { text: text }
4999
4895
  if (subItens) { jsonItem.items = (Array.isArray(subItens) ? subItens : [subItens]) };
@@ -5004,7 +4900,7 @@ if (!window.fixedTimeZone) {
5004
4900
 
5005
4901
  /**
5006
4902
  * @type function
5007
- * @name {{changeValueAccordion}}
4903
+ * @name {{accordionChangeValue}}
5008
4904
  * @nameTags accordion | acordeão | abrir | fechar | colapse
5009
4905
  * @description {{accordionChangeValueDescription}}
5010
4906
  * @param {ObjectType.STRING} idAccordion {{accordionIdParamDescription}}
@@ -5287,8 +5183,9 @@ if (!window.fixedTimeZone) {
5287
5183
  * @description {{createChartDescription}}
5288
5184
  * @arbitraryParams true
5289
5185
  */
5290
- this.cronapi.chart.createChart = function(/** @type {ObjectType.OBJECT} @description {{createChartId}} @blockType ids_from_screen*/ chartId, /** @type {ObjectType.STRING} @description {{createChartType}} @blockType util_dropdown @keys line|bar|horizontalBar|doughnut|pie|polarArea @values line|bar|horizontalBar|doughnut|pie|polarArea */ type, /** @type {ObjectType.LIST} @description {{createChartLegends}} */ chartLegends, /** @type {ObjectType.LIST} @description {{createChartOptions}} */ options, /** @type {ObjectType.LIST} @description {{createChartSeries}} */ series) {
5186
+ this.cronapi.chart.createChart = function(/** @type {ObjectType.OBJECT} @description {{createChartId}} @blockType ids_from_screen*/ chartId, /** @type {ObjectType.STRING} @description {{createChartType}} @blockType util_dropdown @keys line|bar|horizontalBar|doughnut|pie|polarArea @values line|bar|horizontalBar|doughnut|pie|polarArea */ type, /** @type {ObjectType.LIST} @description {{createChartLegends}} */ chartLegends, /** @type {ObjectType.LIST} @description {{createChartOptions}} */ options, /** @type {ObjectType.LIST} @description {{createChartSeries}} */ series) {
5291
5187
 
5188
+ var colors = options && options.colors ? options.colors : [];
5292
5189
  var CSS_COLOR_NAMES = ["#FF5C00","#0E53A7","#48DD00","#FFD500","#7309AA","#CD0074","#00AF64","#BF8230","#F16D95","#A65000","#A65000","#AF66D5"];
5293
5190
  var colorIndex = 0;
5294
5191
 
@@ -5393,7 +5290,7 @@ if (!window.fixedTimeZone) {
5393
5290
  //Applying configs in Datasets
5394
5291
  $.each(json.data.datasets, function(index,value){
5395
5292
  value.fill = false;
5396
- value.backgroundColor = CSS_COLOR_NAMES[nextColor()];
5293
+ value.backgroundColor = colors[index] ? colors[index] : CSS_COLOR_NAMES[nextColor()];
5397
5294
  value.borderColor = value.backgroundColor;
5398
5295
  beginAtZero();
5399
5296
  displayLegend();
@@ -5406,7 +5303,11 @@ if (!window.fixedTimeZone) {
5406
5303
  json.data.datasets = getDataset(arguments);
5407
5304
  //Applying configs in Datasets
5408
5305
  $.each(json.data.datasets, function(index,value){
5409
- value.backgroundColor = CSS_COLOR_NAMES[nextColor()];
5306
+ if(json.data.datasets.length === 1 && colors.length > 1){
5307
+ value.backgroundColor = colors;
5308
+ }else{
5309
+ value.backgroundColor = colors[index] ? colors[index] : CSS_COLOR_NAMES[nextColor()];
5310
+ }
5410
5311
  value.borderColor = value.backgroundColor;
5411
5312
  });
5412
5313
  beginAtZero();
@@ -5424,8 +5325,7 @@ if (!window.fixedTimeZone) {
5424
5325
  dtset.backgroundColor = [];
5425
5326
  dtset.borderColor = [];
5426
5327
  $.each(dtset.data, function(indexx,valuee){
5427
- dtset.backgroundColor.push( CSS_COLOR_NAMES[nextColor()] );
5428
-
5328
+ dtset.backgroundColor.push( colors[indexx] ? colors[indexx] : CSS_COLOR_NAMES[nextColor()] );
5429
5329
  });
5430
5330
  dtset.borderColor = dtset.backgroundColor;
5431
5331
  json.data.datasets.push(dtset);
@@ -5614,7 +5514,324 @@ if (!window.fixedTimeZone) {
5614
5514
  */
5615
5515
  this.cronapi.screen.back = function() {
5616
5516
  history.back();
5617
- }
5517
+ };
5518
+
5519
+ /**
5520
+ * @category {{notificationCategory}}
5521
+ * @categoryTags notification | notification
5522
+ */
5523
+ this.cronapi.notification = {};
5524
+
5525
+ /**
5526
+ * @type function
5527
+ * @name {{confirmDialogAlertName}}
5528
+ * @nameTags confirmDialog | Confirmar | alert | modal | alerta
5529
+ * @description {{confirmDialogAlertDescription}}
5530
+ * @param {ObjectType.STRING} icon {{icon}
5531
+ * @param {ObjectType.STRING} title {{title}}
5532
+ * @param {ObjectType.STRING} subtitle {{subtitle}}
5533
+ * @param {ObjectType.OBJECT} buttonConfirmDialogAlert {{confimDialogAlert.listButton}}
5534
+ * @platform W
5535
+ * @multilayer true
5536
+ */
5537
+ this.cronapi.notification.confirmDialogAlert = function(/** @type {ObjectType.STRING} @description {{icon}} @blockType util_dropdown @keys error|success|warning|info @values {{error}}|{{success}}|{{warning}}|{{info}} */ icon, title, subtitle, /** @type {ObjectType.OBJECT} */ buttonConfirmDialogAlert) {
5538
+
5539
+ let idDialog = 'cronapp-dialog-' + Math.random();
5540
+ let dialog = $(`<span id="${idDialog}"></span>`);
5541
+ $('body').append(dialog);
5542
+
5543
+ let dataDialog = {
5544
+ width: "450px",
5545
+ title: false,
5546
+ closable: false,
5547
+ modal: true,
5548
+ content: "",
5549
+ animation: {
5550
+ open: {
5551
+ effects: "zoom:in"
5552
+ },
5553
+ close: {
5554
+ effects: "zoom:out"
5555
+ }
5556
+ },
5557
+ buttonLayout: "normal",
5558
+ actions: [],
5559
+ close: function(e) {
5560
+ setInterval(() => {
5561
+ $(`#${idDialog}`).data("kendoDialog").destroy();
5562
+ }, 3000);
5563
+ }
5564
+ };
5565
+
5566
+ setIcon(icon, title, subtitle);
5567
+ setButton(buttonConfirmDialogAlert);
5568
+
5569
+ dialog.kendoDialog(dataDialog);
5570
+ dialog.data("kendoDialog").open();
5571
+
5572
+ async function setIcon(icon, title, subtitle){
5573
+ switch (icon){
5574
+ case "error":
5575
+ icon = '<div class="cronapp-icon cronapp-error" style="display: flex;"> <span class="cronapp-x-mark"><span class="cronapp-x-mark-line-left"></span><span class="cronapp-x-mark-line-right"></span></span></div>';
5576
+ break;
5577
+
5578
+ case "success":
5579
+ icon = '<div class="cronapp-icon cronapp-success"><div class="cronapp-success-circular-line-left"></div><span class="cronapp-success-line-tip"></span> <span class="cronapp-success-line-long"></span><div class="cronapp-success-ring"></div><div class="cronapp-success-fix"></div> <div class="cronapp-success-circular-line-right"></div></div>';
5580
+ break;
5581
+
5582
+ case "warning":
5583
+ icon = '<div class="cronapp-icon cronapp-warning"><div class="cronapp-icon-content">!</div></div>';
5584
+ break;
5585
+
5586
+ case "info":
5587
+ icon = '<div class="cronapp-icon cronapp-info"><div class="cronapp-icon-content">i</div></div>';
5588
+ break;
5589
+ }
5590
+ await setContent(icon, title, subtitle);
5591
+ }
5592
+
5593
+ function setContent(icon, title, subtitle){
5594
+ dataDialog.content = '<div id="modalBodyConfirmDialog"> <div class="icon">'+ icon +'</div> <h2 class="title">'+ title +'</h2> <h3 class="subtitle">'+ subtitle +'</h3> </div>';
5595
+ }
5596
+
5597
+ function setButton(buttonConfirmDialogAlert){
5598
+ let buttons = (Array.isArray(buttonConfirmDialogAlert) ? buttonConfirmDialogAlert : [buttonConfirmDialogAlert]);
5599
+
5600
+ let hasButton = false;
5601
+
5602
+ for (let i = 0; i < buttons.length; i++) {
5603
+ let button = buttons[i];
5604
+ if(button){
5605
+ dataDialog.actions.push({
5606
+ text: button.title,
5607
+ action: button.value,
5608
+ primary: button.primaryValue == 'true' ? true : null
5609
+ });
5610
+
5611
+ hasButton = true;
5612
+
5613
+ }
5614
+ };
5615
+
5616
+ // If you have not added a button to the modal. Add to be able to close the modal.
5617
+ if(!hasButton){
5618
+ dataDialog.actions.push({
5619
+ text: "OK",
5620
+ primary: true
5621
+ });
5622
+ };
5623
+
5624
+ }
5625
+
5626
+ };
5627
+
5628
+ /**
5629
+ * @type function
5630
+ * @name {{buttonConfirmDialogAlert}}
5631
+ * @nameTags confirmDialog | botão | button | alert | modal | alerta
5632
+ * @description {{buttonConfirmDialogAlertDescription}}
5633
+ * @platform W
5634
+ * @param {ObjectType.BOOLEAN} primaryButton {{buttonConfirmDialogAlert.primaryButton}}
5635
+ * @param {ObjectType.STRING} title {{title}}
5636
+ * @param {ObjectType.STRING} value {{buttonConfirmDialogAlert.value}}
5637
+ * @returns {ObjectType.OBJECT}
5638
+ */
5639
+ this.cronapi.notification.buttonConfirmDialogAlert = function (/** @type {ObjectType.STRING} @description {{buttonConfirmDialogAlert.primaryButton}} @blockType util_dropdown @keys true|false @values {{yes}}|{{no}} */ primaryButton, title, /** @type {ObjectType.STATEMENT} @description {{buttonConfirmDialogAlert.value}} */ value) {
5640
+ return {
5641
+ title: title,
5642
+ value: value,
5643
+ primaryValue: primaryButton
5644
+ };
5645
+ };
5646
+
5647
+ /**
5648
+ * @type function
5649
+ * @name {{screenNotifySimpleName}}
5650
+ * @description {{screenNotifySimpleDescription}}
5651
+ * @nameTags show | exibir | exibe | notification | notificação
5652
+ * @param {ObjectType.STRING} status {{screenNotifySimpleParam0}}
5653
+ * @param {ObjectType.STRING} message {{screenNotifySimpleParam1}}
5654
+ * @param {ObjectType.STRING} animation {{screenNotifySimpleParam2}}
5655
+ * @param {ObjectType.STRING} verticalPosition {{screenNotifySimpleParam3}}
5656
+ * @param {ObjectType.STRING} horizontalPosition {{screenNotifySimpleParam4}}
5657
+ * @param {ObjectType.STRING} autoHide {{screenNotifySimpleParam5}}
5658
+ */
5659
+ this.cronapi.notification.customNotify = function(/** @type {ObjectType.STRING} @description {{status}} @blockType util_dropdown @keys error|success|warning|info @values {{error}}|{{success}}|{{warning}}|{{info}} */ status, /** @type {ObjectType.STRING} */ message, /** @type {ObjectType.STRING} @description {{animation}} @blockType util_dropdown @keys fade|slide|zoom @values {{fade}}|{{slide}}|{{zoom}} */ animation, /** @type {ObjectType.STRING} @description {{verticalPosition}} @blockType util_dropdown @keys top|bottom @values {{top}}|{{bottom}} */ verticalPosition, /** @type {ObjectType.STRING} @description {{horizontalPosition}} @blockType util_dropdown @keys left|center|right @values {{left}}|{{center}}|{{right}} */ horizontalPosition, /** @type {ObjectType.STRING} @description {{autoHide}} @blockType util_dropdown @keys true|false @values {{yes}}|{{no}} */ autoHide) {
5660
+
5661
+ let idCustomNotification = "customNotification" ;
5662
+
5663
+ let dataNotification = {
5664
+ stacking: "default",
5665
+ autoHideAfter: 5000,
5666
+ position: {
5667
+ pinned: true
5668
+ },
5669
+ animation: {
5670
+ open: {
5671
+ effects: null
5672
+ },
5673
+ close: {
5674
+ effects: null
5675
+ }
5676
+ }
5677
+ };
5678
+
5679
+ if (animation || verticalPosition || horizontalPosition || autoHide) {
5680
+ customNotification(message, status, animation, verticalPosition, horizontalPosition, autoHide);
5681
+ } else {
5682
+ defaultNotification(message, status);
5683
+ }
5684
+
5685
+ async function defaultNotification(message, status) {
5686
+
5687
+ let cronappConfig = {
5688
+ id: "CronappNotification",
5689
+ verticalPosition: "top",
5690
+ horizontalPosition: "left",
5691
+ animation: "slide",
5692
+ autoHide: "false"
5693
+ };
5694
+
5695
+ setVerticalPosition(cronappConfig.verticalPosition);
5696
+ setHorizontalPosition(cronappConfig.horizontalPosition);
5697
+ setAnimation(cronappConfig.animation);
5698
+ setAutoHide(cronappConfig.autoHide);
5699
+
5700
+ if (!isNotificationInitialized(cronappConfig.id)) {
5701
+ initializeNotification(cronappConfig.id, dataNotification);
5702
+ }
5703
+
5704
+ showNotification(cronappConfig.id, message, status);
5705
+
5706
+ }
5707
+
5708
+ async function customNotification(message, status, animation, verticalPosition, horizontalPosition, autoHide) {
5709
+
5710
+ setVerticalPosition(verticalPosition);
5711
+ setHorizontalPosition(horizontalPosition);
5712
+ setAnimation(animation);
5713
+ setAutoHide(autoHide);
5714
+
5715
+ initializeNotification(idCustomNotification, dataNotification);
5716
+ showNotification(idCustomNotification, message, status);
5717
+
5718
+ }
5719
+
5720
+ function setVerticalPosition(verticalPosition){
5721
+ switch (verticalPosition) {
5722
+ case "bottom":
5723
+ dataNotification.position.bottom = 20;
5724
+ idCustomNotification = idCustomNotification.concat('-bottom');
5725
+ break;
5726
+
5727
+ default:
5728
+ dataNotification.position.top = 60;
5729
+ idCustomNotification = idCustomNotification.concat('-top');
5730
+
5731
+ }
5732
+ }
5733
+
5734
+ function setHorizontalPosition(horizontalPosition){
5735
+ switch (horizontalPosition) {
5736
+ case "right":
5737
+ dataNotification.position.right = 20;
5738
+ idCustomNotification = idCustomNotification.concat('-right');
5739
+ break;
5740
+
5741
+ case "center":
5742
+ dataNotification.show = centerElementScreen;
5743
+ idCustomNotification = idCustomNotification.concat('-center');
5744
+ break;
5745
+
5746
+ default:
5747
+ dataNotification.position.left = 20;
5748
+ idCustomNotification = idCustomNotification.concat('-left');
5749
+
5750
+ }
5751
+ }
5752
+
5753
+ function centerElementScreen(e){
5754
+ if (e.sender.getNotifications().length == 1) {
5755
+ var element = e.element.parent(),
5756
+ eWidth = element.width(),
5757
+ wWidth = $(window).width()
5758
+ var newLeft;
5759
+
5760
+ newLeft = Math.floor(wWidth / 2 - eWidth / 2);
5761
+
5762
+ e.element.parent().css({ left: newLeft });
5763
+ }
5764
+ }
5765
+
5766
+ function setAnimation(animation){
5767
+ switch (animation) {
5768
+ case "slide":
5769
+ if (dataNotification.show && dataNotification.position.bottom != null) {
5770
+ dataNotification.animation.open.effects = "slideIn:up";
5771
+ idCustomNotification = idCustomNotification.concat('-slideIn-up');
5772
+
5773
+ } else if (dataNotification.show && dataNotification.position.top != null) {
5774
+ dataNotification.animation.open.effects = "slideIn:down";
5775
+ idCustomNotification = idCustomNotification.concat('-slideIn-dow');
5776
+
5777
+ } else if (dataNotification.position.left != null) {
5778
+ dataNotification.animation.open.effects = "slideIn:right";
5779
+ idCustomNotification = idCustomNotification.concat('-slideIn-right');
5780
+
5781
+ } else if (dataNotification.position.left == null) {
5782
+ dataNotification.animation.open.effects = "slideIn:left";
5783
+ idCustomNotification = idCustomNotification.concat('-slideIn-left');
5784
+ }
5785
+
5786
+ dataNotification.animation.close.effects = "slideOut";
5787
+ break;
5788
+
5789
+ case "zoom":
5790
+ dataNotification.animation.open.effects = "zoomIn";
5791
+ dataNotification.animation.close.effects = "zoomOut";
5792
+ idCustomNotification = idCustomNotification.concat('-zoom');
5793
+ break;
5794
+
5795
+ default:
5796
+ dataNotification.animation.open.effects = "fadeIn";
5797
+ dataNotification.animation.close.effects = "fadeOut";
5798
+ idCustomNotification = idCustomNotification.concat('-fade');
5799
+ }
5800
+ }
5801
+
5802
+ function setAutoHide(autoHide){
5803
+ if(autoHide == "false"){
5804
+ dataNotification.autoHideAfter = 0;
5805
+ idCustomNotification = idCustomNotification.concat('-autoHideAfter');
5806
+ }
5807
+ }
5808
+
5809
+ async function initializeNotification(id, options) {
5810
+ if (!hasHTMLElement(id)) {
5811
+ let idNotification = $(`<span id="${id}"></span>`);
5812
+ $('body').append(idNotification);
5813
+
5814
+ await $(`#${id}`).kendoNotification(options);
5815
+
5816
+ if(horizontalPosition == "center"){
5817
+ centerElementScreen(e)
5818
+ }
5819
+ }
5820
+ }
5821
+
5822
+ function isNotificationInitialized(id) {
5823
+ return $(`#${id}`).getKendoNotification();
5824
+ }
5825
+
5826
+ function showNotification(id, message, status) {
5827
+ $(`#${id}`).getKendoNotification().show(message, status);
5828
+ }
5829
+
5830
+ function hasHTMLElement(id) {
5831
+ return document.getElementById(id);
5832
+ }
5833
+
5834
+ };
5618
5835
 
5619
5836
  /**
5620
5837
  * @category CategoryType.REGEX