fng-bootstrap-datetime 0.12.0-beta.192 → 0.12.0-beta.193

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.
@@ -55,7 +55,7 @@ angular.module('ui.bootstrap.datetimepicker', ["ui.bootstrap.dateparser", "ui.bo
55
55
  hiddenDate: "=",
56
56
  datepickerTemplateUrl: "@",
57
57
  datepickerPopupTemplateUrl: "@",
58
- timepickerTemplateUrl: "@"
58
+ timepickerTemplateUrl: "@",
59
59
  },
60
60
  template: function (elem, attrs) {
61
61
  function dashCase(name) {
@@ -67,9 +67,10 @@ angular.module('ui.bootstrap.datetimepicker', ["ui.bootstrap.dateparser", "ui.bo
67
67
  function createAttr(innerAttr, dateTimeAttrOpt) {
68
68
  var dateTimeAttr = angular.isDefined(dateTimeAttrOpt) ? dateTimeAttrOpt : innerAttr;
69
69
  if (attrs[dateTimeAttr]) {
70
- return dashCase(innerAttr) + "=\"" + dateTimeAttr + "\" ";
71
- } else if (dateTimeAttr in attrs) { // attribute with an empty value such as "required"
72
- return dateTimeAttr + " ";
70
+ return `${dashCase(innerAttr)}="${attrs[dateTimeAttr]}" `;
71
+ } else if (dateTimeAttr in attrs) {
72
+ // attribute with an empty value such as "required"
73
+ return `${dateTimeAttr} `;
73
74
  } else {
74
75
  return '';
75
76
  }
@@ -78,18 +79,18 @@ angular.module('ui.bootstrap.datetimepicker', ["ui.bootstrap.dateparser", "ui.bo
78
79
  function createFuncAttr(innerAttr, funcArgs, dateTimeAttrOpt, defaultImpl) {
79
80
  var dateTimeAttr = angular.isDefined(dateTimeAttrOpt) ? dateTimeAttrOpt : innerAttr;
80
81
  if (attrs[dateTimeAttr]) {
81
- return dashCase(innerAttr) + "=\"" + dateTimeAttr + "({" + funcArgs + "})\" ";
82
+ return `${dashCase(innerAttr)}="${dateTimeAttr}({${funcArgs}})" `;
82
83
  } else {
83
- return angular.isDefined(defaultImpl) ? dashCase(innerAttr) + "=\"" + defaultImpl + "\"" : "";
84
+ return angular.isDefined(defaultImpl) ? `${dashCase(innerAttr)}="${defaultImpl}" ` : "";
84
85
  }
85
86
  }
86
87
 
87
88
  function createEvalAttr(innerAttr, dateTimeAttrOpt) {
88
89
  var dateTimeAttr = angular.isDefined(dateTimeAttrOpt) ? dateTimeAttrOpt : innerAttr;
89
90
  if (attrs[dateTimeAttr]) {
90
- return dashCase(innerAttr) + "=\"" + attrs[dateTimeAttr] + "\" ";
91
+ return `${dashCase(innerAttr)}="${attrs[dateTimeAttr]}" `;
91
92
  } else {
92
- return dashCase(innerAttr) + " ";
93
+ return `${dashCase(innerAttr)} `;
93
94
  }
94
95
  }
95
96
 
@@ -116,9 +117,9 @@ angular.module('ui.bootstrap.datetimepicker', ["ui.bootstrap.dateparser", "ui.bo
116
117
  ["yearRange"],
117
118
  ["required"],
118
119
  ["showButtonBar"],
119
- ["ngHide", "hiddenDate"],
120
- ["ngReadonly", "readonlyDate"],
121
- ["ngDisabled", "disabledDate"]
120
+ ["ngHide", "hiddendate"],
121
+ ["ngReadonly", "readonlydate"],
122
+ ["ngDisabled", "disableddate"]
122
123
  ].reduce(createAttrConcat, '') +
123
124
  createFuncAttr("ngClick",
124
125
  "$event: $event, opened: opened",
@@ -145,8 +146,8 @@ angular.module('ui.bootstrap.datetimepicker', ["ui.bootstrap.dateparser", "ui.bo
145
146
  ["required"],
146
147
  ["meredians"],
147
148
  ["mousewheel"],
148
- ["ngHide", "hiddenTime"],
149
- ["ngDisabled", "readonlyTime"]
149
+ ["ngHide", "hiddentime"],
150
+ ["ngDisabled", "readonlytime"]
150
151
  ].reduce(createAttrConcat, '') +
151
152
  createEvalAttr("showSpinners", "showSpinners") +
152
153
  createEvalAttr("templateUrl", "timepickerTemplateUrl") +
@@ -169,6 +170,23 @@ angular.module('ui.bootstrap.datetimepicker', ["ui.bootstrap.dateparser", "ui.bo
169
170
  }
170
171
  }
171
172
  getForm();
173
+ // ****************************************************
174
+ // HACK RIGHT HERE!
175
+ // For cases where formsAngular.elemSecurityFuncBinding is set to either "one-time" or "normal", the
176
+ // result of the call to handleReadOnlyDisabled() made by the fngUiBootstrapDatetimePicker directive will
177
+ // include reference(s) to the function identified by formsAngular.elemSecurityFuncName (with the
178
+ // assumption that external code has assigned a function of that name to $rootScope). because our
179
+ // scope is isolated, this will be inaccessible unless we do the following...:
180
+ if (formsAngular.elemSecurityFuncName) {
181
+ $scope[formsAngular.elemSecurityFuncName] = $scope.$root[formsAngular.elemSecurityFuncName];
182
+ }
183
+ // as this is only going to work for disabled state arising from fng security, and not the case
184
+ // where an fng field has a string-valued readonly attribute that refers to a function on the parent
185
+ // scope, it's only a partial solution. the general solution would presumably be to replace our isolated
186
+ // scope definition with "scope:true", thus giving it full ancestor access. however, I gave
187
+ // that a quick try and found that it broke things, and it doesn't seem worth spending any more time
188
+ // on that right now.
189
+ // ****************************************************
172
190
  $scope.date_change = function () {
173
191
  // If we changed the date only, set the time (h,m) on it.
174
192
  // This is important in case the previous date was null.
@@ -364,8 +382,8 @@ angular.module('ui.bootstrap.datetimepicker', ["ui.bootstrap.dateparser", "ui.bo
364
382
  uiBootstrapDateModule.controller('fngUiBootstrapDatetimePickerCtrl',['$scope', function($scope) {
365
383
  $scope.dateOptions = {};
366
384
  }])
367
- .directive('fngUiBootstrapDatetimePicker', ['$compile', '$filter', 'pluginHelper', 'formMarkupHelper', 'cssFrameworkService',
368
- function ($compile, $filter, pluginHelper) {
385
+ .directive('fngUiBootstrapDatetimePicker', ['$compile', 'pluginHelper',
386
+ function ($compile, pluginHelper) {
369
387
  return {
370
388
  restrict: 'E',
371
389
  replace: true,
@@ -373,8 +391,8 @@ angular.module('ui.bootstrap.datetimepicker', ["ui.bootstrap.dateparser", "ui.bo
373
391
  priority: 1,
374
392
  link: function (scope, element, attrs) {
375
393
  var template;
376
- var processedAttr = pluginHelper.extractFromAttr(attrs, 'fngUiBootstrapDatetimePicker');
377
- var overRiddenDefaults = {
394
+ var processedAttrs = pluginHelper.extractFromAttr(attrs, 'fngUiBootstrapDatetimePicker');
395
+ var overriddenDefaults = {
378
396
  'show-button-bar': false,
379
397
  'show-meridian': false,
380
398
  'date-format': 'dd/MM/yyyy'
@@ -393,27 +411,37 @@ angular.module('ui.bootstrap.datetimepicker', ["ui.bootstrap.dateparser", "ui.bo
393
411
  }
394
412
  });
395
413
 
396
- overRiddenDefaults = Object.assign({}, overRiddenDefaults, processedAttr.directiveOptions);
397
- var overRiddenDateDefaults = {
414
+ overriddenDefaults = Object.assign({}, overriddenDefaults, processedAttrs.directiveOptions);
415
+ var overriddenDateDefaults = {
398
416
  showWeeks: false
399
417
  };
400
418
  var jsonDateOptions = {};
401
- if (processedAttr.directiveOptions['date-options']) {
402
- jsonDateOptions = JSON.parse(processedAttr.directiveOptions['date-options'].replace(/'/g, '"'));
419
+ if (processedAttrs.directiveOptions['date-options']) {
420
+ jsonDateOptions = JSON.parse(processedAttrs.directiveOptions['date-options'].replace(/'/g, '"'));
403
421
  }
404
- scope.dateOptions = Object.assign({}, overRiddenDateDefaults, jsonDateOptions);
422
+ scope.dateOptions = Object.assign({}, overriddenDateDefaults, jsonDateOptions);
405
423
 
406
- const isArray = processedAttr.info.array;
407
- template = pluginHelper.buildInputMarkup(scope, attrs.model, processedAttr.info, processedAttr.options, isArray, isArray, function (buildingBlocks) {
408
- var str = '<div class="dtwrap"><datetimepicker ' + buildingBlocks.common;
409
- for (var opt in overRiddenDefaults) {
410
- if (opt !== 'date-options') {
411
- str += ' ' + opt + '="' + overRiddenDefaults[opt] + '"';
424
+ const isArray = processedAttrs.info.array;
425
+ template = pluginHelper.buildInputMarkup(
426
+ scope,
427
+ attrs,
428
+ {
429
+ processedAttrs,
430
+ addButtons: isArray,
431
+ needsX: isArray,
432
+ },
433
+ function (buildingBlocks) {
434
+ var str = '<div class="dtwrap"><datetimepicker ' + buildingBlocks.common.trim();
435
+ for (var opt in overriddenDefaults) {
436
+ if (opt !== 'date-options') {
437
+ str += ` ${opt}="${overriddenDefaults[opt]}"`;
438
+ }
412
439
  }
440
+ str += " " + pluginHelper.genDateTimePickerDisabledStr(scope, processedAttrs, "");
441
+ str += ' date-options="dateOptions"></datetimepicker></div>';
442
+ return str;
413
443
  }
414
- str += ' date-options="dateOptions"></datetimepicker></div>';
415
- return str;
416
- });
444
+ );
417
445
  element.replaceWith($compile(template)(scope));
418
446
  }
419
447
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fng-bootstrap-datetime",
3
- "version": "0.12.0-beta.192",
3
+ "version": "0.12.0-beta.193",
4
4
  "description": "datetime input plugin for forms-angular",
5
5
  "main": "fng-bootstrap-datetime.js",
6
6
  "scripts": {