@mediafly/js-ui 51.3.3-1 → 51.4.0-0
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/lib/constants/constants.js +1 -2
- package/lib/constants/constants.js.map +1 -1
- package/lib/date-input/date-input.js +12 -33
- package/lib/date-input/date-input.js.map +1 -1
- package/lib/date-input/validate-date.js +8 -12
- package/lib/date-input/validate-date.js.map +1 -1
- package/lib/date-time-zone-picker/date-time-zone-factory.js +49 -62
- package/lib/date-time-zone-picker/date-time-zone-factory.js.map +1 -1
- package/lib/date-time-zone-picker/date-time-zone-picker.html +6 -6
- package/lib/date-time-zone-picker/date-time-zone-picker.js +59 -119
- package/lib/date-time-zone-picker/date-time-zone-picker.js.map +1 -1
- package/lib/date-time-zone-picker/datepicker.html +3 -2
- package/lib/date-time-zone-picker/datepicker.js +26 -79
- package/lib/date-time-zone-picker/datepicker.js.map +1 -1
- package/lib/date-time-zone-picker/time-format-filter.js +8 -8
- package/lib/date-time-zone-picker/time-format-filter.js.map +1 -1
- package/lib/date-time-zone-picker/time-zone-picker.js +1 -1
- package/lib/date-time-zone-picker/timepicker.html +2 -1
- package/lib/date-time-zone-picker/timepicker.js +40 -35
- package/lib/date-time-zone-picker/timepicker.js.map +1 -1
- package/lib/feedback/feedback.component.html +17 -7
- package/lib/styles.css +10 -22
- package/lib/time-input/time-input.js +23 -27
- package/lib/time-input/time-input.js.map +1 -1
- package/lib/time-input/validate-time.js +3 -6
- package/lib/time-input/validate-time.js.map +1 -1
- package/lib/tsconfig.deploy.tsbuildinfo +25 -163
- package/package.json +4 -4
- package/src/components/constants/constants.js +1 -2
- package/src/components/date-input/date-input.js +12 -31
- package/src/components/date-input/validate-date.js +10 -14
- package/src/components/date-time-zone-picker/date-time-zone-factory.ts +49 -62
- package/src/components/date-time-zone-picker/date-time-zone-picker.html +6 -6
- package/src/components/date-time-zone-picker/date-time-zone-picker.ts +70 -131
- package/src/components/date-time-zone-picker/datepicker.html +3 -2
- package/src/components/date-time-zone-picker/datepicker.ts +26 -83
- package/src/components/date-time-zone-picker/time-format-filter.ts +8 -8
- package/src/components/date-time-zone-picker/time-zone-picker.js +1 -1
- package/src/components/date-time-zone-picker/timepicker.html +2 -1
- package/src/components/date-time-zone-picker/timepicker.js +47 -46
- package/src/components/feedback/feedback.component.html +17 -7
- package/src/components/feedback/feedback.less +24 -13
- package/src/components/less/objects/containers.less +15 -17
- package/src/components/less/variables/colors.less +8 -0
- package/src/components/time-input/time-input.js +24 -27
- package/src/components/time-input/validate-time.js +3 -6
- package/src/index.spec.js +1 -1
- package/tsconfig.tsbuildinfo +7221 -0
- package/webpack.config.js +0 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import angular from 'angular'
|
|
2
|
-
|
|
2
|
+
import moment from 'moment'
|
|
3
3
|
|
|
4
4
|
angular.module('app').directive('mflyValidateDate', function mflyValidateDate () {
|
|
5
5
|
|
|
@@ -7,25 +7,21 @@ angular.module('app').directive('mflyValidateDate', function mflyValidateDate ()
|
|
|
7
7
|
|
|
8
8
|
$ctrl.$validators.dateFormat = function (modelValue, viewValue) {
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
var validDateFormats = [
|
|
11
|
+
'D-MMM-YYYY', 'D/MMM/YYYY',
|
|
12
|
+
'DD-MMM-YYYY', 'DD/MMM/YYYY',
|
|
13
|
+
'MM-DD-YYYY', 'MM/DD/YYYY',
|
|
14
|
+
'M-D-YYYY', 'M/D/YYYY',
|
|
15
|
+
'MM-DD-YY', 'MM/DD/YY',
|
|
16
|
+
'M-D-YY', 'M/D/YY'
|
|
17
|
+
];
|
|
18
18
|
|
|
19
19
|
// Empty models shouldn't be "invalid" - that's covered by "required".
|
|
20
20
|
if (viewValue === '') {
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
return validDateFormats.some(format => {
|
|
26
|
-
const parsed = DateTime.fromFormat(viewValue, format)
|
|
27
|
-
return parsed.isValid
|
|
28
|
-
})
|
|
24
|
+
return moment(viewValue, validDateFormats, true).isValid();
|
|
29
25
|
};
|
|
30
26
|
}
|
|
31
27
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import angular from 'angular'
|
|
2
2
|
import _ from 'lodash'
|
|
3
|
-
import
|
|
3
|
+
import moment from 'moment'
|
|
4
4
|
|
|
5
5
|
angular.module('app').factory('dateTimeZoneFactory', function dateTimeZoneFactory() {
|
|
6
6
|
|
|
@@ -38,58 +38,44 @@ angular.module('app').factory('dateTimeZoneFactory', function dateTimeZoneFactor
|
|
|
38
38
|
{ value: 12, zone: 'NZST - New Zealand Standard Time', display: 'NZST' }
|
|
39
39
|
]
|
|
40
40
|
|
|
41
|
-
// using string validate on the datepicker gives us more control
|
|
41
|
+
// using string validate on the datepicker gives us more control w moment's loose parsing
|
|
42
42
|
const validDateFormats = [
|
|
43
|
-
|
|
44
|
-
'
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'
|
|
51
|
-
'
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
78
|
-
'
|
|
79
|
-
'M.d.yy',
|
|
80
|
-
// Abbreviated month name formats (MMM)
|
|
81
|
-
'd-MMM-yyyy',
|
|
82
|
-
'MMM-d-yyyy',
|
|
83
|
-
'd/MMM/yyyy',
|
|
84
|
-
'MMM/d/yyyy',
|
|
85
|
-
'd.MMM.yyyy',
|
|
86
|
-
'MMM.d.yyyy',
|
|
87
|
-
'd-MMM-yy',
|
|
88
|
-
'MMM-d-yy',
|
|
89
|
-
'd/MMM/yy',
|
|
90
|
-
'MMM/d/yy',
|
|
91
|
-
'd.MMM.yy',
|
|
92
|
-
'MMM.d.yy'
|
|
43
|
+
'D-MMMM-YYYY',
|
|
44
|
+
'D-MM-YYYY',
|
|
45
|
+
'D-M-YYYY',
|
|
46
|
+
'MMMM-D-YYYY',
|
|
47
|
+
'MM-D-YYYY',
|
|
48
|
+
'M-D-YYYY',
|
|
49
|
+
'D/MMMM/YYYY',
|
|
50
|
+
'D/MM/YYYY',
|
|
51
|
+
'D/M/YYYY',
|
|
52
|
+
'MMMM/D/YYYY',
|
|
53
|
+
'MM/D/YYYY',
|
|
54
|
+
'M/D/YYYY',
|
|
55
|
+
'D.MMMM.YYYY',
|
|
56
|
+
'D.MM.YYYY',
|
|
57
|
+
'D.M.YYYY',
|
|
58
|
+
'MMMM.D.YYYY',
|
|
59
|
+
'MM.D.YYYY',
|
|
60
|
+
'M.D.YYYY',
|
|
61
|
+
'D-MMMM-YY',
|
|
62
|
+
'D-MM-YY',
|
|
63
|
+
'D-M-YY',
|
|
64
|
+
'MMMM-D-YY',
|
|
65
|
+
'MM-D-YY',
|
|
66
|
+
'M-D-YY',
|
|
67
|
+
'D/MMMM/YY',
|
|
68
|
+
'D/MM/YY',
|
|
69
|
+
'D/M/YY',
|
|
70
|
+
'MMMM/D/YY',
|
|
71
|
+
'MM/D/YY',
|
|
72
|
+
'M/D/YY',
|
|
73
|
+
'D.MMMM.YY',
|
|
74
|
+
'D.MM.YY',
|
|
75
|
+
'D.M.YY',
|
|
76
|
+
'MMMM.D.YY',
|
|
77
|
+
'MM.D.YY',
|
|
78
|
+
'M.D.YY'
|
|
93
79
|
]
|
|
94
80
|
|
|
95
81
|
|
|
@@ -99,27 +85,28 @@ angular.module('app').factory('dateTimeZoneFactory', function dateTimeZoneFactor
|
|
|
99
85
|
|
|
100
86
|
validDateFormats,
|
|
101
87
|
|
|
102
|
-
getTimeZone(
|
|
88
|
+
getTimeZone(momentDate) {
|
|
103
89
|
|
|
104
|
-
if (
|
|
90
|
+
if (momentDate.isValid()) {
|
|
105
91
|
|
|
106
92
|
// Get the timezone offset in hours and adjust the sign
|
|
107
|
-
let zoneOffset =
|
|
93
|
+
let zoneOffset = (momentDate.utcOffset() / 60)
|
|
108
94
|
|
|
109
95
|
// consider a shift for DST
|
|
110
|
-
//
|
|
111
|
-
|
|
96
|
+
// must use isDST on a frest moment object -
|
|
97
|
+
// the passed variable is parsedZone and thus will always return isDST false
|
|
98
|
+
const isDST = moment(momentDate.format()).isDST()
|
|
112
99
|
|
|
113
|
-
// at this point
|
|
114
|
-
// so for example if we are UTC -6 AND we are DST, then our
|
|
100
|
+
// at this point zoneOffest is our true offest from UTC 0
|
|
101
|
+
// so for example if we are UTC -6 AND we are DST, then our moment is really "Mountain Time" which is is -7
|
|
115
102
|
// during the winter but is -6 during DST -- if we want to consistently show the label 'MST' for this date
|
|
116
|
-
// we need to select -7 although the offset is -6 (or subtracting 1 from our
|
|
103
|
+
// we need to select -7 although the offset is -6 (or subtracting 1 from our actyual utc output)
|
|
117
104
|
zoneOffset = (isDST) ? zoneOffset - 1 : zoneOffset
|
|
118
105
|
|
|
119
106
|
// NOTE: The above DST adjustment is somewhat arbitrary.
|
|
120
107
|
// isDST() cannot be globally accurate as it works purely off a date and an offset.
|
|
121
|
-
// No actual timezone information is used except for
|
|
122
|
-
// Recommendation to switch to
|
|
108
|
+
// No actual timezone information is used except for assumptins made from the users current locale.
|
|
109
|
+
// Recommendation to switch to moment's timezone.js in the future.
|
|
123
110
|
|
|
124
111
|
return this.getTimeZoneByOffset(zoneOffset)
|
|
125
112
|
}
|
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
input-id="{{ inputId }}"
|
|
7
7
|
is-disabled="isDisabled"
|
|
8
8
|
is-required="{{ isRequired }}"
|
|
9
|
-
date-
|
|
9
|
+
date-moment="dateMoment"
|
|
10
10
|
on-open="pickerOpened()"
|
|
11
11
|
on-date-change="updateDate(newDate)">
|
|
12
12
|
</mfly:date-picker>
|
|
13
13
|
</div>
|
|
14
14
|
|
|
15
|
-
<div class="o-col-xs-7" ng-show="type === 'datetime' &&
|
|
15
|
+
<div class="o-col-xs-7" ng-show="type === 'datetime' && dateMoment && !isDisabled">
|
|
16
16
|
<mfly:time-picker
|
|
17
17
|
input-id="{{ inputId }}Time"
|
|
18
|
-
time-
|
|
18
|
+
time-moment="timeMoment"
|
|
19
19
|
ng-show="!isDisabled"
|
|
20
|
-
on-time-change="updateTime(
|
|
20
|
+
on-time-change="updateTime()">
|
|
21
21
|
</mfly:time-picker>
|
|
22
22
|
|
|
23
23
|
<mfly:time-zone-picker
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
</div>
|
|
29
29
|
|
|
30
30
|
<!-- If the time is disabled, show plain text instead of controls -->
|
|
31
|
-
<div class="o-col-xs-7" ng-show="type === 'datetime' &&
|
|
31
|
+
<div class="o-col-xs-7" ng-show="type === 'datetime' && dateMoment && isDisabled">
|
|
32
32
|
<div class="pull-left disabled">
|
|
33
|
-
<span>{{
|
|
33
|
+
<span>{{ parentMoment.format('hh:mm a') }} {{ (timeZone) ? timeZone.display : '' }}</span>
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
36
36
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import angular from 'angular'
|
|
2
|
-
import
|
|
2
|
+
import moment from 'moment'
|
|
3
3
|
|
|
4
4
|
// This type is necessary because the directive link function expects something
|
|
5
5
|
// conforming to ng.IController, but we want the types from ng.INgModelController
|
|
@@ -23,104 +23,73 @@ angular.module('app').directive('mflyDateTimeZonePicker', ['dateTimeZoneFactory'
|
|
|
23
23
|
template: require('./date-time-zone-picker.html'),
|
|
24
24
|
link($scope: ScopeKeyValuePair, _element, _attr, ngModelCtrl: PatchedNgModelController) {
|
|
25
25
|
|
|
26
|
-
// Init function creates
|
|
27
|
-
// These
|
|
28
|
-
// timezone object is also created but is not a
|
|
29
|
-
// Each component only alters its respective
|
|
26
|
+
// Init function creates moment dates from our utc string provided by the API
|
|
27
|
+
// These moment dates are bound to the datepicker and timepicker (the
|
|
28
|
+
// timezone object is also created but is not a moment)
|
|
29
|
+
// Each component only alters its respective moment date, then tells this
|
|
30
30
|
// component when a change is made
|
|
31
31
|
// When a change is made, this component combines the 3 datetime elements
|
|
32
32
|
// and sends a utc string back to the api
|
|
33
33
|
// ------------------------------------------------------------------
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
// Create a base
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const dt = DateTime.fromISO(value, { setZone: true })
|
|
42
|
-
// Calculate offset in hours (including minutes as decimal)
|
|
43
|
-
const offset = dt.offset / 60
|
|
44
|
-
// Find the matching time zone object
|
|
45
|
-
const matchedZone = dateTimeZoneFactory.getTimeZoneByOffset(offset)
|
|
46
|
-
// If found, set the zone on the DateTime object
|
|
47
|
-
if (matchedZone) {
|
|
48
|
-
// Format offset as UTC±HH:MM for non-integer offsets
|
|
49
|
-
const absOffset = Math.abs(matchedZone.value)
|
|
50
|
-
const hours = Math.floor(absOffset)
|
|
51
|
-
const minutes = Math.round((absOffset - hours) * 60)
|
|
52
|
-
const sign = matchedZone.value >= 0 ? '+' : '-'
|
|
53
|
-
const zoneString =
|
|
54
|
-
minutes === 0
|
|
55
|
-
? `UTC${sign}${hours}`
|
|
56
|
-
: `UTC${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`
|
|
57
|
-
$scope.parentLuxon = dt.setZone(zoneString, { keepLocalTime: true })
|
|
58
|
-
$scope.timeZone = matchedZone
|
|
59
|
-
} else {
|
|
60
|
-
// Fallback: just use the parsed DateTime
|
|
61
|
-
$scope.parentLuxon = dt
|
|
62
|
-
$scope.timeZone = null
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
throw new Error(`Invalid value type ${typeof value} (${value})`)
|
|
66
|
-
}
|
|
34
|
+
function initParentMomentFromAPI(value) {
|
|
35
|
+
|
|
36
|
+
// Create a base moment and bound copies for each child component.
|
|
37
|
+
$scope.parentMoment = moment.parseZone(value)
|
|
38
|
+
|
|
39
|
+
$scope.timeMoment = moment({ hour: $scope.parentMoment.hour(), minute: $scope.parentMoment.minute() })
|
|
40
|
+
$scope.dateMoment = moment({ year: $scope.parentMoment.year(), month: $scope.parentMoment.month(), date: $scope.parentMoment.date() })
|
|
67
41
|
|
|
68
|
-
|
|
69
|
-
|
|
42
|
+
// The timezone component takes a custom timezone object instead of
|
|
43
|
+
// a moment. The factory returns a timezone, adjusting for DST.
|
|
44
|
+
$scope.timeZone = dateTimeZoneFactory.getTimeZone($scope.parentMoment)
|
|
70
45
|
}
|
|
71
46
|
|
|
72
|
-
function
|
|
47
|
+
function initParentMomentFromDatePicker(newDate) {
|
|
73
48
|
// when selecting a date from null or for the first time we need to
|
|
74
|
-
// initialize the
|
|
75
|
-
$scope.
|
|
76
|
-
|
|
77
|
-
// the
|
|
78
|
-
//
|
|
79
|
-
$scope.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
second: 0,
|
|
93
|
-
millisecond: 0,
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
// and init the time zone from the users's local time zone as we did in the initFromAPI function
|
|
97
|
-
$scope.timeZone = dateTimeZoneFactory.getTimeZone($scope.parentLuxon)
|
|
49
|
+
// initialize the parentMoment
|
|
50
|
+
$scope.parentMoment = moment()
|
|
51
|
+
|
|
52
|
+
// the dateMoment is set by the datepicker, but we want to update the parent
|
|
53
|
+
// moment to have the same date
|
|
54
|
+
$scope.parentMoment.month(newDate.month())
|
|
55
|
+
$scope.parentMoment.year(newDate.year())
|
|
56
|
+
$scope.parentMoment.date(newDate.date())
|
|
57
|
+
|
|
58
|
+
// we then init the timeMoment with a default of 12:00am
|
|
59
|
+
$scope.timeMoment = moment('12:00 AM', 'hh:mm A')
|
|
60
|
+
|
|
61
|
+
// parent moment will have the now, but should also inisially have 12:00am
|
|
62
|
+
$scope.parentMoment.hour($scope.timeMoment.hour())
|
|
63
|
+
$scope.parentMoment.minute($scope.timeMoment.minute())
|
|
64
|
+
|
|
65
|
+
// and init the time zone from the users's local time zone as we did in the initFromAPI funciton
|
|
66
|
+
$scope.timeZone = dateTimeZoneFactory.getTimeZone($scope.parentMoment)
|
|
98
67
|
}
|
|
99
68
|
|
|
100
69
|
// Formatter runs when incoming values come from the model - this is
|
|
101
|
-
// where we initialize our
|
|
102
|
-
ngModelCtrl.$formatters.push(function
|
|
70
|
+
// where we initialize our moment.
|
|
71
|
+
ngModelCtrl.$formatters.push(function(modelValue) {
|
|
103
72
|
|
|
104
73
|
if (modelValue) {
|
|
105
|
-
|
|
74
|
+
initParentMomentFromAPI(modelValue)
|
|
106
75
|
}
|
|
107
76
|
else {
|
|
108
77
|
// If we don't have a value, we should insure we clear the control
|
|
109
78
|
// by passing NULL to the update function.
|
|
110
|
-
$scope.
|
|
79
|
+
$scope.dateMoment = null
|
|
111
80
|
}
|
|
112
81
|
|
|
113
82
|
return modelValue
|
|
114
83
|
})
|
|
115
84
|
|
|
116
|
-
ngModelCtrl.$parsers.push(function
|
|
85
|
+
ngModelCtrl.$parsers.push(function(modelValue) {
|
|
117
86
|
return modelValue
|
|
118
87
|
})
|
|
119
88
|
|
|
120
|
-
function
|
|
89
|
+
function updateAPIFromMoment() {
|
|
121
90
|
|
|
122
|
-
if ($scope.
|
|
123
|
-
ngModelCtrl.$setViewValue($scope.
|
|
91
|
+
if ($scope.parentMoment) {
|
|
92
|
+
ngModelCtrl.$setViewValue($scope.parentMoment.format())
|
|
124
93
|
}
|
|
125
94
|
else {
|
|
126
95
|
ngModelCtrl.$setViewValue(null)
|
|
@@ -128,90 +97,60 @@ angular.module('app').directive('mflyDateTimeZonePicker', ['dateTimeZoneFactory'
|
|
|
128
97
|
}
|
|
129
98
|
|
|
130
99
|
|
|
131
|
-
$scope.updateDate = function
|
|
132
|
-
// This is fired when the datepicker has updated the date portion of the
|
|
133
|
-
// Update the
|
|
100
|
+
$scope.updateDate = function(newDate) {
|
|
101
|
+
// This is fired when the datepicker has updated the date portion of the moment
|
|
102
|
+
// Update the parentMoment with only the date change
|
|
134
103
|
if (newDate) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
$scope.parentLuxon = $scope.parentLuxon.set({
|
|
141
|
-
month: newDate.month,
|
|
142
|
-
year: newDate.year,
|
|
143
|
-
day: newDate.day
|
|
144
|
-
})
|
|
104
|
+
if ($scope.parentMoment) {
|
|
105
|
+
// if we have a parent moment update it
|
|
106
|
+
$scope.parentMoment.month(newDate.month())
|
|
107
|
+
$scope.parentMoment.year(newDate.year())
|
|
108
|
+
$scope.parentMoment.date(newDate.date())
|
|
145
109
|
}
|
|
146
110
|
else {
|
|
147
|
-
// if we do not have a parent
|
|
148
|
-
|
|
111
|
+
// if we do not have a parent moment b/c no previous date existed
|
|
112
|
+
initParentMomentFromDatePicker(newDate)
|
|
149
113
|
}
|
|
150
114
|
}
|
|
151
115
|
else {
|
|
152
116
|
// we are clearing out a date
|
|
153
|
-
$scope.
|
|
154
|
-
$scope.parentLuxon = null
|
|
117
|
+
$scope.parentMoment = ''
|
|
155
118
|
}
|
|
156
119
|
|
|
157
|
-
// changing between DST could alter our UTC
|
|
120
|
+
// changing between DST could alter our UTC offest
|
|
158
121
|
// this adjustment happens in updateTimeZone which we can call here
|
|
159
|
-
|
|
160
|
-
$scope.updateTimeZone($scope.timeZone.value)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
updateAPIFromLuxon()
|
|
122
|
+
$scope.updateTimeZone($scope.timeZone.value)
|
|
164
123
|
}
|
|
165
124
|
|
|
166
125
|
|
|
167
|
-
$scope.updateTime = function
|
|
168
|
-
// This is fired when the timepicker has updated the time portion of the
|
|
169
|
-
// Update the
|
|
170
|
-
$scope.
|
|
171
|
-
|
|
172
|
-
minute: newTime.minute,
|
|
173
|
-
second: 0,
|
|
174
|
-
millisecond: 0,
|
|
175
|
-
})
|
|
126
|
+
$scope.updateTime = function() {
|
|
127
|
+
// This is fired when the timepicker has updated the time portion of the moment
|
|
128
|
+
// Update the parentMoment with only the time change
|
|
129
|
+
$scope.parentMoment.hour($scope.timeMoment.hour())
|
|
130
|
+
$scope.parentMoment.minute($scope.timeMoment.minute())
|
|
176
131
|
|
|
177
|
-
|
|
132
|
+
updateAPIFromMoment()
|
|
178
133
|
}
|
|
179
134
|
|
|
180
|
-
$scope.updateTimeZone = function
|
|
135
|
+
$scope.updateTimeZone = function(zoneOffset) {
|
|
181
136
|
|
|
182
|
-
if ($scope.
|
|
137
|
+
if ($scope.parentMoment !== '') {
|
|
183
138
|
|
|
184
|
-
// The zone
|
|
139
|
+
// The zone offest displays with a dst offset (see date-time-zone-factory for details)
|
|
185
140
|
// When we save back to the API we need to re-account for that offset
|
|
186
|
-
// Create a
|
|
187
|
-
const isDST =
|
|
141
|
+
// Create a moment to determine if we are dst
|
|
142
|
+
const isDST = moment($scope.parentMoment.format()).isDST()
|
|
188
143
|
|
|
189
144
|
// adjust the zoneOffset passed from the UI if the date is dst
|
|
190
145
|
zoneOffset = (isDST) ? zoneOffset + 1 : zoneOffset
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
// Luxon expects UTC offsets in the format "UTC+HH:MM" or "UTC-HH:MM"
|
|
194
|
-
const sign = zoneOffset >= 0 ? '+' : '-'
|
|
195
|
-
const absOffset = Math.abs(zoneOffset)
|
|
196
|
-
const hours = Math.floor(absOffset)
|
|
197
|
-
const minutes = Math.round((absOffset - hours) * 60)
|
|
198
|
-
|
|
199
|
-
let zoneString
|
|
200
|
-
if (minutes === 0) {
|
|
201
|
-
// For whole hours, we can use the simple format like "UTC+3" or "UTC-5"
|
|
202
|
-
zoneString = `UTC${sign}${hours}`
|
|
203
|
-
} else {
|
|
204
|
-
// For fractional hours, we need the HH:MM format like "UTC+03:30" or "UTC-03:30"
|
|
205
|
-
zoneString = `UTC${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
$scope.parentLuxon = $scope.parentLuxon.setZone(zoneString, { keepLocalTime: true })
|
|
146
|
+
// update the zone/offset change
|
|
147
|
+
$scope.parentMoment.utcOffset(zoneOffset, true)
|
|
209
148
|
}
|
|
210
149
|
|
|
211
|
-
|
|
150
|
+
updateAPIFromMoment()
|
|
212
151
|
}
|
|
213
152
|
|
|
214
|
-
$scope.pickerOpened = function
|
|
153
|
+
$scope.pickerOpened = function() {
|
|
215
154
|
$scope.onOpen()
|
|
216
155
|
}
|
|
217
156
|
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
autocomplete="off"
|
|
7
7
|
class="o-form-control"
|
|
8
8
|
id="{{ inputId }}"
|
|
9
|
-
mfly-datepicker="
|
|
9
|
+
mfly-datepicker="momentDate"
|
|
10
10
|
name="mflyDatepicker"
|
|
11
|
-
ng-blur="
|
|
11
|
+
ng-blur="focusAddOn = false"
|
|
12
|
+
ng-change="validateDate()"
|
|
12
13
|
ng-disabled="isDisabled"
|
|
13
14
|
ng-focus="focusAddOn = true"
|
|
14
15
|
ng-keydown="inputKeyDown($event)"
|