cronapp-framework-js 3.2.0-SP.9 → 3.2.1-SP.1

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/js/directives.js CHANGED
@@ -2581,11 +2581,12 @@
2581
2581
  }, 200);
2582
2582
  }
2583
2583
 
2584
- function getCommandForEditButtonDatabase(opt, command) {
2584
+ function getCommandForEditButtonDatabase(opt, command, iconClass) {
2585
2585
  var cmd;
2586
2586
  let idForCommand = app.common.generateId();
2587
2587
  let ariaLabel = $translate.instant('Edit');
2588
- 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>`;
2588
+ let iconEditClass = iconClass ? iconClass : "k-icon k-i-edit";
2589
+ let template = `<a href class='k-button k-grid-edit k-grid-${idForCommand}' aria-label='${ariaLabel}'><span class='${iconEditClass}'></span></a>`;
2589
2590
  if ((opt.editable == 'popupCustom') || (opt.editable == 'datasource')) {
2590
2591
  cmd = {
2591
2592
  name: idForCommand,
@@ -2625,11 +2626,12 @@
2625
2626
  return cmd;
2626
2627
  }
2627
2628
 
2628
- function getCommandForRemoveButtonDatabase(opt, command) {
2629
+ function getCommandForRemoveButtonDatabase(opt, command, iconClass) {
2629
2630
  var cmd;
2630
2631
  let idForCommand = app.common.generateId();
2631
2632
  let ariaLabel = $translate.instant('Remove');
2632
- 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>`;
2633
+ let iconDeleteClass = iconClass ? iconClass : "k-icon k-i-close";
2634
+ let template = `<a href class='k-button k-grid-delete k-grid-${idForCommand}' aria-label='${ariaLabel}'><span class='${iconDeleteClass}'></span></a>`;
2633
2635
 
2634
2636
  if ((opt.editable == 'popupCustom') || (opt.editable == 'datasource')) {
2635
2637
  cmd = {
@@ -2824,10 +2826,10 @@
2824
2826
  command.forEach(function(f) {
2825
2827
  var cmd;
2826
2828
  if ( f == "edit") {
2827
- cmd = getCommandForEditButtonDatabase.bind(this)(options, f);
2829
+ cmd = getCommandForEditButtonDatabase.bind(this)(options, f, column.iconEditClass);
2828
2830
  }
2829
2831
  else {
2830
- cmd = getCommandForRemoveButtonDatabase.bind(this)(options, f);
2832
+ cmd = getCommandForRemoveButtonDatabase.bind(this)(options, f, column.iconDeleteClass);
2831
2833
  }
2832
2834
  commands.push(cmd);
2833
2835
  }.bind(this));
@@ -5512,101 +5514,134 @@
5512
5514
  }])
5513
5515
 
5514
5516
  .directive('cronBreadcrumbs', function ($rootScope) {
5515
- 'use strict';
5516
- return {
5517
- restrict: 'E',
5518
- replace: true,
5519
- link: function (scope, element, attrs) {
5520
-
5521
- var bcAction = attrs.ngInit ? attrs.ngInit : null;
5522
- const bcDelimiterIcon = attrs.crnDelimiterIcon;
5523
- const bcTypeMenu = attrs.typeMenu;
5524
- const bcMenuId = attrs.idMenu ? attrs.idMenu : null;
5525
- const bcId = attrs.id;
5526
- const bcIconRoot = attrs.breadcrumbIcon ? attrs.breadcrumbIcon : null;
5527
- const bcList = [];
5528
-
5529
- const fillAction = async () => {
5517
+ 'use strict';
5518
+ return {
5519
+ restrict: 'E',
5520
+ replace: true,
5521
+ link: function (scope, element, attrs) {
5522
+
5523
+ let bcAction = attrs.ngInit ? attrs.ngInit : null;
5524
+ let bcList = [];
5525
+ const bcDelimiterIcon = attrs.crnDelimiterIcon;
5526
+ const bcTypeMenu = attrs.typeMenu;
5527
+ const bcMenuId = attrs.idMenu ? attrs.idMenu : null;
5528
+ const bcId = attrs.id;
5529
+ const bcIconRoot = attrs.breadcrumbIcon ? attrs.breadcrumbIcon : null;
5530
+
5531
+
5532
+ const destroyBreadcrumb = () => {
5533
+ const $bcElement = $(`#${bcId}`);
5534
+ if ($bcElement.data('kendoBreadcrumb')) {
5535
+ $bcElement.data('kendoBreadcrumb').destroy();
5536
+ $bcElement.empty();
5537
+ }
5538
+ };
5539
+
5540
+
5541
+ const fillAction = async () => {
5530
5542
  const shortVersion = bcAction.replace("cronapi.client('js.", 'blockly.js.');
5531
5543
  bcAction = shortVersion.replace("').run()", '');
5532
5544
  bcAction = scope.$eval(bcAction);
5533
5545
  bcList = await bcAction();
5534
5546
 
5535
5547
  const onclick = async (e) => {
5536
- if (e.item.action) {
5548
+ if (e.item.action) {
5537
5549
  e.item.action();
5538
5550
  }
5539
5551
  };
5540
5552
 
5553
+
5554
+ destroyBreadcrumb();
5555
+
5556
+
5541
5557
  $(`#${bcId}`).kendoBreadcrumb({
5542
5558
  items: bcList,
5543
5559
  delimiterIcon: bcDelimiterIcon,
5544
5560
  navigational: true,
5545
- click : onclick
5561
+ click: onclick
5546
5562
  });
5547
- }
5563
+ };
5548
5564
 
5549
- const clearAction = (action) => {
5550
- if (action) {
5551
- return action.replace("cronapi.screen.changeView('", '').replace("', [])", '');
5552
- }
5553
- return "#/home";
5554
- }
5555
5565
 
5556
- if (bcAction && bcTypeMenu === "idBloco") {
5557
- fillAction();
5558
- } else {
5559
- var observer = new MutationObserver((mutation, observer) => {
5566
+ const clearAction = (action) => {
5567
+ if (action) {
5568
+ return action.replace("cronapi.screen.changeView('", '').replace("', [])", '');
5569
+ }
5570
+ return "#/home";
5571
+ };
5572
+
5573
+
5574
+ if (bcAction && bcTypeMenu === "idBloco") {
5575
+ fillAction();
5576
+ }
5577
+
5578
+ else {
5579
+ var observer = new MutationObserver((mutation, obs) => {
5560
5580
  const $parent = $(`#${bcMenuId}`).parent();
5561
5581
  const attrOptions = $parent.attr('options');
5582
+
5562
5583
  if (attrOptions) {
5563
- observer.disconnect(); // stop observing
5564
5584
 
5565
- const options = JSON.parse(attrOptions);
5566
- const page = document.location.hash || 'home';
5585
+ obs.disconnect();
5567
5586
 
5568
- const findTrace = (array, action, path = []) => {
5569
- for (let i = 0; i < array.length; i++) {
5570
- var item = array[i];
5571
- item.action = clearAction(item.action);
5572
- if (item.action === action) {
5573
- return [...path, item];
5574
- }
5575
- if (item.menuItems) {
5576
- const result = findTrace(item.menuItems, action, [...path, item]);
5577
- if (result) {
5578
- return result;
5579
- }
5587
+ const options = JSON.parse(attrOptions);
5588
+ const page = document.location.hash || 'home';
5589
+
5590
+ const findTrace = (array, action, path = []) => {
5591
+ for (let i = 0; i < array.length; i++) {
5592
+ var item = array[i];
5593
+ item.action = clearAction(item.action);
5594
+ if (item.action === action) {
5595
+ return [...path, item];
5596
+ }
5597
+ if (item.menuItems) {
5598
+ const result = findTrace(item.menuItems, action, [...path, item]);
5599
+ if (result) {
5600
+ return result;
5580
5601
  }
5581
5602
  }
5582
- return null;
5583
5603
  }
5604
+ return null;
5605
+ };
5584
5606
 
5585
- const trace = findTrace(options.subMenuOptions, page);
5586
- if (trace) {
5587
- for (var index in trace) {
5588
- const item = trace[index];
5589
- bcList.push({
5590
- type: index == 0 ? 'rootitem' : 'item',
5591
- href: item.action,
5592
- text: item.title,
5593
- showText: true,
5594
- showIcon: false
5595
- });
5596
- }
5597
- $(`#${bcId}`).kendoBreadcrumb({
5598
- items: bcList,
5599
- delimiterIcon: bcDelimiterIcon,
5600
- navigational: true
5601
- });
5607
+
5608
+ const trace = findTrace(options.subMenuOptions, page);
5609
+ if (trace) {
5610
+ bcList = [];
5611
+ for (var index in trace) {
5612
+ const item = trace[index];
5613
+ bcList.push({
5614
+ type: index == 0 ? 'rootitem' : 'item',
5615
+ href: item.action,
5616
+ text: item.title,
5617
+ showText: true,
5618
+ showIcon: false
5619
+ });
5602
5620
  }
5621
+
5622
+
5623
+ destroyBreadcrumb();
5624
+
5625
+
5626
+ $(`#${bcId}`).kendoBreadcrumb({
5627
+ items: bcList,
5628
+ delimiterIcon: bcDelimiterIcon,
5629
+ navigational: true
5630
+ });
5631
+ }
5603
5632
  }
5604
- });
5605
- observer.observe(document.body, { childList : true});
5633
+ });
5634
+
5635
+
5636
+ observer.observe(document.body, {
5637
+ childList: true,
5638
+ attributes: true,
5639
+ subtree: true
5640
+ });
5641
+ }
5606
5642
  }
5607
- }
5608
- }
5609
- })
5643
+ };
5644
+ })
5610
5645
 
5611
5646
  .directive('ngInitialValue', function($parse) {
5612
5647
  return {
@@ -6069,7 +6104,7 @@
6069
6104
  $(window).ready(infiniteScrollController.executeInfinityScroll);
6070
6105
  }
6071
6106
  };
6072
- }]);
6107
+ }])
6073
6108
 
6074
6109
  }(app));
6075
6110
 
@@ -6090,63 +6125,181 @@ function maskDirective($compile, $translate, $parse, attrName) {
6090
6125
  return;
6091
6126
 
6092
6127
  var modelGetter = $parse(attrs['ngModel']);
6093
-
6094
6128
  var modelSetter = modelGetter.assign;
6095
6129
 
6096
-
6097
6130
  var $element = $(element);
6098
6131
  if ($element.data('alreadycompiled'))
6099
6132
  return;
6133
+
6100
6134
  $element.data('alreadycompiled', true);
6101
6135
  $element.data('$compile', $compile);
6102
6136
 
6103
6137
  var type = $element.attr("type");
6138
+
6139
+ if (type === "email") {
6140
+ $element.inputmask("email").attr("novalidate", "novalidate");
6141
+ $element.next(".k-tooltip-validation").remove();
6104
6142
 
6105
- if (type == "checkbox" || type == "password" || type == "url"){
6143
+ const observer = new MutationObserver(() => {
6144
+ const tooltip = $element.next(".k-tooltip-validation");
6145
+ if (tooltip.length) tooltip.remove();
6146
+ });
6147
+
6148
+ observer.observe($element[0].parentNode, { childList: true, subtree: true });
6106
6149
  return;
6150
+ }
6151
+
6152
+ if ([
6153
+ "week",
6154
+ "date",
6155
+ "time",
6156
+ "datetime-local",
6157
+ "month",
6158
+ "datetime",
6159
+ "time-local",
6160
+ ].includes(type)) {
6161
+ const iconClass = [
6162
+ "week",
6163
+ "dat",
6164
+ "month",
6165
+ "datetime-local",
6166
+ "datetime",
6167
+ ].includes(type)
6168
+ ? "fa fa-calendar-o"
6169
+ : "fa fa-clock-o";
6170
+
6171
+ const iconWrapper = document.createElement("span");
6172
+ iconWrapper.className = "input-icon-wrapper";
6173
+ iconWrapper.innerHTML = `<i class="${iconClass}" style="cursor: pointer; font-weight: 600;"></i>`;
6174
+
6175
+ const auxInput = document.createElement("input");
6176
+ auxInput.type = type;
6177
+ auxInput.style.position = "absolute";
6178
+ auxInput.style.opacity = "0";
6179
+ auxInput.style.pointerEvents = "none";
6180
+
6181
+ $element.after(iconWrapper);
6182
+ iconWrapper.appendChild(auxInput);
6183
+
6184
+ iconWrapper.addEventListener("click", () => {
6185
+ auxInput.focus();
6186
+ });
6187
+
6188
+ auxInput.addEventListener("change", () => {
6189
+ $element.val(auxInput.value);
6190
+ $element.trigger("input");
6191
+ });
6192
+
6193
+ scope.$watch(
6194
+ () => $element.attr("exibir-icone"),
6195
+ (newValue) => {
6196
+ if (newValue === "true") {
6197
+ iconWrapper.style.display = "inline-block";
6198
+ } else {
6199
+ iconWrapper.style.display = "none";
6200
+ }
6201
+ }
6202
+ );
6107
6203
  }
6108
6204
 
6109
- if(type == "color" || type == "range"){
6110
- $element[0].classList.remove("form-control");
6111
- $element[0].classList.remove("k-textbox");
6205
+ if (["checkbox", "password", "url", "color", "range"].includes(type)) {
6206
+ if (["color", "range"].includes(type)) {
6207
+ $element[0].classList.remove("form-control", "k-textbox");
6208
+ }
6112
6209
  return;
6113
6210
  }
6114
6211
 
6115
- $element.data("type", type);
6116
-
6117
- $element.attr("type", "text");
6212
+ if (!["color", "range", "checkbox"].includes(type)) {
6213
+ $element.data("type", type);
6214
+ $element.attr("type", "text");
6215
+ }
6118
6216
 
6119
6217
  if (ngModelCtrl) {
6120
6218
  ngModelCtrl.$formatters = [];
6121
6219
  ngModelCtrl.$parsers = [];
6122
6220
  }
6123
6221
 
6124
- if (attrs.asDate !== undefined && type == 'text')
6125
- type = "date";
6126
-
6127
- var textMask = true;
6128
-
6129
- var removeMask = false;
6222
+ var attrMask =
6223
+ attrs.mask || attrs.format || parseMaskType(type, $translate);
6224
+ var mask = attrMask.replace(";1", "").replace(";0", "").trim();
6225
+
6226
+ if (!mask) return;
6227
+
6228
+ const placeholder = generateCustomPlaceholder(type, mask);
6229
+ $element.attr("placeholder", placeholder);
6230
+
6231
+ if ([
6232
+ "week",
6233
+ "date",
6234
+ "time",
6235
+ "datetime-local",
6236
+ "month",
6237
+ "datetime",
6238
+ "time-local",
6239
+ ].includes(type)) {
6240
+ $element.addClass("dark-placeholder");
6241
+ }
6130
6242
 
6131
- var attrMask = attrs.mask || attrs.format;
6243
+ $element.on("input blur", function () {
6244
+ if (!$element.val()) {
6245
+ $element.attr("placeholder", placeholder);
6246
+ } else {
6247
+ $element.attr("placeholder", "");
6248
+ }
6249
+ });
6132
6250
 
6133
- if (!attrMask) {
6134
- attrMask = parseMaskType(type, $translate);
6251
+ if (["date", "datetime-local", "datetime", "time", "time-local"].includes(
6252
+ type
6253
+ )) {
6254
+ $element.datetimepicker({
6255
+ format: mask,
6256
+ locale: $translate.use(),
6257
+ });
6258
+ } else if (["number", "money", "integer"].includes(type)) {
6259
+ $element.inputmask("numeric", {
6260
+ prefix: "",
6261
+ rightAlign: false,
6262
+ });
6135
6263
  } else {
6136
- attrMask = parseMaskType(attrMask, $translate);
6137
- }
6138
-
6139
- if (attrMask.endsWith(";0")) {
6140
- removeMask = true;
6264
+ $element.mask(mask);
6141
6265
  }
6142
6266
 
6143
- var mask = attrMask.replace(';1', '').replace(';0', '').trim();
6144
- if (mask == undefined || mask.length == 0) {
6145
- return;
6267
+ function generateCustomPlaceholder(type, mask) {
6268
+ switch (type) {
6269
+ case "week":
6270
+ return "Semana --, ----";
6271
+ case "month":
6272
+ return "-------- de ----";
6273
+ case "time":
6274
+ case "time-local":
6275
+ return "--:--";
6276
+ case "datetime-local":
6277
+ case "datetime":
6278
+ return "dd/mm/aaaa --:--";
6279
+ case "date":
6280
+ return "dd/mm/aaaa";
6281
+ default:
6282
+ return mask
6283
+ .replace(/D/g, "d")
6284
+ .replace(/M/g, "m")
6285
+ .replace(/Y/g, "a")
6286
+ .replace(/H/g, "h")
6287
+ .replace(/m/g, "m")
6288
+ .replace(/s/g, "s")
6289
+ .replace(/-/g, "-")
6290
+ .replace(/:/g, ":")
6291
+ .replace(/\//g, "/");
6292
+ }
6146
6293
  }
6147
6294
 
6148
- if (type == 'date' || type == 'datetime' || type == 'datetime-local' || type == 'month' || type == 'time' || type == 'time-local' || type == 'week') {
6149
-
6295
+ if ([
6296
+ "date",
6297
+ "datetime",
6298
+ "datetime-local",
6299
+ "month",
6300
+ "time",
6301
+ "week",
6302
+ ].includes(type)) {
6150
6303
  var options = {
6151
6304
  format: mask,
6152
6305
  locale: $translate.use(),
@@ -6170,27 +6323,55 @@ function maskDirective($compile, $translate, $parse, attrName) {
6170
6323
  }
6171
6324
  };
6172
6325
 
6173
- if (mask != 'DD/MM/YYYY' && mask != 'MM/DD/YYYY') {
6174
- options.sideBySide = true;
6175
- }
6176
-
6177
- var useUTC = type == 'date' || type == 'datetime' || type == 'time';
6178
-
6179
- if (!window.fixedTimeZone) {
6180
- useUTC = false;
6326
+ if ($element.attr('from-grid')) {
6327
+ var openPopup = function () {
6328
+ var popup = $(this).offset();
6329
+ var isBelowInput = true;
6330
+ var datetimepickerShowing = $(this)
6331
+ .parent()
6332
+ .find(".bootstrap-datetimepicker-widget.dropdown-menu");
6333
+ if (!datetimepickerShowing.length) {
6334
+ isBelowInput = false;
6335
+ datetimepickerShowing = $(this)
6336
+ .parent()
6337
+ .find(".bootstrap-datetimepicker-widget.dropdown-menu.top");
6338
+ }
6339
+ if ($(datetimepickerShowing).offset()) {
6340
+ datetimepickerShowing.appendTo("body");
6341
+ var popupTop = isBelowInput
6342
+ ? popup.top + $element.outerHeight()
6343
+ : popup.top - datetimepickerShowing.outerHeight();
6344
+ datetimepickerShowing.css({
6345
+ top: popupTop,
6346
+ left: popup.left,
6347
+ zIndex: 999999,
6348
+ });
6349
+ }
6350
+ };
6351
+ $element.on("click", openPopup);
6352
+ $element.on("focus", function () {
6353
+ setTimeout(openPopup.bind(this), 100);
6354
+ });
6181
6355
  }
6182
6356
 
6183
- $element.data('mask', mask);
6184
- $element.data('useUTC', useUTC);
6357
+ $element.datetimepicker(options);
6185
6358
 
6186
6359
  if ($element.attr('from-grid')) {
6187
6360
  var openPopup = function() {
6188
6361
  var popup = $(this).offset();
6189
6362
  var isBellowInput = true;
6190
- var datetimepickerShowing = $(this).parent().find('.bootstrap-datetimepicker-widget.dropdown-menu.usetwentyfour.bottom');
6363
+ var datetimepickerShowing = $(this)
6364
+ .parent()
6365
+ .find(
6366
+ '.bootstrap-datetimepicker-widget.dropdown-menu.usetwentyfour.bottom'
6367
+ );
6191
6368
  if (!datetimepickerShowing.length) {
6192
6369
  isBellowInput = false;
6193
- datetimepickerShowing = $(this).parent().find('.bootstrap-datetimepicker-widget.dropdown-menu.usetwentyfour.top');
6370
+ datetimepickerShowing = $(this)
6371
+ .parent()
6372
+ .find(
6373
+ '.bootstrap-datetimepicker-widget.dropdown-menu.usetwentyfour.top'
6374
+ );
6194
6375
  }
6195
6376
  if ($(datetimepickerShowing).offset()) {
6196
6377
  var popupLeft = $(datetimepickerShowing).offset().left;
@@ -6198,11 +6379,10 @@ function maskDirective($compile, $translate, $parse, attrName) {
6198
6379
  var grid = $('body');
6199
6380
  datetimepickerShowing.appendTo(grid);
6200
6381
 
6201
- var popupTop = 0
6382
+ var popupTop = 0;
6202
6383
  if (!isBellowInput)
6203
6384
  popupTop = popup.top - ($(datetimepickerShowing).height() + 15);
6204
- else
6205
- popupTop = popup.top + 35;
6385
+ else popupTop = popup.top + 35;
6206
6386
 
6207
6387
  datetimepickerShowing.css("top", popupTop);
6208
6388
  datetimepickerShowing.css("bottom", "auto");
@@ -6241,10 +6421,8 @@ function maskDirective($compile, $translate, $parse, attrName) {
6241
6421
  $element.val(momentDate.format(mask));
6242
6422
  $element.data('initial-value', null);
6243
6423
  }
6244
-
6245
- }
6246
- else {
6247
- $element.wrap("<div style=\"position:relative\"></div>");
6424
+ } else {
6425
+ $element.wrap('<div style="position:relative"></div>');
6248
6426
  }
6249
6427
  $element.datetimepicker(options);
6250
6428
  if (attrs.fromGrid !== "true") {
@@ -6255,7 +6433,7 @@ function maskDirective($compile, $translate, $parse, attrName) {
6255
6433
  var value = $element.val();
6256
6434
  var momentDate = null;
6257
6435
  if (useUTC) {
6258
- momentDate = moment(value, mask).utcOffset(window.timeZoneOffset, true);
6436
+ momentDate = moment(value, mask).utcOffset( window.timeZoneOffset, true);
6259
6437
  } else {
6260
6438
  momentDate = moment(value, mask);
6261
6439
  }
@@ -6270,48 +6448,27 @@ function maskDirective($compile, $translate, $parse, attrName) {
6270
6448
  });
6271
6449
  }
6272
6450
 
6273
- if (ngModelCtrl ) {
6274
- ngModelCtrl.$formatters.push(function (value) {
6275
- if (value) {
6276
- return formatWithMomentAs(mask, useUTC, value, "string");
6277
- }
6278
-
6279
- if(value === null){
6280
- var dp = $element.datetimepicker(options).data('DateTimePicker');
6281
- dp.date(null);
6282
- }
6451
+ if (ngModelCtrl) {
6452
+ ngModelCtrl.$formatters.push((value) =>
6453
+ value ? moment(value).format(mask) : null
6454
+ );
6283
6455
 
6284
- return null;
6456
+ ngModelCtrl.$parsers.push((value) => {
6457
+ var momentDate = moment(value, mask);
6458
+ return momentDate.isValid() ? momentDate.toDate() : null;
6285
6459
  });
6286
6460
 
6287
- ngModelCtrl.$parsers.push(function (value) {
6288
- if (value) {
6289
- if (value instanceof Date) {
6290
- return value;
6291
- }
6292
- var momentDate = null;
6293
- if (useUTC) {
6294
- momentDate = moment(value, mask).utcOffset(window.timeZoneOffset, true);
6295
- } else {
6296
- momentDate = moment(value, mask);
6297
- }
6298
- if (type == 'time' || type == 'time-local') {
6299
- momentDate = momentDate.year(1970).dayOfYear(1).month(0);
6300
- }
6301
- if (typeof value === "string" && (value.length < mask.length)) {
6302
- let tempValue = formatWithMomentAs(mask, useUTC, value, "string");
6303
- if (tempValue.startsWith(value) && (value.length < tempValue.length) && (isNaN(tempValue[value.length]) || tempValue[value.length] === " ")) {
6304
- ngModelCtrl.$$element.val(tempValue.substring(0, value.length + 1));
6305
- }
6306
- }
6307
- return momentDate.toDate();
6308
- }
6309
-
6310
- return null;
6461
+ $element.on('dp.change', function () {
6462
+ scope.$apply(() => {
6463
+ var value = $element.val();
6464
+ var momentDate = moment(value, mask);
6465
+ if (momentDate.isValid())
6466
+ ngModelCtrl.$setViewValue(momentDate.toDate());
6467
+ });
6311
6468
  });
6312
6469
  }
6313
-
6314
- } else if (type == 'number' || type == 'money' || type == 'integer' || type == 'money-decimal') {
6470
+ }
6471
+ else if (type == 'number' || type == 'money' || type == 'integer' || type == 'money-decimal') {
6315
6472
  removeMask = true;
6316
6473
 
6317
6474
  var currency = mask.trim().replace(/\./g, '').replace(/\,/g, '').replace(/#/g, '').replace(/0/g, '').replace(/9/g, '');
@@ -6364,45 +6521,40 @@ function maskDirective($compile, $translate, $parse, attrName) {
6364
6521
  }
6365
6522
 
6366
6523
  var ipOptions = {
6367
- 'rightAlign': (type == 'money' || type == 'money-decimal'),
6368
- 'unmaskAsNumber': true,
6369
- 'allowMinus': true,
6370
- 'prefix': prefix,
6371
- 'suffix': suffix,
6372
- 'radixPoint': decimal,
6373
- 'digits': precision,
6374
- 'numericInput' : (type == 'money-decimal')
6524
+ rightAlign: ['money', 'money-decimal'].includes(type),
6525
+ allowMinus: true,
6526
+ prefix: prefix,
6527
+ suffix: suffix,
6528
+ radixPoint: decimal,
6529
+ digits: precision,
6530
+ groupSeparator: thousands,
6531
+ autoGroup: !!thousands,
6375
6532
  };
6376
6533
 
6377
- if (thousands) {
6378
- ipOptions['autoGroup'] = true;
6379
- ipOptions['groupSeparator'] = thousands;
6380
- }
6381
-
6382
- $(element).inputmask(inputmaskType, ipOptions);
6383
- useInputMaskPlugin(element, ngModelCtrl, scope, modelSetter, mask);
6534
+ $element.inputmask(inputmaskType, ipOptions);
6535
+ useInputMaskPlugin($element, ngModelCtrl, scope, modelSetter, mask);
6384
6536
  }
6385
- else if (type == 'text' || type == 'tel' || type == 'string') {
6386
-
6387
- let charToNumber = ['D','M', 'Y', 'H', 'm','s'];
6388
- let verifyMaskDateForText = (mask) => { charToNumber.forEach((c) => mask = mask.replaceAll(c,'9')); return mask};
6537
+ else {
6538
+ let charToNumber = ['D', 'M', 'Y', 'H', 'm', 's'];
6539
+ let verifyMaskDateForText = (mask) => {
6540
+ charToNumber.forEach((c) => (mask = mask.replaceAll(c, "9")));
6541
+ return mask;
6542
+ };
6389
6543
  mask = verifyMaskDateForText(mask);
6390
6544
 
6391
6545
  if(!attrs.maskPlaceholder){
6392
6546
  $element.mask(mask);
6393
- useMaskPlugin(element, ngModelCtrl, scope, modelSetter, removeMask);
6394
- }
6395
- else{
6396
- options = {};
6397
- options['placeholder'] = attrs.maskPlaceholder;
6398
- $(element).inputmask(mask, options);
6399
- if(removeMask){
6400
- useInputMaskPlugin(element, ngModelCtrl, scope, modelSetter, mask);
6401
- }
6547
+ useMaskPlugin($element, ngModelCtrl, scope, modelSetter, false);
6548
+ } else {
6549
+ var options = {
6550
+ placeholder: attrs.maskPlaceholder,
6551
+ };
6552
+ $element.inputmask(mask, options);
6553
+ useInputMaskPlugin($element, ngModelCtrl, scope, modelSetter, mask);
6402
6554
  }
6403
6555
  }
6404
- }
6405
- }
6556
+ },
6557
+ };
6406
6558
  }
6407
6559
 
6408
6560
  function useInputMaskPlugin(element, ngModelCtrl, scope, modelSetter, mask){