cronapp-framework-js 2.8.20 → 2.8.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/crn-accordion.components.json +29 -1
- package/components/crn-anchor.components.json +2 -2
- package/components/crn-button.components.json +12 -2
- package/components/crn-cron-crud.components.json +21 -0
- package/components/crn-datasource.components.json +5 -0
- package/components/crn-datepicker.components.json +15 -0
- package/components/crn-datetimepicker.components.json +25 -0
- package/components/crn-dynamic-menu.components.json +21 -0
- package/components/crn-eight-four-container.components.json +43 -0
- package/components/crn-enterprise-autocomplete.components.json +38 -1
- package/components/crn-enterprise-checkbox.components.json +5 -0
- package/components/crn-enterprise-combobox-multiple.components.json +5 -0
- package/components/crn-enterprise-combobox.components.json +11 -1
- package/components/crn-enterprise-dynamic-autocomplete.components.json +39 -2
- package/components/crn-enterprise-dynamic-combobox.components.json +18 -1
- package/components/crn-four-eight-container.components.json +43 -0
- package/components/crn-horizontal-container.components.json +50 -42
- package/components/crn-icon.components.json +20 -12
- package/components/crn-image.components.json +4 -4
- package/components/crn-label.components.json +1 -0
- package/components/crn-one-container.components.json +43 -0
- package/components/crn-rating.components.json +31 -31
- package/components/crn-table.components.json +1 -2
- package/components/crn-textarea.components.json +9 -0
- package/components/crn-textinput.components.json +16 -5
- package/components/crn-three-container.components.json +43 -0
- package/components/crn-trhee-six-three-container.components.json +43 -0
- package/components/crn-two-container.components.json +43 -0
- package/components/crn-upload-file.components.json +2 -3
- package/components/crn-upload.components.json +2 -2
- package/components/crn-vertical-container.components.json +17 -9
- package/components/css/checkbox-color.css +16 -0
- package/components/css/color-default.css +2 -0
- package/components/css/font-size.css +15 -0
- package/components/css/image.css +15 -0
- package/components/templates/Component_Container/crn-eight-four-container.template.html +4 -0
- package/components/templates/Component_Container/crn-four-eight-container.template.html +4 -0
- package/components/templates/Component_Container/crn-one-container.template.html +1 -0
- package/components/templates/Component_Container/crn-three-container.template.html +5 -0
- package/components/templates/Component_Container/crn-three-six-three-container.template.html +5 -0
- package/components/templates/Component_Container/crn-two-container.template.html +4 -0
- package/components/templates/button.template.html +2 -2
- package/components/templates/cron-autocomplete.designtime.html +3 -3
- package/components/templates/cron-checkbox.template.html +1 -2
- package/components/templates/cron-combobox-multiple.template.html +1 -1
- package/components/templates/cron-crud.template.html +71 -0
- package/components/templates/cron-dynamic-combobox.template.html +2 -3
- package/components/templates/fileupload-button.template.html +1 -1
- package/components/templates/fileupload.template.html +1 -1
- package/components/templates/form.template.html +44 -21
- package/components/templates/grid-horizontal.template.html +4 -2
- package/components/templates/grid-vertical.template.html +4 -2
- package/components/templates/icon.template.html +1 -1
- package/components/templates/image.default.template.html +1 -2
- package/components/templates/rating.template.html +7 -7
- package/components/templates/social-button-bar.template.html +11 -12
- package/components/templates/sub-form.template.html +44 -11
- package/components/templates/textinputbutton.template.html +3 -1
- package/css/animate.css +433 -0
- package/css/app.css +131 -32
- package/css/modalTemplate.css +25 -0
- package/css/themes/custom/fuse/custom-fuse.min.css +1 -5
- package/css/themes/custom/material/components_css/crn-navbar.css +30 -32
- package/css/themes/custom/material/custom-material.css +16 -11
- package/css/themes/custom/navigator/custom-navigator.css +71 -76
- package/dist/components/css/checkbox-color.css +1 -1
- package/dist/components/css/color-default.css +1 -1
- package/dist/components/css/font-size.css +1 -0
- package/dist/components/css/image.css +1 -0
- package/dist/components/js/jquery.inputmask.bundle.js +1 -1
- package/dist/components/js/jquery.mask.min.js +1 -1
- package/dist/components/js/qrcode.js +1 -1
- package/dist/components/templates/Component_Container/crn-eight-four-container.template.html +1 -0
- package/dist/components/templates/Component_Container/crn-four-eight-container.template.html +1 -0
- package/dist/components/templates/Component_Container/crn-one-container.template.html +1 -0
- package/dist/components/templates/Component_Container/crn-three-container.template.html +1 -0
- package/dist/components/templates/Component_Container/crn-three-six-three-container.template.html +1 -0
- package/dist/components/templates/Component_Container/crn-two-container.template.html +1 -0
- package/dist/components/templates/button.template.html +1 -1
- package/dist/components/templates/cron-autocomplete.designtime.html +1 -1
- package/dist/components/templates/cron-checkbox.template.html +1 -1
- package/dist/components/templates/cron-combobox-multiple.template.html +1 -1
- package/dist/components/templates/cron-crud.template.html +1 -0
- package/dist/components/templates/cron-dynamic-combobox.template.html +1 -1
- package/dist/components/templates/fileupload-button.template.html +1 -1
- package/dist/components/templates/fileupload.template.html +1 -1
- package/dist/components/templates/form.template.html +1 -1
- package/dist/components/templates/grid-horizontal.template.html +1 -1
- package/dist/components/templates/grid-vertical.template.html +1 -1
- package/dist/components/templates/icon.template.html +1 -1
- package/dist/components/templates/image.default.template.html +1 -1
- package/dist/components/templates/rating.template.html +1 -1
- package/dist/components/templates/social-button-bar.template.html +1 -1
- package/dist/components/templates/sub-form.template.html +1 -1
- package/dist/components/templates/textinputbutton.template.html +1 -1
- package/dist/css/app.css +1 -1
- package/dist/i18n/locale_en_us.json +2 -1
- package/dist/i18n/locale_pt_br.json +2 -1
- package/dist/img/barcode.png +0 -0
- package/dist/img/cron-icon/crn-cron-crud.svg +1 -0
- package/dist/img/cron-icon/crn-eight-four-container.svg +1 -0
- package/dist/img/cron-icon/crn-four-eight-container.svg +1 -0
- package/dist/img/cron-icon/crn-one-container.svg +1 -0
- package/dist/img/cron-icon/crn-three-container.svg +1 -0
- package/dist/img/cron-icon/crn-three-six-three-container.svg +1 -0
- package/dist/img/cron-icon/crn-two-container.svg +1 -0
- package/dist/img/cronGrid.png +0 -0
- package/dist/img/cronRichEditor.png +0 -0
- package/dist/img/cronapp-logo-login.png +0 -0
- package/dist/img/logo.png +0 -0
- package/dist/img/placehold-100x100.png +0 -0
- package/dist/img/placehold-900x500.png +0 -0
- package/dist/img/qrcode.png +0 -0
- package/dist/img/selectFile.png +0 -0
- package/dist/img/switch.png +0 -0
- package/dist/js/app.js +1 -1
- package/dist/js/controllers.js +1 -1
- package/dist/js/directives.js +1 -1
- package/dist/js/upload.service.js +1 -1
- package/i18n/locale_en_us.json +2 -1
- package/i18n/locale_pt_br.json +2 -1
- package/img/cron-icon/crn-cron-crud.svg +28 -0
- package/img/cron-icon/crn-eight-four-container.svg +18 -0
- package/img/cron-icon/crn-four-eight-container.svg +20 -0
- package/img/cron-icon/crn-one-container.svg +17 -0
- package/img/cron-icon/crn-three-container.svg +21 -0
- package/img/cron-icon/crn-three-six-three-container.svg +19 -0
- package/img/cron-icon/crn-two-container.svg +18 -0
- package/img/placehold-900x500.png +0 -0
- package/js/app.js +48 -22
- package/js/controllers.js +18 -11
- package/js/directives.js +2081 -1900
- package/js/upload.service.js +7 -3
- package/package.json +11 -11
package/js/directives.js
CHANGED
|
@@ -386,7 +386,7 @@
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
})
|
|
389
|
-
|
|
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
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
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
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
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
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
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
|
-
}
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
|
|
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
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
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
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
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
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
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
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
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
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
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
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
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
|
-
|
|
1609
|
-
update.error(angular.copy(data));
|
|
1586
|
+
} else {
|
|
1587
|
+
read.error();
|
|
1610
1588
|
}
|
|
1611
|
-
)
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
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
|
-
|
|
1626
|
-
|
|
1608
|
+
(data) => {
|
|
1609
|
+
update.error(angular.copy(data));
|
|
1627
1610
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
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
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
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
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
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
|
-
|
|
1715
|
+
this.initCulture();
|
|
1716
1716
|
|
|
1717
|
-
|
|
1717
|
+
$.getScript(baseUrl, function() {
|
|
1718
1718
|
|
|
1719
|
-
|
|
1719
|
+
let kendoDatasource = app.kendoHelper.getDataSource(options.dataSourceScreen.entityDataSource, scope, true, options.dataSourceScreen.rowsPerPage);
|
|
1720
1720
|
|
|
1721
|
-
|
|
1721
|
+
let schedulerProperties = this.getSchedulerProperties(options, datasource, scope);
|
|
1722
1722
|
|
|
1723
|
-
|
|
1723
|
+
schedulerElement.kendoScheduler(schedulerProperties);
|
|
1724
1724
|
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1725
|
+
// Get reference to the kendo.ui.Scheduler instance
|
|
1726
|
+
let scheduler = schedulerElement.data("kendoScheduler");
|
|
1727
|
+
let lastView;
|
|
1728
1728
|
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
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
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
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
|
-
|
|
1762
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
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
|
-
|
|
1826
|
-
|
|
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
|
-
|
|
1804
|
+
let security = toolbarButton.security ? `cronapp-security="${toolbarButton.security}"` : "";
|
|
1833
1805
|
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
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
|
-
|
|
1854
|
-
item: selectedRows.length ? cronappDatasource.active : null,
|
|
1855
|
-
index: selectedRows.length ? cronappDatasource.cursor : null
|
|
1856
|
-
}
|
|
1841
|
+
$('#' + buttonId).click(function() {
|
|
1857
1842
|
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
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
|
-
|
|
1881
|
-
|
|
1853
|
+
var consolidated = {
|
|
1854
|
+
item: selectedRows.length ? cronappDatasource.active : null,
|
|
1855
|
+
index: selectedRows.length ? cronappDatasource.cursor : null
|
|
1856
|
+
}
|
|
1882
1857
|
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
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
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
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
|
-
|
|
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, '&')
|
|
1966
|
-
.replace(/</g, '<')
|
|
1967
|
-
.replace(/>/g, '>')
|
|
1968
|
-
.replace(/"/g, '"')
|
|
1969
|
-
.replace(/'/g, ''');
|
|
1970
|
-
},
|
|
1971
|
-
decodeHTML: function(value){
|
|
1972
|
-
return value.replace(/'/g, "'")
|
|
1973
|
-
.replace(/"/g, '"')
|
|
1974
|
-
.replace(/>/g, '>')
|
|
1975
|
-
.replace(/</g, '<')
|
|
1976
|
-
.replace(/&/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
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
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, '&')
|
|
1966
|
+
.replace(/</g, '<')
|
|
1967
|
+
.replace(/>/g, '>')
|
|
1968
|
+
.replace(/"/g, '"')
|
|
1969
|
+
.replace(/'/g, ''');
|
|
1970
|
+
},
|
|
1971
|
+
decodeHTML: function(value){
|
|
1972
|
+
return value.replace(/'/g, "'")
|
|
1973
|
+
.replace(/"/g, '"')
|
|
1974
|
+
.replace(/>/g, '>')
|
|
1975
|
+
.replace(/</g, '<')
|
|
1976
|
+
.replace(/&/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
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
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
|
-
|
|
1994
|
+
grid.showColumn(idx);
|
|
2027
1995
|
}
|
|
2028
|
-
|
|
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
|
-
|
|
2039
|
-
if (
|
|
2040
|
-
widthDevice =
|
|
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 =
|
|
2047
|
-
|
|
2048
|
-
|
|
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
|
-
|
|
2052
|
-
|
|
2051
|
+
getColumns: function(options, datasource, scope, tooltips) {
|
|
2052
|
+
var helperDirective = this;
|
|
2053
2053
|
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
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.
|
|
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
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
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
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
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
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
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
|
-
|
|
2108
|
-
|
|
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
|
-
|
|
2119
|
-
return editor.bind(this);
|
|
2120
|
-
}
|
|
2122
|
+
async function editor(container, opt) {
|
|
2121
2123
|
|
|
2122
|
-
|
|
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
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
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[
|
|
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
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
$input.
|
|
2185
|
-
$input.
|
|
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
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
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
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
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
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
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
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
+
function getAggregateFooter(column, group) {
|
|
2303
|
+
if (column && column.aggregates) {
|
|
2304
|
+
var footer = [];
|
|
2305
|
+
column.aggregates.forEach(function(a) {
|
|
2302
2306
|
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
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
|
-
|
|
2312
|
+
var typeForTemplate = group ? a.groupFooterTemplate : a.footerTemplate;
|
|
2309
2313
|
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2314
|
+
if (typeForTemplate) {
|
|
2315
|
+
typeForTemplate = typeForTemplate + ': ';
|
|
2316
|
+
} else {
|
|
2317
|
+
typeForTemplate = '';
|
|
2318
|
+
}
|
|
2315
2319
|
|
|
2316
|
-
|
|
2320
|
+
var footerTemplate = typeForTemplate + typeForLabel;
|
|
2317
2321
|
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
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
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2331
|
+
footer.push(footerTemplate);
|
|
2332
|
+
});
|
|
2333
|
+
return footer.join('<br/>');
|
|
2334
|
+
}
|
|
2335
|
+
return undefined;
|
|
2330
2336
|
}
|
|
2331
|
-
return undefined;
|
|
2332
|
-
}
|
|
2333
2337
|
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
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
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
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
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2367
|
+
field: column.field,
|
|
2402
2368
|
title: column.headerText,
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
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
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
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
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
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.
|
|
2423
|
-
|
|
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 = ' ' + 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
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2429
|
+
var tooltip = '';
|
|
2430
|
+
if (column.tooltip && column.tooltip.length)
|
|
2431
|
+
tooltip = column.tooltip;
|
|
2428
2432
|
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2433
|
+
if (tooltip) {
|
|
2434
|
+
var classForTooltip = app.common.generateId();
|
|
2435
|
+
tooltips[classForTooltip] = tooltip;
|
|
2436
|
+
className += ' ' + classForTooltip;
|
|
2437
|
+
}
|
|
2434
2438
|
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
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
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
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
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
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
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
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
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
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
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
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
|
-
|
|
2487
|
-
|
|
2488
|
-
index: index
|
|
2489
|
-
}
|
|
2538
|
+
if (!options.allowPaging)
|
|
2539
|
+
pageable = options.allowPaging;
|
|
2490
2540
|
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
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
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
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
|
-
|
|
2535
|
-
pageable = options.allowPaging;
|
|
2553
|
+
var toolbar = [];
|
|
2536
2554
|
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
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
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2574
|
-
|
|
2583
|
+
if (toolbarButton.title == "pdf" || toolbarButton.title == "excel") {
|
|
2584
|
+
toolbar.push(toolbarButton.title);
|
|
2585
|
+
}
|
|
2575
2586
|
}
|
|
2576
2587
|
}
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
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
|
-
|
|
2585
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
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
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
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
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
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
|
-
|
|
2659
|
-
|
|
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
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
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
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
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
|
-
|
|
2700
|
+
var collapseCurrent = function(grid, trDetail, trMaster) {
|
|
2697
2701
|
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
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
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
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
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
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
|
-
|
|
2721
|
-
|
|
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
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
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
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
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
|
-
}
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2739
|
-
};
|
|
2738
|
+
});
|
|
2739
|
+
}
|
|
2740
|
+
};
|
|
2740
2741
|
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
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
|
-
|
|
2754
|
-
};
|
|
2754
|
+
return hasFilterableColumn;
|
|
2755
|
+
};
|
|
2755
2756
|
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
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
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
});
|
|
2768
|
-
return result;
|
|
2769
|
-
};
|
|
2768
|
+
});
|
|
2769
|
+
return result;
|
|
2770
|
+
};
|
|
2770
2771
|
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
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
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
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
|
-
|
|
2811
|
+
var datasource = app.kendoHelper.getDataSource(options.dataSourceScreen.entityDataSource, scope, options.allowPaging, options.pageCount, options.columns, options.groupings);
|
|
2811
2812
|
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
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
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
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
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
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
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2871
|
+
if (attrs && attrs.ngEdit) {
|
|
2872
|
+
scope.$eval(attrs.ngEdit);
|
|
2873
|
+
}
|
|
2873
2874
|
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
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
|
-
|
|
2899
|
-
if (
|
|
2900
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2910
|
-
|
|
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
|
-
}
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
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
|
-
|
|
2931
|
-
|
|
2932
|
-
}
|
|
2925
|
+
compileListing(e);
|
|
2926
|
+
}.bind(this));
|
|
2927
|
+
},
|
|
2928
|
+
dataBound: function(e) {
|
|
2929
|
+
setTimeout(() => this.dataSource.transport.options.selectActiveInGrid(), 100);
|
|
2933
2930
|
|
|
2934
|
-
|
|
2935
|
-
|
|
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
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
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
|
-
|
|
2969
|
-
|
|
2970
|
-
}
|
|
2971
|
-
|
|
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;
|
|
2986
|
+
|
|
2987
|
+
},
|
|
2988
|
+
link: function (scope, element, attrs, ngModelCtrl) {
|
|
2983
2989
|
|
|
2984
|
-
|
|
2990
|
+
if (element.children().length)
|
|
2991
|
+
return;
|
|
2985
2992
|
|
|
2986
|
-
|
|
2987
|
-
|
|
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";
|
|
2988
2999
|
|
|
2989
|
-
if (element.children().length)
|
|
2990
|
-
return;
|
|
2991
3000
|
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
baseUrl += "pt-BR.min.js";
|
|
2996
|
-
else
|
|
2997
|
-
baseUrl += "en-US.min.js";
|
|
3001
|
+
this.initCulture();
|
|
3002
|
+
var helperDirective = this;
|
|
3003
|
+
$.getScript(baseUrl, function () {
|
|
2998
3004
|
|
|
3005
|
+
var options = JSON.parse(attrs.options || "{}");
|
|
2999
3006
|
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
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;
|
|
3003
3011
|
|
|
3004
|
-
|
|
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
|
+
}
|
|
3005
3026
|
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
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
|
-
}
|
|
3027
|
+
var tooltips = helperDirective.getTooltipsDefault();
|
|
3028
|
+
var kendoGridInit = helperDirective.generateKendoGridInit(options, scope, ngModelCtrl, attrs, tooltips);
|
|
3029
|
+
kendoGridInit.scrollable = attrs.scrollable === "true";
|
|
3025
3030
|
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
$templateDyn.find('.k-pager-refresh.k-link').show();
|
|
3065
|
-
$templateDyn.find('.saveorcancelchanges').hide();
|
|
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) });
|
|
3037
|
+
|
|
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
|
-
|
|
3085
|
-
|
|
3088
|
+
}
|
|
3089
|
+
};
|
|
3090
|
+
}])
|
|
3086
3091
|
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
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
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
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
|
-
|
|
3123
|
+
let getAllParent = function(cronappDatasource, item, ids, resolve, reject) {
|
|
3123
3124
|
|
|
3124
|
-
|
|
3125
|
-
|
|
3125
|
+
if (item[schema.model.id])
|
|
3126
|
+
ids.push(item[schema.model.id]);
|
|
3126
3127
|
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
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
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
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
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3162
|
+
let helperDirective = this;
|
|
3163
|
+
let waitingPromise = false;
|
|
3164
|
+
let datasource = new kendo.data.HierarchicalDataSource({
|
|
3165
|
+
transport: {
|
|
3166
|
+
push: function(callback) {
|
|
3166
3167
|
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3168
|
+
if (!helperDirective.dataSourceEventsPush && this.options.cronappDatasource) {
|
|
3169
|
+
helperDirective.dataSourceEventsPush = {
|
|
3170
|
+
create: function(data) {
|
|
3170
3171
|
|
|
3171
|
-
|
|
3172
|
+
reloadAndExpand.bind(this)(data);
|
|
3172
3173
|
|
|
3173
|
-
|
|
3174
|
-
|
|
3174
|
+
}.bind(this),
|
|
3175
|
+
update: function(data) {
|
|
3175
3176
|
|
|
3176
|
-
|
|
3177
|
+
reloadAndExpand.bind(this)(data);
|
|
3177
3178
|
|
|
3178
|
-
|
|
3179
|
-
|
|
3179
|
+
}.bind(this),
|
|
3180
|
+
delete: function(data) {
|
|
3180
3181
|
|
|
3181
|
-
|
|
3182
|
-
|
|
3182
|
+
reloadAndExpand.bind(this)(data);
|
|
3183
|
+
ngModelCtrl.$setViewValue(null);
|
|
3183
3184
|
|
|
3184
|
-
|
|
3185
|
-
|
|
3185
|
+
}.bind(this),
|
|
3186
|
+
overRideRefresh: function(data) {
|
|
3186
3187
|
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3188
|
+
this.options.fromRefresh = true;
|
|
3189
|
+
this.options.kendoObj.dataSource.read();
|
|
3190
|
+
ngModelCtrl.$setViewValue(null);
|
|
3190
3191
|
|
|
3191
|
-
|
|
3192
|
-
|
|
3192
|
+
}.bind(this),
|
|
3193
|
+
read: function(data) {
|
|
3193
3194
|
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3195
|
+
if (!waitingPromise) {
|
|
3196
|
+
this.options.kendoObj.dataSource.read();
|
|
3197
|
+
ngModelCtrl.$setViewValue(null);
|
|
3198
|
+
}
|
|
3198
3199
|
|
|
3199
|
-
|
|
3200
|
-
|
|
3200
|
+
}.bind(this)
|
|
3201
|
+
};
|
|
3201
3202
|
|
|
3202
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3226
|
+
for (key in e.data)
|
|
3227
|
+
if(e.data[key] == undefined)
|
|
3228
|
+
delete e.data[key];
|
|
3242
3229
|
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
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
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
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`};
|
|
3243
|
+
|
|
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
|
+
}
|
|
3296
3255
|
|
|
3297
|
-
|
|
3298
|
-
|
|
3256
|
+
cronappDatasource.rowsPerPage = e.data.pageSize;
|
|
3257
|
+
cronappDatasource.offset = (e.data.page - 1);
|
|
3299
3258
|
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3259
|
+
|
|
3260
|
+
let fetchData = {};
|
|
3261
|
+
fetchData.params = paramsOData;
|
|
3262
|
+
|
|
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
|
+
}
|
|
3309
3306
|
},
|
|
3310
|
-
|
|
3307
|
+
schema: schema
|
|
3308
|
+
});
|
|
3309
|
+
return datasource;
|
|
3310
|
+
},
|
|
3311
|
+
link: function (scope, element, attrs, ngModelCtrl) {
|
|
3311
3312
|
|
|
3312
|
-
|
|
3313
|
-
|
|
3313
|
+
let $templateDyn = $('<div></div>');
|
|
3314
|
+
let options = JSON.parse(attrs.options);
|
|
3314
3315
|
|
|
3315
|
-
|
|
3316
|
+
let helperDirective = this;
|
|
3316
3317
|
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
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
|
+
};
|
|
3325
3326
|
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
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());
|
|
3332
3333
|
|
|
3333
|
-
|
|
3334
|
-
|
|
3334
|
+
let cronappDatasource = this.dataSource.transport.options.cronappDatasource;
|
|
3335
|
+
scope.safeApply(cronappDatasource.goTo(item));
|
|
3335
3336
|
|
|
3336
|
-
|
|
3337
|
-
|
|
3337
|
+
if(options.fieldType && options.fieldType === 'key')
|
|
3338
|
+
cronappDatasource.active = changeObjectField(cronappDatasource, cronappDatasource.active);
|
|
3338
3339
|
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3340
|
+
ngModelCtrl.$setViewValue(cronappDatasource.active);
|
|
3341
|
+
}
|
|
3342
|
+
}).data('kendoTreeView');
|
|
3343
|
+
kendoObj.dataSource.transport.options.kendoObj = kendoObj;
|
|
3343
3344
|
|
|
3344
|
-
|
|
3345
|
-
|
|
3345
|
+
element.html($templateDyn);
|
|
3346
|
+
$compile($templateDyn)(element.scope());
|
|
3346
3347
|
|
|
3347
|
-
|
|
3348
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -4448,12 +4466,16 @@
|
|
|
4448
4466
|
require: 'ngModel',
|
|
4449
4467
|
link: function(scope, elem, attrs, ngModelCtrl) {
|
|
4450
4468
|
|
|
4451
|
-
attrs.theme = $(elem).find('i').attr('xattr-theme');
|
|
4452
|
-
attrs.iconOn = $(elem).find('i').attr('class');
|
|
4453
|
-
|
|
4454
4469
|
var $elem = $(elem);
|
|
4455
4470
|
var starArray = [];
|
|
4456
4471
|
|
|
4472
|
+
var icon = $elem.find('i');
|
|
4473
|
+
|
|
4474
|
+
attrs.iconSize = icon[0].dataset.size;
|
|
4475
|
+
attrs.iconTheme = icon[0].dataset.theme;
|
|
4476
|
+
attrs.iconOn = icon[0].className;
|
|
4477
|
+
attrs.iconOn = attrs.iconOn.replace(attrs.iconSize).replace(attrs.iconTheme);
|
|
4478
|
+
|
|
4457
4479
|
if (attrs.xattrDefaultValue) {
|
|
4458
4480
|
ngModelCtrl.$viewValue = 0; //set new view value
|
|
4459
4481
|
ngModelCtrl.$commitViewValue();
|
|
@@ -4461,6 +4483,7 @@
|
|
|
4461
4483
|
|
|
4462
4484
|
for (var i=1;i<=5;i++) {
|
|
4463
4485
|
starArray.push($(elem).find('i').get(i - 1));
|
|
4486
|
+
$(starArray[i-1]).removeClass(attrs.iconOn);
|
|
4464
4487
|
$(starArray[i-1]).addClass(attrs.iconOff || "fa fa-star-o");
|
|
4465
4488
|
}
|
|
4466
4489
|
|
|
@@ -4489,13 +4512,16 @@
|
|
|
4489
4512
|
for (var i=1;i<=5;i++) {
|
|
4490
4513
|
stars[i-1].removeClass(attrs.iconOff || 'fa fa-star-o');
|
|
4491
4514
|
stars[i-1].removeClass(attrs.iconOn);
|
|
4492
|
-
stars[i-1].removeClass(attrs.
|
|
4515
|
+
stars[i-1].removeClass(attrs.iconSize);
|
|
4516
|
+
stars[i-1].removeClass(attrs.iconTheme);
|
|
4493
4517
|
if (i <= value) {
|
|
4494
4518
|
stars[i-1].addClass(attrs.iconOn);
|
|
4495
|
-
stars[i-1].addClass(attrs.
|
|
4519
|
+
stars[i-1].addClass(attrs.iconSize);
|
|
4520
|
+
stars[i-1].addClass(attrs.iconTheme);
|
|
4496
4521
|
} else {
|
|
4497
4522
|
stars[i-1].addClass(attrs.iconOff || 'fa fa-star-o');
|
|
4498
|
-
stars[i-1].addClass(attrs.
|
|
4523
|
+
stars[i-1].addClass(attrs.iconSize);
|
|
4524
|
+
stars[i-1].addClass(attrs.iconTheme);
|
|
4499
4525
|
}
|
|
4500
4526
|
}
|
|
4501
4527
|
return value;
|
|
@@ -4507,92 +4533,175 @@
|
|
|
4507
4533
|
}
|
|
4508
4534
|
})
|
|
4509
4535
|
|
|
4510
|
-
.directive('cronDynamicMenu', ['$compile', '$translate', function($compile, $translate){
|
|
4536
|
+
.directive('cronDynamicMenu', ['$compile', '$translate', function ($compile, $translate) {
|
|
4511
4537
|
'use strict';
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4538
|
+
const populateSubitems = (item) => {
|
|
4539
|
+
var subitem = item.menuItems;
|
|
4540
|
+
var templateSubitens = '';
|
|
4541
|
+
|
|
4542
|
+
subitem.forEach((subitem) => {
|
|
4543
|
+
var securitySubitem = (subitem.security && subitem.security != null) ? ' cronapp-security="' + subitem.security + '" ' : '';
|
|
4544
|
+
var actionSubitem = (subitem.action && subitem.action != null) ? ' ng-click="' + subitem.action + '" ' : '';
|
|
4545
|
+
var hideSubitem = (subitem.hide && subitem.hide != null) ? ' ng-hide="' + subitem.hide + '" ' : '';
|
|
4546
|
+
var iconClassSubitem = (subitem.iconClass && subitem.iconClass != null) ? '<i class="' + subitem.iconClass + '"></i> ' : '';
|
|
4547
|
+
var titleSubitem = '<span></span>';
|
|
4548
|
+
var caretSubitem = (subitem.menuItems && Array.isArray(subitem.menuItems) && (subitem.menuItems.length > 0)) ? '<span class="caret submenu"></span>' : '';
|
|
4549
|
+
|
|
4550
|
+
if (subitem.title) {
|
|
4551
|
+
titleSubitem = '<span>' + $translate.instant(subitem.title) + '</span>';
|
|
4552
|
+
}
|
|
4553
|
+
|
|
4554
|
+
if (subitem.menuItems.length > 0) {
|
|
4555
|
+
templateSubitens = templateSubitens + '<li class="dropdown-submenu">\
|
|
4556
|
+
<a class="dropdown-item dropdown-toggle" role="button" aria-haspopup="true" aria-expanded="false" href=""' + securitySubitem + actionSubitem + '>' + iconClassSubitem + titleSubitem + caretSubitem + '</a>\
|
|
4557
|
+
' + populateItems(subitem.menuItems) + '\
|
|
4558
|
+
</li>';
|
|
4559
|
+
|
|
4560
|
+
} else {
|
|
4561
|
+
templateSubitens = templateSubitens + '<li class="dropdown-submenu">\
|
|
4562
|
+
<a role="button" aria-haspopup="true" aria-expanded="false" href=""' + securitySubitem + actionSubitem + '>' + iconClassSubitem + titleSubitem + caretSubitem + '</a>\
|
|
4563
|
+
</li>';
|
|
4564
|
+
}
|
|
4565
|
+
});
|
|
4566
|
+
|
|
4567
|
+
if (templateSubitens != '') {
|
|
4568
|
+
templateSubitens = '<ul class="dropdown-menu">' + templateSubitens + '</ul>';
|
|
4569
|
+
}
|
|
4570
|
+
|
|
4571
|
+
return templateSubitens;
|
|
4572
|
+
};
|
|
4573
|
+
|
|
4574
|
+
const populateItems = (items) => {
|
|
4575
|
+
var templateItens = '';
|
|
4576
|
+
|
|
4577
|
+
if (items && items.length > 0 && Array.isArray(items)) {
|
|
4578
|
+
items.forEach(function (item) {
|
|
4579
|
+
|
|
4580
|
+
var security = (item.security && item.security != null) ? ' cronapp-security="' + item.security + '" ' : '';
|
|
4581
|
+
var action = (item.action && item.action != null) ? ' ng-click="' + item.action + '" ' : '';
|
|
4582
|
+
var hide = (item.hide && item.hide != null) ? ' ng-hide="' + item.hide + '" ' : '';
|
|
4583
|
+
var iconClass = (item.iconClass && item.iconClass != null) ? '<i class="' + item.iconClass + '"></i> ' : '';
|
|
4584
|
+
var title = '<span></span>';
|
|
4585
|
+
var caret = (item.menuItems && Array.isArray(item.menuItems) && (item.menuItems.length > 0)) ? '<span class="caret submenu"></span>' : '';
|
|
4586
|
+
|
|
4587
|
+
if (item.title) {
|
|
4588
|
+
title = '<span>' + $translate.instant(item.title) + '</span>';
|
|
4589
|
+
}
|
|
4590
|
+
|
|
4591
|
+
if (item.menuItems.length > 0) {
|
|
4592
|
+
templateItens = templateItens + '\
|
|
4593
|
+
<li class="dropdown-submenu" ' + hide + '> \
|
|
4594
|
+
<a href="" ' + action + ' class="dropdown-item dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' + iconClass + title + caret + ' </a> \
|
|
4595
|
+
' + populateSubitems(item) + '\
|
|
4596
|
+
</li>';
|
|
4597
|
+
} else {
|
|
4598
|
+
templateItens = templateItens + '\
|
|
4599
|
+
<li class="dropdown-submenu" ' + hide + '> \
|
|
4600
|
+
<a href="" ' + action + ' class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' + iconClass + title + caret + ' </a> \
|
|
4601
|
+
</li>';
|
|
4533
4602
|
}
|
|
4603
|
+
|
|
4604
|
+
});
|
|
4605
|
+
|
|
4606
|
+
if (templateItens != '') {
|
|
4607
|
+
templateItens = '<ul class="dropdown-menu">' + templateItens + '</ul>';
|
|
4534
4608
|
}
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4609
|
+
}
|
|
4610
|
+
|
|
4611
|
+
return templateItens;
|
|
4612
|
+
}
|
|
4613
|
+
return {
|
|
4614
|
+
restrict: 'EA',
|
|
4615
|
+
populateMenu: function (menuOptions, isVertical) {
|
|
4539
4616
|
var template = '';
|
|
4540
|
-
|
|
4541
|
-
if (menuOptions && menuOptions!= null && menuOptions.subMenuOptions && menuOptions.subMenuOptions != null && Array.isArray(menuOptions.subMenuOptions)){
|
|
4542
|
-
|
|
4543
|
-
menuOptions.subMenuOptions.forEach(function(menu) {
|
|
4617
|
+
|
|
4618
|
+
if (menuOptions && menuOptions != null && menuOptions.subMenuOptions && menuOptions.subMenuOptions != null && Array.isArray(menuOptions.subMenuOptions)) {
|
|
4619
|
+
|
|
4620
|
+
menuOptions.subMenuOptions.forEach(function (menu) {
|
|
4621
|
+
|
|
4544
4622
|
var security = (menu.security && menu.security != null) ? ' cronapp-security="' + menu.security + '" ' : '';
|
|
4545
4623
|
var action = (menu.action && menu.action != null) ? ' ng-click="' + menu.action + '" ' : '';
|
|
4546
4624
|
var caret = (menu.menuItems && Array.isArray(menu.menuItems) && (menu.menuItems.length > 0)) ? '<span class="caret"></span>' : '';
|
|
4547
4625
|
var hide = (menu.hide && menu.hide != null) ? ' ng-hide="' + menu.hide + '" ' : '';
|
|
4548
|
-
var iconClass = (menu.iconClass && menu.iconClass != null) ? '<i class="'+ menu.iconClass +'"></i> ' : '';
|
|
4626
|
+
var iconClass = (menu.iconClass && menu.iconClass != null) ? '<i class="' + menu.iconClass + '"></i> ' : '';
|
|
4549
4627
|
var title = '<span></span>'
|
|
4550
|
-
|
|
4628
|
+
|
|
4629
|
+
if (menu.title) {
|
|
4551
4630
|
title = '<span>' + $translate.instant(menu.title) + '</span>';
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4631
|
+
}
|
|
4632
|
+
|
|
4633
|
+
template = template + '\
|
|
4634
|
+
<li class="dropdown nav-item '+ (isVertical ? 'col-md-12 padding-0' : '') + '"' + security + hide + '>\
|
|
4635
|
+
<a href="" ' + action + ' class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">\
|
|
4636
|
+
' + iconClass + title + caret + '\
|
|
4637
|
+
</a> \
|
|
4638
|
+
' + populateItems(menu.menuItems) + '\
|
|
4639
|
+
</li>';
|
|
4640
|
+
|
|
4560
4641
|
})
|
|
4561
4642
|
}
|
|
4562
|
-
|
|
4643
|
+
|
|
4563
4644
|
return template;
|
|
4564
4645
|
},
|
|
4565
|
-
link: function(scope, element, attrs) {
|
|
4646
|
+
link: function (scope, element, attrs) {
|
|
4566
4647
|
$translate.onReady(() => {
|
|
4567
4648
|
//Somente fica na vertical se for o menu principal da IDE (E estiver configurado para isso)
|
|
4568
|
-
let isVertical =
|
|
4569
|
-
|
|
4570
|
-
var TEMPLATE_MAIN = '<ul
|
|
4649
|
+
let isVertical = element.closest('.crn-navigator-vertical').length;
|
|
4650
|
+
|
|
4651
|
+
var TEMPLATE_MAIN = '<ul class="nav navbar-nav ' + (isVertical ? 'col-md-12 padding-0' : '') + ' "></ul>';
|
|
4571
4652
|
var options = {};
|
|
4572
4653
|
try {
|
|
4573
4654
|
options = JSON.parse(attrs.options);
|
|
4574
|
-
} catch(e) {
|
|
4655
|
+
} catch (e) {
|
|
4575
4656
|
console.log('CronDynamicMenu: Invalid configuration!')
|
|
4576
4657
|
}
|
|
4577
|
-
|
|
4658
|
+
|
|
4578
4659
|
var main = $(TEMPLATE_MAIN);
|
|
4579
4660
|
main.attr('id', attrs.id);
|
|
4580
|
-
|
|
4661
|
+
|
|
4581
4662
|
var menus = this.populateMenu(options, isVertical);
|
|
4582
4663
|
main.append(menus);
|
|
4583
4664
|
if (isVertical) {
|
|
4584
|
-
main.append(
|
|
4665
|
+
main.append($('#navbar2 li:first').addClass('col-md-12 padding-0'));
|
|
4585
4666
|
}
|
|
4586
|
-
|
|
4667
|
+
|
|
4587
4668
|
var newElement = angular.element(main);
|
|
4588
4669
|
element.html('');
|
|
4589
4670
|
element.append(main);
|
|
4590
|
-
element.attr('id'
|
|
4671
|
+
element.attr('id', null);
|
|
4591
4672
|
$compile(newElement)(scope);
|
|
4673
|
+
|
|
4674
|
+
var multilevelAction = attrs.multilevelAction;
|
|
4675
|
+
|
|
4676
|
+
if (multilevelAction === 'hover') {
|
|
4677
|
+
$('.dropdown-menu .dropdown-submenu').on('mouseover', function () {
|
|
4678
|
+
var subMenu = $(this).children('ul.dropdown-menu');
|
|
4679
|
+
subMenu.addClass('displayBlock');
|
|
4680
|
+
});
|
|
4681
|
+
|
|
4682
|
+
$('.dropdown-menu .dropdown-submenu').on('mouseout', function () {
|
|
4683
|
+
var subMenu = $(this).children('ul.dropdown-menu');
|
|
4684
|
+
subMenu.removeClass('displayBlock');
|
|
4685
|
+
});
|
|
4686
|
+
}
|
|
4687
|
+
if (multilevelAction === 'click') {
|
|
4688
|
+
$('.dropdown-menu a.dropdown-toggle').on('click', function (e) {
|
|
4689
|
+
if (!$(this).next().hasClass('show')) {
|
|
4690
|
+
$(this).parents('.dropdown-menu').first().find('.show').removeClass("show");
|
|
4691
|
+
}
|
|
4692
|
+
var $subMenu = $(this).next(".dropdown-menu");
|
|
4693
|
+
$subMenu.toggleClass('show');
|
|
4694
|
+
$(this).parents('li.nav-item.dropdown').on('hidden.bs.dropdown', function (e) {
|
|
4695
|
+
$('.dropdown-submenu .show').removeClass("show");
|
|
4696
|
+
});
|
|
4697
|
+
return false;
|
|
4698
|
+
});
|
|
4699
|
+
}
|
|
4700
|
+
|
|
4592
4701
|
});
|
|
4593
4702
|
}
|
|
4594
4703
|
}
|
|
4595
|
-
|
|
4704
|
+
}])
|
|
4596
4705
|
|
|
4597
4706
|
.directive('ngInitialValue', function($parse) {
|
|
4598
4707
|
return {
|
|
@@ -4640,47 +4749,37 @@
|
|
|
4640
4749
|
link: function (scope, el, attrs, ctrl) {
|
|
4641
4750
|
ctrl.$formatters = [];
|
|
4642
4751
|
ctrl.$parsers = [];
|
|
4643
|
-
|
|
4644
|
-
let
|
|
4752
|
+
|
|
4753
|
+
let falseValue = attrs.ngFalseValue ? attrs.ngFalseValue.split("'").join("") : false;
|
|
4754
|
+
let trueValue = attrs.ngTrueValue ? attrs.ngTrueValue.split("'").join("") : true;
|
|
4645
4755
|
|
|
4646
4756
|
if (attrs.crnAllowNullValues == 'true') {
|
|
4647
4757
|
ctrl.$render = function () {
|
|
4648
4758
|
let viewValue = ctrl.$viewValue;
|
|
4649
4759
|
el.data('checked', viewValue);
|
|
4650
|
-
viewValue = '' + viewValue;
|
|
4651
4760
|
switch (viewValue) {
|
|
4652
4761
|
case true:
|
|
4653
4762
|
case trueValue:
|
|
4654
4763
|
el.prop('indeterminate', false);
|
|
4655
4764
|
el.prop('checked', true);
|
|
4765
|
+
viewValue = trueValue;
|
|
4656
4766
|
break;
|
|
4657
4767
|
case false:
|
|
4658
4768
|
case falseValue:
|
|
4659
4769
|
el.prop('indeterminate', false);
|
|
4660
4770
|
el.prop('checked', false);
|
|
4771
|
+
viewValue = falseValue;
|
|
4661
4772
|
break;
|
|
4662
4773
|
default:
|
|
4774
|
+
viewValue = null;
|
|
4663
4775
|
el.prop('indeterminate', true);
|
|
4664
4776
|
}
|
|
4777
|
+
ctrl.$setViewValue(viewValue);
|
|
4665
4778
|
};
|
|
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
4779
|
} else if (attrs.crnAllowNullValues == 'false') {
|
|
4680
4780
|
ctrl.$render = function () {
|
|
4681
4781
|
let viewValue = ctrl.$viewValue;
|
|
4682
|
-
viewValue
|
|
4683
|
-
if (viewValue === undefined || viewValue === null) {
|
|
4782
|
+
if (ctrl.$viewValue === undefined || ctrl.$viewValue === null) {
|
|
4684
4783
|
ctrl.$setViewValue(false);
|
|
4685
4784
|
viewValue = false;
|
|
4686
4785
|
}
|
|
@@ -4694,27 +4793,30 @@
|
|
|
4694
4793
|
case trueValue:
|
|
4695
4794
|
el.prop('indeterminate', false);
|
|
4696
4795
|
el.prop('checked', true);
|
|
4796
|
+
viewValue = trueValue;
|
|
4697
4797
|
break;
|
|
4698
4798
|
default:
|
|
4699
4799
|
el.prop('indeterminate', false);
|
|
4700
4800
|
el.prop('checked', false);
|
|
4801
|
+
viewValue = falseValue;
|
|
4701
4802
|
break;
|
|
4702
4803
|
}
|
|
4804
|
+
ctrl.$setViewValue(viewValue);
|
|
4703
4805
|
};
|
|
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
4806
|
}
|
|
4807
|
+
el.bind('click', function () {
|
|
4808
|
+
let checked;
|
|
4809
|
+
switch (el.data('checked')) {
|
|
4810
|
+
case false:
|
|
4811
|
+
case falseValue:
|
|
4812
|
+
checked = attrs.ngTrueValue ? trueValue : true;
|
|
4813
|
+
break;
|
|
4814
|
+
default:
|
|
4815
|
+
checked = attrs.ngFalseValue ? falseValue : false;
|
|
4816
|
+
}
|
|
4817
|
+
ctrl.$setViewValue(checked);
|
|
4818
|
+
scope.$apply(ctrl.$render);
|
|
4819
|
+
});
|
|
4718
4820
|
}
|
|
4719
4821
|
};
|
|
4720
4822
|
}])
|
|
@@ -4740,24 +4842,88 @@
|
|
|
4740
4842
|
}])
|
|
4741
4843
|
|
|
4742
4844
|
.directive('updateLanguage', function($rootScope) {
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4845
|
+
return {
|
|
4846
|
+
link: function( scope, element ) {
|
|
4847
|
+
var listener = function( event, translationResp ) {
|
|
4848
|
+
var defaultLang = "en",
|
|
4849
|
+
currentlang = translationResp.language;
|
|
4850
|
+
|
|
4851
|
+
if (currentlang === 'pt_br')
|
|
4852
|
+
currentlang = "pt-br";
|
|
4853
|
+
else if (currentlang.startsWith('en'))
|
|
4854
|
+
currentlang = "en";
|
|
4855
|
+
|
|
4856
|
+
element.attr("lang", currentlang || defaultLang );
|
|
4857
|
+
};
|
|
4858
|
+
|
|
4859
|
+
$rootScope.$on('$translateChangeSuccess', listener);
|
|
4860
|
+
}
|
|
4861
|
+
};
|
|
4862
|
+
})
|
|
4756
4863
|
|
|
4757
|
-
|
|
4864
|
+
.directive("fromGrid", ($compile) => {
|
|
4865
|
+
return {
|
|
4866
|
+
restrict: 'A',
|
|
4867
|
+
priority: -999999,
|
|
4868
|
+
exist: (element) => {
|
|
4869
|
+
let id = element.attr('id');
|
|
4870
|
+
return $(`#${id}`).length;
|
|
4871
|
+
},
|
|
4872
|
+
isFromGrid: (attr) => {
|
|
4873
|
+
return attr.fromGrid === "true";
|
|
4874
|
+
},
|
|
4875
|
+
isCompiled: (element) => {
|
|
4876
|
+
return element.data('alreadycompiled');
|
|
4877
|
+
},
|
|
4878
|
+
getDateAs: function (element, value, as) {
|
|
4879
|
+
let mask = element.data('mask');
|
|
4880
|
+
let useUTC = element.data('useUTC');
|
|
4881
|
+
return formatWithMomentAs(mask, useUTC, value, as);
|
|
4882
|
+
},
|
|
4883
|
+
prepareValue: function (element, value) {
|
|
4884
|
+
let columnType = element.data('column-type') || '';
|
|
4885
|
+
if (columnType.startsWith('date')) {
|
|
4886
|
+
value = this.getDateAs(element, value, "date");
|
|
4887
|
+
}
|
|
4888
|
+
return value;
|
|
4889
|
+
},
|
|
4890
|
+
formatComponent: function (element, value) {
|
|
4891
|
+
let kendoObj = element.data('kendoDropDownList') || element.data('kendoSlider');
|
|
4892
|
+
let columnType = element.data('column-type') || '';
|
|
4893
|
+
if (columnType.startsWith('date')) {
|
|
4894
|
+
element.val(this.getDateAs(element, value, "string"));
|
|
4895
|
+
}
|
|
4896
|
+
else if (kendoObj) {
|
|
4897
|
+
kendoObj.value(value);
|
|
4898
|
+
}
|
|
4899
|
+
},
|
|
4900
|
+
compileGridListing: function(element, scope) {
|
|
4901
|
+
let sender = element.data('ref-component');
|
|
4902
|
+
if (sender && sender.tbody && sender.tbody.length && !$(sender.tbody).find('.k-grid-edit-row').length) {
|
|
4903
|
+
var toCompile = sender.tbody;
|
|
4904
|
+
setTimeout(() => {
|
|
4905
|
+
scope.safeApply(() => {
|
|
4906
|
+
var trs = $(toCompile);
|
|
4907
|
+
var x = angular.element(trs);
|
|
4908
|
+
$compile(x)(scope);
|
|
4909
|
+
});
|
|
4910
|
+
});
|
|
4911
|
+
}
|
|
4912
|
+
},
|
|
4913
|
+
link: function (scope, element, attr) {
|
|
4914
|
+
scope.$watch(attr.ngModel, (value) => {
|
|
4915
|
+
if (this.isFromGrid(attr) && this.exist(element) && this.isCompiled(element)) {
|
|
4916
|
+
value = this.prepareValue(element, value);
|
|
4917
|
+
this.formatComponent(element, value);
|
|
4918
|
+
this.compileGridListing(element, scope);
|
|
4919
|
+
call = element.data('change-grid-model');
|
|
4920
|
+
call && call(value);
|
|
4758
4921
|
}
|
|
4759
|
-
|
|
4922
|
+
});
|
|
4923
|
+
}
|
|
4924
|
+
}
|
|
4760
4925
|
})
|
|
4926
|
+
|
|
4761
4927
|
}(app));
|
|
4762
4928
|
|
|
4763
4929
|
function maskDirectiveAsDate($compile, $translate, $parse) {
|
|
@@ -4785,6 +4951,7 @@ function maskDirective($compile, $translate, $parse, attrName) {
|
|
|
4785
4951
|
if ($element.data('alreadycompiled'))
|
|
4786
4952
|
return;
|
|
4787
4953
|
$element.data('alreadycompiled', true);
|
|
4954
|
+
$element.data('$compile', $compile);
|
|
4788
4955
|
|
|
4789
4956
|
var type = $element.attr("type");
|
|
4790
4957
|
|
|
@@ -4866,6 +5033,9 @@ function maskDirective($compile, $translate, $parse, attrName) {
|
|
|
4866
5033
|
useUTC = false;
|
|
4867
5034
|
}
|
|
4868
5035
|
|
|
5036
|
+
$element.data('mask', mask);
|
|
5037
|
+
$element.data('useUTC', useUTC);
|
|
5038
|
+
|
|
4869
5039
|
if ($element.attr('from-grid')) {
|
|
4870
5040
|
var openPopup = function() {
|
|
4871
5041
|
var popup = $(this).offset();
|
|
@@ -4898,16 +5068,20 @@ function maskDirective($compile, $translate, $parse, attrName) {
|
|
|
4898
5068
|
setTimeout(openPopup.bind(this), 100);
|
|
4899
5069
|
});
|
|
4900
5070
|
$element.on('dp.change', function () {
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
5071
|
+
scope.safeApply(function () {
|
|
5072
|
+
var momentDate = null;
|
|
5073
|
+
if (useUTC) {
|
|
5074
|
+
momentDate = moment($element.val(), mask).utcOffset(window.timeZoneOffset, true);
|
|
5075
|
+
} else {
|
|
5076
|
+
momentDate = moment($element.val(), mask);
|
|
5077
|
+
}
|
|
5078
|
+
if (type == 'time' || type == 'time-local') {
|
|
5079
|
+
momentDate = momentDate.year(1970).dayOfYear(1).month(0);
|
|
5080
|
+
}
|
|
5081
|
+
if (momentDate.isValid() && ngModelCtrl) {
|
|
5082
|
+
modelSetter(scope, momentDate.toDate());
|
|
5083
|
+
}
|
|
5084
|
+
});
|
|
4911
5085
|
});
|
|
4912
5086
|
if ($element.data('initial-value')) {
|
|
4913
5087
|
var initialValue = $element.data('initial-value');
|
|
@@ -4926,46 +5100,33 @@ function maskDirective($compile, $translate, $parse, attrName) {
|
|
|
4926
5100
|
$element.wrap("<div style=\"position:relative\"></div>");
|
|
4927
5101
|
}
|
|
4928
5102
|
$element.datetimepicker(options);
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
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()){
|
|
5103
|
+
if (attrs.fromGrid !== "true") {
|
|
5104
|
+
$element.on('dp.change', function () {
|
|
5105
|
+
if ($(this).is(":visible")) {
|
|
5106
|
+
$(this).trigger('change');
|
|
5107
|
+
scope.safeApply(function () {
|
|
5108
|
+
var value = $element.val();
|
|
5109
|
+
var momentDate = null;
|
|
5110
|
+
if (useUTC) {
|
|
5111
|
+
momentDate = moment(value, mask).utcOffset(window.timeZoneOffset, true);
|
|
5112
|
+
} else {
|
|
4964
5113
|
momentDate = moment(value, mask);
|
|
4965
5114
|
}
|
|
4966
|
-
|
|
5115
|
+
if (type == 'time' || type == 'time-local') {
|
|
5116
|
+
momentDate = momentDate.year(1970).dayOfYear(1).month(0);
|
|
5117
|
+
}
|
|
5118
|
+
if (momentDate.isValid() && ngModelCtrl) {
|
|
5119
|
+
modelSetter(scope, momentDate.toDate());
|
|
5120
|
+
}
|
|
5121
|
+
});
|
|
5122
|
+
}
|
|
5123
|
+
});
|
|
5124
|
+
}
|
|
4967
5125
|
|
|
4968
|
-
|
|
5126
|
+
if (ngModelCtrl ) {
|
|
5127
|
+
ngModelCtrl.$formatters.push(function (value) {
|
|
5128
|
+
if (value) {
|
|
5129
|
+
return formatWithMomentAs(mask, useUTC, value, "string");
|
|
4969
5130
|
}
|
|
4970
5131
|
|
|
4971
5132
|
if(value === null){
|
|
@@ -5068,29 +5229,20 @@ function maskDirective($compile, $translate, $parse, attrName) {
|
|
|
5068
5229
|
$(element).inputmask(inputmaskType, ipOptions);
|
|
5069
5230
|
useInputMaskPlugin(element, ngModelCtrl, scope, modelSetter, mask);
|
|
5070
5231
|
}
|
|
5071
|
-
else if (type == 'text' || type == 'tel') {
|
|
5232
|
+
else if (type == 'text' || type == 'tel' || type == 'string') {
|
|
5072
5233
|
if(!attrs.maskPlaceholder){
|
|
5073
5234
|
$element.mask(mask);
|
|
5074
5235
|
useMaskPlugin(element, ngModelCtrl, scope, modelSetter, removeMask);
|
|
5075
5236
|
}
|
|
5076
5237
|
else{
|
|
5077
5238
|
options = {};
|
|
5078
|
-
options['placeholder'] = attrs.maskPlaceholder
|
|
5239
|
+
options['placeholder'] = attrs.maskPlaceholder;
|
|
5079
5240
|
$(element).inputmask(mask, options);
|
|
5080
5241
|
if(removeMask){
|
|
5081
5242
|
useInputMaskPlugin(element, ngModelCtrl, scope, modelSetter, mask);
|
|
5082
5243
|
}
|
|
5083
5244
|
}
|
|
5084
5245
|
}
|
|
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
5246
|
}
|
|
5095
5247
|
}
|
|
5096
5248
|
}
|
|
@@ -5242,6 +5394,16 @@ function transformText() {
|
|
|
5242
5394
|
|
|
5243
5395
|
|
|
5244
5396
|
app.kendoHelper = {
|
|
5397
|
+
getCorrectlyDS: (name, scope) => {
|
|
5398
|
+
if (scope[name].apiVersion) {
|
|
5399
|
+
return scope[name];
|
|
5400
|
+
}
|
|
5401
|
+
else {
|
|
5402
|
+
let ds = scope.$parent[name];
|
|
5403
|
+
scope[name] = ds;
|
|
5404
|
+
return ds;
|
|
5405
|
+
}
|
|
5406
|
+
},
|
|
5245
5407
|
receivePushData: comp => !comp || !comp.dataSource || (comp.dataSource.transport.options.refComponent = comp),
|
|
5246
5408
|
getSchema: function(dataSource) {
|
|
5247
5409
|
var parseAttribute = [
|
|
@@ -5339,8 +5501,8 @@ app.kendoHelper = {
|
|
|
5339
5501
|
};
|
|
5340
5502
|
|
|
5341
5503
|
var pageSize = 10;
|
|
5342
|
-
if (
|
|
5343
|
-
pageSize =
|
|
5504
|
+
if (app.kendoHelper.getCorrectlyDS(dataSource.name, scope))
|
|
5505
|
+
pageSize = app.kendoHelper.getCorrectlyDS(dataSource.name, scope).rowsPerPage;
|
|
5344
5506
|
|
|
5345
5507
|
//Quando não for data UTC
|
|
5346
5508
|
var offsetMiliseconds = new Date().getTimezoneOffset() * 60000;
|
|
@@ -5435,7 +5597,7 @@ app.kendoHelper = {
|
|
|
5435
5597
|
if (this.options.isComponentInDocument(this.options.refComponent)) {
|
|
5436
5598
|
let current = this.options.getCurrentCallbackForPush(callback, this.options.refComponent);
|
|
5437
5599
|
let acceptedMethod = current[type];
|
|
5438
|
-
|
|
5600
|
+
|
|
5439
5601
|
if (acceptedMethod) {
|
|
5440
5602
|
acceptedMethod(data);
|
|
5441
5603
|
}
|
|
@@ -5535,13 +5697,13 @@ app.kendoHelper = {
|
|
|
5535
5697
|
if (dataSource.append) {
|
|
5536
5698
|
append = dataSource.append;
|
|
5537
5699
|
}
|
|
5538
|
-
|
|
5700
|
+
|
|
5539
5701
|
var fetchOptions = {};
|
|
5540
5702
|
//indicates that the search has already been clicked, set the fetchOptions orign to loadDataStrategy
|
|
5541
5703
|
if (cronappDatasource.loadDataStrategy === "button" && cronappDatasource.data.length > 0) {
|
|
5542
5704
|
fetchOptions.origin = cronappDatasource.loadDataStrategy;
|
|
5543
5705
|
}
|
|
5544
|
-
|
|
5706
|
+
|
|
5545
5707
|
cronappDatasource.append = append;
|
|
5546
5708
|
cronappDatasource.fetch(fetchData, {
|
|
5547
5709
|
success: function(data) {
|
|
@@ -5625,7 +5787,7 @@ app.kendoHelper = {
|
|
|
5625
5787
|
return callback;
|
|
5626
5788
|
return component;
|
|
5627
5789
|
},
|
|
5628
|
-
cronappDatasource:
|
|
5790
|
+
cronappDatasource: app.kendoHelper.getCorrectlyDS(dataSource.name, scope)
|
|
5629
5791
|
}
|
|
5630
5792
|
},
|
|
5631
5793
|
pageSize: pageSize,
|
|
@@ -5955,39 +6117,32 @@ app.kendoHelper = {
|
|
|
5955
6117
|
useUTC = false;
|
|
5956
6118
|
}
|
|
5957
6119
|
|
|
5958
|
-
|
|
5959
|
-
|
|
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
|
-
}
|
|
6120
|
+
$element.data('mask', options.momentFormat);
|
|
6121
|
+
$element.data('useUTC', useUTC);
|
|
5979
6122
|
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
};
|
|
6123
|
+
var onChange = function() {
|
|
6124
|
+
var value = $element.val();
|
|
6125
|
+
if (!value || value.trim() == '') {
|
|
6126
|
+
if (ngModelCtrl)
|
|
6127
|
+
ngModelCtrl.$setViewValue('');
|
|
5986
6128
|
} else {
|
|
5987
|
-
|
|
6129
|
+
var valueDate = formatWithMomentAs(options.momentFormat, useUTC, value, "date");
|
|
6130
|
+
if (ngModelCtrl) {
|
|
6131
|
+
ngModelCtrl.$setViewValue(valueDate);
|
|
6132
|
+
$element.data('changed', true);
|
|
6133
|
+
}
|
|
5988
6134
|
}
|
|
5989
6135
|
}
|
|
5990
6136
|
|
|
6137
|
+
if (scope) {
|
|
6138
|
+
options['change'] = function() {
|
|
6139
|
+
scope.$apply(function () {
|
|
6140
|
+
onChange();
|
|
6141
|
+
});
|
|
6142
|
+
};
|
|
6143
|
+
} else {
|
|
6144
|
+
options['change'] = onChange;
|
|
6145
|
+
}
|
|
5991
6146
|
|
|
5992
6147
|
if (options.type == 'date') {
|
|
5993
6148
|
return $element.kendoDatePicker(options).data('kendoDatePicker');
|
|
@@ -6088,3 +6243,29 @@ window.useMask = function(value, format, type) {
|
|
|
6088
6243
|
|
|
6089
6244
|
return mask;
|
|
6090
6245
|
};
|
|
6246
|
+
|
|
6247
|
+
window.formatWithMomentAs = function (mask, useUTC, value, as) {
|
|
6248
|
+
|
|
6249
|
+
if (!value) return;
|
|
6250
|
+
|
|
6251
|
+
let momentDate = null;
|
|
6252
|
+
|
|
6253
|
+
if (value instanceof Date || value.startsWith('/Date')) {
|
|
6254
|
+
if (useUTC) {
|
|
6255
|
+
momentDate = moment(value).utcOffset(window.timeZoneOffset);
|
|
6256
|
+
} else {
|
|
6257
|
+
momentDate = moment(value);
|
|
6258
|
+
}
|
|
6259
|
+
}
|
|
6260
|
+
else {
|
|
6261
|
+
if (useUTC) {
|
|
6262
|
+
momentDate = moment(value, mask).utcOffset(window.timeZoneOffset, true);
|
|
6263
|
+
} else {
|
|
6264
|
+
momentDate = moment(value, mask);
|
|
6265
|
+
}
|
|
6266
|
+
}
|
|
6267
|
+
if (as === 'string') {
|
|
6268
|
+
return momentDate.format(mask);
|
|
6269
|
+
}
|
|
6270
|
+
return momentDate.toDate();
|
|
6271
|
+
};
|