cronapp-framework-js 2.8.21 → 2.8.25

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 (85) hide show
  1. package/components/crn-accordion.components.json +29 -1
  2. package/components/crn-anchor.components.json +2 -2
  3. package/components/crn-datepicker.components.json +15 -0
  4. package/components/crn-datetimepicker.components.json +25 -0
  5. package/components/crn-dynamic-menu.components.json +21 -0
  6. package/components/crn-eight-four-container.components.json +43 -0
  7. package/components/crn-enterprise-autocomplete.components.json +38 -1
  8. package/components/crn-enterprise-combobox.components.json +11 -1
  9. package/components/crn-enterprise-dynamic-autocomplete.components.json +39 -2
  10. package/components/crn-enterprise-dynamic-combobox.components.json +18 -1
  11. package/components/crn-four-eight-container.components.json +43 -0
  12. package/components/crn-horizontal-container.components.json +40 -43
  13. package/components/crn-label.components.json +1 -0
  14. package/components/crn-one-container.components.json +43 -0
  15. package/components/crn-rating.components.json +3 -5
  16. package/components/crn-table.components.json +1 -2
  17. package/components/crn-textarea.components.json +9 -0
  18. package/components/crn-textinput.components.json +16 -5
  19. package/components/crn-three-container.components.json +43 -0
  20. package/components/crn-trhee-six-three-container.components.json +43 -0
  21. package/components/crn-two-container.components.json +43 -0
  22. package/components/crn-vertical-container.components.json +17 -9
  23. package/components/templates/Component_Container/crn-eight-four-container.template.html +4 -0
  24. package/components/templates/Component_Container/crn-four-eight-container.template.html +4 -0
  25. package/components/templates/Component_Container/crn-one-container.template.html +1 -0
  26. package/components/templates/Component_Container/crn-three-container.template.html +5 -0
  27. package/components/templates/Component_Container/crn-three-six-three-container.template.html +5 -0
  28. package/components/templates/Component_Container/crn-two-container.template.html +4 -0
  29. package/components/templates/cron-autocomplete.designtime.html +3 -3
  30. package/components/templates/grid-horizontal.template.html +4 -2
  31. package/components/templates/grid-vertical.template.html +4 -2
  32. package/components/templates/rating.template.html +6 -6
  33. package/css/animate.css +433 -0
  34. package/css/app.css +104 -32
  35. package/css/modalTemplate.css +25 -0
  36. package/css/themes/custom/fuse/custom-fuse.min.css +1 -5
  37. package/css/themes/custom/material/components_css/crn-navbar.css +30 -32
  38. package/css/themes/custom/material/custom-material.css +16 -11
  39. package/css/themes/custom/navigator/custom-navigator.css +71 -76
  40. package/dist/components/js/jquery.inputmask.bundle.js +1 -1
  41. package/dist/components/js/jquery.mask.min.js +1 -1
  42. package/dist/components/js/qrcode.js +1 -1
  43. package/dist/components/templates/Component_Container/crn-eight-four-container.template.html +1 -0
  44. package/dist/components/templates/Component_Container/crn-four-eight-container.template.html +1 -0
  45. package/dist/components/templates/Component_Container/crn-one-container.template.html +1 -0
  46. package/dist/components/templates/Component_Container/crn-three-container.template.html +1 -0
  47. package/dist/components/templates/Component_Container/crn-three-six-three-container.template.html +1 -0
  48. package/dist/components/templates/Component_Container/crn-two-container.template.html +1 -0
  49. package/dist/components/templates/cron-autocomplete.designtime.html +1 -1
  50. package/dist/components/templates/grid-horizontal.template.html +1 -1
  51. package/dist/components/templates/grid-vertical.template.html +1 -1
  52. package/dist/components/templates/rating.template.html +1 -1
  53. package/dist/css/app.css +1 -1
  54. package/dist/i18n/locale_en_us.json +2 -1
  55. package/dist/i18n/locale_pt_br.json +2 -1
  56. package/dist/img/barcode.png +0 -0
  57. package/dist/img/cron-icon/crn-eight-four-container.svg +1 -0
  58. package/dist/img/cron-icon/crn-four-eight-container.svg +1 -0
  59. package/dist/img/cron-icon/crn-one-container.svg +1 -0
  60. package/dist/img/cron-icon/crn-three-container.svg +1 -0
  61. package/dist/img/cron-icon/crn-three-six-three-container.svg +1 -0
  62. package/dist/img/cron-icon/crn-two-container.svg +1 -0
  63. package/dist/img/cronGrid.png +0 -0
  64. package/dist/img/cronRichEditor.png +0 -0
  65. package/dist/img/cronapp-logo-login.png +0 -0
  66. package/dist/img/logo.png +0 -0
  67. package/dist/img/placehold-100x100.png +0 -0
  68. package/dist/img/placehold-900x500.png +0 -0
  69. package/dist/img/qrcode.png +0 -0
  70. package/dist/img/selectFile.png +0 -0
  71. package/dist/img/switch.png +0 -0
  72. package/dist/js/app.js +1 -1
  73. package/dist/js/directives.js +1 -1
  74. package/i18n/locale_en_us.json +2 -1
  75. package/i18n/locale_pt_br.json +2 -1
  76. package/img/cron-icon/crn-eight-four-container.svg +18 -0
  77. package/img/cron-icon/crn-four-eight-container.svg +20 -0
  78. package/img/cron-icon/crn-one-container.svg +17 -0
  79. package/img/cron-icon/crn-three-container.svg +21 -0
  80. package/img/cron-icon/crn-three-six-three-container.svg +19 -0
  81. package/img/cron-icon/crn-two-container.svg +18 -0
  82. package/img/placehold-900x500.png +0 -0
  83. package/js/app.js +9 -1
  84. package/js/directives.js +2067 -1894
  85. package/package.json +1 -1
package/js/directives.js CHANGED
@@ -386,7 +386,7 @@
386
386
  }
387
387
  }
388
388
  })
389
- .directive('dynamicFile', function($compile, $translate) {
389
+ .directive('dynamicFile', function($compile, $translate) {
390
390
  var template = '';
391
391
  return {
392
392
  restrict: 'A',
@@ -395,18 +395,18 @@
395
395
  link: function(scope, element, attr) {
396
396
  var s = scope;
397
397
  var required = (attr.ngRequired && attr.ngRequired == "true"?"required":"");
398
-
398
+
399
399
  var splitedNgModel = attr.ngModel.split('.');
400
400
  var datasource = splitedNgModel[0];
401
401
  var field = splitedNgModel[splitedNgModel.length-1];
402
402
  var number = Math.floor((Math.random() * 1000) + 20);
403
403
  var content = element.html();
404
-
404
+
405
405
  var maxFileSize = "";
406
406
  if (attr.maxFileSize)
407
407
  maxFileSize = attr.maxFileSize;
408
408
  let fileInfo = attr.fileInfo ? `'${attr.fileInfo}'`: 'undefined';
409
-
409
+
410
410
  var templateDyn = '\
411
411
  <div ng-show="!$ngModel$" ngf-drop="" ngf-drag-over-class="dragover">\
412
412
  <input id="$id$" aria-label="$userHtml$" ng-if="!$ngModel$" autocomplete="off" tabindex="-1" class="uiSelectRequired ui-select-offscreen" style="top: inherit !important;margin-left: 85px !important;margin-top: 50px !important; display: none;" type=text ng-model="$ngModel$" $required$>\
@@ -443,7 +443,7 @@
443
443
  .split('$lblDownload$').join($translate.instant('download'))
444
444
  .split('$fileInfo$').join(fileInfo)
445
445
  );
446
-
446
+
447
447
  element.html(templateDyn);
448
448
  $compile(templateDyn)(element.scope());
449
449
  }
@@ -762,12 +762,12 @@
762
762
  link: function (scope, element, attrs, ngModelCtrl) {
763
763
 
764
764
  let waitAngularReady = () => {
765
- if (scope.$$phase !== '$apply' && scope.$$phase !== '$digest') {
766
- element.find('i').remove();
767
- }
768
- else {
769
- setTimeout( () => waitAngularReady(), 200);
770
- }
765
+ if (scope.$$phase !== '$apply' && scope.$$phase !== '$digest') {
766
+ element.find('i').remove();
767
+ }
768
+ else {
769
+ setTimeout( () => waitAngularReady(), 200);
770
+ }
771
771
  };
772
772
  waitAngularReady();
773
773
 
@@ -1414,1938 +1414,1939 @@
1414
1414
  };
1415
1415
  })
1416
1416
 
1417
- .directive('cronScheduler', ['$compile', '$translate', function($compile, $translate) {
1418
- return {
1419
- estrict: 'E',
1420
- replace: true,
1421
- initCulture: function() {
1422
- var culture = $translate.use();
1423
- culture = culture.replace(/_/gm, '-');
1424
- var parts = culture.split('-');
1425
- parts[parts.length - 1] = parts[parts.length - 1].toUpperCase();
1426
- culture = parts.join('-');
1427
- kendo.culture(culture);
1428
- },
1429
- getSchedulerModel: function(datasourceFields) {
1430
- let model = {
1431
- id: "id", // The "id" of the event is the "taskId" field
1432
- fields: {}
1433
- };
1434
- for(let key in datasourceFields) {
1435
- model.fields[key] = {from: datasourceFields[key].name, validation: { required: !datasourceFields[key].nullable } };
1436
- }
1417
+ .directive('cronScheduler', ['$compile', '$translate', function($compile, $translate) {
1418
+ return {
1419
+ estrict: 'E',
1420
+ replace: true,
1421
+ initCulture: function() {
1422
+ var culture = $translate.use();
1423
+ culture = culture.replace(/_/gm, '-');
1424
+ var parts = culture.split('-');
1425
+ parts[parts.length - 1] = parts[parts.length - 1].toUpperCase();
1426
+ culture = parts.join('-');
1427
+ kendo.culture(culture);
1428
+ },
1429
+ getSchedulerModel: function(datasourceFields) {
1430
+ let model = {
1431
+ id: "id", // The "id" of the event is the "taskId" field
1432
+ fields: {}
1433
+ };
1434
+ for(let key in datasourceFields) {
1435
+ model.fields[key] = {from: datasourceFields[key].name, validation: { required: !datasourceFields[key].nullable } };
1436
+ }
1437
1437
 
1438
- return model
1439
- },
1440
- mergeSchedulerEventWithDatasourceActive: (datasource, item) => {
1441
- //In order to merge the new event info with the active item from datasorce.
1442
- return Object.assign(datasource.active, item);
1443
- },
1444
- setDatasourceActiveItem: function (datasource, item, keyField) {
1445
- if (item) {
1446
- for (let key in datasource.data) {
1447
- let dsItem = datasource.data[key][keyField];
1448
- if (dsItem !== null && dsItem === item[keyField]) {
1449
- datasource.active = datasource.copy(datasource.data[key], {});
1450
- return datasource.active;
1451
- }
1452
- }
1453
- // If item is not present clean active
1454
- datasource.startEditing({});
1455
- return datasource.active;
1456
- }
1457
- },
1458
- getSchedulerProperties: function(options, datasource, scope) {
1459
- let schedulerStartDate = (options.initialDateStrategy === 'Expression' ? scope.$eval(generateBlocklyCall(options.initialDateBlocklyInfo)) : options.initialDate);
1460
- let lastSearchedPeriod = {start: null, end: null};
1461
- let needsToFetchData = function(searchablePeriod) {
1462
- return !angular.equals(lastSearchedPeriod, searchablePeriod);
1463
- };
1464
- let visibleViews = [];
1465
- if(options.views) {
1466
- for(let viewIndex in options.views) {
1467
- let view = options.views[viewIndex];
1468
- if(view.visible) {
1469
- visibleViews.push(view);
1438
+ return model
1439
+ },
1440
+ mergeSchedulerEventWithDatasourceActive: (datasource, item) => {
1441
+ //In order to merge the new event info with the active item from datasorce.
1442
+ return Object.assign(datasource.active, item);
1443
+ },
1444
+ setDatasourceActiveItem: function (datasource, item, keyField) {
1445
+ if (item) {
1446
+ for (let key in datasource.data) {
1447
+ let dsItem = datasource.data[key][keyField];
1448
+ if (dsItem !== null && dsItem === item[keyField]) {
1449
+ datasource.active = datasource.copy(datasource.data[key], {});
1450
+ return datasource.active;
1451
+ }
1470
1452
  }
1453
+ // If item is not present clean active
1454
+ datasource.startEditing({});
1455
+ return datasource.active;
1471
1456
  }
1472
- } else {
1473
- if(options.showDayTab) {
1474
- visibleViews.push('day');
1475
- }
1476
- if(options.showAgendaTab) {
1477
- visibleViews.push('agenda');
1478
- }
1479
- if(options.showMonthTab) {
1480
- visibleViews.push('month');
1481
- }
1482
- if(options.showTimelineTab) {
1483
- visibleViews.push('timeline');
1484
- }
1485
- if(options.showWeekTab) {
1486
- visibleViews.push('week');
1487
- }
1488
- if(options.showWorkWeekTab) {
1489
- visibleViews.push('workWeek');
1457
+ },
1458
+ getSchedulerProperties: function(options, datasource, scope) {
1459
+ let schedulerStartDate = (options.initialDateStrategy === 'Expression' ? scope.$eval(generateBlocklyCall(options.initialDateBlocklyInfo)) : options.initialDate);
1460
+ let lastSearchedPeriod = {start: null, end: null};
1461
+ let needsToFetchData = function(searchablePeriod) {
1462
+ return !angular.equals(lastSearchedPeriod, searchablePeriod);
1463
+ };
1464
+ let visibleViews = [];
1465
+ if(options.views) {
1466
+ for(let viewIndex in options.views) {
1467
+ let view = options.views[viewIndex];
1468
+ if(view.visible) {
1469
+ visibleViews.push(view);
1470
+ }
1471
+ }
1472
+ } else {
1473
+ if(options.showDayTab) {
1474
+ visibleViews.push('day');
1475
+ }
1476
+ if(options.showAgendaTab) {
1477
+ visibleViews.push('agenda');
1478
+ }
1479
+ if(options.showMonthTab) {
1480
+ visibleViews.push('month');
1481
+ }
1482
+ if(options.showTimelineTab) {
1483
+ visibleViews.push('timeline');
1484
+ }
1485
+ if(options.showWeekTab) {
1486
+ visibleViews.push('week');
1487
+ }
1488
+ if(options.showWorkWeekTab) {
1489
+ visibleViews.push('workWeek');
1490
+ }
1490
1491
  }
1491
- }
1492
1492
 
1493
1493
 
1494
- let cronSchedulerProperties = {
1495
- dateHeaderTemplate: kendo.template(`#=kendo.toString(date, ${kendo.culture().name.toLowerCase().includes('pt')?'\'ddd dd/M\'':'\'ddd M/dd\''})#`),
1496
- showWorkHours: options.showWorkHours,
1497
- selectable: true,
1498
- date: schedulerStartDate,
1499
- mobile: true,
1500
- allDaySlot: options.allDaySlot,
1501
- messages: {
1502
- editor: {
1503
- timezone: $translate.instant('TimezoneEvent')
1504
- }
1505
- },
1506
- currentTimeMarker: (options.currentTimeMarker ? {
1507
- updateInterval: 10000,
1508
- useLocalTimezone: false
1509
- } : options.currentTimeMarker),
1510
- views: visibleViews,
1511
- navigate: function(e) {
1512
- //Navigated from
1513
- let view = e.sender.view();
1514
-
1515
- // The view has:
1516
- // A startDate method which returns the start date of the view.
1517
- // An endDate method which returns the end date of the view.
1518
-
1519
- //kendo.format("view:: start: {0:d}; end: {1:d};", view.startDate(), view.endDate())
1520
- },
1521
- dataBound: function(e) {
1522
- //Navigated to
1523
- let view = e.sender.view();
1494
+ let cronSchedulerProperties = {
1495
+ dateHeaderTemplate: kendo.template(`#=kendo.toString(date, ${kendo.culture().name.toLowerCase().includes('pt')?'\'ddd dd/M\'':'\'ddd M/dd\''})#`),
1496
+ showWorkHours: options.showWorkHours,
1497
+ selectable: true,
1498
+ date: schedulerStartDate,
1499
+ mobile: true,
1500
+ allDaySlot: options.allDaySlot,
1501
+ messages: {
1502
+ editor: {
1503
+ timezone: $translate.instant('TimezoneEvent')
1504
+ }
1505
+ },
1506
+ currentTimeMarker: (options.currentTimeMarker ? {
1507
+ updateInterval: 10000,
1508
+ useLocalTimezone: false
1509
+ } : options.currentTimeMarker),
1510
+ views: visibleViews,
1511
+ navigate: function(e) {
1512
+ //Navigated from
1513
+ let view = e.sender.view();
1514
+
1515
+ // The view has:
1516
+ // A startDate method which returns the start date of the view.
1517
+ // An endDate method which returns the end date of the view.
1518
+
1519
+ //kendo.format("view:: start: {0:d}; end: {1:d};", view.startDate(), view.endDate())
1520
+ },
1521
+ dataBound: function(e) {
1522
+ //Navigated to
1523
+ let view = e.sender.view();
1524
1524
 
1525
- // The view has:
1526
- // A startDate method which returns the start date of the view.
1527
- // An endDate method which returns the end date of the view.
1525
+ // The view has:
1526
+ // A startDate method which returns the start date of the view.
1527
+ // An endDate method which returns the end date of the view.
1528
1528
 
1529
- //kendo.format("view:: start: {0:d}; end: {1:d};", view.startDate(), view.endDate())
1530
- },
1531
- change: (e) => {
1532
- if (e && e.events && e.events.length) {
1533
- this.setDatasourceActiveItem(datasource, e.events[0], 'id');
1534
- } else {
1535
- datasource.startInserting({});
1536
- }
1537
- console.log('Active: ', datasource.active);
1538
- },
1539
- edit: function (e) {
1540
- if (options && options.allowCustomAction) {
1541
- let container = e.container;
1542
-
1543
- let btnLabel = options.customActionLabel ? options.customActionLabel : $translate.instant(Details);
1544
- /* ACTION: ADD custom button */
1545
- let detailButton = $('<a class="k-button">' + btnLabel + '</a>');
1546
-
1547
- //wire its click event
1548
- detailButton.click(function (e) {
1549
- scope.safeApply(() => {
1550
- scope.$eval(generateBlocklyCall(options.customActionBlockly));
1529
+ //kendo.format("view:: start: {0:d}; end: {1:d};", view.startDate(), view.endDate())
1530
+ },
1531
+ change: (e) => {
1532
+ if (e && e.events && e.events.length) {
1533
+ this.setDatasourceActiveItem(datasource, e.events[0], 'id');
1534
+ } else {
1535
+ datasource.startInserting({});
1536
+ }
1537
+ console.log('Active: ', datasource.active);
1538
+ },
1539
+ edit: function (e) {
1540
+ if (options && options.allowCustomAction) {
1541
+ let container = e.container;
1542
+
1543
+ let btnLabel = options.customActionLabel ? options.customActionLabel : $translate.instant(Details);
1544
+ /* ACTION: ADD custom button */
1545
+ let detailButton = $('<a class="k-button">' + btnLabel + '</a>');
1546
+
1547
+ //wire its click event
1548
+ detailButton.click(function (e) {
1549
+ scope.safeApply(() => {
1550
+ scope.$eval(generateBlocklyCall(options.customActionBlockly));
1551
+ });
1551
1552
  });
1552
- });
1553
1553
 
1554
- //add the button to the container
1555
- let buttonsContainer = container.find(".k-edit-buttons");
1556
- buttonsContainer.append(detailButton);
1554
+ //add the button to the container
1555
+ let buttonsContainer = container.find(".k-edit-buttons");
1556
+ buttonsContainer.append(detailButton);
1557
1557
 
1558
- }
1558
+ }
1559
1559
 
1560
- },
1561
- dataSource: {
1562
- batch: false, // Enable batch updates
1563
- transport: {
1564
- read: function(read) {
1565
- read.data = read.data || {};
1566
- // verify if lastSearchedPeriod is the same searched now. If so ignore search.
1567
- if(needsToFetchData(read.data)) {
1568
- lastSearchedPeriod = read.data;
1569
-
1570
- if(jQuery.isEmptyObject(read.data)) {
1571
- read.data[options.schedulerDataModel.start.name] = schedulerStartDate;
1572
- }
1573
- let paramsOData = kendo.data.transports.odata.parameterMap(read.data, 'read');
1574
- let orderBy = '';
1575
- let fetchData = {};
1576
- fetchData.params = paramsOData;
1577
- datasource.fetch(fetchData, {
1578
- success: function(data) {
1579
- read.success(angular.copy(data));
1580
- },
1581
- canceled: function(data) {
1582
- // notify the data source that the request failed
1583
- read.error(angular.copy(data));
1560
+ },
1561
+ dataSource: {
1562
+ batch: false, // Enable batch updates
1563
+ transport: {
1564
+ read: function(read) {
1565
+ read.data = read.data || {};
1566
+ // verify if lastSearchedPeriod is the same searched now. If so ignore search.
1567
+ if(needsToFetchData(read.data)) {
1568
+ lastSearchedPeriod = read.data;
1569
+
1570
+ if(jQuery.isEmptyObject(read.data)) {
1571
+ read.data[options.schedulerDataModel.start.name] = schedulerStartDate;
1584
1572
  }
1585
- }, false);
1586
- } else {
1587
- read.error();
1588
- }
1589
- }.bind(this),
1590
- update: (update) => {
1591
- let item = this.parseToDatasourceSchema(datasource, update.data, options);
1592
- datasource.startEditing(datasource.active);
1593
- this.mergeSchedulerEventWithDatasourceActive(datasource, item);
1594
- datasource.update(
1595
- datasource.active,
1596
- (data) => {
1597
- let updatedItem = angular.copy(data);
1598
- update.success(updatedItem);
1599
- datasource.fetch({}, {
1600
- success: (allData) => {
1601
- this.setDatasourceActiveItem(datasource, updatedItem, 'id');
1573
+ let paramsOData = kendo.data.transports.odata.parameterMap(read.data, 'read');
1574
+ let orderBy = '';
1575
+ let fetchData = {};
1576
+ fetchData.params = paramsOData;
1577
+ datasource.fetch(fetchData, {
1578
+ success: function(data) {
1579
+ read.success(angular.copy(data));
1602
1580
  },
1603
- canceled: (data) => {
1581
+ canceled: function(data) {
1604
1582
  // notify the data source that the request failed
1583
+ read.error(angular.copy(data));
1605
1584
  }
1606
1585
  }, false);
1607
- },
1608
- (data) => {
1609
- update.error(angular.copy(data));
1586
+ } else {
1587
+ read.error();
1610
1588
  }
1611
- );
1612
- },
1613
- create: (create) => {
1614
- let item = this.parseToDatasourceSchema(datasource, create.data, options);
1615
- this.mergeSchedulerEventWithDatasourceActive(datasource, item);
1616
- datasource.insert(
1617
- datasource.active,
1618
- (data) => {
1619
- let newItem = angular.copy(data);
1620
- create.success(newItem);
1621
- datasource.fetch({}, {
1622
- success: (allData) => {
1623
- this.setDatasourceActiveItem(datasource, newItem, 'id');
1589
+ }.bind(this),
1590
+ update: (update) => {
1591
+ let item = this.parseToDatasourceSchema(datasource, update.data, options);
1592
+ datasource.startEditing(datasource.active);
1593
+ this.mergeSchedulerEventWithDatasourceActive(datasource, item);
1594
+ datasource.update(
1595
+ datasource.active,
1596
+ (data) => {
1597
+ let updatedItem = angular.copy(data);
1598
+ update.success(updatedItem);
1599
+ datasource.fetch({}, {
1600
+ success: (allData) => {
1601
+ this.setDatasourceActiveItem(datasource, updatedItem, 'id');
1602
+ },
1603
+ canceled: (data) => {
1604
+ // notify the data source that the request failed
1605
+ }
1606
+ }, false);
1624
1607
  },
1625
- canceled: function(data) {
1626
- // notify the data source that the request failed
1608
+ (data) => {
1609
+ update.error(angular.copy(data));
1627
1610
  }
1628
- }, false);
1629
- },
1630
- (data) => {
1631
- create.error(angular.copy(data));
1632
- }
1633
- );
1611
+ );
1612
+ },
1613
+ create: (create) => {
1614
+ let item = this.parseToDatasourceSchema(datasource, create.data, options);
1615
+ this.mergeSchedulerEventWithDatasourceActive(datasource, item);
1616
+ datasource.insert(
1617
+ datasource.active,
1618
+ (data) => {
1619
+ let newItem = angular.copy(data);
1620
+ create.success(newItem);
1621
+ datasource.fetch({}, {
1622
+ success: (allData) => {
1623
+ this.setDatasourceActiveItem(datasource, newItem, 'id');
1624
+ },
1625
+ canceled: function(data) {
1626
+ // notify the data source that the request failed
1627
+ }
1628
+ }, false);
1629
+ },
1630
+ (data) => {
1631
+ create.error(angular.copy(data));
1632
+ }
1633
+ );
1634
+ },
1635
+ destroy: function(destroy) {
1636
+ datasource.removeSilent(
1637
+ this.parseToDatasourceSchema(datasource, destroy.data, options),
1638
+ function(data) {
1639
+ destroy.success(angular.copy(data));
1640
+ },
1641
+ function(data) {
1642
+ destroy.error(angular.copy(data));
1643
+ }
1644
+ );
1645
+ }.bind(this)
1634
1646
  },
1635
- destroy: function(destroy) {
1636
- datasource.removeSilent(
1637
- this.parseToDatasourceSchema(datasource, destroy.data, options),
1638
- function(data) {
1639
- destroy.success(angular.copy(data));
1640
- },
1641
- function(data) {
1642
- destroy.error(angular.copy(data));
1643
- }
1644
- );
1645
- }.bind(this)
1646
- },
1647
- schema: {
1648
- model: this.getSchedulerModel(options.schedulerDataModel)
1647
+ schema: {
1648
+ model: this.getSchedulerModel(options.schedulerDataModel)
1649
+ }
1649
1650
  }
1651
+ };
1652
+ if(!options.views) {
1653
+ cronSchedulerProperties.editable = options.editable;
1654
+ }
1655
+ if(window.fixedTimeZone && window.timeZone) {
1656
+ cronSchedulerProperties.timezone = window.timeZone;
1657
+ }
1658
+ return cronSchedulerProperties;
1659
+ },
1660
+ showError: function(scope, title, message) {
1661
+ let info = {
1662
+ message: message,
1663
+ title: title,
1664
+ delay: null
1665
+ };
1666
+ scope.Notification.error(info);
1667
+ },
1668
+ parseToDatasourceSchema: function(datasource, object, options) {
1669
+ let parsedObj = {};
1670
+ //Antigo parse setava nulo no campo title (se viesse vazio e quebrava o kendo na visualização do tipo mensal)
1671
+ for(let key in datasource.schema) {
1672
+ let name = datasource.schema[key].name;
1673
+ parsedObj[name] = object[name];
1674
+ }
1675
+
1676
+ parsedObj[options.schedulerDataModel.isAllDay.name] = parsedObj[options.schedulerDataModel.isAllDay.name] === true;
1677
+ if (!parsedObj[options.schedulerDataModel.id.name])
1678
+ delete parsedObj[options.schedulerDataModel.id.name];
1679
+ return parsedObj;
1680
+ },
1681
+ link: function(scope, element, attrs, ngModelCtrl) {
1682
+ let schedulerElement = $('<div></div>');
1683
+ let options = JSON.parse(attrs.options || "{}");
1684
+ let datasource;
1685
+ if(options.dataSourceScreen && options.dataSourceScreen.entityDataSource) {
1686
+ datasource = eval(options.dataSourceScreen.entityDataSource.name);
1687
+ }
1688
+ //Validate Component Configuration
1689
+ if(!datasource) {
1690
+ // There is no Datasource
1691
+ let errorObject = {};
1692
+ $translate('DatasourceNotFoundMessage').then((datasourceNotFoundMessage) => {
1693
+ errorObject.message = datasourceNotFoundMessage;
1694
+ return $translate('Scheduler');
1695
+ }).then((scheduler) => {
1696
+ errorObject.component = scheduler;
1697
+ return $translate('DatasourceNotFoundTitle');
1698
+ }).then((datasourceNotFoundTitle) => {
1699
+ errorObject.title = datasourceNotFoundTitle;
1700
+ this.showError(scope, errorObject.title, errorObject.message.replace('{0}', errorObject.component));
1701
+ });
1702
+ return;
1703
+ }else if(jQuery.isEmptyObject(options.schedulerDataModel)){
1704
+ //TODO ADD Message to not relation fields added
1705
+ return;
1650
1706
  }
1651
- };
1652
- if(!options.views) {
1653
- cronSchedulerProperties.editable = options.editable;
1654
- }
1655
- if(window.fixedTimeZone && window.timeZone) {
1656
- cronSchedulerProperties.timezone = window.timeZone;
1657
- }
1658
- return cronSchedulerProperties;
1659
- },
1660
- showError: function(scope, title, message) {
1661
- let info = {
1662
- message: message,
1663
- title: title,
1664
- delay: null
1665
- };
1666
- scope.Notification.error(info);
1667
- },
1668
- parseToDatasourceSchema: function(datasource, object, options) {
1669
- let parsedObj = {};
1670
- //Antigo parse setava nulo no campo title (se viesse vazio e quebrava o kendo na visualização do tipo mensal)
1671
- for(let key in datasource.schema) {
1672
- let name = datasource.schema[key].name;
1673
- parsedObj[name] = object[name];
1674
- }
1675
-
1676
- parsedObj[options.schedulerDataModel.isAllDay.name] = parsedObj[options.schedulerDataModel.isAllDay.name] === true;
1677
- if (!parsedObj[options.schedulerDataModel.id.name])
1678
- delete parsedObj[options.schedulerDataModel.id.name];
1679
- return parsedObj;
1680
- },
1681
- link: function(scope, element, attrs, ngModelCtrl) {
1682
- let schedulerElement = $('<div></div>');
1683
- let options = JSON.parse(attrs.options || "{}");
1684
- let datasource;
1685
- if(options.dataSourceScreen && options.dataSourceScreen.entityDataSource) {
1686
- datasource = eval(options.dataSourceScreen.entityDataSource.name);
1687
- }
1688
- //Validate Component Configuration
1689
- if(!datasource) {
1690
- // There is no Datasource
1691
- let errorObject = {};
1692
- $translate('DatasourceNotFoundMessage').then((datasourceNotFoundMessage) => {
1693
- errorObject.message = datasourceNotFoundMessage;
1694
- return $translate('Scheduler');
1695
- }).then((scheduler) => {
1696
- errorObject.component = scheduler;
1697
- return $translate('DatasourceNotFoundTitle');
1698
- }).then((datasourceNotFoundTitle) => {
1699
- errorObject.title = datasourceNotFoundTitle;
1700
- this.showError(scope, errorObject.title, errorObject.message.replace('{0}', errorObject.component));
1701
- });
1702
- return;
1703
- }else if(jQuery.isEmptyObject(options.schedulerDataModel)){
1704
- //TODO ADD Message to not relation fields added
1705
- return;
1706
- }
1707
1707
 
1708
- let baseUrl = 'node_modules/cronapp-lib-js/dist/js/kendo-ui/js/messages/kendo.messages.';
1709
- if($translate.use() === 'pt_br') {
1710
- baseUrl += "pt-BR.min.js";
1711
- } else {
1712
- baseUrl += "en-US.min.js";
1713
- }
1708
+ let baseUrl = 'node_modules/cronapp-lib-js/dist/js/kendo-ui/js/messages/kendo.messages.';
1709
+ if($translate.use() === 'pt_br') {
1710
+ baseUrl += "pt-BR.min.js";
1711
+ } else {
1712
+ baseUrl += "en-US.min.js";
1713
+ }
1714
1714
 
1715
- this.initCulture();
1715
+ this.initCulture();
1716
1716
 
1717
- $.getScript(baseUrl, function() {
1717
+ $.getScript(baseUrl, function() {
1718
1718
 
1719
- let kendoDatasource = app.kendoHelper.getDataSource(options.dataSourceScreen.entityDataSource, scope, true, options.dataSourceScreen.rowsPerPage);
1719
+ let kendoDatasource = app.kendoHelper.getDataSource(options.dataSourceScreen.entityDataSource, scope, true, options.dataSourceScreen.rowsPerPage);
1720
1720
 
1721
- let schedulerProperties = this.getSchedulerProperties(options, datasource, scope);
1721
+ let schedulerProperties = this.getSchedulerProperties(options, datasource, scope);
1722
1722
 
1723
- schedulerElement.kendoScheduler(schedulerProperties);
1723
+ schedulerElement.kendoScheduler(schedulerProperties);
1724
1724
 
1725
- // Get reference to the kendo.ui.Scheduler instance
1726
- let scheduler = schedulerElement.data("kendoScheduler");
1727
- let lastView;
1725
+ // Get reference to the kendo.ui.Scheduler instance
1726
+ let scheduler = schedulerElement.data("kendoScheduler");
1727
+ let lastView;
1728
1728
 
1729
- scheduler.bind('navigate', function(e) {
1730
- scheduler._previousView = e.sender.view();
1731
- });
1732
- scheduler.bind('dataBound', function(e) {
1733
- scheduler._currentView = e.sender.view();
1734
- if(scheduler._previousView) {
1735
- let sameView = compare(scheduler._previousView._dates, scheduler._currentView._dates);
1736
- if(!sameView) {
1737
- let params = {};
1738
- params[options.schedulerDataModel.start.name] = scheduler._currentView._startDate;
1739
- params[options.schedulerDataModel.end.name] = scheduler._currentView._endDate;
1740
- scheduler.dataSource.read(params);
1741
- scheduler._previousView = scheduler._currentView;
1729
+ scheduler.bind('navigate', function(e) {
1730
+ scheduler._previousView = e.sender.view();
1731
+ });
1732
+ scheduler.bind('dataBound', function(e) {
1733
+ scheduler._currentView = e.sender.view();
1734
+ if(scheduler._previousView) {
1735
+ let sameView = compare(scheduler._previousView._dates, scheduler._currentView._dates);
1736
+ if(!sameView) {
1737
+ let params = {};
1738
+ params[options.schedulerDataModel.start.name] = scheduler._currentView._startDate;
1739
+ params[options.schedulerDataModel.end.name] = scheduler._currentView._endDate;
1740
+ scheduler.dataSource.read(params);
1741
+ scheduler._previousView = scheduler._currentView;
1742
+ }
1742
1743
  }
1743
- }
1744
1744
 
1745
- });
1745
+ });
1746
1746
 
1747
- function compare(arr1, arr2) {
1748
- if(!arr1 || !arr2) return
1749
- let result;
1750
- arr1.forEach((e1, i) => arr2.forEach(e2 => {
1751
- if(e1.getTime() !== e2.getTime()) {
1752
- result = false
1753
- } else {
1754
- result = true
1755
- }
1756
- }));
1757
- return result
1758
- }
1759
- }.bind(this));
1747
+ function compare(arr1, arr2) {
1748
+ if(!arr1 || !arr2) return
1749
+ let result;
1750
+ arr1.forEach((e1, i) => arr2.forEach(e2 => {
1751
+ if(e1.getTime() !== e2.getTime()) {
1752
+ result = false
1753
+ } else {
1754
+ result = true
1755
+ }
1756
+ }));
1757
+ return result
1758
+ }
1759
+ }.bind(this));
1760
1760
 
1761
- element.html(schedulerElement);
1762
- $compile(schedulerElement)(element.scope());
1763
- }
1764
- }
1765
- }])
1766
-
1767
-
1768
- .directive('cronGrid', ['$compile', '$translate', function($compile, $translate) {
1769
- return {
1770
- restrict: 'E',
1771
- replace: true,
1772
- require: 'ngModel',
1773
- initCulture: function() {
1774
- var culture = $translate.use();
1775
- culture = culture.replace(/_/gm,'-');
1776
- var parts = culture.split('-');
1777
- parts[parts.length - 1] = parts[parts.length - 1].toUpperCase();
1778
- culture = parts.join('-');
1779
- kendo.culture(culture);
1780
- },
1781
- changeObjectField: function(dataSource, obj){
1782
- obj = dataSource.getKeyValues(obj);
1783
- var keys = Object.keys(obj);
1784
- if(keys.length === 1){
1785
- obj = obj[keys];
1761
+ element.html(schedulerElement);
1762
+ $compile(schedulerElement)(element.scope());
1786
1763
  }
1787
- return obj;
1788
- },
1789
- generateToolbarButtonCall: function(toolbarButton, scope, options) {
1790
- var buttonCall;
1791
- var generateObjTemplate = function(functionToCall, title, iconClass) {
1792
- var obj = {
1793
- template: function() {
1794
- var buttonId = app.common.generateId();
1795
- return createTemplateButton(buttonId, functionToCall, title, iconClass);
1796
- }.bind(this)
1797
- };
1798
- return obj;
1799
- }.bind(this);
1800
-
1801
- var createTemplateButton = function(buttonId, functionToCall, title, iconClass) {
1802
- var template = '';
1764
+ }
1765
+ }])
1803
1766
 
1804
- let security = toolbarButton.security ? `cronapp-security="${toolbarButton.security}"` : "";
1805
1767
 
1806
- if (toolbarButton.type == "SaveOrCancelChanges") {
1807
- if (toolbarButton.saveButton)
1808
- template = '<a #SECURITY# role="button" class="saveorcancelchanges k-button k-button-icontext k-grid-save-changes" id="#BUTTONID#" href="javascript:void(0)"><span class="k-icon k-i-check"></span>#TITLE#</a>';
1809
- else
1810
- template = '<a #SECURITY# role="button" class="saveorcancelchanges k-button k-button-icontext k-grid-cancel-changes" id="#BUTTONID#" href="javascript:void(0)"><span class="k-icon k-i-cancel" ></span>#TITLE#</a>';
1811
- }
1812
- else if (toolbarButton.type == "Blockly" || toolbarButton.type == "Customized") {
1813
- template = '<a #SECURITY# class="k-button k-grid-custom" id="#BUTTONID#" href="javascript:void(0)"><span class="#ICONCLASS#" ></span>#TITLE#</a>';
1814
- }
1815
- else if (toolbarButton.type == "Native" && toolbarButton.title == 'create') {
1816
- template = '<a #SECURITY# role="button" id="#BUTTONID#" class="k-button k-button-icontext k-grid-add" href="javascript:void(0)"><span class="k-icon k-i-plus"></span>{{"Add" | translate}}</a>';
1817
- }
1818
- else if (toolbarButton.type == "Native" && toolbarButton.title == 'excel') {
1819
- template = '<a #SECURITY# role="button" id="#BUTTONID#" class="k-button k-button-icontext k-grid-excel" href="javascript:void(0)"><span class="k-icon k-i-file-excel"></span>{{"exportExcel" | translate}}</a>';
1820
- }
1821
- else if (toolbarButton.type == "Native" && toolbarButton.title == 'pdf') {
1822
- template = '<a #SECURITY# role="button" id="#BUTTONID#" class="k-button k-button-icontext k-grid-pdf" href="javascript:void(0)"><span class="k-icon k-i-file-pdf"></span>{{"exportPDF" | translate}}</a>';
1768
+ .directive('cronGrid', ['$compile', '$translate', function($compile, $translate) {
1769
+ return {
1770
+ restrict: 'E',
1771
+ replace: true,
1772
+ require: 'ngModel',
1773
+ initCulture: function() {
1774
+ var culture = $translate.use();
1775
+ culture = culture.replace(/_/gm,'-');
1776
+ var parts = culture.split('-');
1777
+ parts[parts.length - 1] = parts[parts.length - 1].toUpperCase();
1778
+ culture = parts.join('-');
1779
+ kendo.culture(culture);
1780
+ },
1781
+ changeObjectField: function(dataSource, obj){
1782
+ obj = dataSource.getKeyValues(obj);
1783
+ var keys = Object.keys(obj);
1784
+ if(keys.length === 1){
1785
+ obj = obj[keys];
1823
1786
  }
1787
+ return obj;
1788
+ },
1789
+ generateToolbarButtonCall: function(toolbarButton, scope, options) {
1790
+ var buttonCall;
1791
+ var generateObjTemplate = function(functionToCall, title, iconClass) {
1792
+ var obj = {
1793
+ template: function() {
1794
+ var buttonId = app.common.generateId();
1795
+ return createTemplateButton(buttonId, functionToCall, title, iconClass);
1796
+ }.bind(this)
1797
+ };
1798
+ return obj;
1799
+ }.bind(this);
1824
1800
 
1825
- template = template
1826
- .split('#BUTTONID#').join(buttonId)
1827
- .split('#FUNCTIONCALL#').join(this.encodeHTML(functionToCall))
1828
- .split('#TITLE#').join(title)
1829
- .split('#ICONCLASS#').join(iconClass)
1830
- .split('#SECURITY#').join(security);
1801
+ var createTemplateButton = function(buttonId, functionToCall, title, iconClass) {
1802
+ var template = '';
1831
1803
 
1832
- var cronappDatasource = eval(options.dataSourceScreen.entityDataSource.name);
1804
+ let security = toolbarButton.security ? `cronapp-security="${toolbarButton.security}"` : "";
1833
1805
 
1834
- var waitRender = setInterval(function() {
1835
- if ($('#' + buttonId).length > 0) {
1836
- scope.safeApply(function() {
1837
- var x = angular.element($('#' + buttonId ));
1838
- $compile(x)(scope);
1839
- });
1806
+ if (toolbarButton.type == "SaveOrCancelChanges") {
1807
+ if (toolbarButton.saveButton)
1808
+ template = '<a #SECURITY# role="button" class="saveorcancelchanges k-button k-button-icontext k-grid-save-changes" id="#BUTTONID#" href="javascript:void(0)"><span class="k-icon k-i-check"></span>#TITLE#</a>';
1809
+ else
1810
+ template = '<a #SECURITY# role="button" class="saveorcancelchanges k-button k-button-icontext k-grid-cancel-changes" id="#BUTTONID#" href="javascript:void(0)"><span class="k-icon k-i-cancel" ></span>#TITLE#</a>';
1811
+ }
1812
+ else if (toolbarButton.type == "Blockly" || toolbarButton.type == "Customized") {
1813
+ template = '<a #SECURITY# class="k-button k-grid-custom" id="#BUTTONID#" href="javascript:void(0)"><span class="#ICONCLASS#" ></span>#TITLE#</a>';
1814
+ }
1815
+ else if (toolbarButton.type == "Native" && toolbarButton.title == 'create') {
1816
+ template = '<a #SECURITY# role="button" id="#BUTTONID#" class="k-button k-button-icontext k-grid-add" href="javascript:void(0)"><span class="k-icon k-i-plus"></span>{{"Add" | translate}}</a>';
1817
+ }
1818
+ else if (toolbarButton.type == "Native" && toolbarButton.title == 'excel') {
1819
+ template = '<a #SECURITY# role="button" id="#BUTTONID#" class="k-button k-button-icontext k-grid-excel" href="javascript:void(0)"><span class="k-icon k-i-file-excel"></span>{{"exportExcel" | translate}}</a>';
1820
+ }
1821
+ else if (toolbarButton.type == "Native" && toolbarButton.title == 'pdf') {
1822
+ template = '<a #SECURITY# role="button" id="#BUTTONID#" class="k-button k-button-icontext k-grid-pdf" href="javascript:void(0)"><span class="k-icon k-i-file-pdf"></span>{{"exportPDF" | translate}}</a>';
1823
+ }
1840
1824
 
1841
- $('#' + buttonId).click(function() {
1825
+ template = template
1826
+ .split('#BUTTONID#').join(buttonId)
1827
+ .split('#FUNCTIONCALL#').join(this.encodeHTML(functionToCall))
1828
+ .split('#TITLE#').join(title)
1829
+ .split('#ICONCLASS#').join(iconClass)
1830
+ .split('#SECURITY#').join(security);
1842
1831
 
1843
- var currentGrid = options.refComponent;
1844
- var selectedRows = [];
1845
- currentGrid.select().each(function() {
1846
- var gridRow = currentGrid.dataItem(this);
1847
- cronappDatasource.data.forEach(function(dsRow) {
1848
- if (dsRow.__$id == gridRow.__$id)
1849
- selectedRows.push(dsRow);
1850
- });
1832
+ var cronappDatasource = eval(options.dataSourceScreen.entityDataSource.name);
1833
+
1834
+ var waitRender = setInterval(function() {
1835
+ if ($('#' + buttonId).length > 0) {
1836
+ scope.safeApply(function() {
1837
+ var x = angular.element($('#' + buttonId ));
1838
+ $compile(x)(scope);
1851
1839
  });
1852
1840
 
1853
- var consolidated = {
1854
- item: selectedRows.length ? cronappDatasource.active : null,
1855
- index: selectedRows.length ? cronappDatasource.cursor : null
1856
- }
1841
+ $('#' + buttonId).click(function() {
1857
1842
 
1858
- let selectedRowsKeyOrObj = [];
1859
- if(options.fieldType && options.fieldType === 'key') {
1860
- selectedRows.forEach(item => {
1861
- selectedRowsKeyOrObj.push(this.changeObjectField(cronappDatasource, cronappDatasource.findObjInDs(item)));
1843
+ var currentGrid = options.refComponent;
1844
+ var selectedRows = [];
1845
+ currentGrid.select().each(function() {
1846
+ var gridRow = currentGrid.dataItem(this);
1847
+ cronappDatasource.data.forEach(function(dsRow) {
1848
+ if (dsRow.__$id == gridRow.__$id)
1849
+ selectedRows.push(dsRow);
1850
+ });
1862
1851
  });
1863
- }
1864
- else {
1865
- selectedRowsKeyOrObj = selectedRows;
1866
- }
1867
-
1868
- var contextVars = {
1869
- 'currentData': cronappDatasource.data,
1870
- 'datasource': cronappDatasource.copyWithoutAngularObj(),
1871
- 'selectedIndex': selectedRows.length ? cronappDatasource.cursor : null,
1872
- 'index': selectedRows.length ? cronappDatasource.cursor : null,
1873
- 'selectedRow': selectedRows.length ? cronappDatasource.active : null,
1874
- 'consolidated': consolidated,
1875
- 'item': selectedRows.length ? cronappDatasource.active : null,
1876
- 'selectedKeys': selectedRows.length ? cronappDatasource.getKeyValues(cronappDatasource.findObjInDs(selectedRows[0]), true) : null,
1877
- 'selectedRows': selectedRowsKeyOrObj
1878
- };
1879
1852
 
1880
- scope.$eval(functionToCall, contextVars) ;
1881
- }.bind(this));
1853
+ var consolidated = {
1854
+ item: selectedRows.length ? cronappDatasource.active : null,
1855
+ index: selectedRows.length ? cronappDatasource.cursor : null
1856
+ }
1882
1857
 
1883
- clearInterval(waitRender);
1884
- }
1885
- }.bind(this),200);
1858
+ let selectedRowsKeyOrObj = [];
1859
+ if(options.fieldType && options.fieldType === 'key') {
1860
+ selectedRows.forEach(item => {
1861
+ selectedRowsKeyOrObj.push(this.changeObjectField(cronappDatasource, cronappDatasource.findObjInDs(item)));
1862
+ });
1863
+ }
1864
+ else {
1865
+ selectedRowsKeyOrObj = selectedRows;
1866
+ }
1886
1867
 
1887
- return template;
1888
- }.bind(this);
1889
-
1890
- var call = '';
1891
- if (toolbarButton.type == 'Customized')
1892
- call = toolbarButton.execute;
1893
- else if (toolbarButton.methodCall)
1894
- call = toolbarButton.methodCall;
1895
- else
1896
- call = generateBlocklyCall(toolbarButton.blocklyInfo);
1897
-
1898
- var title = toolbarButton.title == undefined ? '': toolbarButton.title;
1899
- buttonCall = generateObjTemplate(call, title, toolbarButton.iconClass);
1900
- return buttonCall;
1901
- },
1902
- generateModalSaveOrCancelButtonCall: function(buttonType, functionToCall, datasourceName, modalId, scope) {
1868
+ var contextVars = {
1869
+ 'currentData': cronappDatasource.data,
1870
+ 'datasource': cronappDatasource.copyWithoutAngularObj(),
1871
+ 'selectedIndex': selectedRows.length ? cronappDatasource.cursor : null,
1872
+ 'index': selectedRows.length ? cronappDatasource.cursor : null,
1873
+ 'selectedRow': selectedRows.length ? cronappDatasource.active : null,
1874
+ 'consolidated': consolidated,
1875
+ 'item': selectedRows.length ? cronappDatasource.active : null,
1876
+ 'selectedKeys': selectedRows.length ? cronappDatasource.getKeyValues(cronappDatasource.findObjInDs(selectedRows[0]), true) : null,
1877
+ 'selectedRows': selectedRowsKeyOrObj
1878
+ };
1879
+
1880
+ scope.$eval(functionToCall, contextVars) ;
1881
+ }.bind(this));
1903
1882
 
1904
- var buttonId = app.common.generateId();
1905
- var compileTemplateAngular = function(buttonType, functionToCall, datasourceName, modalId) {
1906
- var template;
1907
- if (buttonType == 'save')
1908
- template = '<button id="#BUTTONID#" aria-label="#ARIALABELSAVE#" class="btn btn-primary btn-fab ng-binding grid-save-button-modal k-button" data-component="crn-button" ng-click="#FUNCTIONCALL#" onclick="(!#DATASOURCENAME#.missingRequiredField(true)?$(\'##MODALID#\').modal(\'hide\'):void(0))"><span class="k-icon k-i-check"></span></button>';
1909
- else
1910
- template = '<button id="#BUTTONID#" aria-label="#ARIALABELCANCEL#" type="button" class="btn btn-default btn-fab ng-binding k-button" data-component="crn-button" data-dismiss="modal"><span class="k-icon k-i-cancel"></span></button>'
1911
- template = template
1912
- .split('#BUTTONID#').join(buttonId)
1913
- .split('#FUNCTIONCALL#').join(functionToCall)
1914
- .split('#DATASOURCENAME#').join(datasourceName)
1915
- .split('#ARIALABELSAVE#').join($translate.instant('SaveChanges'))
1916
- .split('#ARIALABELCANCEL#').join($translate.instant('CancelChanges'))
1917
- .split('#MODALID#').join(modalId);
1918
-
1919
- var waitRender = setInterval(function() {
1920
- if ($('#' + buttonId).length > 0) {
1921
- scope.safeApply(function() {
1922
- var x = angular.element($('#' + buttonId ));
1923
- $compile(x)(scope);
1924
1883
  clearInterval(waitRender);
1925
- });
1926
- }
1927
- },200);
1884
+ }
1885
+ }.bind(this),200);
1928
1886
 
1929
- return template;
1930
- };
1931
- buttonCall = compileTemplateAngular(buttonType, functionToCall, datasourceName, modalId);
1932
- return buttonCall;
1933
- },
1934
- addButtonsInModal: function(modal, datasourceName, scope) {
1935
- var $footerModal = $('#' + modal).find('.modal-footer');
1936
- if (!$footerModal.find('.grid-save-button-modal').length) {
1937
- var functionToCall = datasourceName + '.post();'
1938
- var buttonSave = this.generateModalSaveOrCancelButtonCall('save', functionToCall, datasourceName, modal, scope);
1939
- $footerModal.append(buttonSave);
1940
- var buttonCancel = this.generateModalSaveOrCancelButtonCall('cancel', null, null, null, scope);
1941
- $footerModal.append(buttonCancel);
1942
- }
1943
- },
1944
- getObjectId: function(obj) {
1945
- if (!obj)
1946
- obj = "";
1947
- else if (obj instanceof Date) {
1948
- var momentDate = moment.utc(obj);
1949
- obj = new Date(momentDate.format('YYYY-MM-DDTHH:mm:ss'));
1950
- }
1951
- else if (typeof obj === 'object') {
1952
- //Verifica se tem id, senão pega o primeiro campo
1953
- if (obj["id"])
1954
- obj = obj["id"];
1955
- else {
1956
- for (var key in obj) {
1957
- obj = obj[key];
1958
- break;
1959
- }
1960
- }
1961
- }
1962
- return obj;
1963
- },
1964
- encodeHTML: function(value){
1965
- return value.replace(/&/g, '&amp;')
1966
- .replace(/</g, '&lt;')
1967
- .replace(/>/g, '&gt;')
1968
- .replace(/"/g, '&quot;')
1969
- .replace(/'/g, '&apos;');
1970
- },
1971
- decodeHTML: function(value){
1972
- return value.replace(/&apos;/g, "'")
1973
- .replace(/&quot;/g, '"')
1974
- .replace(/&gt;/g, '>')
1975
- .replace(/&lt;/g, '<')
1976
- .replace(/&amp;/g, '&');
1977
- },
1978
- getColumnByField: function(options, fieldName) {
1979
- var selected = null;
1980
- options.columns.forEach(function(column) {
1981
- if (column.field == fieldName)
1982
- selected = column;
1983
- });
1984
- return selected;
1985
- },
1887
+ return template;
1888
+ }.bind(this);
1986
1889
 
1987
- resizeGridUsingWidthForDevice: function(grid){
1988
- for (let idx = 0; idx < grid.columns.length; idx++) {
1989
- let widthDevice = this.getWidthForDevice(grid.columns[idx]);
1990
- grid.columns[idx].width = widthDevice.width;
1991
- if (!widthDevice.visible)
1992
- grid.hideColumn(idx);
1890
+ var call = '';
1891
+ if (toolbarButton.type == 'Customized')
1892
+ call = toolbarButton.execute;
1893
+ else if (toolbarButton.methodCall)
1894
+ call = toolbarButton.methodCall;
1993
1895
  else
1994
- grid.showColumn(idx);
1995
- }
1996
- if (grid.options.hasSecurity) {
1997
- let $lastCol = $(grid.element.find('col')).last();
1998
- $lastCol.css('width','0px');
1999
- }
2000
- },
1896
+ call = generateBlocklyCall(toolbarButton.blocklyInfo);
2001
1897
 
2002
- getWidthForDevice: function(column) {
2003
- let widthDeviceBig = 1210;
2004
- let widthDeviceDesktop = 1002;
2005
- let widthDeviceMedium = 778;
2006
- let widthDeviceSmall = 424;
1898
+ var title = toolbarButton.title == undefined ? '': toolbarButton.title;
1899
+ buttonCall = generateObjTemplate(call, title, toolbarButton.iconClass);
1900
+ return buttonCall;
1901
+ },
1902
+ generateModalSaveOrCancelButtonCall: function(buttonType, functionToCall, datasourceName, modalId, scope) {
1903
+
1904
+ var buttonId = app.common.generateId();
1905
+ var compileTemplateAngular = function(buttonType, functionToCall, datasourceName, modalId) {
1906
+ var template;
1907
+ if (buttonType == 'save')
1908
+ template = '<button id="#BUTTONID#" aria-label="#ARIALABELSAVE#" class="btn btn-primary btn-fab ng-binding grid-save-button-modal k-button" data-component="crn-button" ng-click="#FUNCTIONCALL#" onclick="(!#DATASOURCENAME#.missingRequiredField(true)?$(\'##MODALID#\').modal(\'hide\'):void(0))"><span class="k-icon k-i-check"></span></button>';
1909
+ else
1910
+ template = '<button id="#BUTTONID#" aria-label="#ARIALABELCANCEL#" type="button" class="btn btn-default btn-fab ng-binding k-button" data-component="crn-button" data-dismiss="modal"><span class="k-icon k-i-cancel"></span></button>'
1911
+ template = template
1912
+ .split('#BUTTONID#').join(buttonId)
1913
+ .split('#FUNCTIONCALL#').join(functionToCall)
1914
+ .split('#DATASOURCENAME#').join(datasourceName)
1915
+ .split('#ARIALABELSAVE#').join($translate.instant('SaveChanges'))
1916
+ .split('#ARIALABELCANCEL#').join($translate.instant('CancelChanges'))
1917
+ .split('#MODALID#').join(modalId);
2007
1918
 
2008
- let currentWindowWidth = $(window).width();
1919
+ var waitRender = setInterval(function() {
1920
+ if ($('#' + buttonId).length > 0) {
1921
+ scope.safeApply(function() {
1922
+ var x = angular.element($('#' + buttonId ));
1923
+ $compile(x)(scope);
1924
+ clearInterval(waitRender);
1925
+ });
1926
+ }
1927
+ },200);
2009
1928
 
2010
- let getDevice = function(device) {
2011
- let wd;
2012
- column.widthDevices.forEach( d => {
2013
- if (d.device === device)
2014
- wd = d;
1929
+ return template;
1930
+ };
1931
+ buttonCall = compileTemplateAngular(buttonType, functionToCall, datasourceName, modalId);
1932
+ return buttonCall;
1933
+ },
1934
+ addButtonsInModal: function(modal, datasourceName, scope) {
1935
+ var $footerModal = $('#' + modal).find('.modal-footer');
1936
+ if (!$footerModal.find('.grid-save-button-modal').length) {
1937
+ var functionToCall = datasourceName + '.post();'
1938
+ var buttonSave = this.generateModalSaveOrCancelButtonCall('save', functionToCall, datasourceName, modal, scope);
1939
+ $footerModal.append(buttonSave);
1940
+ var buttonCancel = this.generateModalSaveOrCancelButtonCall('cancel', null, null, null, scope);
1941
+ $footerModal.append(buttonCancel);
1942
+ }
1943
+ },
1944
+ getObjectId: function(obj) {
1945
+ if (!obj)
1946
+ obj = "";
1947
+ else if (obj instanceof Date) {
1948
+ var momentDate = moment.utc(obj);
1949
+ obj = new Date(momentDate.format('YYYY-MM-DDTHH:mm:ss'));
1950
+ }
1951
+ else if (typeof obj === 'object') {
1952
+ //Verifica se tem id, senão pega o primeiro campo
1953
+ if (obj["id"])
1954
+ obj = obj["id"];
1955
+ else {
1956
+ for (var key in obj) {
1957
+ obj = obj[key];
1958
+ break;
1959
+ }
1960
+ }
1961
+ }
1962
+ return obj;
1963
+ },
1964
+ encodeHTML: function(value){
1965
+ return value.replace(/&/g, '&amp;')
1966
+ .replace(/</g, '&lt;')
1967
+ .replace(/>/g, '&gt;')
1968
+ .replace(/"/g, '&quot;')
1969
+ .replace(/'/g, '&apos;');
1970
+ },
1971
+ decodeHTML: function(value){
1972
+ return value.replace(/&apos;/g, "'")
1973
+ .replace(/&quot;/g, '"')
1974
+ .replace(/&gt;/g, '>')
1975
+ .replace(/&lt;/g, '<')
1976
+ .replace(/&amp;/g, '&');
1977
+ },
1978
+ getColumnByField: function(options, fieldName) {
1979
+ var selected = null;
1980
+ options.columns.forEach(function(column) {
1981
+ if (column.field == fieldName)
1982
+ selected = column;
2015
1983
  });
1984
+ return selected;
1985
+ },
2016
1986
 
2017
- //Se não tiver definido o width para determinada resolução procura a proxima acima, se n tiver acima, pega a que existir
2018
- if (wd === undefined) {
2019
- if (device === "deviceSmall")
2020
- wd = getDevice("deviceMedium");
2021
- else if (device === "deviceMedium")
2022
- wd = getDevice("deviceDesktop");
2023
- else if (device === "deviceDesktop")
2024
- wd = getDevice("deviceBig");
1987
+ resizeGridUsingWidthForDevice: function(grid){
1988
+ for (let idx = 0; idx < grid.columns.length; idx++) {
1989
+ let widthDevice = this.getWidthForDevice(grid.columns[idx]);
1990
+ grid.columns[idx].width = widthDevice.width;
1991
+ if (!widthDevice.visible)
1992
+ grid.hideColumn(idx);
2025
1993
  else
2026
- wd = column.widthDevices[0];
1994
+ grid.showColumn(idx);
2027
1995
  }
2028
- return wd;
2029
- };
1996
+ if (grid.options.hasSecurity) {
1997
+ let $lastCol = $(grid.element.find('col')).last();
1998
+ $lastCol.css('width','0px');
1999
+ }
2000
+ },
2001
+
2002
+ getWidthForDevice: function(column) {
2003
+ let widthDeviceBig = 1210;
2004
+ let widthDeviceDesktop = 1002;
2005
+ let widthDeviceMedium = 778;
2006
+ let widthDeviceSmall = 424;
2030
2007
 
2008
+ let currentWindowWidth = $(window).width();
2009
+
2010
+ let getDevice = function(device) {
2011
+ let wd;
2012
+ column.widthDevices.forEach( d => {
2013
+ if (d.device === device)
2014
+ wd = d;
2015
+ });
2016
+
2017
+ //Se não tiver definido o width para determinada resolução procura a proxima acima, se n tiver acima, pega a que existir
2018
+ if (wd === undefined) {
2019
+ if (device === "deviceSmall")
2020
+ wd = getDevice("deviceMedium");
2021
+ else if (device === "deviceMedium")
2022
+ wd = getDevice("deviceDesktop");
2023
+ else if (device === "deviceDesktop")
2024
+ wd = getDevice("deviceBig");
2025
+ else
2026
+ wd = column.widthDevices[0];
2027
+ }
2028
+ return wd;
2029
+ };
2031
2030
 
2032
- let widthDevice = { width: column.width };
2033
- if (column.visible !== undefined && column.visible !== null)
2034
- widthDevice.visible = column.visible;
2035
- else
2036
- widthDevice.visible = !column.hidden;
2037
2031
 
2038
- if (column.widthDevices !== null && column.widthDevices !== undefined && column.widthDevices.length > 0) {
2039
- if (currentWindowWidth >= widthDeviceBig)
2040
- widthDevice = getDevice("deviceBig");
2041
- else if (currentWindowWidth >= widthDeviceDesktop && currentWindowWidth < widthDeviceBig)
2042
- widthDevice = getDevice("deviceDesktop");
2043
- else if (currentWindowWidth >= widthDeviceMedium && currentWindowWidth < widthDeviceDesktop)
2044
- widthDevice = getDevice("deviceMedium");
2032
+ let widthDevice = { width: column.width };
2033
+ if (column.visible !== undefined && column.visible !== null)
2034
+ widthDevice.visible = column.visible;
2045
2035
  else
2046
- widthDevice = getDevice("deviceSmall");
2047
- }
2048
- return widthDevice;
2049
- },
2036
+ widthDevice.visible = !column.hidden;
2037
+
2038
+ if (column.widthDevices !== null && column.widthDevices !== undefined && column.widthDevices.length > 0) {
2039
+ if (currentWindowWidth >= widthDeviceBig)
2040
+ widthDevice = getDevice("deviceBig");
2041
+ else if (currentWindowWidth >= widthDeviceDesktop && currentWindowWidth < widthDeviceBig)
2042
+ widthDevice = getDevice("deviceDesktop");
2043
+ else if (currentWindowWidth >= widthDeviceMedium && currentWindowWidth < widthDeviceDesktop)
2044
+ widthDevice = getDevice("deviceMedium");
2045
+ else
2046
+ widthDevice = getDevice("deviceSmall");
2047
+ }
2048
+ return widthDevice;
2049
+ },
2050
2050
 
2051
- getColumns: function(options, datasource, scope, tooltips) {
2052
- var helperDirective = this;
2051
+ getColumns: function(options, datasource, scope, tooltips) {
2052
+ var helperDirective = this;
2053
2053
 
2054
- function getTemplate(column) {
2055
- var template = "#=showTreatedValue("+column.field+")#";
2056
- if (column.inputType == 'switch') {
2057
- template =
2058
- '<span class="k-switch km-switch k-widget km-widget k-switch-off km-switch-off" style="width: 100%">\
2059
- <span class="k-switch-wrapper km-switch-wrapper">\
2060
- <span class="k-switch-background km-switch-background" style="margin-left: #=' + column.field + ' ? "80%": "0%" #"></span>\
2054
+ function getTemplate(column) {
2055
+ var template = "#=showTreatedValue("+column.field+")#";
2056
+ if (column.inputType == 'switch') {
2057
+ template =
2058
+ '<span class="k-switch km-switch k-widget km-widget k-switch-off km-switch-off" style="width: 100%">\
2059
+ <span class="k-switch-wrapper km-switch-wrapper">\
2060
+ <span class="k-switch-background km-switch-background" style="margin-left: #=' + column.field + ' ? "80%": "0%" #"></span>\
2061
2061
  </span>\
2062
2062
  <span class="k-switch-container km-switch-container">\
2063
2063
  <span class="k-switch-handle km-switch-handle" style=#=' + column.field + ' ? "float:right;margin-right:-1px": "margin-left:0%" #>\
2064
2064
  </span>\
2065
2065
  </span>\
2066
2066
  </span>';
2067
- }
2068
- else if (column.inputType == 'checkbox' || column.type == 'boolean') {
2069
- template = "<input crn-set-indeterminate=#=" + column.field + "# type='checkbox' class='k-checkbox' #=" + column.field + " ? \"checked='checked'\": '' # />" +
2070
- "<label class='k-checkbox-label k-no-text'></label>"
2071
- }
2072
- else if (column.displayField && column.displayField.length > 0) {
2073
- if (hasMask(column.type) || (column.format && column.format != 'null')) {
2074
- template = "#= useMask("+column.displayField+",'"+column.format+"','"+column.type+"') #";
2075
2067
  }
2076
- else {
2077
- template = "#="+column.displayField+"#";
2068
+ else if (column.inputType == 'checkbox' || column.type == 'boolean') {
2069
+ template = "<input crn-set-indeterminate=#=" + column.field + "# type='checkbox' class='k-checkbox' #=" + column.field + " ? \"checked='checked'\": '' # />" +
2070
+ "<label class='k-checkbox-label k-no-text'></label>"
2078
2071
  }
2072
+ else if (column.displayField && column.displayField.length > 0) {
2073
+ if (hasMask(column.type) || (column.format && column.format != 'null')) {
2074
+ template = "#= useMask("+column.displayField+",'"+column.format+"','"+column.type+"') #";
2075
+ }
2076
+ else {
2077
+ template = "#="+column.displayField+"#";
2078
+ }
2079
+ }
2080
+ else if (hasMask(column.type) || (column.format && column.format != 'null') ) {
2081
+ template = "#= useMask("+column.field+",'"+column.format+"','"+column.type+"') #";
2082
+ }
2083
+ else if (column.showAsImage) {
2084
+ template = column.showAsImageTemplate ? column.showAsImageTemplate : "<img src='#:${column.field}#'/>";
2085
+ template = eval('`' + template + '`');
2086
+ }
2087
+ return template;
2079
2088
  }
2080
- else if (hasMask(column.type) || (column.format && column.format != 'null') ) {
2081
- template = "#= useMask("+column.field+",'"+column.format+"','"+column.type+"') #";
2082
- }
2083
- else if (column.showAsImage) {
2084
- template = column.showAsImageTemplate ? column.showAsImageTemplate : "<img src='#:${column.field}#'/>";
2085
- template = eval('`' + template + '`');
2089
+
2090
+ function hasMask(type){
2091
+ if(type && (typeof type === "string")){
2092
+ return (type.startsWith('date') || type.startsWith('month')
2093
+ || type.startsWith('time') || type.startsWith('week')
2094
+ || type.startsWith('money') || type.startsWith('number')
2095
+ || type.startsWith('tel') || type.startsWith('integer'));
2096
+ }else{
2097
+ return false;
2098
+ }
2086
2099
  }
2087
- return template;
2088
- }
2089
2100
 
2090
- function hasMask(type){
2091
- if(type && (typeof type === "string")){
2092
- return (type.startsWith('date') || type.startsWith('month')
2093
- || type.startsWith('time') || type.startsWith('week')
2094
- || type.startsWith('money') || type.startsWith('number')
2095
- || type.startsWith('tel') || type.startsWith('integer'));
2096
- }else{
2097
- return false;
2101
+ function getFormat(column) {
2102
+ if (!hasMask(column.type))
2103
+ return column.format;
2104
+ return undefined;
2098
2105
  }
2099
- }
2100
2106
 
2101
- function getFormat(column) {
2102
- if (!hasMask(column.type))
2103
- return column.format;
2104
- return undefined;
2105
- }
2107
+ function isRequired(fieldName) {
2108
+ var required = false;
2109
+ var selected = null;
2110
+ if (datasource.schema.model.fields[fieldName]){
2111
+ selected = datasource.schema.model.fields[fieldName];
2112
+ }
2113
+ if (selected)
2114
+ required = !selected.nullable;
2115
+ return required;
2116
+ }
2106
2117
 
2107
- function isRequired(fieldName) {
2108
- var required = false;
2109
- var selected = null;
2110
- if (datasource.schema.model.fields[fieldName]){
2111
- selected = datasource.schema.model.fields[fieldName];
2118
+ function getEditor(column) {
2119
+ return editor.bind(this);
2112
2120
  }
2113
- if (selected)
2114
- required = !selected.nullable;
2115
- return required;
2116
- }
2117
2121
 
2118
- function getEditor(column) {
2119
- return editor.bind(this);
2120
- }
2122
+ async function editor(container, opt) {
2121
2123
 
2122
- async function editor(container, opt) {
2124
+ let compileAfterRender = (componentId) => {
2125
+ return new Promise((resolve, reject) => {
2126
+ let waitRender = setInterval(function() {
2127
+ let $myElement = $('#' + componentId);
2128
+ if ($myElement.length > 0) {
2129
+ var x = angular.element($myElement);
2130
+ $compile(x)(scope);
2131
+ clearInterval(waitRender);
2132
+ resolve(componentId);
2133
+ }
2134
+ },10);
2135
+ });
2136
+ };
2123
2137
 
2124
- var column = this.getColumnByField(options, opt.field);
2125
- if (column.visibleCrud != undefined && !column.visibleCrud) {
2126
- container.parent().find('.k-edit-label [for='+ column.field +']').parent().remove();
2127
- container.remove();
2128
- }
2129
- var required = isRequired(opt.field) ? "required" : "";
2130
- var buttonId = app.common.generateId();
2131
- var $input = $('<input '+required+' name="' + opt.field + '" id="' + buttonId + '"from-grid=true />');
2132
- if (column.inputType == 'dynamicComboBox' || column.inputType == 'comboBox') {
2133
- var kendoConfig = app.kendoHelper.getConfigComboboxSync(column.comboboxOptions, scope);
2134
- kendoConfig.autoBind = true;
2135
- kendoConfig.optionLabel = undefined;
2136
- if (column.displayField) {
2137
- kendoConfig.change = function(e) {
2138
- opt.model.set(column.displayField, this.text());
2138
+ let changeGridModel = (value) => {
2139
+ if (value !== opt.model[opt.field]) {
2140
+ opt.model[opt.field] = value;
2139
2141
  opt.model.dirty = true;
2140
- opt.model.dirtyFields[column.displayField] = true;
2142
+ opt.model.dirtyFields[opt.field] = true;
2141
2143
  }
2142
- }
2143
- $input.appendTo(container).kendoDropDownList(kendoConfig, scope);
2144
- }
2145
- else if (column.inputType == 'slider') {
2146
- var kendoConfig = app.kendoHelper.getConfigSlider(column.sliderOptions);
2147
- $input.appendTo(container).kendoSlider(kendoConfig, scope);
2148
- }
2149
- else if (column.inputType == 'switch') {
2150
- var kendoConfig = app.kendoHelper.getConfigSwitch(column.switchOptions);
2151
- $input.appendTo(container).kendoMobileSwitch(kendoConfig, scope);
2152
- }
2153
- else if (column.inputType == 'checkbox' || column.type == 'boolean') {
2154
- var guid = app.common.generateId();
2155
- $input = $('<input id="'+guid+'" name="' + opt.field + '" class="k-checkbox" type="checkbox" ><label class="k-checkbox-label" for="'+guid+'"></label>');
2156
- $input.appendTo(container);
2157
- }
2158
- else if (column.inputType == 'date') {
2159
- $input.attr('cron-date', '');
2160
- $input.attr('options', JSON.stringify(column.dateOptions));
2161
- $input.data('initial-date', opt.model[opt.field]);
2162
- $input.appendTo(container).off('change');
2163
- var waitRender = setInterval(function() {
2164
- if ($('#' + buttonId).length > 0) {
2165
- var x = angular.element($('#' + buttonId ));
2166
- $compile(x)(scope);
2167
- clearInterval(waitRender);
2168
-
2169
- $('#' + buttonId).on('change', function() {
2170
- setTimeout(function() {
2171
- opt.model[opt.field] = $('#' + buttonId ).data('rawvalue');
2172
- opt.model.dirty = true;
2173
- opt.model.dirtyFields[opt.field] = true;
2174
- }.bind(this));
2144
+ };
2175
2145
 
2176
- });
2146
+ var column = this.getColumnByField(options, opt.field);
2147
+ if (column.visibleCrud != undefined && !column.visibleCrud) {
2148
+ container.parent().find('.k-edit-label [for='+ column.field +']').parent().remove();
2149
+ container.remove();
2150
+ }
2151
+ var required = isRequired(opt.field) ? "required" : "";
2152
+ var buttonId = app.common.generateId();
2153
+
2154
+ let ngModel = `${options.dataSourceScreen.name}.active.${opt.field}`;
2155
+ var $input = $(`<input ${required} name="${opt.field}" id="${buttonId}" from-grid=true ng-model="${ngModel}" />`); //
2156
+ $input.data('change-grid-model', changeGridModel);
2157
+ $input.data('column-type', column.type);
2158
+
2159
+ if (column.inputType == 'dynamicComboBox' || column.inputType == 'comboBox') {
2160
+ var kendoConfig = app.kendoHelper.getConfigComboboxSync(column.comboboxOptions, scope);
2161
+ kendoConfig.autoBind = true;
2162
+ kendoConfig.optionLabel = undefined;
2163
+ if (column.displayField) {
2164
+ kendoConfig.change = function(e) {
2165
+ opt.model.set(column.displayField, this.text());
2166
+ opt.model.dirty = true;
2167
+ opt.model.dirtyFields[column.displayField] = true;
2168
+ }
2177
2169
  }
2178
- },10);
2179
- }
2180
- else {
2181
- $input.attr('type', column.type);
2182
- $input.attr('mask', column.format ? column.format : '');
2183
- if (column.format === '999.999.999-99;0' || column.format === '99.999.999/9999-99;0') {
2184
- $input.attr('valid', column.format === '999.999.999-99;0' ? 'cpf' : 'cnpj');
2185
- $input.attr('data-' + column.field.toLocaleLowerCase() + 'validation-msg', $translate.instant('invalid.' + $input.attr('valid')));
2170
+ let dropdown = $input.appendTo(container).kendoDropDownList(kendoConfig, scope).data('kendoDropDownList');
2171
+ $input.data('kendoDropDownList', dropdown);
2172
+ }
2173
+ else if (column.inputType == 'slider') {
2174
+ var kendoConfig = app.kendoHelper.getConfigSlider(column.sliderOptions);
2175
+ kendoConfig.change = (e) => scope.$apply(() => scope.$eval(`${ngModel}=${e.value}`));
2176
+ let slider = $input.appendTo(container).kendoSlider(kendoConfig, scope).data('kendoSlider');
2177
+ $input.data('kendoSlider', slider);
2178
+ }
2179
+ else if (column.inputType == 'switch') {
2180
+ var kendoConfig = app.kendoHelper.getConfigSwitch(column.switchOptions);
2181
+ $input.appendTo(container).kendoMobileSwitch(kendoConfig, scope);
2182
+ }
2183
+ else if (column.inputType == 'checkbox' || column.type == 'boolean') {
2184
+ $input = $(`<input id="${buttonId}" name="${opt.field}" ng-false-value="false" ng-true-value="true" crn-allow-null-values="${!required}" class="k-checkbox" type="checkbox" from-grid=true ng-model="${ngModel}"><label class="k-checkbox-label" for="${buttonId}"></label>`);
2185
+ $input.data('change-grid-model', changeGridModel);
2186
+ $input.appendTo(container);
2187
+ }
2188
+ else if (column.inputType == 'date') {
2189
+ $input.attr('cron-date', '');
2190
+ $input.attr('options', JSON.stringify(column.dateOptions));
2191
+ $input.data('initial-date', opt.model[opt.field]);
2192
+ $input.attr('type', "datetime");
2193
+ $input.appendTo(container).off('change');
2186
2194
  }
2187
- $input.attr('class', 'k-input k-textbox');
2188
- $input.data('initial-value', opt.model[opt.field]);
2189
- $input.appendTo(container);
2190
-
2191
- var waitRender = setInterval(function() {
2192
- let myElement = $('#' + buttonId);
2193
- if (myElement.length > 0) {
2194
- myElement.off('change');
2195
- myElement.on('change', function() {
2196
- let rawValue = myElement.data('rawvalue');
2197
- let value = myElement.val();
2198
- opt.model[opt.field] = rawValue || value;
2199
- opt.model.dirty = true;
2200
- opt.model.dirtyFields[opt.field] = true;
2201
- });
2202
-
2203
- var x = angular.element(myElement);
2204
- $compile(x)(scope);
2205
- clearInterval(waitRender);
2195
+ else {
2196
+ $input.attr('type', column.type);
2197
+ $input.attr('mask', column.format ? column.format : '');
2198
+ if (column.format === '999.999.999-99;0' || column.format === '99.999.999/9999-99;0') {
2199
+ $input.attr('valid', column.format === '999.999.999-99;0' ? 'cpf' : 'cnpj');
2200
+ $input.attr('data-' + column.field.toLocaleLowerCase() + 'validation-msg', $translate.instant('invalid.' + $input.attr('valid')));
2206
2201
  }
2207
- },10);
2208
- }
2209
-
2210
- }
2202
+ $input.css('text-align', column.alignment);
2203
+ $input.attr('class', 'k-input k-textbox');
2204
+ $input.data('initial-value', opt.model[opt.field]);
2205
+ $input.appendTo(container);
2206
+ }
2211
2207
 
2212
- function getCommandForEditButtonDatabase(opt, command) {
2213
- var cmd;
2214
- let idForCommand = app.common.generateId();
2215
- let ariaLabel = $translate.instant('Edit');
2216
- let template = `<a href class='k-button k-grid-edit k-grid-${idForCommand}' aria-label='${ariaLabel}'><span class='k-icon k-i-edit'></span></a>`;
2217
- if ((opt.editable == 'popupCustom') || (opt.editable == 'datasource')) {
2218
- cmd = {
2219
- name: idForCommand,
2220
- template: template,
2221
- click: function(e) {
2222
- e.preventDefault();
2223
- var tr = $(e.target).closest("tr");
2224
- var grid = tr.closest('table');
2225
- var item = this.dataItem(tr);
2226
- var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2227
- scope.safeApply(function() {
2228
- if (!options.hideModalButtons) {
2229
- helperDirective.addButtonsInModal(options.popupEdit, cronappDatasource.name, scope);
2230
- }
2208
+ compileAfterRender(buttonId).then((resultId) => {
2209
+ $(`#${resultId}`).data('alreadycompiled', true);
2210
+ $(`#${resultId}`).data('$compile', $compile);
2211
+ $(`#${resultId}`).data('ref-component', options.refComponent)
2212
+ });
2231
2213
 
2232
- var currentItem = cronappDatasource.goTo(item);
2233
- cronappDatasource.startEditing(currentItem, function(xxx) {});
2234
- if (opt.editable != 'datasource') {
2235
- cronapi.screen.showModal(options.popupEdit);
2236
- }
2237
- else {
2238
- cronapi.internal.focusFormInput();
2239
- }
2240
- });
2241
- return;
2242
- }
2243
- };
2244
- }
2245
- else {
2246
- cmd = {
2247
- name: command,
2248
- template: template,
2249
- text: { edit: " ", update: " ", cancel: " " },
2250
- };
2251
2214
  }
2252
- return cmd;
2253
- }
2254
2215
 
2255
- function getCommandForRemoveButtonDatabase(opt, command) {
2256
- var cmd;
2257
- let idForCommand = app.common.generateId();
2258
- let ariaLabel = $translate.instant('Remove');
2259
- let template = `<a href class='k-button k-grid-delete k-grid-${idForCommand}' aria-label='${ariaLabel}'><span class='k-icon k-i-close'></span></a>`;
2260
-
2261
- if ((opt.editable == 'popupCustom') || (opt.editable == 'datasource')) {
2262
- cmd = {
2263
- name: idForCommand,
2264
- template: template,
2265
- click: function(e) {
2266
- e.preventDefault();
2267
- var tr = $(e.target).closest("tr");
2268
- var item = this.dataItem(tr);
2269
- var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2270
- var self = this;
2271
- scope.safeApply(function() {
2272
- var currentItem = cronappDatasource.goTo(item);
2273
- cronappDatasource.remove(currentItem);
2274
- });
2275
- }
2276
- };
2277
- } else {
2278
- cmd = {
2279
- name: command,
2280
- template: template
2281
- };
2216
+ function getCommandForEditButtonDatabase(opt, command) {
2217
+ var cmd;
2218
+ let idForCommand = app.common.generateId();
2219
+ let ariaLabel = $translate.instant('Edit');
2220
+ let template = `<a href class='k-button k-grid-edit k-grid-${idForCommand}' aria-label='${ariaLabel}'><span class='k-icon k-i-edit'></span></a>`;
2221
+ if ((opt.editable == 'popupCustom') || (opt.editable == 'datasource')) {
2222
+ cmd = {
2223
+ name: idForCommand,
2224
+ template: template,
2225
+ click: function(e) {
2226
+ e.preventDefault();
2227
+ var tr = $(e.target).closest("tr");
2228
+ var grid = tr.closest('table');
2229
+ var item = this.dataItem(tr);
2230
+ var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2231
+ scope.safeApply(function() {
2232
+ if (!options.hideModalButtons) {
2233
+ helperDirective.addButtonsInModal(options.popupEdit, cronappDatasource.name, scope);
2234
+ }
2235
+
2236
+ var currentItem = cronappDatasource.goTo(item);
2237
+ cronappDatasource.startEditing(currentItem, function(xxx) {});
2238
+ if (opt.editable != 'datasource') {
2239
+ cronapi.screen.showModal(options.popupEdit);
2240
+ }
2241
+ else {
2242
+ cronapi.internal.focusFormInput();
2243
+ }
2244
+ });
2245
+ return;
2246
+ }
2247
+ };
2248
+ }
2249
+ else {
2250
+ cmd = {
2251
+ name: command,
2252
+ template: template,
2253
+ text: { edit: " ", update: " ", cancel: " " },
2254
+ };
2255
+ }
2256
+ return cmd;
2257
+ }
2258
+
2259
+ function getCommandForRemoveButtonDatabase(opt, command) {
2260
+ var cmd;
2261
+ let idForCommand = app.common.generateId();
2262
+ let ariaLabel = $translate.instant('Remove');
2263
+ let template = `<a href class='k-button k-grid-delete k-grid-${idForCommand}' aria-label='${ariaLabel}'><span class='k-icon k-i-close'></span></a>`;
2264
+
2265
+ if ((opt.editable == 'popupCustom') || (opt.editable == 'datasource')) {
2266
+ cmd = {
2267
+ name: idForCommand,
2268
+ template: template,
2269
+ click: function(e) {
2270
+ e.preventDefault();
2271
+ var tr = $(e.target).closest("tr");
2272
+ var item = this.dataItem(tr);
2273
+ var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2274
+ var self = this;
2275
+ scope.safeApply(function() {
2276
+ var currentItem = cronappDatasource.goTo(item);
2277
+ cronappDatasource.remove(currentItem);
2278
+ });
2279
+ }
2280
+ };
2281
+ } else {
2282
+ cmd = {
2283
+ name: command,
2284
+ template: template
2285
+ };
2286
+ }
2287
+ return cmd;
2282
2288
  }
2283
- return cmd;
2284
- }
2285
2289
 
2286
- function getAggregate(column) {
2287
- if (column && column.aggregates) {
2288
- var aggregates = [];
2289
- column.aggregates.forEach(function(a) {
2290
- aggregates.push(a.type);
2291
- });
2292
- if (aggregates.length > 0)
2293
- return aggregates;
2290
+ function getAggregate(column) {
2291
+ if (column && column.aggregates) {
2292
+ var aggregates = [];
2293
+ column.aggregates.forEach(function(a) {
2294
+ aggregates.push(a.type);
2295
+ });
2296
+ if (aggregates.length > 0)
2297
+ return aggregates;
2298
+ }
2299
+ return undefined;
2294
2300
  }
2295
- return undefined;
2296
- }
2297
2301
 
2298
- function getAggregateFooter(column, group) {
2299
- if (column && column.aggregates) {
2300
- var footer = [];
2301
- column.aggregates.forEach(function(a) {
2302
+ function getAggregateFooter(column, group) {
2303
+ if (column && column.aggregates) {
2304
+ var footer = [];
2305
+ column.aggregates.forEach(function(a) {
2302
2306
 
2303
- var typeForLabel = '#=data.' + column.field + ' ? data.' + column.field + '.' + a.type + ' : 0 #';
2304
- if (a.type == 'average' || a.type == 'sum') {
2305
- typeForLabel = "#=useMask(data." + column.field + " ? data." + column.field + "." + a.type + " : 0" + ",'" + column.format + "','" + column.type + "')#";
2306
- }
2307
+ var typeForLabel = '#=data.' + column.field + ' ? data.' + column.field + '.' + a.type + ' : 0 #';
2308
+ if (a.type == 'average' || a.type == 'sum') {
2309
+ typeForLabel = "#=useMask(data." + column.field + " ? data." + column.field + "." + a.type + " : 0" + ",'" + column.format + "','" + column.type + "')#";
2310
+ }
2307
2311
 
2308
- var typeForTemplate = group ? a.groupFooterTemplate : a.footerTemplate;
2312
+ var typeForTemplate = group ? a.groupFooterTemplate : a.footerTemplate;
2309
2313
 
2310
- if (typeForTemplate) {
2311
- typeForTemplate = typeForTemplate + ': ';
2312
- } else {
2313
- typeForTemplate = '';
2314
- }
2314
+ if (typeForTemplate) {
2315
+ typeForTemplate = typeForTemplate + ': ';
2316
+ } else {
2317
+ typeForTemplate = '';
2318
+ }
2315
2319
 
2316
- var footerTemplate = typeForTemplate + typeForLabel;
2320
+ var footerTemplate = typeForTemplate + typeForLabel;
2317
2321
 
2318
- if (column.alignment) {
2319
- // alinha o rodapé ao conteúdo quando o alinhamento selecionado for 'Direita'
2320
- if (column.alignment === 'right' && !group) {
2321
- footerTemplate = '<div style="text-align: ' + column.alignment + '" class="k-fix-margin">' + footerTemplate + '</div>';
2322
- } else {
2323
- footerTemplate = '<div style="text-align: ' + column.alignment + '">' + footerTemplate + '</div>';
2322
+ if (column.alignment) {
2323
+ // alinha o rodapé ao conteúdo quando o alinhamento selecionado for 'Direita'
2324
+ if (column.alignment === 'right' && !group) {
2325
+ footerTemplate = '<div style="text-align: ' + column.alignment + '" class="k-fix-margin">' + footerTemplate + '</div>';
2326
+ } else {
2327
+ footerTemplate = '<div style="text-align: ' + column.alignment + '">' + footerTemplate + '</div>';
2328
+ }
2324
2329
  }
2325
- }
2326
2330
 
2327
- footer.push(footerTemplate);
2328
- });
2329
- return footer.join('<br/>');
2331
+ footer.push(footerTemplate);
2332
+ });
2333
+ return footer.join('<br/>');
2334
+ }
2335
+ return undefined;
2330
2336
  }
2331
- return undefined;
2332
- }
2333
2337
 
2334
- function getAggregateHeader(column) {
2335
- if (hasMask(column.type) || (column.format && column.format != 'null')) {
2336
- return column.headerText +": #=useMask(value,'"+column.format+"','"+column.type+"')#";
2338
+ function getAggregateHeader(column) {
2339
+ if (hasMask(column.type) || (column.format && column.format != 'null')) {
2340
+ return column.headerText +": #=useMask(value,'"+column.format+"','"+column.type+"')#";
2341
+ }
2342
+ return undefined;
2337
2343
  }
2338
- return undefined;
2339
- }
2340
2344
 
2341
- function getAttributes(column) {
2342
- let attributes = {};
2343
- if (column) {
2344
- if (column.alignment) {
2345
- attributes["style"] = "text-align: " + column.alignment + ";"
2346
- }
2347
- if (column.security) {
2348
- attributes["cronapp-security"] = column.security;
2345
+ function getAttributes(column) {
2346
+ let attributes = {};
2347
+ if (column) {
2348
+ if (column.alignment) {
2349
+ attributes["style"] = "text-align: " + column.alignment + ";"
2350
+ }
2351
+ if (column.security) {
2352
+ attributes["cronapp-security"] = column.security;
2353
+ }
2349
2354
  }
2355
+ return attributes;
2350
2356
  }
2351
- return attributes;
2352
- }
2353
2357
 
2354
- var columns = [];
2355
- if (options.columns) {
2356
- options.columns.forEach(function(column) {
2357
-
2358
- let widthDevice = this.getWidthForDevice(column);
2359
-
2360
- if (column.dataType == "Database") {
2358
+ var columns = [];
2359
+ if (options.columns) {
2360
+ options.columns.forEach(function(column) {
2361
2361
 
2362
- var addColumn = {
2363
- field: column.field,
2364
- title: column.headerText,
2365
- type: column.type,
2366
- width: widthDevice.width,
2367
- sortable: column.sortable,
2368
- filterable: column.filterable,
2369
- hidden: !widthDevice.visible
2370
- };
2371
- addColumn.template = getTemplate(column);
2372
- addColumn.format = getFormat(column);
2373
- addColumn.editor = getEditor.bind(this)(column);
2374
- addColumn.aggregates = getAggregate(column);
2375
- addColumn.footerTemplate = getAggregateFooter(column, false);
2376
- addColumn.groupFooterTemplate = getAggregateFooter(column, true);
2377
- addColumn.groupHeaderTemplate = getAggregateHeader(column);
2378
- addColumn.attributes = getAttributes(column);
2379
- addColumn.headerAttributes = addColumn.attributes;
2380
- addColumn.widthDevices = column.widthDevices;
2381
- columns.push(addColumn);
2382
- }
2383
- else if (column.dataType == "Command") {
2384
- //Se não for editavel, não adiciona colunas de comando
2385
- if (options.editable != 'no') {
2386
- var command = column.command.split('|');
2362
+ let widthDevice = this.getWidthForDevice(column);
2387
2363
 
2388
- var commands = [];
2389
- command.forEach(function(f) {
2390
- var cmd;
2391
- if ( f == "edit") {
2392
- cmd = getCommandForEditButtonDatabase.bind(this)(options, f);
2393
- }
2394
- else {
2395
- cmd = getCommandForRemoveButtonDatabase.bind(this)(options, f);
2396
- }
2397
- commands.push(cmd);
2398
- }.bind(this));
2364
+ if (column.dataType == "Database") {
2399
2365
 
2400
2366
  var addColumn = {
2401
- command: commands,
2367
+ field: column.field,
2402
2368
  title: column.headerText,
2403
- width: widthDevice.width ? widthDevice.width : 155,
2404
- hidden: !widthDevice.visible,
2405
- attributes: getAttributes(column)
2369
+ type: column.type,
2370
+ width: widthDevice.width,
2371
+ sortable: column.sortable,
2372
+ filterable: column.filterable,
2373
+ hidden: !widthDevice.visible
2406
2374
  };
2375
+ addColumn.template = getTemplate(column);
2376
+ addColumn.format = getFormat(column);
2377
+ addColumn.editor = getEditor.bind(this)(column);
2378
+ addColumn.aggregates = getAggregate(column);
2379
+ addColumn.footerTemplate = getAggregateFooter(column, false);
2380
+ addColumn.groupFooterTemplate = getAggregateFooter(column, true);
2381
+ addColumn.groupHeaderTemplate = getAggregateHeader(column);
2382
+ addColumn.attributes = getAttributes(column);
2383
+ addColumn.headerAttributes = addColumn.attributes;
2384
+ addColumn.widthDevices = column.widthDevices;
2407
2385
  columns.push(addColumn);
2408
2386
  }
2409
- }
2410
- else if (column.dataType == "Blockly" || column.dataType == "Customized" || column.dataType == "CustomizedLink") {
2411
- var label = column.label == undefined ? '': column.label;
2412
- if (column.iconClass && label)
2413
- label = '&nbsp;' + label;
2387
+ else if (column.dataType == "Command") {
2388
+ //Se não for editavel, não adiciona colunas de comando
2389
+ if (options.editable != 'no') {
2390
+ var command = column.command.split('|');
2391
+
2392
+ var commands = [];
2393
+ command.forEach(function(f) {
2394
+ var cmd;
2395
+ if ( f == "edit") {
2396
+ cmd = getCommandForEditButtonDatabase.bind(this)(options, f);
2397
+ }
2398
+ else {
2399
+ cmd = getCommandForRemoveButtonDatabase.bind(this)(options, f);
2400
+ }
2401
+ commands.push(cmd);
2402
+ }.bind(this));
2414
2403
 
2415
- var className = '';
2416
- if (column.dataType == "CustomizedLink") {
2417
- className = 'k-custom-link';
2418
- }
2419
- else {
2420
- className = 'k-custom-command' + (label ? ' k-button-with-label' : '');
2404
+ var addColumn = {
2405
+ command: commands,
2406
+ title: column.headerText,
2407
+ width: widthDevice.width ? widthDevice.width : 155,
2408
+ hidden: !widthDevice.visible,
2409
+ attributes: getAttributes(column)
2410
+ };
2411
+ columns.push(addColumn);
2412
+ }
2421
2413
  }
2422
- if (column.theme)
2423
- className += ' ' + column.theme;
2414
+ else if (column.dataType == "Blockly" || column.dataType == "Customized" || column.dataType == "CustomizedLink") {
2415
+ var label = column.label == undefined ? '': column.label;
2416
+ if (column.iconClass && label)
2417
+ label = '&nbsp;' + label;
2418
+
2419
+ var className = '';
2420
+ if (column.dataType == "CustomizedLink") {
2421
+ className = 'k-custom-link';
2422
+ }
2423
+ else {
2424
+ className = 'k-custom-command' + (label ? ' k-button-with-label' : '');
2425
+ }
2426
+ if (column.theme)
2427
+ className += ' ' + column.theme;
2424
2428
 
2425
- var tooltip = '';
2426
- if (column.tooltip && column.tooltip.length)
2427
- tooltip = column.tooltip;
2429
+ var tooltip = '';
2430
+ if (column.tooltip && column.tooltip.length)
2431
+ tooltip = column.tooltip;
2428
2432
 
2429
- if (tooltip) {
2430
- var classForTooltip = app.common.generateId();
2431
- tooltips[classForTooltip] = tooltip;
2432
- className += ' ' + classForTooltip;
2433
- }
2433
+ if (tooltip) {
2434
+ var classForTooltip = app.common.generateId();
2435
+ tooltips[classForTooltip] = tooltip;
2436
+ className += ' ' + classForTooltip;
2437
+ }
2434
2438
 
2435
- let idForCommand = app.common.generateId();
2436
- let ariaLabel = tooltip || label || idForCommand;
2437
- let template = `<a href class='k-button ${className} k-grid-${idForCommand}' aria-label='${ariaLabel}'><span class='${column.iconClass}'></span>${label}</a>`;
2439
+ let idForCommand = app.common.generateId();
2440
+ let ariaLabel = tooltip || label || idForCommand;
2441
+ let template = `<a href class='k-button ${className} k-grid-${idForCommand}' aria-label='${ariaLabel}'><span class='${column.iconClass}'></span>${label}</a>`;
2438
2442
 
2439
- var addColumn = {
2440
- command: [{
2441
- name: idForCommand,
2442
- template: template,
2443
- click: function(e) {
2444
- e.preventDefault();
2445
- var tr = $(e.target).closest("tr");
2446
- var grid = tr.closest('table');
2443
+ var addColumn = {
2444
+ command: [{
2445
+ name: idForCommand,
2446
+ template: template,
2447
+ click: function(e) {
2448
+ e.preventDefault();
2449
+ var tr = $(e.target).closest("tr");
2450
+ var grid = tr.closest('table');
2451
+
2452
+ var itemAsObj = this.dataItem(tr);
2453
+ var item = this.dataItem(tr);
2454
+ var index = $(grid.find('tbody')[0]).children().index(tr)
2455
+
2456
+
2457
+ var call = undefined;
2458
+ if (column.dataType == "Customized" || column.dataType == "CustomizedLink")
2459
+ call = column.execute;
2460
+ else
2461
+ call = generateBlocklyCall(column.blocklyInfo);
2462
+
2463
+ var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2464
+ var currentGrid = options.refComponent;
2465
+ var selectedRows = [];
2466
+ currentGrid.select().each(function() {
2467
+ var gridRow = currentGrid.dataItem(this);
2468
+ cronappDatasource.data.forEach(function(dsRow) {
2469
+ if (dsRow.__$id == gridRow.__$id)
2470
+ selectedRows.push(dsRow);
2471
+ });
2472
+ });
2447
2473
 
2448
- var itemAsObj = this.dataItem(tr);
2449
- var item = this.dataItem(tr);
2450
- var index = $(grid.find('tbody')[0]).children().index(tr)
2474
+ if (!(cronappDatasource.inserting || cronappDatasource.editing)) {
2475
+ var tr = e.currentTarget.parentElement.parentElement;
2476
+ this.select(tr);
2477
+ }
2451
2478
 
2479
+ let selectedRowsKeyOrObj = [];
2480
+ if(options.fieldType && options.fieldType === 'key') {
2481
+ item = helperDirective.changeObjectField(cronappDatasource, cronappDatasource.findObjInDs(item));
2482
+ selectedRows.forEach(row => {
2483
+ selectedRowsKeyOrObj.push(helperDirective.changeObjectField(cronappDatasource, cronappDatasource.findObjInDs(row)));
2484
+ });
2485
+ }
2486
+ else {
2487
+ selectedRowsKeyOrObj = selectedRows;
2488
+ }
2452
2489
 
2453
- var call = undefined;
2454
- if (column.dataType == "Customized" || column.dataType == "CustomizedLink")
2455
- call = column.execute;
2456
- else
2457
- call = generateBlocklyCall(column.blocklyInfo);
2458
-
2459
- var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2460
- var currentGrid = options.refComponent;
2461
- var selectedRows = [];
2462
- currentGrid.select().each(function() {
2463
- var gridRow = currentGrid.dataItem(this);
2464
- cronappDatasource.data.forEach(function(dsRow) {
2465
- if (dsRow.__$id == gridRow.__$id)
2466
- selectedRows.push(dsRow);
2467
- });
2468
- });
2490
+ var consolidated = {
2491
+ item: item,
2492
+ index: index
2493
+ }
2469
2494
 
2470
- if (!(cronappDatasource.inserting || cronappDatasource.editing)) {
2471
- var tr = e.currentTarget.parentElement.parentElement;
2472
- this.select(tr);
2495
+ var contextVars = {
2496
+ 'currentData': cronappDatasource.data,
2497
+ 'datasource': cronappDatasource.copyWithoutAngularObj(),
2498
+ 'selectedIndex': index,
2499
+ 'index': index,
2500
+ 'selectedRow': item,
2501
+ 'consolidated': consolidated,
2502
+ 'item': item,
2503
+ 'selectedKeys': cronappDatasource.getKeyValues(cronappDatasource.findObjInDs(itemAsObj), true),
2504
+ 'selectedRows': selectedRowsKeyOrObj
2505
+ };
2506
+
2507
+ cronappDatasource.goTo(itemAsObj);
2508
+ scope.$eval(call, contextVars);
2509
+ return;
2473
2510
  }
2511
+ }],
2512
+ width: widthDevice.width,
2513
+ title: column.headerText ? column.headerText: '',
2514
+ hidden: !widthDevice.visible,
2515
+ attributes: getAttributes(column)
2516
+ };
2517
+ columns.push(addColumn);
2518
+ }
2519
+ else if (column.dataType == "Selectable") {
2520
+ var checkColumn = {
2521
+ selectable: true,
2522
+ attributes: getAttributes(column)
2523
+ };
2524
+ columns.push(checkColumn);
2525
+ }
2526
+ }.bind(this));
2527
+ }
2474
2528
 
2475
- let selectedRowsKeyOrObj = [];
2476
- if(options.fieldType && options.fieldType === 'key') {
2477
- item = helperDirective.changeObjectField(cronappDatasource, cronappDatasource.findObjInDs(item));
2478
- selectedRows.forEach(row => {
2479
- selectedRowsKeyOrObj.push(helperDirective.changeObjectField(cronappDatasource, cronappDatasource.findObjInDs(row)));
2480
- });
2481
- }
2482
- else {
2483
- selectedRowsKeyOrObj = selectedRows;
2484
- }
2529
+ return columns;
2530
+ },
2531
+ getPageAble: function(options) {
2532
+ var pageable = {
2533
+ refresh: options.allowRefreshGrid,
2534
+ pageSizes: options.allowSelectionTotalPageToShow,
2535
+ buttonCount: 5
2536
+ };
2485
2537
 
2486
- var consolidated = {
2487
- item: item,
2488
- index: index
2489
- }
2538
+ if (!options.allowPaging)
2539
+ pageable = options.allowPaging;
2490
2540
 
2491
- var contextVars = {
2492
- 'currentData': cronappDatasource.data,
2493
- 'datasource': cronappDatasource.copyWithoutAngularObj(),
2494
- 'selectedIndex': index,
2495
- 'index': index,
2496
- 'selectedRow': item,
2497
- 'consolidated': consolidated,
2498
- 'item': item,
2499
- 'selectedKeys': cronappDatasource.getKeyValues(cronappDatasource.findObjInDs(itemAsObj), true),
2500
- 'selectedRows': selectedRowsKeyOrObj
2501
- };
2502
-
2503
- cronappDatasource.goTo(itemAsObj);
2504
- scope.$eval(call, contextVars);
2505
- return;
2506
- }
2507
- }],
2508
- width: widthDevice.width,
2509
- title: column.headerText ? column.headerText: '',
2510
- hidden: !widthDevice.visible,
2511
- attributes: getAttributes(column)
2512
- };
2513
- columns.push(addColumn);
2514
- }
2515
- else if (column.dataType == "Selectable") {
2516
- var checkColumn = {
2517
- selectable: true,
2518
- attributes: getAttributes(column)
2519
- };
2520
- columns.push(checkColumn);
2521
- }
2522
- }.bind(this));
2523
- }
2541
+ return pageable;
2542
+ },
2543
+ getToolbar: function(options, scope) {
2524
2544
 
2525
- return columns;
2526
- },
2527
- getPageAble: function(options) {
2528
- var pageable = {
2529
- refresh: options.allowRefreshGrid,
2530
- pageSizes: options.allowSelectionTotalPageToShow,
2531
- buttonCount: 5
2532
- };
2545
+ function generateToolbarTemplate(toolbarButton) {
2546
+ let security = toolbarButton.security ? `cronapp-security="${toolbarButton.security}" class` : "class";
2547
+ if (toolbarButton.template)
2548
+ toolbarButton.template = toolbarButton.template.split("class").join(security);
2549
+ let buttonTemplate = { template: toolbarButton.template };
2550
+ return buttonTemplate;
2551
+ }
2533
2552
 
2534
- if (!options.allowPaging)
2535
- pageable = options.allowPaging;
2553
+ var toolbar = [];
2536
2554
 
2537
- return pageable;
2538
- },
2539
- getToolbar: function(options, scope) {
2540
-
2541
- function generateToolbarTemplate(toolbarButton) {
2542
- let security = toolbarButton.security ? `cronapp-security="${toolbarButton.security}" class` : "class";
2543
- if (toolbarButton.template)
2544
- toolbarButton.template = toolbarButton.template.split("class").join(security);
2545
- let buttonTemplate = { template: toolbarButton.template };
2546
- return buttonTemplate;
2547
- }
2555
+ options.toolBarButtons.forEach(function(toolbarButton) {
2556
+ if (toolbarButton.type == "Native") {
2557
+ //Se a grade for editavel, adiciona todos os commands
2558
+ if (options.editable != 'no') {
2559
+ if ((options.editable == 'datasource' || options.editable == 'popupCustom') && toolbarButton.title == 'create') {
2560
+ var datasourceName = options.dataSourceScreen.name;
2561
+ var popupInsert = options.popupInsert;
2562
+ toolbarButton.methodCall = datasourceName + ".startInserting();";
2563
+ if (options.editable == 'popupCustom') {
2564
+ toolbarButton.methodCall = toolbarButton.methodCall + " cronapi.screen.showModal('"+popupInsert+"');";
2565
+ }
2566
+ else {
2567
+ toolbarButton.methodCall += "cronapi.internal.focusFormInput();"
2568
+ }
2569
+ var button = this.generateToolbarButtonCall(toolbarButton, scope, options);
2570
+ toolbar.push(button);
2548
2571
 
2549
- var toolbar = [];
2550
-
2551
- options.toolBarButtons.forEach(function(toolbarButton) {
2552
- if (toolbarButton.type == "Native") {
2553
- //Se a grade for editavel, adiciona todos os commands
2554
- if (options.editable != 'no') {
2555
- if ((options.editable == 'datasource' || options.editable == 'popupCustom') && toolbarButton.title == 'create') {
2556
- var datasourceName = options.dataSourceScreen.name;
2557
- var popupInsert = options.popupInsert;
2558
- toolbarButton.methodCall = datasourceName + ".startInserting();";
2559
- if (options.editable == 'popupCustom') {
2560
- toolbarButton.methodCall = toolbarButton.methodCall + " cronapi.screen.showModal('"+popupInsert+"');";
2572
+ if (!options.hideModalButtons) {
2573
+ this.addButtonsInModal(popupInsert, datasourceName, scope);
2574
+ }
2561
2575
  }
2562
2576
  else {
2563
- toolbarButton.methodCall += "cronapi.internal.focusFormInput();"
2564
- }
2565
- var button = this.generateToolbarButtonCall(toolbarButton, scope, options);
2566
- toolbar.push(button);
2567
-
2568
- if (!options.hideModalButtons) {
2569
- this.addButtonsInModal(popupInsert, datasourceName, scope);
2577
+ let toolbarOp = this.generateToolbarButtonCall(toolbarButton, scope, options);
2578
+ toolbar.push(toolbarOp);
2570
2579
  }
2571
2580
  }
2581
+ //Senão, adiciona somente commands que não sejam de crud
2572
2582
  else {
2573
- let toolbarOp = this.generateToolbarButtonCall(toolbarButton, scope, options);
2574
- toolbar.push(toolbarOp);
2583
+ if (toolbarButton.title == "pdf" || toolbarButton.title == "excel") {
2584
+ toolbar.push(toolbarButton.title);
2585
+ }
2575
2586
  }
2576
2587
  }
2577
- //Senão, adiciona somente commands que não sejam de crud
2578
- else {
2579
- if (toolbarButton.title == "pdf" || toolbarButton.title == "excel") {
2580
- toolbar.push(toolbarButton.title);
2588
+ else if (toolbarButton.type == "Blockly" || toolbarButton.type == "Customized") {
2589
+ var buttonBlockly = this.generateToolbarButtonCall(toolbarButton, scope, options);
2590
+ toolbar.push(buttonBlockly);
2591
+ }
2592
+ else if (toolbarButton.type == "SaveOrCancelChanges") {
2593
+ if (options.editable != 'no') {
2594
+ var buttonSaveOrCancel = this.generateToolbarButtonCall(toolbarButton, scope, options);
2595
+ toolbar.push(buttonSaveOrCancel);
2581
2596
  }
2582
2597
  }
2583
- }
2584
- else if (toolbarButton.type == "Blockly" || toolbarButton.type == "Customized") {
2585
- var buttonBlockly = this.generateToolbarButtonCall(toolbarButton, scope, options);
2586
- toolbar.push(buttonBlockly);
2587
- }
2588
- else if (toolbarButton.type == "SaveOrCancelChanges") {
2589
- if (options.editable != 'no') {
2590
- var buttonSaveOrCancel = this.generateToolbarButtonCall(toolbarButton, scope, options);
2591
- toolbar.push(buttonSaveOrCancel);
2598
+ else if (toolbarButton.type == "Template" || toolbarButton.type == "Title") {
2599
+ let buttonTemplate = generateToolbarTemplate(toolbarButton);
2600
+ toolbar.push(buttonTemplate);
2592
2601
  }
2593
- }
2594
- else if (toolbarButton.type == "Template" || toolbarButton.type == "Title") {
2595
- let buttonTemplate = generateToolbarTemplate(toolbarButton);
2596
- toolbar.push(buttonTemplate);
2597
- }
2598
2602
 
2599
- }.bind(this));
2600
-
2601
- if (toolbar.length == 0)
2602
- toolbar = undefined;
2603
- return toolbar;
2604
- },
2605
- getEditable: function(options) {
2606
- var editable = {
2607
- mode: options.editable,
2608
- confirmation: false
2609
- };
2610
- if (options.editable == 'batch') {
2611
- editable = true;
2612
- }
2613
- else if (options.editable == 'no' || options.editable == 'popupCustom' || options.editable == 'datasource') {
2614
- editable = false;
2615
- }
2616
- return editable;
2617
- },
2618
- getTooltipsDefault: function() {
2619
- var tooltips = {
2620
- k_grid_edit : $translate.instant('Edit'),
2621
- k_grid_delete: $translate.instant('Remove'),
2622
- k_grid_update: $translate.instant('Save'),
2623
- k_grid_cancel: $translate.instant('Cancel')
2624
- };
2625
- return tooltips;
2626
- },
2627
- setTooltips: function($divContainer, tooltips) {
2628
- for (var key in tooltips) {
2629
- var classFilter = '.' + key.replace(/_/g,'-');
2630
- $divContainer.kendoTooltip({
2631
- filter: classFilter,
2632
- content: function(e){
2633
- var classKey = e.sender.options.filter.substr(1).replace(/-/g,'_');
2634
- return tooltips[classKey];
2635
- }
2636
- });
2637
- }
2638
- },
2639
- generateKendoGridInit: function(options, scope, ngModelCtrl, attrs, tooltips) {
2603
+ }.bind(this));
2640
2604
 
2641
- var helperDirective = this;
2642
- function detailInit(e) {
2643
- //Significa que está fechando o detalhe (não é para fazer nada)
2644
- if (e.masterRow.find('a').hasClass('k-i-expand')) {
2645
- collapseCurrent(this, e.detailRow, e.masterRow);
2646
- return;
2605
+ if (toolbar.length == 0)
2606
+ toolbar = undefined;
2607
+ return toolbar;
2608
+ },
2609
+ getEditable: function(options) {
2610
+ var editable = {
2611
+ mode: options.editable,
2612
+ confirmation: false
2613
+ };
2614
+ if (options.editable == 'batch') {
2615
+ editable = true;
2616
+ }
2617
+ else if (options.editable == 'no' || options.editable == 'popupCustom' || options.editable == 'datasource') {
2618
+ editable = false;
2647
2619
  }
2620
+ return editable;
2621
+ },
2622
+ getTooltipsDefault: function() {
2623
+ var tooltips = {
2624
+ k_grid_edit : $translate.instant('Edit'),
2625
+ k_grid_delete: $translate.instant('Remove'),
2626
+ k_grid_update: $translate.instant('Save'),
2627
+ k_grid_cancel: $translate.instant('Cancel')
2628
+ };
2629
+ return tooltips;
2630
+ },
2631
+ setTooltips: function($divContainer, tooltips) {
2632
+ for (var key in tooltips) {
2633
+ var classFilter = '.' + key.replace(/_/g,'-');
2634
+ $divContainer.kendoTooltip({
2635
+ filter: classFilter,
2636
+ content: function(e){
2637
+ var classKey = e.sender.options.filter.substr(1).replace(/-/g,'_');
2638
+ return tooltips[classKey];
2639
+ }
2640
+ });
2641
+ }
2642
+ },
2643
+ generateKendoGridInit: function(options, scope, ngModelCtrl, attrs, tooltips) {
2648
2644
 
2649
- var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2650
- if (!(cronappDatasource.inserting || cronappDatasource.editing)) {
2651
- if (this.selectable) {
2652
- this.select(e.masterRow);
2645
+ var helperDirective = this;
2646
+ function detailInit(e) {
2647
+ //Significa que está fechando o detalhe (não é para fazer nada)
2648
+ if (e.masterRow.find('a').hasClass('k-i-expand')) {
2649
+ collapseCurrent(this, e.detailRow, e.masterRow);
2650
+ return;
2653
2651
  }
2654
- else {
2655
- setToActiveInCronappDataSource.bind(this)(e.data);
2656
- collapseAllExcecptCurrent(this, e.detailRow, e.masterRow);
2652
+
2653
+ var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2654
+ if (!(cronappDatasource.inserting || cronappDatasource.editing)) {
2655
+ if (this.selectable) {
2656
+ this.select(e.masterRow);
2657
+ }
2658
+ else {
2659
+ setToActiveInCronappDataSource.bind(this)(e.data);
2660
+ collapseAllExcecptCurrent(this, e.detailRow, e.masterRow);
2661
+ }
2662
+ //Obtendo todos os detalhes da grade atual, fechando e removendo todos (exceto o que esta sendo aberto agora)
2663
+ e.sender.options.listCurrentOptions.forEach(function(currentOptions) {
2664
+ var currentKendoGridInit = helperDirective.generateKendoGridInit(currentOptions, scope, undefined, undefined, tooltips);
2665
+
2666
+ var $gridDiv = $("<div/>");
2667
+ var grid = $gridDiv.appendTo(e.detailCell).kendoGrid(currentKendoGridInit).data('kendoGrid');
2668
+ app.kendoHelper.receivePushData(grid);
2669
+ currentOptions.refComponent = grid;
2670
+ //Resize da tela para ajustar obter o widthDevices correto
2671
+ window.addEventListener("resize", () => { helperDirective.resizeGridUsingWidthForDevice(grid) });
2672
+
2673
+ helperDirective.setTooltips($gridDiv, tooltips);
2674
+ });
2657
2675
  }
2658
- //Obtendo todos os detalhes da grade atual, fechando e removendo todos (exceto o que esta sendo aberto agora)
2659
- e.sender.options.listCurrentOptions.forEach(function(currentOptions) {
2660
- var currentKendoGridInit = helperDirective.generateKendoGridInit(currentOptions, scope, undefined, undefined, tooltips);
2676
+ else
2677
+ collapseAllExcecptCurrent(this, null, null);
2661
2678
 
2662
- var $gridDiv = $("<div/>");
2663
- var grid = $gridDiv.appendTo(e.detailCell).kendoGrid(currentKendoGridInit).data('kendoGrid');
2664
- app.kendoHelper.receivePushData(grid);
2665
- currentOptions.refComponent = grid;
2666
- //Resize da tela para ajustar obter o widthDevices correto
2667
- window.addEventListener("resize", () => { helperDirective.resizeGridUsingWidthForDevice(grid) });
2668
2679
 
2669
- helperDirective.setTooltips($gridDiv, tooltips);
2670
- });
2671
2680
  }
2672
- else
2673
- collapseAllExcecptCurrent(this, null, null);
2674
2681
 
2682
+ var collapseAllExcecptCurrent = function(grid, trDetail, trMaster) {
2675
2683
 
2676
- }
2677
-
2678
- var collapseAllExcecptCurrent = function(grid, trDetail, trMaster) {
2679
-
2680
- var masters = grid.table.find('.k-master-row');
2681
- masters.each(function() {
2682
- if (trMaster == null || this != trMaster[0]) {
2683
- grid.collapseRow(this);
2684
- }
2685
- });
2684
+ var masters = grid.table.find('.k-master-row');
2685
+ masters.each(function() {
2686
+ if (trMaster == null || this != trMaster[0]) {
2687
+ grid.collapseRow(this);
2688
+ }
2689
+ });
2686
2690
 
2687
- var details = grid.table.find('.k-detail-row');
2688
- details.each(function() {
2689
- if (trDetail == null || this != trDetail[0]) {
2690
- $(this).remove();
2691
- }
2692
- });
2691
+ var details = grid.table.find('.k-detail-row');
2692
+ details.each(function() {
2693
+ if (trDetail == null || this != trDetail[0]) {
2694
+ $(this).remove();
2695
+ }
2696
+ });
2693
2697
 
2694
- };
2698
+ };
2695
2699
 
2696
- var collapseCurrent = function(grid, trDetail, trMaster) {
2700
+ var collapseCurrent = function(grid, trDetail, trMaster) {
2697
2701
 
2698
- var masters = grid.table.find('.k-master-row');
2699
- masters.each(function() {
2700
- if (trMaster != null || this == trMaster[0]) {
2701
- grid.collapseRow(this);
2702
- }
2703
- });
2702
+ var masters = grid.table.find('.k-master-row');
2703
+ masters.each(function() {
2704
+ if (trMaster != null || this == trMaster[0]) {
2705
+ grid.collapseRow(this);
2706
+ }
2707
+ });
2704
2708
 
2705
- var details = grid.table.find('.k-detail-row');
2706
- details.each(function() {
2707
- if (trDetail != null || this == trDetail[0]) {
2708
- $(this).remove();
2709
- }
2710
- });
2709
+ var details = grid.table.find('.k-detail-row');
2710
+ details.each(function() {
2711
+ if (trDetail != null || this == trDetail[0]) {
2712
+ $(this).remove();
2713
+ }
2714
+ });
2711
2715
 
2712
- };
2716
+ };
2713
2717
 
2714
- var setToActiveInCronappDataSource = function(item) {
2715
- var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2716
- if (!(cronappDatasource.inserting || cronappDatasource.editing))
2717
- scope.safeApply(cronappDatasource.goTo(item));
2718
- };
2718
+ var setToActiveInCronappDataSource = function(item) {
2719
+ var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2720
+ if (!(cronappDatasource.inserting || cronappDatasource.editing))
2721
+ scope.safeApply(cronappDatasource.goTo(item));
2722
+ };
2719
2723
 
2720
- var compileListing = function(e) {
2721
- if (e.sender.tbody && e.sender.tbody.length) {
2724
+ var compileListing = function(e) {
2725
+ if (e.sender.tbody && e.sender.tbody.length && !$(e.sender.tbody).find('.k-grid-edit-row').length) {
2722
2726
 
2723
- var toCompile = e.sender.tbody;
2724
- if (toCompile.parent() && toCompile.parent().parent() && toCompile.parent().parent().parent() )
2725
- toCompile = toCompile.parent().parent().parent();
2727
+ var toCompile = e.sender.tbody;
2728
+ if (toCompile.parent() && toCompile.parent().parent() && toCompile.parent().parent().parent() )
2729
+ toCompile = toCompile.parent().parent().parent();
2726
2730
 
2727
- scope.safeApply(function() {
2728
- var trs = $(toCompile);
2729
- var x = angular.element(trs);
2730
- //setTimeout apenas para sair da thread
2731
- setTimeout(()=> {
2731
+ scope.safeApply(function() {
2732
+ var trs = $(toCompile);
2733
+ var x = angular.element(trs);
2732
2734
  $compile(x)(scope);
2733
2735
  if (options.refComponent) {
2734
2736
  helperDirective.resizeGridUsingWidthForDevice(options.refComponent);
2735
2737
  }
2736
- },100);
2737
- });
2738
- }
2739
- };
2738
+ });
2739
+ }
2740
+ };
2740
2741
 
2741
- var anyFilterableColumn = function(options) {
2742
- var hasFilterableColumn = false;
2743
- if (options.columns) {
2744
- for (var i = 0; i<options.columns.length; i++) {
2745
- if (options.columns[i].dataType == "Database") {
2746
- if (options.columns[i].filterable){
2747
- hasFilterableColumn = true;
2748
- break;
2742
+ var anyFilterableColumn = function(options) {
2743
+ var hasFilterableColumn = false;
2744
+ if (options.columns) {
2745
+ for (var i = 0; i<options.columns.length; i++) {
2746
+ if (options.columns[i].dataType == "Database") {
2747
+ if (options.columns[i].filterable){
2748
+ hasFilterableColumn = true;
2749
+ break;
2750
+ }
2749
2751
  }
2750
2752
  }
2751
2753
  }
2752
- }
2753
- return hasFilterableColumn;
2754
- };
2754
+ return hasFilterableColumn;
2755
+ };
2755
2756
 
2756
- var getVisibleColumnByIdx = function(idx) {
2757
- var result;
2758
- var currIdx = 0;
2759
- options.columns.forEach(function(column) {
2760
- if (column.dataType == "Database") {
2761
- if (currIdx == idx && column.visible) {
2762
- result = column;
2757
+ var getVisibleColumnByIdx = function(idx) {
2758
+ var result;
2759
+ var currIdx = 0;
2760
+ options.columns.forEach(function(column) {
2761
+ if (column.dataType == "Database") {
2762
+ if (currIdx == idx && column.visible) {
2763
+ result = column;
2764
+ }
2765
+ if (column.visible)
2766
+ currIdx++;
2763
2767
  }
2764
- if (column.visible)
2765
- currIdx++;
2766
- }
2767
- });
2768
- return result;
2769
- };
2768
+ });
2769
+ return result;
2770
+ };
2770
2771
 
2771
- var excelExport = function(e) {
2772
- let sheet = e.workbook.sheets[0];
2773
- let regexAngular = new RegExp("\{\{(.*?)\}\}");
2774
-
2775
- for (let rowIndex = 1; rowIndex < sheet.rows.length; rowIndex++) {
2776
- let row = sheet.rows[rowIndex];
2777
- for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex ++) {
2778
-
2779
- let column = getVisibleColumnByIdx(cellIndex);
2780
- //Formata pro excel e adiciona o timezone
2781
- if (column && row.cells[cellIndex].value instanceof Date) {
2782
- let dateValue = new Date(row.cells[cellIndex].value.getTime());
2783
- dateValue.setMinutes(dateValue.getMinutes() + dateValue.getTimezoneOffset());
2784
- dateValue.setSeconds(dateValue.getSeconds());
2785
- row.cells[cellIndex].value = dateValue;
2786
- if (column.type == 'time')
2787
- row.cells[cellIndex].format = "[$-x-systime]hh:mm:ss";
2788
- else if (column.type == 'datetime')
2789
- row.cells[cellIndex].format = "dd/mm/yyyy hh:mm:ss;@";
2790
- }
2772
+ var excelExport = function(e) {
2773
+ let sheet = e.workbook.sheets[0];
2774
+ let regexAngular = new RegExp("\{\{(.*?)\}\}");
2775
+
2776
+ for (let rowIndex = 1; rowIndex < sheet.rows.length; rowIndex++) {
2777
+ let row = sheet.rows[rowIndex];
2778
+ for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex ++) {
2779
+
2780
+ let column = getVisibleColumnByIdx(cellIndex);
2781
+ //Formata pro excel e adiciona o timezone
2782
+ if (column && row.cells[cellIndex].value instanceof Date) {
2783
+ let dateValue = new Date(row.cells[cellIndex].value.getTime());
2784
+ dateValue.setMinutes(dateValue.getMinutes() + dateValue.getTimezoneOffset());
2785
+ dateValue.setSeconds(dateValue.getSeconds());
2786
+ row.cells[cellIndex].value = dateValue;
2787
+ if (column.type == 'time')
2788
+ row.cells[cellIndex].format = "[$-x-systime]hh:mm:ss";
2789
+ else if (column.type == 'datetime')
2790
+ row.cells[cellIndex].format = "dd/mm/yyyy hh:mm:ss;@";
2791
+ }
2791
2792
 
2792
- if (row.type === "footer") {
2793
- if (row.cells[cellIndex].value) {
2794
- let rawValue = row.cells[cellIndex].value;
2795
- let content = $(rawValue)[0].innerHTML;
2796
- let regexExecution = regexAngular.exec(content);
2797
- if (regexExecution && regexExecution.length > 1) {
2798
- content = content.replace(regexExecution[0],"");
2799
- let evaluatedExpression = scope.$eval(regexExecution[1]);
2800
- row.cells[cellIndex].value = `${content}${evaluatedExpression}`;
2793
+ if (row.type === "footer") {
2794
+ if (row.cells[cellIndex].value) {
2795
+ let rawValue = row.cells[cellIndex].value;
2796
+ let content = $(rawValue)[0].innerHTML;
2797
+ let regexExecution = regexAngular.exec(content);
2798
+ if (regexExecution && regexExecution.length > 1) {
2799
+ content = content.replace(regexExecution[0],"");
2800
+ let evaluatedExpression = scope.$eval(regexExecution[1]);
2801
+ row.cells[cellIndex].value = `${content}${evaluatedExpression}`;
2802
+ }
2801
2803
  }
2802
2804
  }
2803
2805
  }
2804
2806
  }
2805
- }
2806
- };
2807
+ };
2807
2808
 
2808
2809
 
2809
2810
 
2810
- var datasource = app.kendoHelper.getDataSource(options.dataSourceScreen.entityDataSource, scope, options.allowPaging, options.pageCount, options.columns, options.groupings);
2811
+ var datasource = app.kendoHelper.getDataSource(options.dataSourceScreen.entityDataSource, scope, options.allowPaging, options.pageCount, options.columns, options.groupings);
2811
2812
 
2812
- var columns = this.getColumns(options, datasource, scope, tooltips);
2813
- var pageAble = this.getPageAble(options);
2814
- var toolbar = this.getToolbar(options, scope);
2815
- var editable = this.getEditable(options);
2816
- var filterable = anyFilterableColumn(options);
2813
+ var columns = this.getColumns(options, datasource, scope, tooltips);
2814
+ var pageAble = this.getPageAble(options);
2815
+ var toolbar = this.getToolbar(options, scope);
2816
+ var editable = this.getEditable(options);
2817
+ var filterable = anyFilterableColumn(options);
2817
2818
 
2818
- var kendoGridInit = {
2819
- hasSecurity: options.columns.filter(c => c.security).length,
2820
- toolbar: toolbar,
2821
- pdf: {
2822
- allPages: true,
2823
- avoidLinks: true,
2824
- paperSize: "A4",
2825
- margin: { top: "2cm", left: "1cm", right: "1cm", bottom: "1cm" },
2826
- landscape: true,
2827
- repeatHeaders: true,
2828
- scale: 0.8
2829
- },
2830
- dataSource: datasource,
2831
- editable: editable,
2832
- height: options.height,
2833
- groupable: options.allowGrouping,
2834
- sortable: options.allowSorting,
2835
- filterable: true,
2836
- pageable: pageAble,
2837
- columns: columns,
2838
- selectable: options.allowSelectionRow,
2839
- detailInit: (options.details && options.details.length > 0) ? detailInit : undefined,
2840
- listCurrentOptions: (options.details && options.details.length > 0) ? options.details : undefined,
2841
- excelExport: excelExport,
2842
- edit: function(e) {
2843
- this.dataSource.transport.options.disableAndSelect(e);
2844
- var container = e.container;
2845
- var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2846
- if (e.model.isNew() && !e.model.dirty) {
2847
- var model = e.model;
2848
- cronappDatasource.startInserting(null, function(active) {
2849
- for (var key in active) {
2850
- if (model.fields[key]) {
2851
- if (model.fields[key].validation && model.fields[key].validation.required) {
2852
- var input = container.find("input[name='" + key + "']");
2853
- if (input.length) {
2854
- //TODO: Verificar com a telerik https://stackoverflow.com/questions/22179758/kendo-grid-using-model-set-to-update-the-value-of-required-fields-triggers-vali
2855
- input.val(active[key]).trigger('change');
2819
+ var kendoGridInit = {
2820
+ hasSecurity: options.columns.filter(c => c.security).length,
2821
+ toolbar: toolbar,
2822
+ pdf: {
2823
+ allPages: true,
2824
+ avoidLinks: true,
2825
+ paperSize: "A4",
2826
+ margin: { top: "2cm", left: "1cm", right: "1cm", bottom: "1cm" },
2827
+ landscape: true,
2828
+ repeatHeaders: true,
2829
+ scale: 0.8
2830
+ },
2831
+ dataSource: datasource,
2832
+ editable: editable,
2833
+ height: options.height,
2834
+ groupable: options.allowGrouping,
2835
+ sortable: options.allowSorting,
2836
+ filterable: true,
2837
+ pageable: pageAble,
2838
+ columns: columns,
2839
+ selectable: options.allowSelectionRow,
2840
+ detailInit: (options.details && options.details.length > 0) ? detailInit : undefined,
2841
+ listCurrentOptions: (options.details && options.details.length > 0) ? options.details : undefined,
2842
+ excelExport: excelExport,
2843
+ edit: function(e) {
2844
+ this.dataSource.transport.options.disableAndSelect(e);
2845
+ var container = e.container;
2846
+ var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2847
+ if (e.model.isNew()) {
2848
+ var model = e.model;
2849
+ cronappDatasource.startInserting(null, function(active) {
2850
+ for (var key in active) {
2851
+ if (model.fields[key]) {
2852
+ if (model.fields[key].validation && model.fields[key].validation.required) {
2853
+ var input = container.find("input[name='" + key + "']");
2854
+ if (input.length) {
2855
+ //TODO: Verificar com a telerik https://stackoverflow.com/questions/22179758/kendo-grid-using-model-set-to-update-the-value-of-required-fields-triggers-vali
2856
+ input.val(active[key]).trigger('change');
2857
+ }
2856
2858
  }
2859
+ model.set(key, active[key]);
2857
2860
  }
2858
- model.set(key, active[key]);
2859
2861
  }
2860
- }
2861
- });
2862
- }
2863
- else if (!e.model.isNew() && !e.model.dirty) {
2864
- scope.safeApply(function() {
2865
- var currentItem = cronappDatasource.goTo(e.model);
2866
- cronappDatasource.startEditing(currentItem, function(xxx) {});
2867
- });
2868
- }
2862
+ });
2863
+ }
2864
+ else if (!e.model.isNew() && !e.model.dirty) {
2865
+ scope.safeApply(function() {
2866
+ var currentItem = cronappDatasource.goTo(e.model);
2867
+ cronappDatasource.startEditing(currentItem, function(xxx) {});
2868
+ });
2869
+ }
2869
2870
 
2870
- if (attrs && attrs.ngEdit) {
2871
- scope.$eval(attrs.ngEdit);
2872
- }
2871
+ if (attrs && attrs.ngEdit) {
2872
+ scope.$eval(attrs.ngEdit);
2873
+ }
2873
2874
 
2874
- compileListing(e);
2875
- },
2876
- change: function(e) {
2877
- var item = this.dataItem(this.select());
2878
- setToActiveInCronappDataSource.bind(this)(item);
2879
- var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2880
- if(options.fieldType && options.fieldType === 'key'){
2881
- cronappDatasource.active = helperDirective.changeObjectField(cronappDatasource, cronappDatasource.active);
2882
- }
2883
- if (ngModelCtrl) {
2884
- if ("multiple" === options.allowSelectionRowType) {
2885
- let selecteds = [];
2886
- this.select().each((i, row)=> {
2887
- let item = this.dataItem(row);
2888
- let objInDs = cronappDatasource.findObjInDs(item, false);
2889
- if(options.fieldType && options.fieldType === 'key'){
2890
- objInDs = helperDirective.changeObjectField(cronappDatasource, objInDs);
2891
- }
2892
- if (objInDs !== null){
2893
- selecteds.push(objInDs);
2894
- }
2895
- });
2896
- ngModelCtrl.$setViewValue(selecteds);
2875
+ compileListing(e);
2876
+ },
2877
+ change: function(e) {
2878
+ var item = this.dataItem(this.select());
2879
+ setToActiveInCronappDataSource.bind(this)(item);
2880
+ var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2881
+ if(options.fieldType && options.fieldType === 'key'){
2882
+ cronappDatasource.active = helperDirective.changeObjectField(cronappDatasource, cronappDatasource.active);
2897
2883
  }
2898
- else{
2899
- if (item) {
2900
- ngModelCtrl.$setViewValue(cronappDatasource.active);
2884
+ if (ngModelCtrl) {
2885
+ if ("multiple" === options.allowSelectionRowType) {
2886
+ let selecteds = [];
2887
+ this.select().each((i, row)=> {
2888
+ let item = this.dataItem(row);
2889
+ let objInDs = cronappDatasource.findObjInDs(item, false);
2890
+ if(options.fieldType && options.fieldType === 'key'){
2891
+ objInDs = helperDirective.changeObjectField(cronappDatasource, objInDs);
2892
+ }
2893
+ if (objInDs !== null){
2894
+ selecteds.push(objInDs);
2895
+ }
2896
+ });
2897
+ ngModelCtrl.$setViewValue(selecteds);
2901
2898
  }
2902
- else {
2903
- ngModelCtrl.$setViewValue(null);
2899
+ else{
2900
+ if (item) {
2901
+ ngModelCtrl.$setViewValue(cronappDatasource.active);
2902
+ }
2903
+ else {
2904
+ ngModelCtrl.$setViewValue(null);
2905
+ }
2904
2906
  }
2905
2907
  }
2906
- }
2907
- collapseAllExcecptCurrent(this, this.select().next(), this.select());
2908
+ collapseAllExcecptCurrent(this, this.select().next(), this.select());
2908
2909
 
2909
- if (attrs && attrs.ngChange) {
2910
- scope.$eval(attrs.ngChange);
2911
- }
2912
-
2913
- compileListing(e);
2914
- },
2915
- cancel: function(e) {
2916
- var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2917
- scope.safeApply(cronappDatasource.cancel());
2918
- this.dataSource.transport.options.enableAndSelect(e);
2919
- setTimeout(function() {
2920
- if (attrs && attrs.ngCancel) {
2921
- scope.$eval(attrs.ngCancel);
2910
+ if (attrs && attrs.ngChange) {
2911
+ scope.$eval(attrs.ngChange);
2922
2912
  }
2923
2913
 
2924
2914
  compileListing(e);
2925
- }.bind(this));
2926
- },
2927
- dataBound: function(e) {
2928
- setTimeout(() => this.dataSource.transport.options.selectActiveInGrid(), 100);
2915
+ },
2916
+ cancel: function(e) {
2917
+ var cronappDatasource = this.dataSource.transport.options.cronappDatasource;
2918
+ scope.safeApply(cronappDatasource.cancel());
2919
+ this.dataSource.transport.options.enableAndSelect(e);
2920
+ setTimeout(function() {
2921
+ if (attrs && attrs.ngCancel) {
2922
+ scope.$eval(attrs.ngCancel);
2923
+ }
2929
2924
 
2930
- if (attrs && attrs.ngDataBound) {
2931
- scope.$eval(attrs.ngDataBound);
2932
- }
2925
+ compileListing(e);
2926
+ }.bind(this));
2927
+ },
2928
+ dataBound: function(e) {
2929
+ setTimeout(() => this.dataSource.transport.options.selectActiveInGrid(), 100);
2933
2930
 
2934
- for(let i=0;i<this.columns.length;i++){
2935
- let col = helperDirective.getColumnByField(options, this.columns[i].field);
2936
- if (col.visible)
2937
- this.showColumn(i);
2938
- }
2939
- if ($('div.k-grouping-header').length == 0) {
2940
- if (options.groupings) {
2941
- options.groupings.forEach((c) => this.hideColumn(c.field));
2931
+ if (attrs && attrs.ngDataBound) {
2932
+ scope.$eval(attrs.ngDataBound);
2942
2933
  }
2943
- }
2944
- else {
2945
- $("div.k-group-indicator").each((i,v) => {
2946
- this.hideColumn($(v).data("field"));
2934
+
2935
+ for(let i=0;i<this.columns.length;i++){
2936
+ let col = helperDirective.getColumnByField(options, this.columns[i].field);
2937
+ if (col.visible)
2938
+ this.showColumn(i);
2939
+ }
2940
+ if ($('div.k-grouping-header').length == 0) {
2941
+ if (options.groupings) {
2942
+ options.groupings.forEach((c) => this.hideColumn(c.field));
2943
+ }
2944
+ }
2945
+ else {
2946
+ $("div.k-group-indicator").each((i,v) => {
2947
+ this.hideColumn($(v).data("field"));
2948
+ });
2949
+ }
2950
+ //Colocando tabindex para poder focar - acessibilidade
2951
+ let grid = this;
2952
+ setTimeout(function() {
2953
+ if (grid.pager) {
2954
+ grid.pager.element.find("a").not(".k-state-disabled").attr("tabindex", "0");
2955
+ }
2947
2956
  });
2957
+
2958
+ compileListing(e);
2948
2959
  }
2949
- //Colocando tabindex para poder focar - acessibilidade
2950
- let grid = this;
2951
- setTimeout(function() {
2952
- if (grid.pager) {
2953
- grid.pager.element.find("a").not(".k-state-disabled").attr("tabindex", "0");
2954
- }
2955
- });
2960
+ };
2956
2961
 
2957
- compileListing(e);
2962
+ if (kendoGridInit.selectable) {
2963
+ if ("multiple" == options.allowSelectionRowType) {
2964
+ kendoGridInit.selectable = "multiple"
2965
+ }
2958
2966
  }
2959
- };
2967
+ kendoGridInit.originalSelectable = kendoGridInit.selectable;
2960
2968
 
2961
- if (kendoGridInit.selectable) {
2962
- if ("multiple" == options.allowSelectionRowType) {
2963
- kendoGridInit.selectable = "multiple"
2969
+ if (attrs && attrs.ngBeforeEdit) {
2970
+ kendoGridInit.beforeEdit = function(e) {scope.$eval(attrs.ngBeforeEdit);};
2971
+ }
2972
+ if (attrs && attrs.ngDataBinding) {
2973
+ kendoGridInit.dataBinding = function(e) {scope.$eval(attrs.ngDataBinding);};
2974
+ }
2975
+ if (attrs && attrs.ngSave) {
2976
+ kendoGridInit.save = function(e) {scope.$eval(attrs.ngSave);};
2977
+ }
2978
+ if (attrs && attrs.ngSaveChanges) {
2979
+ kendoGridInit.saveChanges = function(e) {scope.$eval(attrs.ngSaveChanges);};
2980
+ }
2981
+ if (attrs && attrs.ngRemove) {
2982
+ kendoGridInit.remove = function(e) {scope.$eval(attrs.ngRemove);};
2964
2983
  }
2965
- }
2966
- kendoGridInit.originalSelectable = kendoGridInit.selectable;
2967
2984
 
2968
- if (attrs && attrs.ngBeforeEdit) {
2969
- kendoGridInit.beforeEdit = function(e) {scope.$eval(attrs.ngBeforeEdit);};
2970
- }
2971
- if (attrs && attrs.ngDataBinding) {
2972
- kendoGridInit.dataBinding = function(e) {scope.$eval(attrs.ngDataBinding);};
2973
- }
2974
- if (attrs && attrs.ngSave) {
2975
- kendoGridInit.save = function(e) {scope.$eval(attrs.ngSave);};
2976
- }
2977
- if (attrs && attrs.ngSaveChanges) {
2978
- kendoGridInit.saveChanges = function(e) {scope.$eval(attrs.ngSaveChanges);};
2979
- }
2980
- if (attrs && attrs.ngRemove) {
2981
- kendoGridInit.remove = function(e) {scope.$eval(attrs.ngRemove);};
2982
- }
2985
+ return kendoGridInit;
2983
2986
 
2984
- return kendoGridInit;
2987
+ },
2988
+ link: function (scope, element, attrs, ngModelCtrl) {
2985
2989
 
2986
- },
2987
- link: function (scope, element, attrs, ngModelCtrl) {
2990
+ if (element.children().length)
2991
+ return;
2988
2992
 
2989
- if (element.children().length)
2990
- return;
2993
+ var $templateDyn = $('<div></div>');
2994
+ var baseUrl = 'node_modules/cronapp-lib-js/dist/js/kendo-ui/js/messages/kendo.messages.';
2995
+ if ($translate.use() == 'pt_br')
2996
+ baseUrl += "pt-BR.min.js";
2997
+ else
2998
+ baseUrl += "en-US.min.js";
2991
2999
 
2992
- var $templateDyn = $('<div></div>');
2993
- var baseUrl = 'node_modules/cronapp-lib-js/dist/js/kendo-ui/js/messages/kendo.messages.';
2994
- if ($translate.use() == 'pt_br')
2995
- baseUrl += "pt-BR.min.js";
2996
- else
2997
- baseUrl += "en-US.min.js";
2998
3000
 
3001
+ this.initCulture();
3002
+ var helperDirective = this;
3003
+ $.getScript(baseUrl, function () {
2999
3004
 
3000
- this.initCulture();
3001
- var helperDirective = this;
3002
- $.getScript(baseUrl, function () {
3005
+ var options = JSON.parse(attrs.options || "{}");
3003
3006
 
3004
- var options = JSON.parse(attrs.options || "{}");
3007
+ app.kendoHelper.getCorrectlyDS(options.dataSourceScreen.entityDataSource.name, scope).batchPost = false;
3008
+ var batchMode = options.batchMode == undefined || options.batchMode;
3009
+ if (batchMode && options.editable != 'datasource' && app.kendoHelper.getCorrectlyDS(options.dataSourceScreen.entityDataSource.name, scope) && !app.kendoHelper.getCorrectlyDS(options.dataSourceScreen.entityDataSource.name, scope).dependentLazyPost) {
3010
+ app.kendoHelper.getCorrectlyDS(options.dataSourceScreen.entityDataSource.name, scope).batchPost = true;
3005
3011
 
3006
- scope[options.dataSourceScreen.entityDataSource.name].batchPost = false;
3007
- var batchMode = options.batchMode == undefined || options.batchMode;
3008
- if (batchMode && options.editable != 'datasource' && scope[options.dataSourceScreen.entityDataSource.name] && !scope[options.dataSourceScreen.entityDataSource.name].dependentLazyPost) {
3009
- scope[options.dataSourceScreen.entityDataSource.name].batchPost = true;
3010
-
3011
- options.toolBarButtons = options.toolBarButtons || [];
3012
- options.toolBarButtons.push({
3013
- type: "SaveOrCancelChanges",
3014
- title: $translate.instant('SaveChanges'),
3015
- methodCall: options.dataSourceScreen.entityDataSource.name + ".postBatchData()",
3016
- saveButton: true
3017
- });
3018
- options.toolBarButtons.push({
3019
- type: "SaveOrCancelChanges",
3020
- title: $translate.instant('CancelChanges'),
3021
- methodCall: options.dataSourceScreen.entityDataSource.name + ".cancelBatchData()",
3022
- saveButton: false
3023
- });
3024
- }
3012
+ options.toolBarButtons = options.toolBarButtons || [];
3013
+ options.toolBarButtons.push({
3014
+ type: "SaveOrCancelChanges",
3015
+ title: $translate.instant('SaveChanges'),
3016
+ methodCall: options.dataSourceScreen.entityDataSource.name + ".postBatchData()",
3017
+ saveButton: true
3018
+ });
3019
+ options.toolBarButtons.push({
3020
+ type: "SaveOrCancelChanges",
3021
+ title: $translate.instant('CancelChanges'),
3022
+ methodCall: options.dataSourceScreen.entityDataSource.name + ".cancelBatchData()",
3023
+ saveButton: false
3024
+ });
3025
+ }
3026
+
3027
+ var tooltips = helperDirective.getTooltipsDefault();
3028
+ var kendoGridInit = helperDirective.generateKendoGridInit(options, scope, ngModelCtrl, attrs, tooltips);
3029
+ kendoGridInit.scrollable = attrs.scrollable === "true";
3030
+
3031
+ var grid = $templateDyn.kendoGrid(kendoGridInit).data('kendoGrid');
3032
+ app.kendoHelper.receivePushData(grid);
3033
+ options.refComponent = grid;
3034
+
3035
+ //Resize da tela para ajustar obter o widthDevices correto
3036
+ window.addEventListener("resize", () => { helperDirective.resizeGridUsingWidthForDevice(grid) });
3025
3037
 
3026
- var tooltips = helperDirective.getTooltipsDefault();
3027
- var kendoGridInit = helperDirective.generateKendoGridInit(options, scope, ngModelCtrl, attrs, tooltips);
3028
- kendoGridInit.scrollable = attrs.scrollable === "true";
3029
-
3030
- var grid = $templateDyn.kendoGrid(kendoGridInit).data('kendoGrid');
3031
- app.kendoHelper.receivePushData(grid);
3032
- options.refComponent = grid;
3033
-
3034
- //Resize da tela para ajustar obter o widthDevices correto
3035
- window.addEventListener("resize", () => { helperDirective.resizeGridUsingWidthForDevice(grid) });
3036
-
3037
- helperDirective.setTooltips($templateDyn, tooltips);
3038
-
3039
- scope.safeApply(function() {
3040
- if (scope[options.dataSourceScreen.entityDataSource.name]) {
3041
-
3042
- $templateDyn.find('.k-filter-row').show();
3043
- $templateDyn.find('.k-pager-sizes').show();
3044
- $templateDyn.find('.k-pager-nav').show();
3045
- $templateDyn.find('.k-pager-numbers').show();
3046
- $templateDyn.find('.k-pager-refresh.k-link').show();
3047
- $templateDyn.find('.saveorcancelchanges').hide();
3048
-
3049
- scope[options.dataSourceScreen.entityDataSource.name].addDataSourceEvents(
3050
- {
3051
- "pendingchanges": function(value) {
3052
- if (value) {
3053
- $templateDyn.find('.k-filter-row').hide();
3054
- $templateDyn.find('.k-pager-sizes').hide();
3055
- $templateDyn.find('.k-pager-nav').hide();
3056
- $templateDyn.find('.k-pager-numbers').hide();
3057
- $templateDyn.find('.k-pager-refresh.k-link').hide();
3058
- $templateDyn.find('.saveorcancelchanges').show();
3059
- } else {
3060
- $templateDyn.find('.k-filter-row').show();
3061
- $templateDyn.find('.k-pager-sizes').show();
3062
- $templateDyn.find('.k-pager-nav').show();
3063
- $templateDyn.find('.k-pager-numbers').show();
3064
- $templateDyn.find('.k-pager-refresh.k-link').show();
3065
- $templateDyn.find('.saveorcancelchanges').hide();
3038
+ helperDirective.setTooltips($templateDyn, tooltips);
3039
+
3040
+ scope.safeApply(function() {
3041
+ if (app.kendoHelper.getCorrectlyDS(options.dataSourceScreen.entityDataSource.name, scope)) {
3042
+
3043
+ $templateDyn.find('.k-filter-row').show();
3044
+ $templateDyn.find('.k-pager-sizes').show();
3045
+ $templateDyn.find('.k-pager-nav').show();
3046
+ $templateDyn.find('.k-pager-numbers').show();
3047
+ $templateDyn.find('.k-pager-refresh.k-link').show();
3048
+ $templateDyn.find('.saveorcancelchanges').hide();
3049
+
3050
+ app.kendoHelper.getCorrectlyDS(options.dataSourceScreen.entityDataSource.name, scope).addDataSourceEvents(
3051
+ {
3052
+ "pendingchanges": function(value) {
3053
+ if (value) {
3054
+ $templateDyn.find('.k-filter-row').hide();
3055
+ $templateDyn.find('.k-pager-sizes').hide();
3056
+ $templateDyn.find('.k-pager-nav').hide();
3057
+ $templateDyn.find('.k-pager-numbers').hide();
3058
+ $templateDyn.find('.k-pager-refresh.k-link').hide();
3059
+ $templateDyn.find('.saveorcancelchanges').show();
3060
+ } else {
3061
+ $templateDyn.find('.k-filter-row').show();
3062
+ $templateDyn.find('.k-pager-sizes').show();
3063
+ $templateDyn.find('.k-pager-nav').show();
3064
+ $templateDyn.find('.k-pager-numbers').show();
3065
+ $templateDyn.find('.k-pager-refresh.k-link').show();
3066
+ $templateDyn.find('.saveorcancelchanges').hide();
3067
+ }
3068
+ }
3066
3069
  }
3067
- }
3068
- }
3069
- );
3070
+ );
3071
+
3072
+ app.kendoHelper.getCorrectlyDS(options.dataSourceScreen.entityDataSource.name, scope).addDataSourceEvents(
3073
+ {
3074
+ "afterchanges": function(value) {
3075
+ //QAIBT-610
3076
+ //grid.dataSource.filter([]);
3077
+ }
3078
+ }
3079
+ );
3080
+ }
3081
+ });
3070
3082
 
3071
- scope[options.dataSourceScreen.entityDataSource.name].addDataSourceEvents(
3072
- {
3073
- "afterchanges": function(value) {
3074
- //QAIBT-610
3075
- //grid.dataSource.filter([]);
3076
- }
3077
- }
3078
- );
3079
- }
3080
3083
  });
3081
3084
 
3082
- });
3085
+ element.html($templateDyn);
3086
+ $compile($templateDyn)(element.scope());
3083
3087
 
3084
- element.html($templateDyn);
3085
- $compile($templateDyn)(element.scope());
3088
+ }
3089
+ };
3090
+ }])
3086
3091
 
3087
- }
3088
- };
3089
- }])
3090
-
3091
- .directive('src', function($compile) {
3092
- return {
3093
- restrict: 'A',
3094
- link: function(scope, element, attrs, ctrl) {
3095
- if (element[0].tagName === "IMG" ) {
3096
- if (cronapi.internal.isBase64(attrs.src) ) {
3097
- setTimeout(() => $(element[0]).attr("src", "data:image/png;base64," + attrs.src));
3092
+ .directive('src', function($compile) {
3093
+ return {
3094
+ restrict: 'A',
3095
+ link: function(scope, element, attrs, ctrl) {
3096
+ if (element[0].tagName === "IMG" ) {
3097
+ if (cronapi.internal.isBase64(attrs.src) ) {
3098
+ setTimeout(() => $(element[0]).attr("src", "data:image/png;base64," + attrs.src));
3099
+ }
3098
3100
  }
3099
3101
  }
3100
3102
  }
3101
- }
3102
- })
3103
+ })
3103
3104
 
3104
3105
  .directive('cronTreeView', ['$compile', '$translate', function($compile, $translate) {
3105
- return {
3106
- restrict: 'E',
3107
- replace: true,
3108
- require: 'ngModel',
3109
- scope: true,
3110
- getDataSource: function(options, scope, ngModelCtrl) {
3111
-
3112
- let id = options.dataSourceScreen.schema.filter(field => { return field.key === true })[0].name;
3113
- let schema = {
3114
- model: {
3115
- id: id,
3116
- hasChildren: function(item) {
3117
- return item["hasChildren"];
3118
- }
3119
- }
3120
- }
3106
+ return {
3107
+ restrict: 'E',
3108
+ replace: true,
3109
+ require: 'ngModel',
3110
+ scope: true,
3111
+ getDataSource: function(options, scope, ngModelCtrl) {
3112
+
3113
+ let id = options.dataSourceScreen.schema.filter(field => { return field.key === true })[0].name;
3114
+ let schema = {
3115
+ model: {
3116
+ id: id,
3117
+ hasChildren: function(item) {
3118
+ return item["hasChildren"];
3119
+ }
3120
+ }
3121
+ }
3121
3122
 
3122
- let getAllParent = function(cronappDatasource, item, ids, resolve, reject) {
3123
+ let getAllParent = function(cronappDatasource, item, ids, resolve, reject) {
3123
3124
 
3124
- if (item[schema.model.id])
3125
- ids.push(item[schema.model.id]);
3125
+ if (item[schema.model.id])
3126
+ ids.push(item[schema.model.id]);
3126
3127
 
3127
- let odataUrl = `${cronappDatasource.entity}?$filter=${schema.model.id} eq '${item[options.selfRelationshipField]}'&$format=json&$inlinecount=allpages`;
3128
- if (item[options.selfRelationshipField]) {
3129
- $.ajax({
3130
- url: odataUrl,
3131
- success: (itemResult) => {
3132
- getAllParent(cronappDatasource, itemResult.d.results[0], ids, resolve, reject);
3133
- },
3134
- beforeSend: (xhr) => {
3135
- if (window.uToken) {
3136
- xhr.setRequestHeader ("X-AUTH-TOKEN", window.uToken);
3137
- }
3138
- },
3139
- error: () => reject(),
3140
- type: 'GET',
3141
- });
3142
- }
3143
- else {
3144
- resolve(ids);
3145
- }
3146
- };
3128
+ let odataUrl = `${cronappDatasource.entity}?$filter=${schema.model.id} eq '${item[options.selfRelationshipField]}'&$format=json&$inlinecount=allpages`;
3129
+ if (item[options.selfRelationshipField]) {
3130
+ $.ajax({
3131
+ url: odataUrl,
3132
+ success: (itemResult) => {
3133
+ getAllParent(cronappDatasource, itemResult.d.results[0], ids, resolve, reject);
3134
+ },
3135
+ beforeSend: (xhr) => {
3136
+ if (window.uToken) {
3137
+ xhr.setRequestHeader ("X-AUTH-TOKEN", window.uToken);
3138
+ }
3139
+ },
3140
+ error: () => reject(),
3141
+ type: 'GET',
3142
+ });
3143
+ }
3144
+ else {
3145
+ resolve(ids);
3146
+ }
3147
+ };
3147
3148
 
3148
- let reloadAndExpand = function(data) {
3149
- let finish = () => {
3150
- let promise = new Promise((resolve, reject) => {
3151
- getAllParent(this.options.cronappDatasource, data, [], resolve, reject);
3152
- });
3153
- promise.then(expandIds => {
3154
- this.options.kendoObj.expandPath(expandIds.reverse());
3155
- });
3156
- };
3157
- this.options.kendoObj.dataSource.bind("requestEnd", finish);
3158
- this.options.kendoObj.dataSource.read();
3159
- };
3149
+ let reloadAndExpand = function(data) {
3150
+ let finish = () => {
3151
+ let promise = new Promise((resolve, reject) => {
3152
+ getAllParent(this.options.cronappDatasource, data, [], resolve, reject);
3153
+ });
3154
+ promise.then(expandIds => {
3155
+ this.options.kendoObj.expandPath(expandIds.reverse());
3156
+ });
3157
+ };
3158
+ this.options.kendoObj.dataSource.bind("requestEnd", finish);
3159
+ this.options.kendoObj.dataSource.read();
3160
+ };
3160
3161
 
3161
- let helperDirective = this;
3162
- let waitingPromise = false;
3163
- let datasource = new kendo.data.HierarchicalDataSource({
3164
- transport: {
3165
- push: function(callback) {
3162
+ let helperDirective = this;
3163
+ let waitingPromise = false;
3164
+ let datasource = new kendo.data.HierarchicalDataSource({
3165
+ transport: {
3166
+ push: function(callback) {
3166
3167
 
3167
- if (!helperDirective.dataSourceEventsPush && this.options.cronappDatasource) {
3168
- helperDirective.dataSourceEventsPush = {
3169
- create: function(data) {
3168
+ if (!helperDirective.dataSourceEventsPush && this.options.cronappDatasource) {
3169
+ helperDirective.dataSourceEventsPush = {
3170
+ create: function(data) {
3170
3171
 
3171
- reloadAndExpand.bind(this)(data);
3172
+ reloadAndExpand.bind(this)(data);
3172
3173
 
3173
- }.bind(this),
3174
- update: function(data) {
3174
+ }.bind(this),
3175
+ update: function(data) {
3175
3176
 
3176
- reloadAndExpand.bind(this)(data);
3177
+ reloadAndExpand.bind(this)(data);
3177
3178
 
3178
- }.bind(this),
3179
- delete: function(data) {
3179
+ }.bind(this),
3180
+ delete: function(data) {
3180
3181
 
3181
- reloadAndExpand.bind(this)(data);
3182
- ngModelCtrl.$setViewValue(null);
3182
+ reloadAndExpand.bind(this)(data);
3183
+ ngModelCtrl.$setViewValue(null);
3183
3184
 
3184
- }.bind(this),
3185
- overRideRefresh: function(data) {
3185
+ }.bind(this),
3186
+ overRideRefresh: function(data) {
3186
3187
 
3187
- this.options.fromRefresh = true;
3188
- this.options.kendoObj.dataSource.read();
3189
- ngModelCtrl.$setViewValue(null);
3188
+ this.options.fromRefresh = true;
3189
+ this.options.kendoObj.dataSource.read();
3190
+ ngModelCtrl.$setViewValue(null);
3190
3191
 
3191
- }.bind(this),
3192
- read: function(data) {
3192
+ }.bind(this),
3193
+ read: function(data) {
3193
3194
 
3194
- if (!waitingPromise) {
3195
- this.options.kendoObj.dataSource.read();
3196
- ngModelCtrl.$setViewValue(null);
3197
- }
3195
+ if (!waitingPromise) {
3196
+ this.options.kendoObj.dataSource.read();
3197
+ ngModelCtrl.$setViewValue(null);
3198
+ }
3198
3199
 
3199
- }.bind(this)
3200
- };
3200
+ }.bind(this)
3201
+ };
3201
3202
 
3202
- this.options.cronappDatasource.addDataSourceEvents(helperDirective.dataSourceEventsPush);
3203
- }
3204
- },
3205
-
3206
- read: function (e) {
3207
-
3208
- let conditionIsEmpty = (condition) => {
3209
- let result = true;
3210
- if (condition) {
3211
- let jsonCondition = JSON.parse(condition);
3212
- if (jsonCondition.expression && jsonCondition.expression.args) {
3213
- jsonCondition.expression.args.forEach((a)=> {
3214
- if (a.right !== '' && a.right !== "''" && a.right !== undefined)
3215
- result = false;
3216
- });
3217
- }
3218
- }
3219
- return result;
3220
- };
3203
+ this.options.cronappDatasource.addDataSourceEvents(helperDirective.dataSourceEventsPush);
3204
+ }
3205
+ },
3221
3206
 
3207
+ read: function (e) {
3222
3208
 
3223
- let cronappDatasource = this.options.cronappDatasource;
3209
+ let conditionIsEmpty = (condition) => {
3210
+ let result = true;
3211
+ if (condition) {
3212
+ let jsonCondition = JSON.parse(condition);
3213
+ if (jsonCondition.expression && jsonCondition.expression.args) {
3214
+ jsonCondition.expression.args.forEach((a)=> {
3215
+ if (a.right !== '' && a.right !== "''" && a.right !== undefined)
3216
+ result = false;
3217
+ });
3218
+ }
3219
+ }
3220
+ return result;
3221
+ };
3224
3222
 
3225
- for (key in e.data)
3226
- if(e.data[key] == undefined)
3227
- delete e.data[key];
3228
3223
 
3229
- let logicFilter = { filter: { logic: "and", filters:[] } };
3230
- for (let key in e.data) {
3231
- let kendoFilter = {
3232
- field: options.selfRelationshipField,
3233
- operator: "eq",
3234
- value: e.data[key]
3235
- };
3236
- logicFilter.filter.filters.push(kendoFilter);
3237
- }
3224
+ let cronappDatasource = this.options.cronappDatasource;
3238
3225
 
3239
- let condition = cronappDatasource.condition;
3240
- let conditionEmpty = conditionIsEmpty(condition);
3241
- let paramsOData = { $inlinecount: "allpages", $format: "json", $filter: `${options.selfRelationshipField} eq null`};
3226
+ for (key in e.data)
3227
+ if(e.data[key] == undefined)
3228
+ delete e.data[key];
3242
3229
 
3243
- if (logicFilter.filter.filters.length) {
3244
- cronappDatasource.condition = '';
3245
- paramsOData = kendo.data.transports.odata.parameterMap(logicFilter, 'read');
3246
- }
3247
- else if (this.options.fromRefresh) {
3248
- this.options.fromRefresh = false;
3249
- if (!conditionEmpty) {
3250
- cronappDatasource.cleanup();
3251
- paramsOData = { $inlinecount: "allpages", $format: "json"};
3252
- }
3253
- }
3230
+ let logicFilter = { filter: { logic: "and", filters:[] } };
3231
+ for (let key in e.data) {
3232
+ let kendoFilter = {
3233
+ field: options.selfRelationshipField,
3234
+ operator: "eq",
3235
+ value: e.data[key]
3236
+ };
3237
+ logicFilter.filter.filters.push(kendoFilter);
3238
+ }
3254
3239
 
3255
- cronappDatasource.rowsPerPage = e.data.pageSize;
3256
- cronappDatasource.offset = (e.data.page - 1);
3257
-
3258
-
3259
- let fetchData = {};
3260
- fetchData.params = paramsOData;
3261
-
3262
- helperKendoDs = this;
3263
-
3264
- cronappDatasource.fetch(fetchData, {
3265
- success: function(data) {
3266
-
3267
- let all = data.map(item => {
3268
- let odataUrl = `${this.entity}/$count?$filter=${options.selfRelationshipField} eq '${item[schema.model.id]}'`;
3269
- return new Promise((resolve, reject)=> {
3270
- $.ajax({
3271
- url: odataUrl,
3272
- success: (count) => {
3273
- item["hasChildren"] = eval(count) > 0;
3274
- resolve();
3275
- },
3276
- beforeSend: (xhr) => {
3277
- if (window.uToken) {
3278
- xhr.setRequestHeader ("X-AUTH-TOKEN", window.uToken);
3279
- }
3280
- },
3281
- error: () => reject(),
3282
- type: 'GET',
3283
- });
3284
- });
3285
- });
3286
- waitingPromise = true;
3287
- Promise.all(all).then(() => {
3288
- e.success(data);
3289
- waitingPromise = false;
3290
- });
3291
- },
3292
- canceled: function(data) {
3293
- e.error("canceled", "canceled", "canceled");
3294
- }
3295
- }, true);
3240
+ let condition = cronappDatasource.condition;
3241
+ let conditionEmpty = conditionIsEmpty(condition);
3242
+ let paramsOData = { $inlinecount: "allpages", $format: "json", $filter: `${options.selfRelationshipField} eq null`};
3296
3243
 
3297
- if (condition)
3298
- cronappDatasource.condition = condition;
3244
+ if (logicFilter.filter.filters.length) {
3245
+ cronappDatasource.condition = '';
3246
+ paramsOData = kendo.data.transports.odata.parameterMap(logicFilter, 'read');
3247
+ }
3248
+ else if (this.options.fromRefresh) {
3249
+ this.options.fromRefresh = false;
3250
+ if (!conditionEmpty) {
3251
+ cronappDatasource.cleanup();
3252
+ paramsOData = { $inlinecount: "allpages", $format: "json"};
3253
+ }
3254
+ }
3299
3255
 
3300
- },
3301
- options: {
3302
- fromRead: false,
3303
- cronappDatasource: scope[options.dataSourceScreen.name]
3304
- }
3305
- },
3306
- schema: schema
3307
- });
3308
- return datasource;
3309
- },
3310
- link: function (scope, element, attrs, ngModelCtrl) {
3256
+ cronappDatasource.rowsPerPage = e.data.pageSize;
3257
+ cronappDatasource.offset = (e.data.page - 1);
3311
3258
 
3312
- let $templateDyn = $('<div></div>');
3313
- let options = JSON.parse(attrs.options);
3314
3259
 
3315
- let helperDirective = this;
3260
+ let fetchData = {};
3261
+ fetchData.params = paramsOData;
3316
3262
 
3317
- let changeObjectField = function(dataSource, obj){
3318
- obj = dataSource.getKeyValues(obj);
3319
- var keys = Object.keys(obj);
3320
- if(keys.length === 1){
3321
- obj = obj[keys];
3322
- }
3323
- return obj;
3324
- };
3263
+ helperKendoDs = this;
3264
+
3265
+ cronappDatasource.fetch(fetchData, {
3266
+ success: function(data) {
3267
+
3268
+ let all = data.map(item => {
3269
+ let odataUrl = `${this.entity}/$count?$filter=${options.selfRelationshipField} eq '${item[schema.model.id]}'`;
3270
+ return new Promise((resolve, reject)=> {
3271
+ $.ajax({
3272
+ url: odataUrl,
3273
+ success: (count) => {
3274
+ item["hasChildren"] = eval(count) > 0;
3275
+ resolve();
3276
+ },
3277
+ beforeSend: (xhr) => {
3278
+ if (window.uToken) {
3279
+ xhr.setRequestHeader ("X-AUTH-TOKEN", window.uToken);
3280
+ }
3281
+ },
3282
+ error: () => reject(),
3283
+ type: 'GET',
3284
+ });
3285
+ });
3286
+ });
3287
+ waitingPromise = true;
3288
+ Promise.all(all).then(() => {
3289
+ e.success(data);
3290
+ waitingPromise = false;
3291
+ });
3292
+ },
3293
+ canceled: function(data) {
3294
+ e.error("canceled", "canceled", "canceled");
3295
+ }
3296
+ }, true);
3297
+
3298
+ if (condition)
3299
+ cronappDatasource.condition = condition;
3300
+
3301
+ },
3302
+ options: {
3303
+ fromRead: false,
3304
+ cronappDatasource: app.kendoHelper.getCorrectlyDS(options.dataSourceScreen.name, scope)
3305
+ }
3306
+ },
3307
+ schema: schema
3308
+ });
3309
+ return datasource;
3310
+ },
3311
+ link: function (scope, element, attrs, ngModelCtrl) {
3325
3312
 
3326
- let kendoObj = $templateDyn.kendoTreeView({
3327
- dataSource: helperDirective.getDataSource(options, scope, ngModelCtrl),
3328
- dataTextField: options.textField,
3329
- dataImageUrlField: options.imageUrlField,
3330
- change: function(e) {
3331
- let item = this.dataItem(this.select());
3313
+ let $templateDyn = $('<div></div>');
3314
+ let options = JSON.parse(attrs.options);
3332
3315
 
3333
- let cronappDatasource = this.dataSource.transport.options.cronappDatasource;
3334
- scope.safeApply(cronappDatasource.goTo(item));
3316
+ let helperDirective = this;
3335
3317
 
3336
- if(options.fieldType && options.fieldType === 'key')
3337
- cronappDatasource.active = changeObjectField(cronappDatasource, cronappDatasource.active);
3318
+ let changeObjectField = function(dataSource, obj){
3319
+ obj = dataSource.getKeyValues(obj);
3320
+ var keys = Object.keys(obj);
3321
+ if(keys.length === 1){
3322
+ obj = obj[keys];
3323
+ }
3324
+ return obj;
3325
+ };
3338
3326
 
3339
- ngModelCtrl.$setViewValue(cronappDatasource.active);
3340
- }
3341
- }).data('kendoTreeView');
3342
- kendoObj.dataSource.transport.options.kendoObj = kendoObj;
3327
+ let kendoObj = $templateDyn.kendoTreeView({
3328
+ dataSource: helperDirective.getDataSource(options, scope, ngModelCtrl),
3329
+ dataTextField: options.textField,
3330
+ dataImageUrlField: options.imageUrlField,
3331
+ change: function(e) {
3332
+ let item = this.dataItem(this.select());
3333
+
3334
+ let cronappDatasource = this.dataSource.transport.options.cronappDatasource;
3335
+ scope.safeApply(cronappDatasource.goTo(item));
3343
3336
 
3344
- element.html($templateDyn);
3345
- $compile($templateDyn)(element.scope());
3337
+ if(options.fieldType && options.fieldType === 'key')
3338
+ cronappDatasource.active = changeObjectField(cronappDatasource, cronappDatasource.active);
3346
3339
 
3340
+ ngModelCtrl.$setViewValue(cronappDatasource.active);
3347
3341
  }
3348
- };
3342
+ }).data('kendoTreeView');
3343
+ kendoObj.dataSource.transport.options.kendoObj = kendoObj;
3344
+
3345
+ element.html($templateDyn);
3346
+ $compile($templateDyn)(element.scope());
3347
+
3348
+ }
3349
+ };
3349
3350
  }])
3350
3351
 
3351
3352
  .directive('cronSelect', function ($compile) {
@@ -3377,7 +3378,7 @@
3377
3378
  _ngModelCtrl.$setViewValue(this.value());
3378
3379
  }.bind(combobox));
3379
3380
  }
3380
-
3381
+
3381
3382
  var combobox;
3382
3383
  if (select.dontAllowOutsideList === true) {
3383
3384
  combobox = $element.kendoDropDownList(options).data('kendoDropDownList');
@@ -3396,6 +3397,7 @@
3396
3397
  internalInput.attr("required", "required");
3397
3398
  internalInput.attr("ng-model", attrs.ngModel);
3398
3399
  internalInput.attr("id", attrs.id);
3400
+ internalInput.attr("validationmessage", attrs.validationmessage);
3399
3401
  let $parent = internalInput.parent();
3400
3402
  internalInput.on('change',() => {
3401
3403
  if (attrs.ngRequired === "true") {
@@ -3584,7 +3586,7 @@
3584
3586
  found = _goTo(_scope, _combobox, data);
3585
3587
  }
3586
3588
  if (found) {
3587
- modelSetter(_scope, found[select.dataValueField]);
3589
+ modelSetter(_scope, found[select.dataValueField]);
3588
3590
  }
3589
3591
  } else {
3590
3592
  modelSetter(_scope, null);
@@ -3609,6 +3611,10 @@
3609
3611
  };
3610
3612
  }
3611
3613
 
3614
+ options.messages = {
3615
+ noData: attrs.noResultsMessage ? attrs.noResultsMessage : "NO DATA FOUND"
3616
+ };
3617
+
3612
3618
  options.change = attrs.ngChange ? function (){scope.$eval(attrs.ngChange)}: undefined;
3613
3619
  options.close = attrs.ngClose ? function (){scope.$eval(attrs.ngClose)}: undefined;
3614
3620
  options.dataBound = attrs.ngDataBound ? function (){scope.$eval(attrs.ngDataBound)}: undefined;
@@ -3628,7 +3634,8 @@
3628
3634
  var parent = element.parent();
3629
3635
  var id = attrs.id ? ' id="' + attrs.id + '"' : '';
3630
3636
  var name = attrs.name ? ' name="' + attrs.name + '"' : '';
3631
- var inputSelect = $('<input style="width: 100%;"' + id + name + ' class="cronDynamicSelect" ng-model="' + attrs.ngModel + '"/>');
3637
+ var validationmessage = attrs.validationmessage ? ' validationmessage="' + attrs.validationmessage + '"' : '';
3638
+ var inputSelect = $('<input style="width: 100%;"' + id + name + validationmessage + ' class="cronDynamicSelect" ng-model="' + attrs.ngModel + '"/>');
3632
3639
 
3633
3640
  //https://stackoverflow.com/questions/21948067/issues-with-ng-required-directive-angular-js
3634
3641
  attrs.$observe('required', function(value) {
@@ -3650,6 +3657,8 @@
3650
3657
  $(combobox.element[0]).attr('class','cron-select-offscreen');
3651
3658
  }
3652
3659
 
3660
+ $(combobox.wrapper).children('.k-dropdown-wrap').children('.k-select').before(inputSelect);
3661
+
3653
3662
  var forceChangeModel = function(value) {
3654
3663
  if (combobox.isEvaluating) {
3655
3664
  setTimeout(function() {
@@ -3714,7 +3723,7 @@
3714
3723
  dataSourceScreen.fetch({
3715
3724
  params: {
3716
3725
  $top: 1
3717
- }
3726
+ }
3718
3727
  }, {
3719
3728
  success: function(data) {
3720
3729
  if (data.length) {
@@ -3783,7 +3792,7 @@
3783
3792
  }
3784
3793
  }
3785
3794
 
3786
- _compileAngular(scope, options.combobox.element[0]);
3795
+ _compileAngular(scope, options.combobox.element[0]);
3787
3796
  });
3788
3797
 
3789
3798
  }
@@ -3911,7 +3920,13 @@
3911
3920
  var parent = element.parent();
3912
3921
  var id = attrs.id ? ' id="' + attrs.id + '"' : '';
3913
3922
  var name = attrs.name ? ' name="' + attrs.name + '"' : '';
3914
- $(parent).append('<div style="width: 100%;"> <input style="width: 100%;"' + id + name + ' class="cronMultiSelect" ng-model="' + attrs.ngModel + '"/> </div>');
3923
+
3924
+ let required = attrs.ngRequired && eval(attrs.ngRequired) ? `required="required"`: '';
3925
+ $(parent).append(`<div style="width: 100%;"> <input style="width: 100%;" ${id} ${name} ${required} class="cronMultiSelect" ng-model="${attrs.ngModel}"/> </div>`);
3926
+ $(parent).find('label').attr('for',attrs.id);
3927
+ let $inp = $(`${attrs.id}`);
3928
+ $compile($inp)(scope);
3929
+
3915
3930
  var $element = $(parent).find('input.cronMultiSelect');
3916
3931
  $(element).remove();
3917
3932
 
@@ -4025,7 +4040,7 @@
4025
4040
  combobox.readonly(_scope.$eval(attrs.crnReadonly));
4026
4041
  });
4027
4042
  }
4028
-
4043
+
4029
4044
  var convertArray = function(value) {
4030
4045
  var result = [];
4031
4046
  if (value) {
@@ -4038,6 +4053,16 @@
4038
4053
 
4039
4054
  scope.$watchCollection(function(){return ngModelCtrl.$modelValue}, function(value, old){
4040
4055
  var silent = $(combobox).data('silent');
4056
+
4057
+ if (value.length === 0) {
4058
+ $(`#${attrs.id}`).addClass('ng-empty');
4059
+ attrs.ngRequired && eval(attrs.ngRequired) && $(`#${attrs.id}`).attr('required', 'required');
4060
+ }
4061
+ else {
4062
+ $(`#${attrs.id}`).removeClass('ng-empty');
4063
+ $(`#${attrs.id}`).removeAttr('required');
4064
+ }
4065
+
4041
4066
  $(combobox).data('silent', false);
4042
4067
  if (!silent && (JSON.stringify(value) !== JSON.stringify(old))) {
4043
4068
  if (relactionDS.relationDataSource && relactionDS.relationField) {
@@ -4076,11 +4101,12 @@
4076
4101
  var parent = element.parent();
4077
4102
  var id = attrs.id ? ' id="' + attrs.id + '"' : '';
4078
4103
  var name = attrs.name ? ' name="' + attrs.name + '"' : '';
4104
+ var validationmessage = attrs.validationmessage ? ' validationmessage="' + attrs.validationmessage + '"' : '';
4079
4105
  var required = '';
4080
4106
  if (attrs.ngRequired || attrs.required) {
4081
4107
  required = ' required ';
4082
4108
  }
4083
- $(parent).append('<input style="width: 100%;" ' + id + name + required + ' class="cronAutoComplete" ng-model="' + attrs.ngModel + '"/>');
4109
+ $(parent).append('<input style="width: 100%;" ' + id + name + required + validationmessage + ' class="cronAutoComplete" ng-model="' + attrs.ngModel + '"/>');
4084
4110
  var $element = $(parent).find('input.cronAutoComplete');
4085
4111
  $(element).remove();
4086
4112
 
@@ -4090,6 +4116,20 @@
4090
4116
  });
4091
4117
  }
4092
4118
 
4119
+ if(attrs.autoExpand == "true"){
4120
+ $element.on('focus', function (e) {
4121
+ autoComplete.search();
4122
+ });
4123
+ }
4124
+
4125
+ options.messages = {
4126
+ noData: attrs.noResultsMessage ? attrs.noResultsMessage : "NO DATA FOUND"
4127
+ };
4128
+
4129
+ if(attrs.firstOptionOnBlur == "false"){
4130
+ options.suggest = false;
4131
+ }
4132
+
4093
4133
  var autoComplete = $element.kendoAutoComplete(options).data('kendoAutoComplete');
4094
4134
  autoComplete.enable(true);
4095
4135
 
@@ -4148,6 +4188,7 @@
4148
4188
  if ($element.data('alreadycompiled'))
4149
4189
  return;
4150
4190
  $element.data('alreadycompiled',true);
4191
+ $element.data('$compile', $compile);
4151
4192
 
4152
4193
  if (attrs.fromGrid) {
4153
4194
  $element = $(element);
@@ -4163,30 +4204,7 @@
4163
4204
 
4164
4205
  var datePicker = app.kendoHelper.buildKendoMomentPicker($element, options, scope, ngModelCtrl);
4165
4206
 
4166
- if (attrs.fromGrid) {
4167
- var initialDate = $element.data('initial-date');
4168
- var unmaskedvalue = function() {
4169
- var momentDate = null;
4170
-
4171
- var valueDate = $(this).val();
4172
- if (initialDate) {
4173
- valueDate = initialDate;
4174
- initialDate = undefined;
4175
- }
4176
-
4177
- if (useUTC) {
4178
- momentDate = moment(valueDate, options.momentFormat).utcOffset(window.timeZoneOffset);
4179
- } else {
4180
- momentDate = moment(valueDate, options.momentFormat);
4181
- }
4182
-
4183
- datePicker.value(momentDate.format(options.momentFormat));
4184
- $(this).data('rawvalue', momentDate.toDate());
4185
- }
4186
- $(element).on('keydown', unmaskedvalue).on('keyup', unmaskedvalue).on('change', unmaskedvalue);
4187
- unmaskedvalue.bind($element)();
4188
- }
4189
- else {
4207
+ if (!attrs.fromGrid) {
4190
4208
  if (ngModelCtrl) {
4191
4209
  ngModelCtrl.$formatters.push(function (value) {
4192
4210
  var selDate = null;
@@ -4212,7 +4230,7 @@
4212
4230
  if (value) {
4213
4231
  var momentDate = null;
4214
4232
  if (useUTC) {
4215
- momentDate = moment(datePicker._oldText, options.momentFormat).utcOffset(window.timeZoneOffset);;
4233
+ momentDate = moment(datePicker._oldText, options.momentFormat).utcOffset(window.timeZoneOffset);
4216
4234
  } else {
4217
4235
  momentDate = moment(datePicker._oldText, options.momentFormat);
4218
4236
  }
@@ -4507,92 +4525,175 @@
4507
4525
  }
4508
4526
  })
4509
4527
 
4510
- .directive('cronDynamicMenu', ['$compile', '$translate', function($compile, $translate){
4528
+ .directive('cronDynamicMenu', ['$compile', '$translate', function ($compile, $translate) {
4511
4529
  'use strict';
4512
-
4513
- return {
4514
- restrict: 'EA',
4515
- populateItems: function(items) {
4516
- var template = '';
4517
-
4518
- if (items && items != null && Array.isArray(items)) {
4519
- items.forEach(function(item) {
4520
- var security = (item.security && item.security != null) ? ' cronapp-security="' + item.security + '" ' : '';
4521
- var action = (item.action && item.action != null) ? ' ng-click="' + item.action + '" ' : '';
4522
- var hide = (item.hide && item.hide != null) ? ' ng-hide="' + item.hide + '" ' : '';
4523
- var iconClass = (item.iconClass && item.iconClass != null) ? '<i class="'+ item.iconClass +'"></i>&nbsp;' : '';
4524
- var title = '<span></span>';
4525
- if (item.title)
4526
- title = '<span>' + $translate.instant(item.title) + '</span>';
4527
-
4528
- template = template + '<li'+ hide +'><a href=""' + security + action + '>' + iconClass + title + '</a></li>';
4529
- });
4530
-
4531
- if (template != '') {
4532
- template = '<ul class="dropdown-menu">' + template + '</ul>';
4530
+ const populateSubitems = (item) => {
4531
+ var subitem = item.menuItems;
4532
+ var templateSubitens = '';
4533
+
4534
+ subitem.forEach((subitem) => {
4535
+ var securitySubitem = (subitem.security && subitem.security != null) ? ' cronapp-security="' + subitem.security + '" ' : '';
4536
+ var actionSubitem = (subitem.action && subitem.action != null) ? ' ng-click="' + subitem.action + '" ' : '';
4537
+ var hideSubitem = (subitem.hide && subitem.hide != null) ? ' ng-hide="' + subitem.hide + '" ' : '';
4538
+ var iconClassSubitem = (subitem.iconClass && subitem.iconClass != null) ? '<i class="' + subitem.iconClass + '"></i>&nbsp;' : '';
4539
+ var titleSubitem = '<span></span>';
4540
+ var caretSubitem = (subitem.menuItems && Array.isArray(subitem.menuItems) && (subitem.menuItems.length > 0)) ? '<span class="caret submenu"></span>' : '';
4541
+
4542
+ if (subitem.title) {
4543
+ titleSubitem = '<span>' + $translate.instant(subitem.title) + '</span>';
4544
+ }
4545
+
4546
+ if (subitem.menuItems.length > 0) {
4547
+ templateSubitens = templateSubitens + '<li class="dropdown-submenu">\
4548
+ <a class="dropdown-item dropdown-toggle" role="button" aria-haspopup="true" aria-expanded="false" href=""' + securitySubitem + actionSubitem + '>' + iconClassSubitem + titleSubitem + caretSubitem + '</a>\
4549
+ ' + populateItems(subitem.menuItems) + '\
4550
+ </li>';
4551
+
4552
+ } else {
4553
+ templateSubitens = templateSubitens + '<li class="dropdown-submenu">\
4554
+ <a role="button" aria-haspopup="true" aria-expanded="false" href=""' + securitySubitem + actionSubitem + '>' + iconClassSubitem + titleSubitem + caretSubitem + '</a>\
4555
+ </li>';
4556
+ }
4557
+ });
4558
+
4559
+ if (templateSubitens != '') {
4560
+ templateSubitens = '<ul class="dropdown-menu">' + templateSubitens + '</ul>';
4561
+ }
4562
+
4563
+ return templateSubitens;
4564
+ };
4565
+
4566
+ const populateItems = (items) => {
4567
+ var templateItens = '';
4568
+
4569
+ if (items && items.length > 0 && Array.isArray(items)) {
4570
+ items.forEach(function (item) {
4571
+
4572
+ var security = (item.security && item.security != null) ? ' cronapp-security="' + item.security + '" ' : '';
4573
+ var action = (item.action && item.action != null) ? ' ng-click="' + item.action + '" ' : '';
4574
+ var hide = (item.hide && item.hide != null) ? ' ng-hide="' + item.hide + '" ' : '';
4575
+ var iconClass = (item.iconClass && item.iconClass != null) ? '<i class="' + item.iconClass + '"></i>&nbsp;' : '';
4576
+ var title = '<span></span>';
4577
+ var caret = (item.menuItems && Array.isArray(item.menuItems) && (item.menuItems.length > 0)) ? '<span class="caret submenu"></span>' : '';
4578
+
4579
+ if (item.title) {
4580
+ title = '<span>' + $translate.instant(item.title) + '</span>';
4581
+ }
4582
+
4583
+ if (item.menuItems.length > 0) {
4584
+ templateItens = templateItens + '\
4585
+ <li class="dropdown-submenu" ' + hide + '> \
4586
+ <a href="" ' + action + ' class="dropdown-item dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' + iconClass + title + caret + ' </a> \
4587
+ ' + populateSubitems(item) + '\
4588
+ </li>';
4589
+ } else {
4590
+ templateItens = templateItens + '\
4591
+ <li class="dropdown-submenu" ' + hide + '> \
4592
+ <a href="" ' + action + ' class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' + iconClass + title + caret + ' </a> \
4593
+ </li>';
4533
4594
  }
4595
+
4596
+ });
4597
+
4598
+ if (templateItens != '') {
4599
+ templateItens = '<ul class="dropdown-menu">' + templateItens + '</ul>';
4534
4600
  }
4535
-
4536
- return template;
4537
- },
4538
- populateMenu: function(menuOptions, isVertical) {
4601
+ }
4602
+
4603
+ return templateItens;
4604
+ }
4605
+ return {
4606
+ restrict: 'EA',
4607
+ populateMenu: function (menuOptions, isVertical) {
4539
4608
  var template = '';
4540
-
4541
- if (menuOptions && menuOptions!= null && menuOptions.subMenuOptions && menuOptions.subMenuOptions != null && Array.isArray(menuOptions.subMenuOptions)){
4542
- var _populateItems = this.populateItems;
4543
- menuOptions.subMenuOptions.forEach(function(menu) {
4609
+
4610
+ if (menuOptions && menuOptions != null && menuOptions.subMenuOptions && menuOptions.subMenuOptions != null && Array.isArray(menuOptions.subMenuOptions)) {
4611
+
4612
+ menuOptions.subMenuOptions.forEach(function (menu) {
4613
+
4544
4614
  var security = (menu.security && menu.security != null) ? ' cronapp-security="' + menu.security + '" ' : '';
4545
4615
  var action = (menu.action && menu.action != null) ? ' ng-click="' + menu.action + '" ' : '';
4546
4616
  var caret = (menu.menuItems && Array.isArray(menu.menuItems) && (menu.menuItems.length > 0)) ? '<span class="caret"></span>' : '';
4547
4617
  var hide = (menu.hide && menu.hide != null) ? ' ng-hide="' + menu.hide + '" ' : '';
4548
- var iconClass = (menu.iconClass && menu.iconClass != null) ? '<i class="'+ menu.iconClass +'"></i>&nbsp;' : '';
4618
+ var iconClass = (menu.iconClass && menu.iconClass != null) ? '<i class="' + menu.iconClass + '"></i>&nbsp;' : '';
4549
4619
  var title = '<span></span>'
4550
- if (menu.title)
4620
+
4621
+ if (menu.title) {
4551
4622
  title = '<span>' + $translate.instant(menu.title) + '</span>';
4552
-
4553
- template = template + '\
4554
- <li class="dropdown component-holder crn-menu-item '+(isVertical?'col-md-12 padding-0':'')+'" data-component="crn-menu-item"' + security + hide + '>\
4555
- <a href="" ' + action + ' class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">\
4556
- ' + iconClass + title + caret + '\
4557
- </a> \
4558
- ' + _populateItems(menu.menuItems) + '\
4559
- </li>';
4623
+ }
4624
+
4625
+ template = template + '\
4626
+ <li class="dropdown nav-item '+ (isVertical ? 'col-md-12 padding-0' : '') + '"' + security + hide + '>\
4627
+ <a href="" ' + action + ' class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">\
4628
+ ' + iconClass + title + caret + '\
4629
+ </a> \
4630
+ ' + populateItems(menu.menuItems) + '\
4631
+ </li>';
4632
+
4560
4633
  })
4561
4634
  }
4562
-
4635
+
4563
4636
  return template;
4564
4637
  },
4565
- link: function(scope, element, attrs) {
4638
+ link: function (scope, element, attrs) {
4566
4639
  $translate.onReady(() => {
4567
4640
  //Somente fica na vertical se for o menu principal da IDE (E estiver configurado para isso)
4568
- let isVertical = element.closest('.crn-navigator-vertical').length;
4569
-
4570
- var TEMPLATE_MAIN = '<ul class="nav navbar-nav '+(isVertical?'col-md-12 padding-0':'')+' " style="float:left"></ul>';
4641
+ let isVertical = element.closest('.crn-navigator-vertical').length;
4642
+
4643
+ var TEMPLATE_MAIN = '<ul class="nav navbar-nav ' + (isVertical ? 'col-md-12 padding-0' : '') + ' " style="float:left"></ul>';
4571
4644
  var options = {};
4572
4645
  try {
4573
4646
  options = JSON.parse(attrs.options);
4574
- } catch(e) {
4647
+ } catch (e) {
4575
4648
  console.log('CronDynamicMenu: Invalid configuration!')
4576
4649
  }
4577
-
4650
+
4578
4651
  var main = $(TEMPLATE_MAIN);
4579
4652
  main.attr('id', attrs.id);
4580
-
4653
+
4581
4654
  var menus = this.populateMenu(options, isVertical);
4582
4655
  main.append(menus);
4583
4656
  if (isVertical) {
4584
- main.append( $('#navbar2 li:first').addClass('col-md-12 padding-0') );
4657
+ main.append($('#navbar2 li:first').addClass('col-md-12 padding-0'));
4585
4658
  }
4586
-
4659
+
4587
4660
  var newElement = angular.element(main);
4588
4661
  element.html('');
4589
4662
  element.append(main);
4590
- element.attr('id' , null);
4663
+ element.attr('id', null);
4591
4664
  $compile(newElement)(scope);
4665
+
4666
+ var multilevelAction = attrs.multilevelAction;
4667
+
4668
+ if (multilevelAction === 'hover') {
4669
+ $('.dropdown-menu .dropdown-submenu').on('mouseover', function () {
4670
+ var subMenu = $(this).children('ul.dropdown-menu');
4671
+ subMenu.addClass('displayBlock');
4672
+ });
4673
+
4674
+ $('.dropdown-menu .dropdown-submenu').on('mouseout', function () {
4675
+ var subMenu = $(this).children('ul.dropdown-menu');
4676
+ subMenu.removeClass('displayBlock');
4677
+ });
4678
+ }
4679
+ if (multilevelAction === 'click') {
4680
+ $('.dropdown-menu a.dropdown-toggle').on('click', function (e) {
4681
+ if (!$(this).next().hasClass('show')) {
4682
+ $(this).parents('.dropdown-menu').first().find('.show').removeClass("show");
4683
+ }
4684
+ var $subMenu = $(this).next(".dropdown-menu");
4685
+ $subMenu.toggleClass('show');
4686
+ $(this).parents('li.nav-item.dropdown').on('hidden.bs.dropdown', function (e) {
4687
+ $('.dropdown-submenu .show').removeClass("show");
4688
+ });
4689
+ return false;
4690
+ });
4691
+ }
4692
+
4592
4693
  });
4593
4694
  }
4594
4695
  }
4595
- }])
4696
+ }])
4596
4697
 
4597
4698
  .directive('ngInitialValue', function($parse) {
4598
4699
  return {
@@ -4640,47 +4741,37 @@
4640
4741
  link: function (scope, el, attrs, ctrl) {
4641
4742
  ctrl.$formatters = [];
4642
4743
  ctrl.$parsers = [];
4643
- let falseValue = attrs.ngFalseValue ? attrs.ngFalseValue.split("'").join("") : "false";
4644
- let trueValue = attrs.ngTrueValue ? attrs.ngTrueValue.split("'").join("") : "true";
4744
+
4745
+ let falseValue = attrs.ngFalseValue ? attrs.ngFalseValue.split("'").join("") : false;
4746
+ let trueValue = attrs.ngTrueValue ? attrs.ngTrueValue.split("'").join("") : true;
4645
4747
 
4646
4748
  if (attrs.crnAllowNullValues == 'true') {
4647
4749
  ctrl.$render = function () {
4648
4750
  let viewValue = ctrl.$viewValue;
4649
4751
  el.data('checked', viewValue);
4650
- viewValue = '' + viewValue;
4651
4752
  switch (viewValue) {
4652
4753
  case true:
4653
4754
  case trueValue:
4654
4755
  el.prop('indeterminate', false);
4655
4756
  el.prop('checked', true);
4757
+ viewValue = trueValue;
4656
4758
  break;
4657
4759
  case false:
4658
4760
  case falseValue:
4659
4761
  el.prop('indeterminate', false);
4660
4762
  el.prop('checked', false);
4763
+ viewValue = falseValue;
4661
4764
  break;
4662
4765
  default:
4766
+ viewValue = null;
4663
4767
  el.prop('indeterminate', true);
4664
4768
  }
4769
+ ctrl.$setViewValue(viewValue);
4665
4770
  };
4666
- el.bind('click', function () {
4667
- let checked;
4668
- switch (el.data('checked')) {
4669
- case false:
4670
- case falseValue:
4671
- checked = attrs.ngTrueValue ? trueValue : true;
4672
- break;
4673
- default:
4674
- checked = attrs.ngFalseValue ? falseValue : false;
4675
- }
4676
- ctrl.$setViewValue(checked);
4677
- scope.$apply(ctrl.$render);
4678
- });
4679
4771
  } else if (attrs.crnAllowNullValues == 'false') {
4680
4772
  ctrl.$render = function () {
4681
4773
  let viewValue = ctrl.$viewValue;
4682
- viewValue = '' + viewValue;
4683
- if (viewValue === undefined || viewValue === null) {
4774
+ if (ctrl.$viewValue === undefined || ctrl.$viewValue === null) {
4684
4775
  ctrl.$setViewValue(false);
4685
4776
  viewValue = false;
4686
4777
  }
@@ -4694,27 +4785,30 @@
4694
4785
  case trueValue:
4695
4786
  el.prop('indeterminate', false);
4696
4787
  el.prop('checked', true);
4788
+ viewValue = trueValue;
4697
4789
  break;
4698
4790
  default:
4699
4791
  el.prop('indeterminate', false);
4700
4792
  el.prop('checked', false);
4793
+ viewValue = falseValue;
4701
4794
  break;
4702
4795
  }
4796
+ ctrl.$setViewValue(viewValue);
4703
4797
  };
4704
- el.bind('click', function () {
4705
- let checked;
4706
- switch (el.data('checked')) {
4707
- case false:
4708
- case falseValue:
4709
- checked = attrs.ngTrueValue ? trueValue : true;
4710
- break;
4711
- default:
4712
- checked = attrs.ngFalseValue ? falseValue : false;
4713
- }
4714
- ctrl.$setViewValue(checked);
4715
- scope.$apply(ctrl.$render);
4716
- });
4717
4798
  }
4799
+ el.bind('click', function () {
4800
+ let checked;
4801
+ switch (el.data('checked')) {
4802
+ case false:
4803
+ case falseValue:
4804
+ checked = attrs.ngTrueValue ? trueValue : true;
4805
+ break;
4806
+ default:
4807
+ checked = attrs.ngFalseValue ? falseValue : false;
4808
+ }
4809
+ ctrl.$setViewValue(checked);
4810
+ scope.$apply(ctrl.$render);
4811
+ });
4718
4812
  }
4719
4813
  };
4720
4814
  }])
@@ -4740,24 +4834,88 @@
4740
4834
  }])
4741
4835
 
4742
4836
  .directive('updateLanguage', function($rootScope) {
4743
- return {
4744
- link: function( scope, element ) {
4745
- var listener = function( event, translationResp ) {
4746
- var defaultLang = "en",
4747
- currentlang = translationResp.language;
4748
-
4749
- if (currentlang === 'pt_br')
4750
- currentlang = "pt-br";
4751
- else if (currentlang.startsWith('en'))
4752
- currentlang = "en";
4753
-
4754
- element.attr("lang", currentlang || defaultLang );
4755
- };
4837
+ return {
4838
+ link: function( scope, element ) {
4839
+ var listener = function( event, translationResp ) {
4840
+ var defaultLang = "en",
4841
+ currentlang = translationResp.language;
4842
+
4843
+ if (currentlang === 'pt_br')
4844
+ currentlang = "pt-br";
4845
+ else if (currentlang.startsWith('en'))
4846
+ currentlang = "en";
4847
+
4848
+ element.attr("lang", currentlang || defaultLang );
4849
+ };
4850
+
4851
+ $rootScope.$on('$translateChangeSuccess', listener);
4852
+ }
4853
+ };
4854
+ })
4756
4855
 
4757
- $rootScope.$on('$translateChangeSuccess', listener);
4856
+ .directive("fromGrid", ($compile) => {
4857
+ return {
4858
+ restrict: 'A',
4859
+ priority: -999999,
4860
+ exist: (element) => {
4861
+ let id = element.attr('id');
4862
+ return $(`#${id}`).length;
4863
+ },
4864
+ isFromGrid: (attr) => {
4865
+ return attr.fromGrid === "true";
4866
+ },
4867
+ isCompiled: (element) => {
4868
+ return element.data('alreadycompiled');
4869
+ },
4870
+ getDateAs: function (element, value, as) {
4871
+ let mask = element.data('mask');
4872
+ let useUTC = element.data('useUTC');
4873
+ return formatWithMomentAs(mask, useUTC, value, as);
4874
+ },
4875
+ prepareValue: function (element, value) {
4876
+ let columnType = element.data('column-type') || '';
4877
+ if (columnType.startsWith('date')) {
4878
+ value = this.getDateAs(element, value, "date");
4879
+ }
4880
+ return value;
4881
+ },
4882
+ formatComponent: function (element, value) {
4883
+ let kendoObj = element.data('kendoDropDownList') || element.data('kendoSlider');
4884
+ let columnType = element.data('column-type') || '';
4885
+ if (columnType.startsWith('date')) {
4886
+ element.val(this.getDateAs(element, value, "string"));
4887
+ }
4888
+ else if (kendoObj) {
4889
+ kendoObj.value(value);
4890
+ }
4891
+ },
4892
+ compileGridListing: function(element, scope) {
4893
+ let sender = element.data('ref-component');
4894
+ if (sender && sender.tbody && sender.tbody.length && !$(sender.tbody).find('.k-grid-edit-row').length) {
4895
+ var toCompile = sender.tbody;
4896
+ setTimeout(() => {
4897
+ scope.safeApply(() => {
4898
+ var trs = $(toCompile);
4899
+ var x = angular.element(trs);
4900
+ $compile(x)(scope);
4901
+ });
4902
+ });
4903
+ }
4904
+ },
4905
+ link: function (scope, element, attr) {
4906
+ scope.$watch(attr.ngModel, (value) => {
4907
+ if (this.isFromGrid(attr) && this.exist(element) && this.isCompiled(element)) {
4908
+ value = this.prepareValue(element, value);
4909
+ this.formatComponent(element, value);
4910
+ this.compileGridListing(element, scope);
4911
+ call = element.data('change-grid-model');
4912
+ call && call(value);
4758
4913
  }
4759
- };
4914
+ });
4915
+ }
4916
+ }
4760
4917
  })
4918
+
4761
4919
  }(app));
4762
4920
 
4763
4921
  function maskDirectiveAsDate($compile, $translate, $parse) {
@@ -4785,6 +4943,7 @@ function maskDirective($compile, $translate, $parse, attrName) {
4785
4943
  if ($element.data('alreadycompiled'))
4786
4944
  return;
4787
4945
  $element.data('alreadycompiled', true);
4946
+ $element.data('$compile', $compile);
4788
4947
 
4789
4948
  var type = $element.attr("type");
4790
4949
 
@@ -4866,6 +5025,9 @@ function maskDirective($compile, $translate, $parse, attrName) {
4866
5025
  useUTC = false;
4867
5026
  }
4868
5027
 
5028
+ $element.data('mask', mask);
5029
+ $element.data('useUTC', useUTC);
5030
+
4869
5031
  if ($element.attr('from-grid')) {
4870
5032
  var openPopup = function() {
4871
5033
  var popup = $(this).offset();
@@ -4898,16 +5060,20 @@ function maskDirective($compile, $translate, $parse, attrName) {
4898
5060
  setTimeout(openPopup.bind(this), 100);
4899
5061
  });
4900
5062
  $element.on('dp.change', function () {
4901
- var momentDate = null;
4902
- if (useUTC) {
4903
- momentDate = moment($element.val(), mask).utcOffset(window.timeZoneOffset);
4904
- } else {
4905
- momentDate = moment($element.val(), mask);
4906
- }
4907
- if (type == 'time' || type == 'time-local') {
4908
- momentDate = momentDate.year(1970).dayOfYear(1).month(0);
4909
- }
4910
- $element.data('rawvalue', momentDate.toDate());
5063
+ scope.safeApply(function () {
5064
+ var momentDate = null;
5065
+ if (useUTC) {
5066
+ momentDate = moment($element.val(), mask).utcOffset(window.timeZoneOffset, true);
5067
+ } else {
5068
+ momentDate = moment($element.val(), mask);
5069
+ }
5070
+ if (type == 'time' || type == 'time-local') {
5071
+ momentDate = momentDate.year(1970).dayOfYear(1).month(0);
5072
+ }
5073
+ if (momentDate.isValid() && ngModelCtrl) {
5074
+ modelSetter(scope, momentDate.toDate());
5075
+ }
5076
+ });
4911
5077
  });
4912
5078
  if ($element.data('initial-value')) {
4913
5079
  var initialValue = $element.data('initial-value');
@@ -4926,46 +5092,33 @@ function maskDirective($compile, $translate, $parse, attrName) {
4926
5092
  $element.wrap("<div style=\"position:relative\"></div>");
4927
5093
  }
4928
5094
  $element.datetimepicker(options);
4929
-
4930
- $element.on('dp.change', function () {
4931
- if ($(this).is(":visible")) {
4932
- $(this).trigger('change');
4933
- scope.safeApply(function () {
4934
- var value = $element.val();
4935
- var momentDate = null;
4936
- if (useUTC) {
4937
- momentDate = moment(value, mask).utcOffset(window.timeZoneOffset, true);
4938
- } else {
4939
- momentDate = moment(value, mask);
4940
- }
4941
- if (type == 'time' || type == 'time-local') {
4942
- momentDate = momentDate.year(1970).dayOfYear(1).month(0);
4943
- }
4944
- if (momentDate.isValid() && ngModelCtrl) {
4945
- modelSetter(scope, momentDate.toDate());
4946
- }
4947
- });
4948
- }
4949
- });
4950
-
4951
- if (ngModelCtrl) {
4952
- ngModelCtrl.$formatters.push(function (value) {
4953
- if (value) {
4954
- var momentDate = null;
4955
-
4956
- if (useUTC) {
4957
- momentDate = moment(value).utcOffset(window.timeZoneOffset);
4958
- if(!momentDate.isValid()){
4959
- momentDate = moment(value, mask).utcOffset(window.timeZoneOffset);
4960
- }
4961
- } else {
4962
- momentDate = moment(value);
4963
- if(!momentDate.isValid()){
5095
+ if (attrs.fromGrid !== "true") {
5096
+ $element.on('dp.change', function () {
5097
+ if ($(this).is(":visible")) {
5098
+ $(this).trigger('change');
5099
+ scope.safeApply(function () {
5100
+ var value = $element.val();
5101
+ var momentDate = null;
5102
+ if (useUTC) {
5103
+ momentDate = moment(value, mask).utcOffset(window.timeZoneOffset, true);
5104
+ } else {
4964
5105
  momentDate = moment(value, mask);
4965
5106
  }
4966
- }
5107
+ if (type == 'time' || type == 'time-local') {
5108
+ momentDate = momentDate.year(1970).dayOfYear(1).month(0);
5109
+ }
5110
+ if (momentDate.isValid() && ngModelCtrl) {
5111
+ modelSetter(scope, momentDate.toDate());
5112
+ }
5113
+ });
5114
+ }
5115
+ });
5116
+ }
4967
5117
 
4968
- return momentDate.format(mask);
5118
+ if (ngModelCtrl ) {
5119
+ ngModelCtrl.$formatters.push(function (value) {
5120
+ if (value) {
5121
+ return formatWithMomentAs(mask, useUTC, value, "string");
4969
5122
  }
4970
5123
 
4971
5124
  if(value === null){
@@ -5068,29 +5221,20 @@ function maskDirective($compile, $translate, $parse, attrName) {
5068
5221
  $(element).inputmask(inputmaskType, ipOptions);
5069
5222
  useInputMaskPlugin(element, ngModelCtrl, scope, modelSetter, mask);
5070
5223
  }
5071
- else if (type == 'text' || type == 'tel') {
5224
+ else if (type == 'text' || type == 'tel' || type == 'string') {
5072
5225
  if(!attrs.maskPlaceholder){
5073
5226
  $element.mask(mask);
5074
5227
  useMaskPlugin(element, ngModelCtrl, scope, modelSetter, removeMask);
5075
5228
  }
5076
5229
  else{
5077
5230
  options = {};
5078
- options['placeholder'] = attrs.maskPlaceholder
5231
+ options['placeholder'] = attrs.maskPlaceholder;
5079
5232
  $(element).inputmask(mask, options);
5080
5233
  if(removeMask){
5081
5234
  useInputMaskPlugin(element, ngModelCtrl, scope, modelSetter, mask);
5082
5235
  }
5083
5236
  }
5084
5237
  }
5085
- else {
5086
- if ($element.attr('from-grid')) {
5087
- var unmaskedvalue = function() {
5088
- $(this).data('rawvalue',$(this).val());
5089
- }
5090
- $(element).on('keydown', unmaskedvalue).on('keyup', unmaskedvalue);
5091
- $element.mask(mask);
5092
- }
5093
- }
5094
5238
  }
5095
5239
  }
5096
5240
  }
@@ -5242,6 +5386,16 @@ function transformText() {
5242
5386
 
5243
5387
 
5244
5388
  app.kendoHelper = {
5389
+ getCorrectlyDS: (name, scope) => {
5390
+ if (scope[name].apiVersion) {
5391
+ return scope[name];
5392
+ }
5393
+ else {
5394
+ let ds = scope.$parent[name];
5395
+ scope[name] = ds;
5396
+ return ds;
5397
+ }
5398
+ },
5245
5399
  receivePushData: comp => !comp || !comp.dataSource || (comp.dataSource.transport.options.refComponent = comp),
5246
5400
  getSchema: function(dataSource) {
5247
5401
  var parseAttribute = [
@@ -5339,8 +5493,8 @@ app.kendoHelper = {
5339
5493
  };
5340
5494
 
5341
5495
  var pageSize = 10;
5342
- if (scope[dataSource.name])
5343
- pageSize = scope[dataSource.name].rowsPerPage;
5496
+ if (app.kendoHelper.getCorrectlyDS(dataSource.name, scope))
5497
+ pageSize = app.kendoHelper.getCorrectlyDS(dataSource.name, scope).rowsPerPage;
5344
5498
 
5345
5499
  //Quando não for data UTC
5346
5500
  var offsetMiliseconds = new Date().getTimezoneOffset() * 60000;
@@ -5435,7 +5589,7 @@ app.kendoHelper = {
5435
5589
  if (this.options.isComponentInDocument(this.options.refComponent)) {
5436
5590
  let current = this.options.getCurrentCallbackForPush(callback, this.options.refComponent);
5437
5591
  let acceptedMethod = current[type];
5438
-
5592
+
5439
5593
  if (acceptedMethod) {
5440
5594
  acceptedMethod(data);
5441
5595
  }
@@ -5535,13 +5689,13 @@ app.kendoHelper = {
5535
5689
  if (dataSource.append) {
5536
5690
  append = dataSource.append;
5537
5691
  }
5538
-
5692
+
5539
5693
  var fetchOptions = {};
5540
5694
  //indicates that the search has already been clicked, set the fetchOptions orign to loadDataStrategy
5541
5695
  if (cronappDatasource.loadDataStrategy === "button" && cronappDatasource.data.length > 0) {
5542
5696
  fetchOptions.origin = cronappDatasource.loadDataStrategy;
5543
5697
  }
5544
-
5698
+
5545
5699
  cronappDatasource.append = append;
5546
5700
  cronappDatasource.fetch(fetchData, {
5547
5701
  success: function(data) {
@@ -5625,7 +5779,7 @@ app.kendoHelper = {
5625
5779
  return callback;
5626
5780
  return component;
5627
5781
  },
5628
- cronappDatasource: scope[dataSource.name]
5782
+ cronappDatasource: app.kendoHelper.getCorrectlyDS(dataSource.name, scope)
5629
5783
  }
5630
5784
  },
5631
5785
  pageSize: pageSize,
@@ -5955,39 +6109,32 @@ app.kendoHelper = {
5955
6109
  useUTC = false;
5956
6110
  }
5957
6111
 
5958
- if (!$element.attr('from-grid')) {
5959
- var onChange = function() {
5960
- var value = $element.val();
5961
- if (!value || value.trim() == '') {
5962
- if (ngModelCtrl)
5963
- ngModelCtrl.$setViewValue('');
5964
- } else {
5965
- var momentDate = null;
5966
-
5967
- if (useUTC) {
5968
- momentDate = moment(value, options.momentFormat).utcOffset(window.timeZoneOffset);
5969
- } else {
5970
- momentDate = moment(value, options.momentFormat);
5971
- }
5972
-
5973
- if (ngModelCtrl && momentDate.isValid()) {
5974
- ngModelCtrl.$setViewValue(momentDate.toDate());
5975
- $element.data('changed', true);
5976
- }
5977
- }
5978
- }
6112
+ $element.data('mask', options.momentFormat);
6113
+ $element.data('useUTC', useUTC);
5979
6114
 
5980
- if (scope) {
5981
- options['change'] = function() {
5982
- scope.$apply(function () {
5983
- onChange();
5984
- });
5985
- };
6115
+ var onChange = function() {
6116
+ var value = $element.val();
6117
+ if (!value || value.trim() == '') {
6118
+ if (ngModelCtrl)
6119
+ ngModelCtrl.$setViewValue('');
5986
6120
  } else {
5987
- options['change'] = onChange;
6121
+ var valueDate = formatWithMomentAs(options.momentFormat, useUTC, value, "date");
6122
+ if (ngModelCtrl) {
6123
+ ngModelCtrl.$setViewValue(valueDate);
6124
+ $element.data('changed', true);
6125
+ }
5988
6126
  }
5989
6127
  }
5990
6128
 
6129
+ if (scope) {
6130
+ options['change'] = function() {
6131
+ scope.$apply(function () {
6132
+ onChange();
6133
+ });
6134
+ };
6135
+ } else {
6136
+ options['change'] = onChange;
6137
+ }
5991
6138
 
5992
6139
  if (options.type == 'date') {
5993
6140
  return $element.kendoDatePicker(options).data('kendoDatePicker');
@@ -6088,3 +6235,29 @@ window.useMask = function(value, format, type) {
6088
6235
 
6089
6236
  return mask;
6090
6237
  };
6238
+
6239
+ window.formatWithMomentAs = function (mask, useUTC, value, as) {
6240
+
6241
+ if (!value) return;
6242
+
6243
+ let momentDate = null;
6244
+
6245
+ if (value instanceof Date || value.startsWith('/Date')) {
6246
+ if (useUTC) {
6247
+ momentDate = moment(value).utcOffset(window.timeZoneOffset);
6248
+ } else {
6249
+ momentDate = moment(value);
6250
+ }
6251
+ }
6252
+ else {
6253
+ if (useUTC) {
6254
+ momentDate = moment(value, mask).utcOffset(window.timeZoneOffset, true);
6255
+ } else {
6256
+ momentDate = moment(value, mask);
6257
+ }
6258
+ }
6259
+ if (as === 'string') {
6260
+ return momentDate.format(mask);
6261
+ }
6262
+ return momentDate.toDate();
6263
+ };