cronapi-js 2.8.18 → 2.8.22

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
@@ -60,6 +60,7 @@ if (!window.fixedTimeZone) {
60
60
  this.cronapi.evalInContext = async function(js) {
61
61
  var result = eval('this.cronapi.doEval('+js+')');
62
62
  if (result) {
63
+ result = result.data || result;
63
64
  if (result.commands) {
64
65
  for (var i = 0; i < result.commands.length; i++) {
65
66
  var func = eval(result.commands[i].function);
@@ -1259,13 +1260,6 @@ if (!window.fixedTimeZone) {
1259
1260
  return this.cronapi.$scope.vars[name];
1260
1261
  };
1261
1262
 
1262
- /**
1263
- * @category {{notificationCategory}}
1264
- * @categoryTags notification | notification
1265
- */
1266
- this.cronapi.notification = {};
1267
-
1268
-
1269
1263
  /**
1270
1264
  * @deprecated true
1271
1265
  * @type function
@@ -1285,196 +1279,6 @@ if (!window.fixedTimeZone) {
1285
1279
  this.cronapi.$scope.Notification({'message':message.toString() },type);
1286
1280
  };
1287
1281
 
1288
-
1289
- /**
1290
- * @type function
1291
- * @name {{screenNotifySimpleName}}
1292
- * @description {{screenNotifySimpleDescription}}
1293
- * @nameTags show | exibir | exibe | notification | notificação
1294
- * @param {ObjectType.STRING} status {{screenNotifySimpleParam0}}
1295
- * @param {ObjectType.STRING} message {{screenNotifySimpleParam1}}
1296
- * @param {ObjectType.STRING} animation {{screenNotifySimpleParam2}}
1297
- * @param {ObjectType.STRING} verticalPosition {{screenNotifySimpleParam3}}
1298
- * @param {ObjectType.STRING} horizontalPosition {{screenNotifySimpleParam4}}
1299
- * @param {ObjectType.STRING} autoHide {{screenNotifySimpleParam5}}
1300
- */
1301
- 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) {
1302
-
1303
- let idCustomNotification = "customNotification" ;
1304
-
1305
- let dataNotification = {
1306
- stacking: "default",
1307
- autoHideAfter: 5000,
1308
- position: {
1309
- pinned: true
1310
- },
1311
- animation: {
1312
- open: {
1313
- effects: null
1314
- },
1315
- close: {
1316
- effects: null
1317
- }
1318
- }
1319
- };
1320
-
1321
- if (animation || verticalPosition || horizontalPosition || autoHide) {
1322
- customNotification(message, status, animation, verticalPosition, horizontalPosition, autoHide);
1323
- } else {
1324
- defaultNotification(message, status);
1325
- }
1326
-
1327
- async function defaultNotification(message, status) {
1328
-
1329
- let cronappConfig = {
1330
- id: "CronappNotification",
1331
- verticalPosition: "top",
1332
- horizontalPosition: "left",
1333
- animation: "slide",
1334
- autoHide: "false"
1335
- };
1336
-
1337
- setVerticalPosition(cronappConfig.verticalPosition);
1338
- setHorizontalPosition(cronappConfig.horizontalPosition);
1339
- setAnimation(cronappConfig.animation);
1340
- setAutoHide(cronappConfig.autoHide);
1341
-
1342
- if (!isNotificationInitialized(cronappConfig.id)) {
1343
- initializeNotification(cronappConfig.id, dataNotification);
1344
- }
1345
-
1346
- showNotification(cronappConfig.id, message, status);
1347
-
1348
- }
1349
-
1350
- async function customNotification(message, status, animation, verticalPosition, horizontalPosition, autoHide) {
1351
-
1352
- setVerticalPosition(verticalPosition);
1353
- setHorizontalPosition(horizontalPosition);
1354
- setAnimation(animation);
1355
- setAutoHide(autoHide);
1356
-
1357
- initializeNotification(idCustomNotification, dataNotification);
1358
- showNotification(idCustomNotification, message, status);
1359
-
1360
- }
1361
-
1362
- function setVerticalPosition(verticalPosition){
1363
- switch (verticalPosition) {
1364
- case "bottom":
1365
- dataNotification.position.bottom = 20;
1366
- idCustomNotification = idCustomNotification.concat('-bottom');
1367
- break;
1368
-
1369
- default:
1370
- dataNotification.position.top = 60;
1371
- idCustomNotification = idCustomNotification.concat('-top');
1372
-
1373
- }
1374
- }
1375
-
1376
- function setHorizontalPosition(horizontalPosition){
1377
- switch (horizontalPosition) {
1378
- case "right":
1379
- dataNotification.position.right = 20;
1380
- idCustomNotification = idCustomNotification.concat('-right');
1381
- break;
1382
-
1383
- case "center":
1384
- dataNotification.show = centerElementScreen;
1385
- idCustomNotification = idCustomNotification.concat('-center');
1386
- break;
1387
-
1388
- default:
1389
- dataNotification.position.left = 20;
1390
- idCustomNotification = idCustomNotification.concat('-left');
1391
-
1392
- }
1393
- }
1394
-
1395
- function centerElementScreen(e){
1396
- if (e.sender.getNotifications().length == 1) {
1397
- var element = e.element.parent(),
1398
- eWidth = element.width(),
1399
- wWidth = $(window).width()
1400
- var newLeft;
1401
-
1402
- newLeft = Math.floor(wWidth / 2 - eWidth / 2);
1403
-
1404
- e.element.parent().css({ left: newLeft });
1405
- }
1406
- }
1407
-
1408
- function setAnimation(animation){
1409
- switch (animation) {
1410
- case "slide":
1411
- if (dataNotification.show && dataNotification.position.bottom != null) {
1412
- dataNotification.animation.open.effects = "slideIn:up";
1413
- idCustomNotification = idCustomNotification.concat('-slideIn-up');
1414
-
1415
- } else if (dataNotification.show && dataNotification.position.top != null) {
1416
- dataNotification.animation.open.effects = "slideIn:down";
1417
- idCustomNotification = idCustomNotification.concat('-slideIn-dow');
1418
-
1419
- } else if (dataNotification.position.left != null) {
1420
- dataNotification.animation.open.effects = "slideIn:right";
1421
- idCustomNotification = idCustomNotification.concat('-slideIn-right');
1422
-
1423
- } else if (dataNotification.position.left == null) {
1424
- dataNotification.animation.open.effects = "slideIn:left";
1425
- idCustomNotification = idCustomNotification.concat('-slideIn-left');
1426
- }
1427
-
1428
- dataNotification.animation.close.effects = "slideOut";
1429
- break;
1430
-
1431
- case "zoom":
1432
- dataNotification.animation.open.effects = "zoomIn";
1433
- dataNotification.animation.close.effects = "zoomOut";
1434
- idCustomNotification = idCustomNotification.concat('-zoom');
1435
- break;
1436
-
1437
- default:
1438
- dataNotification.animation.open.effects = "fadeIn";
1439
- dataNotification.animation.close.effects = "fadeOut";
1440
- idCustomNotification = idCustomNotification.concat('-fade');
1441
- }
1442
- }
1443
-
1444
- function setAutoHide(autoHide){
1445
- if(autoHide == "false"){
1446
- dataNotification.autoHideAfter = 0;
1447
- idCustomNotification = idCustomNotification.concat('-autoHideAfter');
1448
- }
1449
- }
1450
-
1451
- async function initializeNotification(id, options) {
1452
- if (!hasHTMLElement(id)) {
1453
- let idNotification = $(`<span id="${id}"></span>`);
1454
- $('body').append(idNotification);
1455
-
1456
- await $(`#${id}`).kendoNotification(options);
1457
-
1458
- if(horizontalPosition == "center"){
1459
- centerElementScreen(e)
1460
- }
1461
- }
1462
- }
1463
-
1464
- function isNotificationInitialized(id) {
1465
- return $(`#${id}`).getKendoNotification();
1466
- }
1467
-
1468
- function showNotification(id, message, status) {
1469
- $(`#${id}`).getKendoNotification().show(message, status);
1470
- }
1471
-
1472
- function hasHTMLElement(id) {
1473
- return document.getElementById(id);
1474
- }
1475
-
1476
- };
1477
-
1478
1282
  /**
1479
1283
  * @type function
1480
1284
  * @name {{datasourceFromScreenName}}
@@ -1678,6 +1482,7 @@ if (!window.fixedTimeZone) {
1678
1482
  };
1679
1483
 
1680
1484
  /**
1485
+ * @deprecated true
1681
1486
  * @type function
1682
1487
  * @name {{datasourceFilterName}}
1683
1488
  * @nameTags filter|datasource
@@ -1695,6 +1500,51 @@ if (!window.fixedTimeZone) {
1695
1500
  }
1696
1501
  };
1697
1502
 
1503
+ /**
1504
+ * @type function
1505
+ * @name {{datasourceFilterName1}}
1506
+ * @nameTags filter|datasource
1507
+ * @description {{datasourceFilterDescription}}
1508
+ * @param {ObjectType.STRING} datasource {{datasourceFilterParam0}}
1509
+ * @param {ObjectType.STRING} condition {{datasourceFilterParam6}}
1510
+ * @param {ObjectType.LIST} filter {{datasourceFilterParam5}}
1511
+ * @multilayer true
1512
+ */
1513
+ 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) {
1514
+
1515
+ let path = filter;
1516
+
1517
+ if(filter instanceof Array){
1518
+ path = filter.join(' ' + condition + ' ');
1519
+ }
1520
+
1521
+ if(getDatasource(datasource).isOData()){
1522
+ getDatasource(datasource).search(path);
1523
+ }
1524
+ else{
1525
+ getDatasource(datasource).filter('/' + path);
1526
+ }
1527
+ };
1528
+
1529
+ /**
1530
+ * @type function
1531
+ * @name {{datasourceFilterName2}}
1532
+ * @nameTags filter|datasource
1533
+ * @description {{datasourceFilterDescription}}
1534
+ * @param {ObjectType.STRING} field {{datasourceFilterParam2}}
1535
+ * @param {ObjectType.STRING} filterType {{datasourceFilterParam3}}
1536
+ * @param {ObjectType.STRING} filterValue {{datasourceFilterParam4}}
1537
+ * @returns {ObjectType.LIST}
1538
+ * @multilayer true
1539
+ */
1540
+ 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) {
1541
+ if(filterType === "substringof"){
1542
+ return "substringof('" + filterValue + "', tolower(" + field + "))";
1543
+ }
1544
+
1545
+ return field + " " + filterType + " " + objToOData(filterValue) + "";
1546
+ };
1547
+
1698
1548
  /**
1699
1549
  * @type function
1700
1550
  * @name {{changeView}}
@@ -1837,13 +1687,6 @@ if (!window.fixedTimeZone) {
1837
1687
  return null;
1838
1688
  };
1839
1689
 
1840
- /**
1841
- * @category {{notificationCategory}}
1842
- * @categoryTags notification | notification
1843
- */
1844
- this.cronapi.notification = {};
1845
-
1846
-
1847
1690
  /**
1848
1691
  * @deprecated true
1849
1692
  * @type function
@@ -1858,170 +1701,46 @@ if (!window.fixedTimeZone) {
1858
1701
  var value = confirm(msg);
1859
1702
  return value;
1860
1703
  };
1704
+
1705
+ /**
1706
+ * @type function
1707
+ * @name {{createDefaultModalName}}
1708
+ * @nameTags createModal|Criar Modal| Modal
1709
+ * @description {{createDefaultModalDescription}}
1710
+ * @param {ObjectType.STRING} title {{createDefaultModalParam1}}
1711
+ * @param {ObjectType.STRING} msg {{createDefaultModalParam2}}
1712
+ * @param {ObjectType.STRING} buttonCancelName {{createDefaultModalParam3}}
1713
+ * @param {ObjectType.STRING} buttonSaveName {{createDefaultModalParam4}}
1714
+ *
1715
+ */
1716
+ this.cronapi.screen.createDefaultModal = function(title, msg, buttonCancelName, buttonSaveName, /** @type {ObjectType.STATEMENT} @description {{createDefaultModalParam5}} */ onSuccess, /** @type {ObjectType.STATEMENT} @description {{createDefaultModalParam6}}*/ onError,/** @type {ObjectType.STATEMENT} @description {{createDefaultModalParam7}}*/ onClose ) {
1717
+ $('#modalTemplateTitle').text(title);
1718
+ $('#modalTemplateBody').text(msg);
1719
+ $('#modalTemplateCancel').text(buttonCancelName);
1720
+ $('#modalTemplateSave').text(buttonSaveName);
1721
+ $( "#modalTemplateClose").unbind( "click" );
1722
+ $('#modalTemplateClose').click(onClose);
1723
+ $( "#modalTemplateCancel").unbind( "click" );
1724
+ $('#modalTemplateCancel').click(onError);
1725
+ $( "#modalTemplateSave").unbind( "click" );
1726
+ $('#modalTemplateSave').click(onSuccess);
1727
+ this.cronapi.screen.showModal('modalTemplate');
1728
+
1729
+ };
1861
1730
 
1862
1731
  /**
1863
1732
  * @type function
1864
- * @name {{confirmDialogAlertName}}
1865
- * @nameTags confirmDialog | Confirmar | alert | modal | alerta
1866
- * @description {{confirmDialogAlertDescription}}
1867
- * @param {ObjectType.STRING} icon {{icon}
1868
- * @param {ObjectType.STRING} title {{title}}
1869
- * @param {ObjectType.STRING} subtitle {{subtitle}}
1870
- * @param {ObjectType.OBJECT} buttonConfirmDialogAlert {{confimDialogAlert.listButton}}
1733
+ * @name {{showModal}}
1734
+ * @nameTags Show| Modal| Exibir| Mostrar
1871
1735
  * @platform W
1736
+ * @description {{showModalDesc}}
1737
+ * @param {ObjectType.STRING} component {{ComponentParam}}
1872
1738
  * @multilayer true
1873
1739
  */
1874
- 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) {
1875
-
1876
- let idDialog = 'cronapp-dialog-' + Math.random();
1877
- let dialog = $(`<span id="${idDialog}"></span>`);
1878
- $('body').append(dialog);
1879
-
1880
- let dataDialog = {
1881
- width: "450px",
1882
- title: false,
1883
- closable: false,
1884
- modal: true,
1885
- content: "",
1886
- animation: {
1887
- open: {
1888
- effects: "zoom:in"
1889
- },
1890
- close: {
1891
- effects: "zoom:out"
1892
- }
1893
- },
1894
- buttonLayout: "normal",
1895
- actions: [],
1896
- close: function(e) {
1897
- setInterval(() => {
1898
- $(`#${idDialog}`).data("kendoDialog").destroy();
1899
- }, 3000);
1900
- }
1901
- };
1902
-
1903
- setIcon(icon, title, subtitle);
1904
- setButton(buttonConfirmDialogAlert);
1905
-
1906
- dialog.kendoDialog(dataDialog);
1907
- dialog.data("kendoDialog").open();
1908
-
1909
- async function setIcon(icon, title, subtitle){
1910
- switch (icon){
1911
- case "error":
1912
- 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>';
1913
- break;
1914
-
1915
- case "success":
1916
- 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>';
1917
- break;
1918
-
1919
- case "warning":
1920
- icon = '<div class="cronapp-icon cronapp-warning"><div class="cronapp-icon-content">!</div></div>';
1921
- break;
1922
-
1923
- case "info":
1924
- icon = '<div class="cronapp-icon cronapp-info"><div class="cronapp-icon-content">i</div></div>';
1925
- break;
1926
- }
1927
- await setContent(icon, title, subtitle);
1928
-
1929
- }
1930
-
1931
- function setContent(icon, title, subtitle){
1932
- dataDialog.content = '<div id="modalBodyConfirmDialog"> <div class="icon">'+ icon +'</div> <h2 class="title">'+ title +'</h2> <h3 class="subtitle">'+ subtitle +'</h3> </div>';
1933
- }
1934
-
1935
- function setButton(buttonConfirmDialogAlert){
1936
- let buttons = (Array.isArray(buttonConfirmDialogAlert) ? buttonConfirmDialogAlert : [buttonConfirmDialogAlert]);
1937
-
1938
- let hasButton = false;
1939
-
1940
- for (let i = 0; i < buttons.length; i++) {
1941
- let button = buttons[i];
1942
- if(button){
1943
- dataDialog.actions.push({
1944
- text: button.title,
1945
- action: button.value,
1946
- primary: button.primaryValue == 'true' ? true : null
1947
- });
1948
-
1949
- hasButton = true;
1950
-
1951
- }
1952
- };
1953
-
1954
- // If you have not added a button to the modal. Add to be able to close the modal.
1955
- if(!hasButton){
1956
- dataDialog.actions.push({
1957
- text: "OK",
1958
- primary: true
1959
- });
1960
- };
1961
-
1962
- }
1963
-
1964
- };
1965
-
1966
- /**
1967
- * @type function
1968
- * @name {{buttonConfirmDialogAlert}}
1969
- * @nameTags confirmDialog | botão | button | alert | modal | alerta
1970
- * @description {{buttonConfirmDialogAlertDescription}}
1971
- * @platform W
1972
- * @param {ObjectType.BOOLEAN} primaryButton {{buttonConfirmDialogAlert.primaryButton}}
1973
- * @param {ObjectType.STRING} title {{title}}
1974
- * @param {ObjectType.STRING} value {{buttonConfirmDialogAlert.value}}
1975
- * @returns {ObjectType.OBJECT}
1976
- */
1977
- 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) {
1978
- return {
1979
- title: title,
1980
- value: value,
1981
- primaryValue: primaryButton
1982
- };
1983
- };
1984
-
1985
-
1986
- /**
1987
- * @type function
1988
- * @name {{createDefaultModalName}}
1989
- * @nameTags createModal|Criar Modal| Modal
1990
- * @description {{createDefaultModalDescription}}
1991
- * @param {ObjectType.STRING} title {{createDefaultModalParam1}}
1992
- * @param {ObjectType.STRING} msg {{createDefaultModalParam2}}
1993
- * @param {ObjectType.STRING} buttonCancelName {{createDefaultModalParam3}}
1994
- * @param {ObjectType.STRING} buttonSaveName {{createDefaultModalParam4}}
1995
- *
1996
- */
1997
- this.cronapi.screen.createDefaultModal = function(title, msg, buttonCancelName, buttonSaveName, /** @type {ObjectType.STATEMENT} @description {{createDefaultModalParam5}} */ onSuccess, /** @type {ObjectType.STATEMENT} @description {{createDefaultModalParam6}}*/ onError,/** @type {ObjectType.STATEMENT} @description {{createDefaultModalParam7}}*/ onClose ) {
1998
- $('#modalTemplateTitle').text(title);
1999
- $('#modalTemplateBody').text(msg);
2000
- $('#modalTemplateCancel').text(buttonCancelName);
2001
- $('#modalTemplateSave').text(buttonSaveName);
2002
- $( "#modalTemplateClose").unbind( "click" );
2003
- $('#modalTemplateClose').click(onClose);
2004
- $( "#modalTemplateCancel").unbind( "click" );
2005
- $('#modalTemplateCancel').click(onError);
2006
- $( "#modalTemplateSave").unbind( "click" );
2007
- $('#modalTemplateSave').click(onSuccess);
2008
- this.cronapi.screen.showModal('modalTemplate');
2009
-
2010
- };
2011
-
2012
- /**
2013
- * @type function
2014
- * @name {{showModal}}
2015
- * @nameTags Show| Modal| Exibir| Mostrar
2016
- * @platform W
2017
- * @description {{showModalDesc}}
2018
- * @param {ObjectType.STRING} component {{ComponentParam}}
2019
- * @multilayer true
2020
- */
2021
- this.cronapi.screen.showModal = function(/** @type {ObjectType.OBJECT} @blockType ids_from_screen*/ id) {
2022
- let modalToShow = `#${id}`;
2023
- let focused = $(':focus');
2024
- let allHover = $(':hover');
1740
+ this.cronapi.screen.showModal = function(/** @type {ObjectType.OBJECT} @blockType ids_from_screen*/ id) {
1741
+ let modalToShow = `#${id}`;
1742
+ let focused = $(':focus');
1743
+ let allHover = $(':hover');
2025
1744
 
2026
1745
  try{
2027
1746
  $(modalToShow).one('shown.bs.modal', function (e) {
@@ -3344,6 +3063,12 @@ if (!window.fixedTimeZone) {
3344
3063
 
3345
3064
  this.cronapi.internal = {};
3346
3065
 
3066
+ this.cronapi.internal.skipIterationLoop = function() {
3067
+ return new Promise((resolve) => {
3068
+ resolve();
3069
+ });
3070
+ };
3071
+
3347
3072
  this.cronapi.internal.coverElement = function($element) {
3348
3073
 
3349
3074
  let cover = (id, obj) => {
@@ -3377,7 +3102,9 @@ if (!window.fixedTimeZone) {
3377
3102
  if ($firstInput && $firstInput.length) {
3378
3103
  let waitBecomeVisible = setInterval(()=> {
3379
3104
  if ($firstInput.is(':visible')) {
3380
- $firstInput.focus();
3105
+ if ($firstInput.data('role') !== 'dropdownlist') {
3106
+ $firstInput.focus();
3107
+ }
3381
3108
  clearInterval(waitBecomeVisible);
3382
3109
  }
3383
3110
  }, 100);
@@ -4651,8 +4378,13 @@ if (!window.fixedTimeZone) {
4651
4378
  let options = { destinationType: Number(destinationType) , sourceType : Number(pictureSourceType) , mediaType: Number(mediaType) , allowEdit: allowEdit};
4652
4379
  if(window.cordova && window.cordova.platformId && window.cordova.platformId !== 'browser') {
4653
4380
 
4654
- let resultWithData = (data) => {
4655
- if (data && !data.startsWith("data:image")) data = "data:image/jpeg;base64, " + data;
4381
+ let resultWithData = async (data) => {
4382
+ if (data.startsWith("file://")) {
4383
+ data = Ionic.WebView.convertFileSrc(data);
4384
+ }
4385
+ else if (data && !data.startsWith("data:image")) {
4386
+ data = "data:image/jpeg;base64, " + data;
4387
+ }
4656
4388
  !success || success(data);
4657
4389
  };
4658
4390
  navigator.camera.getPicture(this.cronapi.util.handleCallback(resultWithData), this.cronapi.util.handleCallback(error), options);
@@ -5454,6 +5186,7 @@ if (!window.fixedTimeZone) {
5454
5186
  */
5455
5187
  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) {
5456
5188
 
5189
+ var colors = options && options.colors ? options.colors : [];
5457
5190
  var CSS_COLOR_NAMES = ["#FF5C00","#0E53A7","#48DD00","#FFD500","#7309AA","#CD0074","#00AF64","#BF8230","#F16D95","#A65000","#A65000","#AF66D5"];
5458
5191
  var colorIndex = 0;
5459
5192
 
@@ -5558,7 +5291,7 @@ if (!window.fixedTimeZone) {
5558
5291
  //Applying configs in Datasets
5559
5292
  $.each(json.data.datasets, function(index,value){
5560
5293
  value.fill = false;
5561
- value.backgroundColor = CSS_COLOR_NAMES[nextColor()];
5294
+ value.backgroundColor = colors[index] ? colors[index] : CSS_COLOR_NAMES[nextColor()];
5562
5295
  value.borderColor = value.backgroundColor;
5563
5296
  beginAtZero();
5564
5297
  displayLegend();
@@ -5571,7 +5304,11 @@ if (!window.fixedTimeZone) {
5571
5304
  json.data.datasets = getDataset(arguments);
5572
5305
  //Applying configs in Datasets
5573
5306
  $.each(json.data.datasets, function(index,value){
5574
- value.backgroundColor = CSS_COLOR_NAMES[nextColor()];
5307
+ if(json.data.datasets.length === 1 && colors.length > 1){
5308
+ value.backgroundColor = colors;
5309
+ }else{
5310
+ value.backgroundColor = colors[index] ? colors[index] : CSS_COLOR_NAMES[nextColor()];
5311
+ }
5575
5312
  value.borderColor = value.backgroundColor;
5576
5313
  });
5577
5314
  beginAtZero();
@@ -5589,8 +5326,7 @@ if (!window.fixedTimeZone) {
5589
5326
  dtset.backgroundColor = [];
5590
5327
  dtset.borderColor = [];
5591
5328
  $.each(dtset.data, function(indexx,valuee){
5592
- dtset.backgroundColor.push( CSS_COLOR_NAMES[nextColor()] );
5593
-
5329
+ dtset.backgroundColor.push( colors[indexx] ? colors[indexx] : CSS_COLOR_NAMES[nextColor()] );
5594
5330
  });
5595
5331
  dtset.borderColor = dtset.backgroundColor;
5596
5332
  json.data.datasets.push(dtset);
@@ -5624,165 +5360,482 @@ if (!window.fixedTimeZone) {
5624
5360
 
5625
5361
 
5626
5362
 
5627
- /**
5628
- * @category CategoryType.SOCIAL
5629
- * @categoryTags login|social|network|facebook|github|google|linkedin
5630
- */
5631
- this.cronapi.social = {};
5363
+ /**
5364
+ * @category {{CategoryType.SOCIAL}}
5365
+ * @categoryTags login|social|network|facebook|github|google|linkedin
5366
+ */
5367
+ this.cronapi.social = {};
5368
+
5369
+
5370
+ this.cronapi.social.gup = function(name,url){
5371
+ if (!url) url = location.href;
5372
+ name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
5373
+ var regexS = "[\\?&]"+name+"=([^&#]*)";
5374
+ var regex = new RegExp( regexS );
5375
+ var results = regex.exec( url );
5376
+ return results == null ? null : results[1];
5377
+ }
5378
+
5379
+ this.cronapi.social.login = function(login,password,options){
5380
+ var item;
5381
+ this.cronapi.screen.showLoading();
5382
+ if (!this.cronapi.logic.isNullOrEmpty(this.cronapi.screen.getHostapp())) {
5383
+ this.cronapi.util.getURLFromOthers('POST', 'application/x-www-form-urlencoded', String(this.cronapi.screen.getHostapp()) + String('auth'), this.cronapi.object.createObjectFromString(['{ \"username\": \"',login,'\" , \"password\": \"',password,'\" } '].join('')), this.cronapi.object.createObjectFromString(['{ \"X-AUTH-TOKEN\": \"',options,'\" } '].join('')), function(sender_item) {
5384
+ item = sender_item;
5385
+ this.cronapi.screen.hide();
5386
+ this.cronapi.util.setLocalStorage('_u', this.cronapi.object.serializeObject(item));
5387
+ this.cronapi.screen.changeView("#/app/logged/home",[ ]);
5388
+ }.bind(this), function(sender_item) {
5389
+ item = sender_item;
5390
+ if (this.cronapi.object.getProperty(item, 'status') == '403' || this.cronapi.object.getProperty(item, 'status') == '401') {
5391
+ this.cronapi.screen.notify('error',this.cronapi.i18n.translate("LoginViewInvalidpassword",[ ]));
5392
+ } else {
5393
+ this.cronapi.screen.notify('error',this.cronapi.object.getProperty(item, 'responseJSON.message'));
5394
+ }
5395
+ this.cronapi.screen.hide();
5396
+ }.bind(this));
5397
+ } else {
5398
+ this.cronapi.screen.hide();
5399
+ this.cronapi.screen.notify('error','HostApp is Required');
5400
+ }
5401
+ }
5402
+
5403
+ /**
5404
+ * @type function
5405
+ * @name {{socialLogin}}
5406
+ * @nameTags login|social|network|facebook|github|google|linkedin
5407
+ * @description {{socialLoginDescription}}
5408
+ * @param {ObjectType.STRING} socialNetwork {{socialNetwork}}
5409
+ * @param {ObjectType.BOOLEAN} clearCacheBeforeOpen {{clearCacheBeforeOpen}}
5410
+ * @returns {ObjectType.VOID}
5411
+ */
5412
+ this.cronapi.social.sociaLogin = function(/** @type {ObjectType.STRING} @description socialNetwork @blockType util_dropdown @keys facebook|github|google|linkedin @values facebook|github|google|linkedin */ socialNetwork, /** @type {ObjectType.BOOLEAN} @blockType util_dropdown @keys false|true*/ clearCache) {
5413
+ var that = this;
5414
+ var u = window.hostApp+"signin/"+socialNetwork+"/";
5415
+ if(window.cordova && cordova.InAppBrowser){
5416
+ var clearCacheString = '';
5417
+ if(clearCache === true || clearCache === 'true'){
5418
+ clearCacheString = ',clearcache=yes';
5419
+ }
5420
+ var cref = cordova.InAppBrowser.open(u, '_blank', 'location=no' + clearCacheString);
5421
+ cref.addEventListener('loadstart', function(event) {
5422
+ if (event.url.indexOf("_ctk") > -1) {
5423
+ cref.close();
5424
+ that.cronapi.social.login.bind(that)('#OAUTH#', '#OAUTH#', that.cronapi.social.gup('_ctk',event.url));
5425
+ }
5426
+ });
5427
+ }else{
5428
+ window.location.href = "signin/"+socialNetwork+"/";
5429
+ }
5430
+ };
5431
+
5432
+ /**
5433
+ * @type function
5434
+ * @name {{ssoLogin}}
5435
+ * @nameTags login|social|oauth
5436
+ * @description {{ssoLoginDescription}}
5437
+ * @returns {ObjectType.VOID}
5438
+ */
5439
+ this.cronapi.social.ssoLogin = async function () {
5440
+ let scope = this.cronapi.$scope;
5441
+
5442
+ let future = new Promise((resolve, reject) => {
5443
+ if (window.cordova && cordova.InAppBrowser) {
5444
+ const ref = cordova.InAppBrowser.open(window.hostApp + 'login', '_blank', 'location=no,footer=yes,zoom=no,enableViewportScale=yes,hidenavigationbuttons=yes');
5445
+ const handlerChange = (event) => {
5446
+ const url = new URL(event.url);
5447
+ const urlParams = new URLSearchParams(url.search);
5448
+
5449
+ if (urlParams.has('_ctk')) {
5450
+
5451
+ ref.removeEventListener('loadstart', handlerChange);
5452
+ // close sso window
5453
+ ref.close();
5454
+
5455
+ // If the page is reloaded the blockly sequence is interrupted
5456
+ scope.login("#OAUTH#", "#OAUTH#", urlParams.get('_ctk'));
5457
+ resolve();
5458
+
5459
+ } else {
5460
+ reject();
5461
+ }
5462
+ };
5463
+
5464
+ ref.addEventListener('loadstart', handlerChange);
5465
+
5466
+ } else {
5467
+ window.ssoWindow = window.open(this.cronapi.internal.getAddressWithHostApp("login"));
5468
+
5469
+ window.addEventListener('message', function (e) {
5470
+ if (e.data && e.data.type === 'sso_user') {
5471
+
5472
+ // close sso window
5473
+ if (window.ssoWindow) {
5474
+ window.ssoWindow.close();
5475
+ }
5476
+
5477
+ // If the page is reloaded the blockly sequence is interrupted
5478
+ scope.login("#OAUTH#", "#OAUTH#", e.data._ctk);
5479
+ resolve();
5480
+
5481
+ }
5482
+ }, false);
5483
+ }
5484
+ });
5485
+
5486
+ return future;
5487
+ };
5488
+
5489
+ /**
5490
+ * @type function
5491
+ * @name {{getSelectedRowsGrid}}
5492
+ * @nameTags getSelectedRowsGrid|Obter linhas selecionadas da grade
5493
+ * @description {{functionToGetSelectedRowsGrid}}
5494
+ * @param {ObjectType.STRING} field {{field}}
5495
+ * @returns {ObjectType.OBJECT}
5496
+ */
5497
+ this.cronapi.screen.getSelectedRowsGrid = function(/** @type {ObjectType.STRING} @blockType field_from_screen*/ field) {
5498
+ var result = [];
5499
+ var grid = $('[ng-model="'+ field +'"]').children().data('kendoGrid');
5500
+ if (grid) {
5501
+ var selected = grid.select();
5502
+ selected.each(function() {
5503
+ var dataItem = grid.dataItem(this);
5504
+ result.push(dataItem);
5505
+ });
5506
+ }
5507
+ return result;
5508
+ };
5509
+
5510
+ /**
5511
+ * @type function
5512
+ * @name {{back}}
5513
+ * @nameTags back|voltar|retroceder|history
5514
+ * @description {{backDescription}}
5515
+ */
5516
+ this.cronapi.screen.back = function() {
5517
+ history.back();
5518
+ };
5519
+
5520
+ /**
5521
+ * @category {{notificationCategory}}
5522
+ * @categoryTags notification | notification
5523
+ */
5524
+ this.cronapi.notification = {};
5525
+
5526
+ /**
5527
+ * @type function
5528
+ * @name {{confirmDialogAlertName}}
5529
+ * @nameTags confirmDialog | Confirmar | alert | modal | alerta
5530
+ * @description {{confirmDialogAlertDescription}}
5531
+ * @param {ObjectType.STRING} icon {{icon}
5532
+ * @param {ObjectType.STRING} title {{title}}
5533
+ * @param {ObjectType.STRING} subtitle {{subtitle}}
5534
+ * @param {ObjectType.OBJECT} buttonConfirmDialogAlert {{confimDialogAlert.listButton}}
5535
+ * @platform W
5536
+ * @multilayer true
5537
+ */
5538
+ 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) {
5539
+
5540
+ let idDialog = 'cronapp-dialog-' + Math.random();
5541
+ let dialog = $(`<span id="${idDialog}"></span>`);
5542
+ $('body').append(dialog);
5543
+
5544
+ let dataDialog = {
5545
+ width: "450px",
5546
+ title: false,
5547
+ closable: false,
5548
+ modal: true,
5549
+ content: "",
5550
+ animation: {
5551
+ open: {
5552
+ effects: "zoom:in"
5553
+ },
5554
+ close: {
5555
+ effects: "zoom:out"
5556
+ }
5557
+ },
5558
+ buttonLayout: "normal",
5559
+ actions: [],
5560
+ close: function(e) {
5561
+ setInterval(() => {
5562
+ $(`#${idDialog}`).data("kendoDialog").destroy();
5563
+ }, 3000);
5564
+ }
5565
+ };
5566
+
5567
+ setIcon(icon, title, subtitle);
5568
+ setButton(buttonConfirmDialogAlert);
5569
+
5570
+ dialog.kendoDialog(dataDialog);
5571
+ dialog.data("kendoDialog").open();
5572
+
5573
+ async function setIcon(icon, title, subtitle){
5574
+ switch (icon){
5575
+ case "error":
5576
+ 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>';
5577
+ break;
5578
+
5579
+ case "success":
5580
+ 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>';
5581
+ break;
5582
+
5583
+ case "warning":
5584
+ icon = '<div class="cronapp-icon cronapp-warning"><div class="cronapp-icon-content">!</div></div>';
5585
+ break;
5586
+
5587
+ case "info":
5588
+ icon = '<div class="cronapp-icon cronapp-info"><div class="cronapp-icon-content">i</div></div>';
5589
+ break;
5590
+ }
5591
+ await setContent(icon, title, subtitle);
5592
+ }
5593
+
5594
+ function setContent(icon, title, subtitle){
5595
+ dataDialog.content = '<div id="modalBodyConfirmDialog"> <div class="icon">'+ icon +'</div> <h2 class="title">'+ title +'</h2> <h3 class="subtitle">'+ subtitle +'</h3> </div>';
5596
+ }
5597
+
5598
+ function setButton(buttonConfirmDialogAlert){
5599
+ let buttons = (Array.isArray(buttonConfirmDialogAlert) ? buttonConfirmDialogAlert : [buttonConfirmDialogAlert]);
5600
+
5601
+ let hasButton = false;
5602
+
5603
+ for (let i = 0; i < buttons.length; i++) {
5604
+ let button = buttons[i];
5605
+ if(button){
5606
+ dataDialog.actions.push({
5607
+ text: button.title,
5608
+ action: button.value,
5609
+ primary: button.primaryValue == 'true' ? true : null
5610
+ });
5611
+
5612
+ hasButton = true;
5613
+
5614
+ }
5615
+ };
5616
+
5617
+ // If you have not added a button to the modal. Add to be able to close the modal.
5618
+ if(!hasButton){
5619
+ dataDialog.actions.push({
5620
+ text: "OK",
5621
+ primary: true
5622
+ });
5623
+ };
5624
+
5625
+ }
5626
+
5627
+ };
5628
+
5629
+ /**
5630
+ * @type function
5631
+ * @name {{buttonConfirmDialogAlert}}
5632
+ * @nameTags confirmDialog | botão | button | alert | modal | alerta
5633
+ * @description {{buttonConfirmDialogAlertDescription}}
5634
+ * @platform W
5635
+ * @param {ObjectType.BOOLEAN} primaryButton {{buttonConfirmDialogAlert.primaryButton}}
5636
+ * @param {ObjectType.STRING} title {{title}}
5637
+ * @param {ObjectType.STRING} value {{buttonConfirmDialogAlert.value}}
5638
+ * @returns {ObjectType.OBJECT}
5639
+ */
5640
+ 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) {
5641
+ return {
5642
+ title: title,
5643
+ value: value,
5644
+ primaryValue: primaryButton
5645
+ };
5646
+ };
5647
+
5648
+ /**
5649
+ * @type function
5650
+ * @name {{screenNotifySimpleName}}
5651
+ * @description {{screenNotifySimpleDescription}}
5652
+ * @nameTags show | exibir | exibe | notification | notificação
5653
+ * @param {ObjectType.STRING} status {{screenNotifySimpleParam0}}
5654
+ * @param {ObjectType.STRING} message {{screenNotifySimpleParam1}}
5655
+ * @param {ObjectType.STRING} animation {{screenNotifySimpleParam2}}
5656
+ * @param {ObjectType.STRING} verticalPosition {{screenNotifySimpleParam3}}
5657
+ * @param {ObjectType.STRING} horizontalPosition {{screenNotifySimpleParam4}}
5658
+ * @param {ObjectType.STRING} autoHide {{screenNotifySimpleParam5}}
5659
+ */
5660
+ 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) {
5661
+
5662
+ let idCustomNotification = "customNotification" ;
5663
+
5664
+ let dataNotification = {
5665
+ stacking: "default",
5666
+ autoHideAfter: 5000,
5667
+ position: {
5668
+ pinned: true
5669
+ },
5670
+ animation: {
5671
+ open: {
5672
+ effects: null
5673
+ },
5674
+ close: {
5675
+ effects: null
5676
+ }
5677
+ }
5678
+ };
5679
+
5680
+ if (animation || verticalPosition || horizontalPosition || autoHide) {
5681
+ customNotification(message, status, animation, verticalPosition, horizontalPosition, autoHide);
5682
+ } else {
5683
+ defaultNotification(message, status);
5684
+ }
5685
+
5686
+ async function defaultNotification(message, status) {
5687
+
5688
+ let cronappConfig = {
5689
+ id: "CronappNotification",
5690
+ verticalPosition: "top",
5691
+ horizontalPosition: "left",
5692
+ animation: "slide",
5693
+ autoHide: "false"
5694
+ };
5695
+
5696
+ setVerticalPosition(cronappConfig.verticalPosition);
5697
+ setHorizontalPosition(cronappConfig.horizontalPosition);
5698
+ setAnimation(cronappConfig.animation);
5699
+ setAutoHide(cronappConfig.autoHide);
5700
+
5701
+ if (!isNotificationInitialized(cronappConfig.id)) {
5702
+ initializeNotification(cronappConfig.id, dataNotification);
5703
+ }
5704
+
5705
+ showNotification(cronappConfig.id, message, status);
5706
+
5707
+ }
5708
+
5709
+ async function customNotification(message, status, animation, verticalPosition, horizontalPosition, autoHide) {
5632
5710
 
5711
+ setVerticalPosition(verticalPosition);
5712
+ setHorizontalPosition(horizontalPosition);
5713
+ setAnimation(animation);
5714
+ setAutoHide(autoHide);
5633
5715
 
5634
- this.cronapi.social.gup = function(name,url){
5635
- if (!url) url = location.href;
5636
- name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
5637
- var regexS = "[\\?&]"+name+"=([^&#]*)";
5638
- var regex = new RegExp( regexS );
5639
- var results = regex.exec( url );
5640
- return results == null ? null : results[1];
5641
- }
5716
+ initializeNotification(idCustomNotification, dataNotification);
5717
+ showNotification(idCustomNotification, message, status);
5642
5718
 
5643
- this.cronapi.social.login = function(login,password,options){
5644
- var item;
5645
- this.cronapi.screen.showLoading();
5646
- if (!this.cronapi.logic.isNullOrEmpty(this.cronapi.screen.getHostapp())) {
5647
- this.cronapi.util.getURLFromOthers('POST', 'application/x-www-form-urlencoded', String(this.cronapi.screen.getHostapp()) + String('auth'), this.cronapi.object.createObjectFromString(['{ \"username\": \"',login,'\" , \"password\": \"',password,'\" } '].join('')), this.cronapi.object.createObjectFromString(['{ \"X-AUTH-TOKEN\": \"',options,'\" } '].join('')), function(sender_item) {
5648
- item = sender_item;
5649
- this.cronapi.screen.hide();
5650
- this.cronapi.util.setLocalStorage('_u', this.cronapi.object.serializeObject(item));
5651
- this.cronapi.screen.changeView("#/app/logged/home",[ ]);
5652
- }.bind(this), function(sender_item) {
5653
- item = sender_item;
5654
- if (this.cronapi.object.getProperty(item, 'status') == '403' || this.cronapi.object.getProperty(item, 'status') == '401') {
5655
- this.cronapi.screen.notify('error',this.cronapi.i18n.translate("LoginViewInvalidpassword",[ ]));
5656
- } else {
5657
- this.cronapi.screen.notify('error',this.cronapi.object.getProperty(item, 'responseJSON.message'));
5658
- }
5659
- this.cronapi.screen.hide();
5660
- }.bind(this));
5661
- } else {
5662
- this.cronapi.screen.hide();
5663
- this.cronapi.screen.notify('error','HostApp is Required');
5664
5719
  }
5665
- }
5666
5720
 
5667
- /**
5668
- * @type function
5669
- * @name {{socialLogin}}
5670
- * @nameTags login|social|network|facebook|github|google|linkedin
5671
- * @description {{socialLoginDescription}}
5672
- * @param {ObjectType.STRING} socialNetwork {{socialNetwork}}
5673
- * @param {ObjectType.BOOLEAN} clearCacheBeforeOpen {{clearCacheBeforeOpen}}
5674
- * @returns {ObjectType.VOID}
5675
- */
5676
- this.cronapi.social.sociaLogin = function(/** @type {ObjectType.STRING} @description socialNetwork @blockType util_dropdown @keys facebook|github|google|linkedin @values facebook|github|google|linkedin */ socialNetwork, /** @type {ObjectType.BOOLEAN} @blockType util_dropdown @keys false|true*/ clearCache) {
5677
- var that = this;
5678
- var u = window.hostApp+"signin/"+socialNetwork+"/";
5679
- if(window.cordova && cordova.InAppBrowser){
5680
- var clearCacheString = '';
5681
- if(clearCache === true || clearCache === 'true'){
5682
- clearCacheString = ',clearcache=yes';
5721
+ function setVerticalPosition(verticalPosition){
5722
+ switch (verticalPosition) {
5723
+ case "bottom":
5724
+ dataNotification.position.bottom = 20;
5725
+ idCustomNotification = idCustomNotification.concat('-bottom');
5726
+ break;
5727
+
5728
+ default:
5729
+ dataNotification.position.top = 60;
5730
+ idCustomNotification = idCustomNotification.concat('-top');
5731
+
5683
5732
  }
5684
- var cref = cordova.InAppBrowser.open(u, '_blank', 'location=no' + clearCacheString);
5685
- cref.addEventListener('loadstart', function(event) {
5686
- if (event.url.indexOf("_ctk") > -1) {
5687
- cref.close();
5688
- that.cronapi.social.login.bind(that)('#OAUTH#', '#OAUTH#', that.cronapi.social.gup('_ctk',event.url));
5689
- }
5690
- });
5691
- }else{
5692
- window.location.href = "signin/"+socialNetwork+"/";
5693
5733
  }
5694
- };
5695
5734
 
5696
- /**
5697
- * @type function
5698
- * @name {{ssoLogin}}
5699
- * @nameTags login|social|oauth
5700
- * @description {{ssoLoginDescription}}
5701
- * @returns {ObjectType.VOID}
5702
- */
5703
- this.cronapi.social.ssoLogin = async function () {
5704
- let scope = this.cronapi.$scope;
5735
+ function setHorizontalPosition(horizontalPosition){
5736
+ switch (horizontalPosition) {
5737
+ case "right":
5738
+ dataNotification.position.right = 20;
5739
+ idCustomNotification = idCustomNotification.concat('-right');
5740
+ break;
5705
5741
 
5706
- let future = new Promise((resolve, reject) => {
5707
- if (window.cordova && cordova.InAppBrowser) {
5708
- const ref = cordova.InAppBrowser.open(window.hostApp + 'login', '_blank', 'location=no,footer=yes,zoom=no,enableViewportScale=yes,hidenavigationbuttons=yes');
5709
- const handlerChange = (event) => {
5710
- const url = new URL(event.url);
5711
- const urlParams = new URLSearchParams(url.search);
5742
+ case "center":
5743
+ dataNotification.show = centerElementScreen;
5744
+ idCustomNotification = idCustomNotification.concat('-center');
5745
+ break;
5712
5746
 
5713
- if (urlParams.has('_ctk')) {
5747
+ default:
5748
+ dataNotification.position.left = 20;
5749
+ idCustomNotification = idCustomNotification.concat('-left');
5714
5750
 
5715
- ref.removeEventListener('loadstart', handlerChange);
5716
- // close sso window
5717
- ref.close();
5751
+ }
5752
+ }
5718
5753
 
5719
- // If the page is reloaded the blockly sequence is interrupted
5720
- scope.login("#OAUTH#", "#OAUTH#", urlParams.get('_ctk'));
5721
- resolve();
5754
+ function centerElementScreen(e){
5755
+ if (e.sender.getNotifications().length == 1) {
5756
+ var element = e.element.parent(),
5757
+ eWidth = element.width(),
5758
+ wWidth = $(window).width()
5759
+ var newLeft;
5722
5760
 
5723
- } else {
5724
- reject();
5761
+ newLeft = Math.floor(wWidth / 2 - eWidth / 2);
5762
+
5763
+ e.element.parent().css({ left: newLeft });
5764
+ }
5765
+ }
5766
+
5767
+ function setAnimation(animation){
5768
+ switch (animation) {
5769
+ case "slide":
5770
+ if (dataNotification.show && dataNotification.position.bottom != null) {
5771
+ dataNotification.animation.open.effects = "slideIn:up";
5772
+ idCustomNotification = idCustomNotification.concat('-slideIn-up');
5773
+
5774
+ } else if (dataNotification.show && dataNotification.position.top != null) {
5775
+ dataNotification.animation.open.effects = "slideIn:down";
5776
+ idCustomNotification = idCustomNotification.concat('-slideIn-dow');
5777
+
5778
+ } else if (dataNotification.position.left != null) {
5779
+ dataNotification.animation.open.effects = "slideIn:right";
5780
+ idCustomNotification = idCustomNotification.concat('-slideIn-right');
5781
+
5782
+ } else if (dataNotification.position.left == null) {
5783
+ dataNotification.animation.open.effects = "slideIn:left";
5784
+ idCustomNotification = idCustomNotification.concat('-slideIn-left');
5725
5785
  }
5726
- };
5727
5786
 
5728
- ref.addEventListener('loadstart', handlerChange);
5787
+ dataNotification.animation.close.effects = "slideOut";
5788
+ break;
5729
5789
 
5730
- } else {
5731
- window.ssoWindow = window.open(this.cronapi.internal.getAddressWithHostApp("login"));
5790
+ case "zoom":
5791
+ dataNotification.animation.open.effects = "zoomIn";
5792
+ dataNotification.animation.close.effects = "zoomOut";
5793
+ idCustomNotification = idCustomNotification.concat('-zoom');
5794
+ break;
5732
5795
 
5733
- window.addEventListener('message', function (e) {
5734
- if (e.data && e.data.type === 'sso_user') {
5796
+ default:
5797
+ dataNotification.animation.open.effects = "fadeIn";
5798
+ dataNotification.animation.close.effects = "fadeOut";
5799
+ idCustomNotification = idCustomNotification.concat('-fade');
5800
+ }
5801
+ }
5735
5802
 
5736
- // close sso window
5737
- if (window.ssoWindow) {
5738
- window.ssoWindow.close();
5739
- }
5803
+ function setAutoHide(autoHide){
5804
+ if(autoHide == "false"){
5805
+ dataNotification.autoHideAfter = 0;
5806
+ idCustomNotification = idCustomNotification.concat('-autoHideAfter');
5807
+ }
5808
+ }
5740
5809
 
5741
- // If the page is reloaded the blockly sequence is interrupted
5742
- scope.login("#OAUTH#", "#OAUTH#", e.data._ctk);
5743
- resolve();
5810
+ async function initializeNotification(id, options) {
5811
+ if (!hasHTMLElement(id)) {
5812
+ let idNotification = $(`<span id="${id}"></span>`);
5813
+ $('body').append(idNotification);
5744
5814
 
5745
- }
5746
- }, false);
5815
+ await $(`#${id}`).kendoNotification(options);
5816
+
5817
+ if(horizontalPosition == "center"){
5818
+ centerElementScreen(e)
5819
+ }
5747
5820
  }
5748
- });
5821
+ }
5749
5822
 
5750
- return future;
5751
- };
5823
+ function isNotificationInitialized(id) {
5824
+ return $(`#${id}`).getKendoNotification();
5825
+ }
5752
5826
 
5753
- /**
5754
- * @type function
5755
- * @name {{getSelectedRowsGrid}}
5756
- * @nameTags getSelectedRowsGrid|Obter linhas selecionadas da grade
5757
- * @description {{functionToGetSelectedRowsGrid}}
5758
- * @param {ObjectType.STRING} field {{field}}
5759
- * @returns {ObjectType.OBJECT}
5760
- */
5761
- this.cronapi.screen.getSelectedRowsGrid = function(/** @type {ObjectType.STRING} @blockType field_from_screen*/ field) {
5762
- var result = [];
5763
- var grid = $('[ng-model="'+ field +'"]').children().data('kendoGrid');
5764
- if (grid) {
5765
- var selected = grid.select();
5766
- selected.each(function() {
5767
- var dataItem = grid.dataItem(this);
5768
- result.push(dataItem);
5769
- });
5827
+ function showNotification(id, message, status) {
5828
+ $(`#${id}`).getKendoNotification().show(message, status);
5770
5829
  }
5771
- return result;
5772
- };
5773
5830
 
5774
- /**
5775
- * @type function
5776
- * @name {{back}}
5777
- * @nameTags back|voltar|retroceder|history
5778
- * @description {{backDescription}}
5779
- */
5780
- this.cronapi.screen.back = function() {
5781
- history.back();
5782
- }
5831
+ function hasHTMLElement(id) {
5832
+ return document.getElementById(id);
5833
+ }
5834
+
5835
+ };
5783
5836
 
5784
5837
  /**
5785
- * @category CategoryType.REGEX
5838
+ * @category {{CategoryType.REGEX}}
5786
5839
  * @categoryTags REGEX|regex
5787
5840
  */
5788
5841
 
@@ -5852,7 +5905,7 @@ if (!window.fixedTimeZone) {
5852
5905
  }
5853
5906
 
5854
5907
  /**
5855
- * @category Calendar
5908
+ * @category {{Calendar}}
5856
5909
  * @categoryTags calendar|calendário
5857
5910
  */
5858
5911
  this.cronapi.calendar = {};
@@ -6503,4 +6556,66 @@ if (!window.fixedTimeZone) {
6503
6556
 
6504
6557
  }
6505
6558
 
6559
+ /**
6560
+ * @category {{breadcrumb}}
6561
+ * @categoryTags breadcrumb|breadcrumbs
6562
+ */
6563
+ this.cronapi.breadcrumb = {};
6564
+
6565
+ /**
6566
+ * @type function
6567
+ * @name {{breadcrumb}}
6568
+ * @description {{breadcrumbDesc}}
6569
+ * @param {ObjectType.MAP} map {{breadcrumbParamMap}}
6570
+ * @returns {ObjectType.STRING}
6571
+ */
6572
+ this.cronapi.breadcrumb.jsonBreadcrumb = function (map) {
6573
+ let breadcrumb = [];
6574
+ map = Array.isArray(map) ? map : [map];
6575
+
6576
+ map.forEach(function (item) {
6577
+ breadcrumb.push(item)
6578
+ });
6579
+ return breadcrumb;
6580
+ };
6581
+
6582
+ /**
6583
+ * @type function
6584
+ * @name {{listBreadcrumb}}
6585
+ * @description {{listBreadcrumbDesc}}
6586
+ * @param {ObjectType.BOOLEAN} root {{listBreadcrumbRoot}}
6587
+ * @param {ObjectType.STRING} titulo {{listBreadcrumbTitulo}}
6588
+ * @param {ObjectType.STRING} icon {{listBreadcrumbIcon}}
6589
+ * @param {ObjectType.STRING} link {{listBreadcrumbLink}}
6590
+ * @returns {ObjectType.STRING}
6591
+ */
6592
+ this.cronapi.breadcrumb.listBreadcrumb = function ( /** @type {ObjectType.BOOLEAN} @description {{listBreadcrumbRoot}} @blockType util_dropdown @keys true|false @values {{yes}}|{{no}} */ root, /** @type {ObjectType.STRING} */ titulo, icon, /** @type {ObjectType.STATEMENT} @description {{listBreadcrumbLink}} */ link) {
6593
+
6594
+ let json = {};
6595
+
6596
+ if (root) {
6597
+ json.type = "rootitem"
6598
+ } else {
6599
+ json.type = "item"
6600
+ }
6601
+
6602
+ json.text = titulo;
6603
+ json.showText = true;
6604
+
6605
+ if (link) {
6606
+ json.href = link
6607
+ } else {
6608
+ json.href = "#"
6609
+ }
6610
+
6611
+ if (icon) {
6612
+ json.icon = icon
6613
+ json.showIcon = true
6614
+ } else {
6615
+ json.showIcon = false
6616
+ }
6617
+
6618
+ return json;
6619
+ };
6620
+
6506
6621
  }).bind(window)();