fng-bootstrap-datetime 0.12.0-beta.191 → 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.
- package/fng-bootstrap-datetime.js +59 -31
- package/package.json +1 -1
@@ -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)
|
71
|
-
} else if (dateTimeAttr in attrs) {
|
72
|
-
|
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)
|
82
|
+
return `${dashCase(innerAttr)}="${dateTimeAttr}({${funcArgs}})" `;
|
82
83
|
} else {
|
83
|
-
return angular.isDefined(defaultImpl) ? dashCase(innerAttr)
|
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)
|
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", "
|
120
|
-
["ngReadonly", "
|
121
|
-
["ngDisabled", "
|
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", "
|
149
|
-
["ngDisabled", "
|
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', '
|
368
|
-
function ($compile,
|
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
|
377
|
-
var
|
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
|
-
|
397
|
-
var
|
414
|
+
overriddenDefaults = Object.assign({}, overriddenDefaults, processedAttrs.directiveOptions);
|
415
|
+
var overriddenDateDefaults = {
|
398
416
|
showWeeks: false
|
399
417
|
};
|
400
418
|
var jsonDateOptions = {};
|
401
|
-
if (
|
402
|
-
jsonDateOptions = JSON.parse(
|
419
|
+
if (processedAttrs.directiveOptions['date-options']) {
|
420
|
+
jsonDateOptions = JSON.parse(processedAttrs.directiveOptions['date-options'].replace(/'/g, '"'));
|
403
421
|
}
|
404
|
-
scope.dateOptions = Object.assign({},
|
422
|
+
scope.dateOptions = Object.assign({}, overriddenDateDefaults, jsonDateOptions);
|
405
423
|
|
406
|
-
const isArray =
|
407
|
-
template = pluginHelper.buildInputMarkup(
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
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
|
-
|
415
|
-
return str;
|
416
|
-
});
|
444
|
+
);
|
417
445
|
element.replaceWith($compile(template)(scope));
|
418
446
|
}
|
419
447
|
};
|