fng-bootstrap-date 0.12.0-beta.204 → 0.12.0-beta.206

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.
@@ -12,8 +12,8 @@
12
12
  $scope.popup.opened = true;
13
13
  }
14
14
  }])
15
- .directive('fngUiBootstrapDatePicker', ['$compile', '$timeout', 'pluginHelper', 'formMarkupHelper', 'cssFrameworkService',
16
- function ($compile, $timeout, pluginHelper, formMarkupHelper) {
15
+ .directive('fngUiBootstrapDatePicker', ['$compile', '$timeout', 'pluginHelper', 'formMarkupHelper', 'recordHandler', 'cssFrameworkService',
16
+ function ($compile, $timeout, pluginHelper, formMarkupHelper, recordHandler) {
17
17
  return {
18
18
  restrict: 'E',
19
19
  replace: true,
@@ -51,7 +51,16 @@
51
51
  scope.dateOptions = Object.assign(overriddenDateDefaults, jsonDateOptions);
52
52
  ["minDate","maxDate"].forEach(v => {
53
53
  if (scope.dateOptions[v] && typeof scope.dateOptions[v] === "string") {
54
- scope.dateOptions[v] = new Date(scope.dateOptions[v]);
54
+ // allow minDate and maxDate to be derived from another (assumed to be date-typed) field, but with
55
+ // the limitation that the value of that field must be available now and must not change
56
+ // (i.e., this is effectively a one-time binding)
57
+ // one possible use case would be to use the value of a hidden "when created" field as a minimum
58
+ // or maximum value for another (not hidden) date field
59
+ if (scope.dateOptions[v].startsWith("record.") || scope.dateOptions[v].startsWith("subDoc.")) {
60
+ scope.dateOptions[v] = recordHandler.getData(scope, scope.dateOptions[v]);
61
+ } else {
62
+ scope.dateOptions[v] = new Date(scope.dateOptions[v]);
63
+ }
55
64
  }
56
65
  })
57
66
 
@@ -122,8 +131,9 @@
122
131
  maxDate = new Date(scope.dateOptions.maxDate).valueOf();
123
132
  }
124
133
  if (minDate || maxDate) {
125
- if (attrs.format !== 'dd/MM/yyyy') {
126
- throw new Error('Unsupported date format in validdate: ' + attrs.format)
134
+ let dateFormat = attrs.format || attrs.dateFormat;
135
+ if (dateFormat !== 'dd/MM/yyyy') {
136
+ throw new Error('Unsupported date format in validdate: ' + dateFormat)
127
137
  }
128
138
  }
129
139
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fng-bootstrap-date",
3
- "version": "0.12.0-beta.204",
3
+ "version": "0.12.0-beta.206",
4
4
  "description": "Date input plugin for forms-angular, using the Bootstrap datepicker from Angular-ui-bootstrap",
5
5
  "main": "fng-bootstrap-date.js",
6
6
  "scripts": {