@mediafly/js-ui 51.3.3-2 → 51.4.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/CHANGELOG.md +5 -0
- 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
package/CHANGELOG.md
CHANGED
|
@@ -4,10 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const angular_1 = __importDefault(require("angular"));
|
|
7
|
-
const { DateTime } = require('luxon');
|
|
8
7
|
angular_1.default.module('app')
|
|
9
8
|
.constant('_', require('lodash'))
|
|
10
|
-
.constant('$
|
|
9
|
+
.constant('$moment', require('moment'))
|
|
11
10
|
.constant('Pikaday', require('pikaday'))
|
|
12
11
|
.constant('PREFIX', '/components/');
|
|
13
12
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/components/constants/constants.js"],"names":[],"mappings":";;;;;AAAA,sDAA6B;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/components/constants/constants.js"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAE7B,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC;KACnB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;KAChC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;KACtC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;KACvC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC"}
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const angular_1 = __importDefault(require("angular"));
|
|
7
7
|
const date_input_html_1 = __importDefault(require("./date-input.html"));
|
|
8
|
-
const
|
|
8
|
+
const moment_1 = __importDefault(require("moment"));
|
|
9
9
|
const pikaday_1 = __importDefault(require("pikaday"));
|
|
10
10
|
angular_1.default.module('app').directive('mflyDateInput', ['translateFactory', function mflyDateInput(translateFactory) {
|
|
11
11
|
return {
|
|
@@ -23,12 +23,12 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
|
|
|
23
23
|
// Ng-model functionality
|
|
24
24
|
// ----------------------------------------
|
|
25
25
|
var validDateFormats = [
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'MM-
|
|
29
|
-
'M-
|
|
30
|
-
'MM-
|
|
31
|
-
'M-
|
|
26
|
+
'D-MMM-YYYY', 'D/MMM/YYYY',
|
|
27
|
+
'DD-MMM-YYYY', 'DD/MMM/YYYY',
|
|
28
|
+
'MM-DD-YYYY', 'MM/DD/YYYY',
|
|
29
|
+
'M-D-YYYY', 'M/D/YYYY',
|
|
30
|
+
'MM-DD-YY', 'MM/DD/YY',
|
|
31
|
+
'M-D-YY', 'M/D/YY'
|
|
32
32
|
];
|
|
33
33
|
// Format the ng-model value as a date string.
|
|
34
34
|
// The result of this function is assigned to `ngModelCtrl.$viewValue`.
|
|
@@ -36,7 +36,7 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
|
|
|
36
36
|
if (!nativeDate) {
|
|
37
37
|
return '';
|
|
38
38
|
}
|
|
39
|
-
return
|
|
39
|
+
return moment_1.default(nativeDate).format('DD-MMM-YYYY');
|
|
40
40
|
});
|
|
41
41
|
// Display the date string in the UI.
|
|
42
42
|
ngModelCtrl.$render = function () {
|
|
@@ -52,14 +52,7 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
|
|
|
52
52
|
$scope.onChange({ value: null });
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
let parsedDate;
|
|
57
|
-
for (const format of validDateFormats) {
|
|
58
|
-
parsedDate = DateTime.fromFormat(viewValue, format);
|
|
59
|
-
if (parsedDate.isValid)
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
const jsDate = parsedDate.toJSDate();
|
|
55
|
+
const jsDate = moment_1.default(viewValue, validDateFormats, true).toDate();
|
|
63
56
|
$scope.onChange({ value: jsDate });
|
|
64
57
|
return jsDate;
|
|
65
58
|
});
|
|
@@ -68,13 +61,7 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
|
|
|
68
61
|
$scope.$watch('date', function (newValue) {
|
|
69
62
|
if (pikaday) {
|
|
70
63
|
// We can't rely on native Date() parsing here (JSUI-185).
|
|
71
|
-
|
|
72
|
-
for (const format of validDateFormats) {
|
|
73
|
-
parsedDate = DateTime.fromFormat(newValue, format);
|
|
74
|
-
if (parsedDate.isValid)
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
pikaday.setDate(parsedDate.toJSDate(), true); // true = do not trigger onSelect
|
|
64
|
+
pikaday.setDate(moment_1.default(newValue, validDateFormats).toDate(), true); // true = do not trigger onSelect
|
|
78
65
|
}
|
|
79
66
|
ngModelCtrl.$setViewValue(newValue);
|
|
80
67
|
});
|
|
@@ -90,7 +77,7 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
|
|
|
90
77
|
// the scope property with a valid-formatted date string.
|
|
91
78
|
onSelect: function (newDate) {
|
|
92
79
|
$scope.$apply(function () {
|
|
93
|
-
$scope.date =
|
|
80
|
+
$scope.date = moment_1.default(newDate).format('DD-MMM-YYYY');
|
|
94
81
|
});
|
|
95
82
|
},
|
|
96
83
|
// We can make the input field disabled, but we need further measures
|
|
@@ -106,15 +93,7 @@ angular_1.default.module('app').directive('mflyDateInput', ['translateFactory',
|
|
|
106
93
|
// object which we initialize from the scope's model date, but ngModel
|
|
107
94
|
// doesn't fill that value in until the digest cycle has stabilized.
|
|
108
95
|
setTimeout(function () {
|
|
109
|
-
|
|
110
|
-
let parsedDate;
|
|
111
|
-
for (const format of validDateFormats) {
|
|
112
|
-
parsedDate = DateTime.fromFormat($scope.date, format);
|
|
113
|
-
if (parsedDate.isValid)
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
pikadayOptions.defaultDate = parsedDate.toJSDate();
|
|
117
|
-
}
|
|
96
|
+
pikadayOptions.defaultDate = moment_1.default($scope.date, validDateFormats).toDate(); // new Date($scope.date)
|
|
118
97
|
pikaday = new pikaday_1.default(pikadayOptions);
|
|
119
98
|
}, 0);
|
|
120
99
|
$scope.requiredText = translateFactory.instant('JSUI.REQUIRED');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-input.js","sourceRoot":"","sources":["../../src/components/date-input/date-input.js"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,wEAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"date-input.js","sourceRoot":"","sources":["../../src/components/date-input/date-input.js"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,wEAAwC;AACxC,oDAA2B;AAC3B,sDAA6B;AAE7B,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,kBAAkB,EAAE,SAAS,aAAa,CAAE,gBAAgB;QAE7G,OAAO;YACN,QAAQ,EAAE,GAAG;YACb,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,SAAS;YAClB,KAAK,EAAE;gBACN,OAAO,EAAE,GAAG;gBACZ,UAAU,EAAE,GAAG;gBACf,QAAQ,EAAE,GAAG;gBACb,QAAQ,EAAE,GAAG;aACb;YACD,Q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,CAAC,YAAY,GAAG,gBAAgB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;gBAC/D,MAAM,CAAC,eAAe,GAAG,gBAAgB,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;YACvE,CAAC;SACD,CAAA;IACF,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -4,27 +4,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const angular_1 = __importDefault(require("angular"));
|
|
7
|
-
const
|
|
7
|
+
const moment_1 = __importDefault(require("moment"));
|
|
8
8
|
angular_1.default.module('app').directive('mflyValidateDate', function mflyValidateDate() {
|
|
9
9
|
function link($scope, $element, $attrs, $ctrl) {
|
|
10
10
|
$ctrl.$validators.dateFormat = function (modelValue, viewValue) {
|
|
11
11
|
var validDateFormats = [
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'MM-
|
|
15
|
-
'M-
|
|
16
|
-
'MM-
|
|
17
|
-
'M-
|
|
12
|
+
'D-MMM-YYYY', 'D/MMM/YYYY',
|
|
13
|
+
'DD-MMM-YYYY', 'DD/MMM/YYYY',
|
|
14
|
+
'MM-DD-YYYY', 'MM/DD/YYYY',
|
|
15
|
+
'M-D-YYYY', 'M/D/YYYY',
|
|
16
|
+
'MM-DD-YY', 'MM/DD/YY',
|
|
17
|
+
'M-D-YY', 'M/D/YY'
|
|
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
|
-
|
|
24
|
-
return validDateFormats.some(format => {
|
|
25
|
-
const parsed = DateTime.fromFormat(viewValue, format);
|
|
26
|
-
return parsed.isValid;
|
|
27
|
-
});
|
|
23
|
+
return moment_1.default(viewValue, validDateFormats, true).isValid();
|
|
28
24
|
};
|
|
29
25
|
}
|
|
30
26
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-date.js","sourceRoot":"","sources":["../../src/components/date-input/validate-date.js"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"validate-date.js","sourceRoot":"","sources":["../../src/components/date-input/validate-date.js"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,oDAA2B;AAE3B,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,kBAAkB,EAAE,SAAS,gBAAgB;IAE5E,SAAS,IAAI,CAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK;QAE7C,KAAK,CAAC,WAAW,CAAC,UAAU,GAAG,UAAU,UAAU,EAAE,SAAS;YAE7D,IAAI,gBAAgB,GAAG;gBACtB,YAAY,EAAE,YAAY;gBAC1B,aAAa,EAAE,aAAa;gBAC5B,YAAY,EAAE,YAAY;gBAC1B,UAAU,EAAE,UAAU;gBACtB,UAAU,EAAE,UAAU;gBACtB,QAAQ,EAAE,QAAQ;aAClB,CAAC;YAEF,sEAAsE;YACtE,IAAI,SAAS,KAAK,EAAE,EAAE;gBACrB,OAAO,IAAI,CAAC;aACZ;YAED,OAAO,gBAAM,CAAC,SAAS,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QAC5D,CAAC,CAAC;IACH,CAAC;IAED,OAAO;QACN,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,IAAI;KACV,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const angular_1 = __importDefault(require("angular"));
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const
|
|
8
|
+
const moment_1 = __importDefault(require("moment"));
|
|
9
9
|
angular_1.default.module('app').factory('dateTimeZoneFactory', function dateTimeZoneFactory() {
|
|
10
10
|
const timeZones = [
|
|
11
11
|
{ value: -12, zone: 'IDLW - Internation Date Line West', display: 'IDLW' },
|
|
@@ -40,78 +40,65 @@ angular_1.default.module('app').factory('dateTimeZoneFactory', function dateTime
|
|
|
40
40
|
{ value: 11, zone: 'SBT - Solomon Islands Time', display: 'SBT' },
|
|
41
41
|
{ value: 12, zone: 'NZST - New Zealand Standard Time', display: 'NZST' }
|
|
42
42
|
];
|
|
43
|
-
// using string validate on the datepicker gives us more control
|
|
43
|
+
// using string validate on the datepicker gives us more control w moment's loose parsing
|
|
44
44
|
const validDateFormats = [
|
|
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
|
-
'
|
|
80
|
-
'
|
|
81
|
-
'M.d.yy',
|
|
82
|
-
// Abbreviated month name formats (MMM)
|
|
83
|
-
'd-MMM-yyyy',
|
|
84
|
-
'MMM-d-yyyy',
|
|
85
|
-
'd/MMM/yyyy',
|
|
86
|
-
'MMM/d/yyyy',
|
|
87
|
-
'd.MMM.yyyy',
|
|
88
|
-
'MMM.d.yyyy',
|
|
89
|
-
'd-MMM-yy',
|
|
90
|
-
'MMM-d-yy',
|
|
91
|
-
'd/MMM/yy',
|
|
92
|
-
'MMM/d/yy',
|
|
93
|
-
'd.MMM.yy',
|
|
94
|
-
'MMM.d.yy'
|
|
45
|
+
'D-MMMM-YYYY',
|
|
46
|
+
'D-MM-YYYY',
|
|
47
|
+
'D-M-YYYY',
|
|
48
|
+
'MMMM-D-YYYY',
|
|
49
|
+
'MM-D-YYYY',
|
|
50
|
+
'M-D-YYYY',
|
|
51
|
+
'D/MMMM/YYYY',
|
|
52
|
+
'D/MM/YYYY',
|
|
53
|
+
'D/M/YYYY',
|
|
54
|
+
'MMMM/D/YYYY',
|
|
55
|
+
'MM/D/YYYY',
|
|
56
|
+
'M/D/YYYY',
|
|
57
|
+
'D.MMMM.YYYY',
|
|
58
|
+
'D.MM.YYYY',
|
|
59
|
+
'D.M.YYYY',
|
|
60
|
+
'MMMM.D.YYYY',
|
|
61
|
+
'MM.D.YYYY',
|
|
62
|
+
'M.D.YYYY',
|
|
63
|
+
'D-MMMM-YY',
|
|
64
|
+
'D-MM-YY',
|
|
65
|
+
'D-M-YY',
|
|
66
|
+
'MMMM-D-YY',
|
|
67
|
+
'MM-D-YY',
|
|
68
|
+
'M-D-YY',
|
|
69
|
+
'D/MMMM/YY',
|
|
70
|
+
'D/MM/YY',
|
|
71
|
+
'D/M/YY',
|
|
72
|
+
'MMMM/D/YY',
|
|
73
|
+
'MM/D/YY',
|
|
74
|
+
'M/D/YY',
|
|
75
|
+
'D.MMMM.YY',
|
|
76
|
+
'D.MM.YY',
|
|
77
|
+
'D.M.YY',
|
|
78
|
+
'MMMM.D.YY',
|
|
79
|
+
'MM.D.YY',
|
|
80
|
+
'M.D.YY'
|
|
95
81
|
];
|
|
96
82
|
return {
|
|
97
83
|
timeZones,
|
|
98
84
|
validDateFormats,
|
|
99
|
-
getTimeZone(
|
|
100
|
-
if (
|
|
85
|
+
getTimeZone(momentDate) {
|
|
86
|
+
if (momentDate.isValid()) {
|
|
101
87
|
// Get the timezone offset in hours and adjust the sign
|
|
102
|
-
let zoneOffset =
|
|
88
|
+
let zoneOffset = (momentDate.utcOffset() / 60);
|
|
103
89
|
// consider a shift for DST
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
//
|
|
90
|
+
// must use isDST on a frest moment object -
|
|
91
|
+
// the passed variable is parsedZone and thus will always return isDST false
|
|
92
|
+
const isDST = moment_1.default(momentDate.format()).isDST();
|
|
93
|
+
// at this point zoneOffest is our true offest from UTC 0
|
|
94
|
+
// so for example if we are UTC -6 AND we are DST, then our moment is really "Mountain Time" which is is -7
|
|
108
95
|
// during the winter but is -6 during DST -- if we want to consistently show the label 'MST' for this date
|
|
109
|
-
// we need to select -7 although the offset is -6 (or subtracting 1 from our
|
|
96
|
+
// we need to select -7 although the offset is -6 (or subtracting 1 from our actyual utc output)
|
|
110
97
|
zoneOffset = (isDST) ? zoneOffset - 1 : zoneOffset;
|
|
111
98
|
// NOTE: The above DST adjustment is somewhat arbitrary.
|
|
112
99
|
// isDST() cannot be globally accurate as it works purely off a date and an offset.
|
|
113
|
-
// No actual timezone information is used except for
|
|
114
|
-
// Recommendation to switch to
|
|
100
|
+
// No actual timezone information is used except for assumptins made from the users current locale.
|
|
101
|
+
// Recommendation to switch to moment's timezone.js in the future.
|
|
115
102
|
return this.getTimeZoneByOffset(zoneOffset);
|
|
116
103
|
}
|
|
117
104
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time-zone-factory.js","sourceRoot":"","sources":["../../src/components/date-time-zone-picker/date-time-zone-factory.ts"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,oDAAsB;AACtB,
|
|
1
|
+
{"version":3,"file":"date-time-zone-factory.js","sourceRoot":"","sources":["../../src/components/date-time-zone-picker/date-time-zone-factory.ts"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,oDAAsB;AACtB,oDAA2B;AAE3B,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,SAAS,mBAAmB;IAEhF,MAAM,SAAS,GAAG;QACjB,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UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;gBAElD,wDAAwD;gBACxD,mFAAmF;gBACnF,mGAAmG;gBACnG,kEAAkE;gBAElE,OAAO,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;aAC3C;YAED,OAAO,IAAI,CAAA;QACZ,CAAC;QAED,mBAAmB,CAAC,MAAM;YAEzB,OAAO,gBAAC,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;QAC5C,CAAC;KACD,CAAA;AACF,CAAC,CAAC,CAAA"}
|
|
@@ -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>
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const angular_1 = __importDefault(require("angular"));
|
|
7
|
-
const
|
|
7
|
+
const moment_1 = __importDefault(require("moment"));
|
|
8
8
|
angular_1.default.module('app').directive('mflyDateTimeZonePicker', ['dateTimeZoneFactory', function mflyDateTimeZonePicker(dateTimeZoneFactory) {
|
|
9
9
|
return {
|
|
10
10
|
restrict: 'E',
|
|
@@ -19,166 +19,106 @@ angular_1.default.module('app').directive('mflyDateTimeZonePicker', ['dateTimeZo
|
|
|
19
19
|
},
|
|
20
20
|
template: require('./date-time-zone-picker.html'),
|
|
21
21
|
link($scope, _element, _attr, ngModelCtrl) {
|
|
22
|
-
// Init function creates
|
|
23
|
-
// These
|
|
24
|
-
// timezone object is also created but is not a
|
|
25
|
-
// Each component only alters its respective
|
|
22
|
+
// Init function creates moment dates from our utc string provided by the API
|
|
23
|
+
// These moment dates are bound to the datepicker and timepicker (the
|
|
24
|
+
// timezone object is also created but is not a moment)
|
|
25
|
+
// Each component only alters its respective moment date, then tells this
|
|
26
26
|
// component when a change is made
|
|
27
27
|
// When a change is made, this component combines the 3 datetime elements
|
|
28
28
|
// and sends a utc string back to the api
|
|
29
29
|
// ------------------------------------------------------------------
|
|
30
|
-
function
|
|
31
|
-
// Create a base
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// Calculate offset in hours (including minutes as decimal)
|
|
39
|
-
const offset = dt.offset / 60;
|
|
40
|
-
// Find the matching time zone object
|
|
41
|
-
const matchedZone = dateTimeZoneFactory.getTimeZoneByOffset(offset);
|
|
42
|
-
// If found, set the zone on the DateTime object
|
|
43
|
-
if (matchedZone) {
|
|
44
|
-
// Format offset as UTC±HH:MM for non-integer offsets
|
|
45
|
-
const absOffset = Math.abs(matchedZone.value);
|
|
46
|
-
const hours = Math.floor(absOffset);
|
|
47
|
-
const minutes = Math.round((absOffset - hours) * 60);
|
|
48
|
-
const sign = matchedZone.value >= 0 ? '+' : '-';
|
|
49
|
-
const zoneString = minutes === 0
|
|
50
|
-
? `UTC${sign}${hours}`
|
|
51
|
-
: `UTC${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
|
|
52
|
-
$scope.parentLuxon = dt.setZone(zoneString, { keepLocalTime: true });
|
|
53
|
-
$scope.timeZone = matchedZone;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
// Fallback: just use the parsed DateTime
|
|
57
|
-
$scope.parentLuxon = dt;
|
|
58
|
-
$scope.timeZone = null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
throw new Error(`Invalid value type ${typeof value} (${value})`);
|
|
63
|
-
}
|
|
64
|
-
$scope.timeLuxon = luxon_1.DateTime.fromObject({ hour: $scope.parentLuxon.hour, minute: $scope.parentLuxon.minute, second: 0, millisecond: 0 });
|
|
65
|
-
$scope.dateLuxon = luxon_1.DateTime.fromObject({ year: $scope.parentLuxon.year, month: $scope.parentLuxon.month, day: $scope.parentLuxon.day });
|
|
30
|
+
function initParentMomentFromAPI(value) {
|
|
31
|
+
// Create a base moment and bound copies for each child component.
|
|
32
|
+
$scope.parentMoment = moment_1.default.parseZone(value);
|
|
33
|
+
$scope.timeMoment = moment_1.default({ hour: $scope.parentMoment.hour(), minute: $scope.parentMoment.minute() });
|
|
34
|
+
$scope.dateMoment = moment_1.default({ year: $scope.parentMoment.year(), month: $scope.parentMoment.month(), date: $scope.parentMoment.date() });
|
|
35
|
+
// The timezone component takes a custom timezone object instead of
|
|
36
|
+
// a moment. The factory returns a timezone, adjusting for DST.
|
|
37
|
+
$scope.timeZone = dateTimeZoneFactory.getTimeZone($scope.parentMoment);
|
|
66
38
|
}
|
|
67
|
-
function
|
|
39
|
+
function initParentMomentFromDatePicker(newDate) {
|
|
68
40
|
// when selecting a date from null or for the first time we need to
|
|
69
|
-
// initialize the
|
|
70
|
-
$scope.
|
|
71
|
-
// the
|
|
72
|
-
//
|
|
73
|
-
$scope.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
$scope.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
minute: $scope.timeLuxon.minute,
|
|
84
|
-
second: 0,
|
|
85
|
-
millisecond: 0,
|
|
86
|
-
});
|
|
87
|
-
// and init the time zone from the users's local time zone as we did in the initFromAPI function
|
|
88
|
-
$scope.timeZone = dateTimeZoneFactory.getTimeZone($scope.parentLuxon);
|
|
41
|
+
// initialize the parentMoment
|
|
42
|
+
$scope.parentMoment = moment_1.default();
|
|
43
|
+
// the dateMoment is set by the datepicker, but we want to update the parent
|
|
44
|
+
// moment to have the same date
|
|
45
|
+
$scope.parentMoment.month(newDate.month());
|
|
46
|
+
$scope.parentMoment.year(newDate.year());
|
|
47
|
+
$scope.parentMoment.date(newDate.date());
|
|
48
|
+
// we then init the timeMoment with a default of 12:00am
|
|
49
|
+
$scope.timeMoment = moment_1.default('12:00 AM', 'hh:mm A');
|
|
50
|
+
// parent moment will have the now, but should also inisially have 12:00am
|
|
51
|
+
$scope.parentMoment.hour($scope.timeMoment.hour());
|
|
52
|
+
$scope.parentMoment.minute($scope.timeMoment.minute());
|
|
53
|
+
// and init the time zone from the users's local time zone as we did in the initFromAPI funciton
|
|
54
|
+
$scope.timeZone = dateTimeZoneFactory.getTimeZone($scope.parentMoment);
|
|
89
55
|
}
|
|
90
56
|
// Formatter runs when incoming values come from the model - this is
|
|
91
|
-
// where we initialize our
|
|
57
|
+
// where we initialize our moment.
|
|
92
58
|
ngModelCtrl.$formatters.push(function (modelValue) {
|
|
93
59
|
if (modelValue) {
|
|
94
|
-
|
|
60
|
+
initParentMomentFromAPI(modelValue);
|
|
95
61
|
}
|
|
96
62
|
else {
|
|
97
63
|
// If we don't have a value, we should insure we clear the control
|
|
98
64
|
// by passing NULL to the update function.
|
|
99
|
-
$scope.
|
|
65
|
+
$scope.dateMoment = null;
|
|
100
66
|
}
|
|
101
67
|
return modelValue;
|
|
102
68
|
});
|
|
103
69
|
ngModelCtrl.$parsers.push(function (modelValue) {
|
|
104
70
|
return modelValue;
|
|
105
71
|
});
|
|
106
|
-
function
|
|
107
|
-
if ($scope.
|
|
108
|
-
ngModelCtrl.$setViewValue($scope.
|
|
72
|
+
function updateAPIFromMoment() {
|
|
73
|
+
if ($scope.parentMoment) {
|
|
74
|
+
ngModelCtrl.$setViewValue($scope.parentMoment.format());
|
|
109
75
|
}
|
|
110
76
|
else {
|
|
111
77
|
ngModelCtrl.$setViewValue(null);
|
|
112
78
|
}
|
|
113
79
|
}
|
|
114
80
|
$scope.updateDate = function (newDate) {
|
|
115
|
-
// This is fired when the datepicker has updated the date portion of the
|
|
116
|
-
// Update the
|
|
81
|
+
// This is fired when the datepicker has updated the date portion of the moment
|
|
82
|
+
// Update the parentMoment with only the date change
|
|
117
83
|
if (newDate) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
$scope.
|
|
123
|
-
month: newDate.month,
|
|
124
|
-
year: newDate.year,
|
|
125
|
-
day: newDate.day
|
|
126
|
-
});
|
|
84
|
+
if ($scope.parentMoment) {
|
|
85
|
+
// if we have a parent moment update it
|
|
86
|
+
$scope.parentMoment.month(newDate.month());
|
|
87
|
+
$scope.parentMoment.year(newDate.year());
|
|
88
|
+
$scope.parentMoment.date(newDate.date());
|
|
127
89
|
}
|
|
128
90
|
else {
|
|
129
|
-
// if we do not have a parent
|
|
130
|
-
|
|
91
|
+
// if we do not have a parent moment b/c no previous date existed
|
|
92
|
+
initParentMomentFromDatePicker(newDate);
|
|
131
93
|
}
|
|
132
94
|
}
|
|
133
95
|
else {
|
|
134
96
|
// we are clearing out a date
|
|
135
|
-
$scope.
|
|
136
|
-
$scope.parentLuxon = null;
|
|
97
|
+
$scope.parentMoment = '';
|
|
137
98
|
}
|
|
138
|
-
// changing between DST could alter our UTC
|
|
99
|
+
// changing between DST could alter our UTC offest
|
|
139
100
|
// this adjustment happens in updateTimeZone which we can call here
|
|
140
|
-
|
|
141
|
-
$scope.updateTimeZone($scope.timeZone.value);
|
|
142
|
-
}
|
|
143
|
-
updateAPIFromLuxon();
|
|
101
|
+
$scope.updateTimeZone($scope.timeZone.value);
|
|
144
102
|
};
|
|
145
|
-
$scope.updateTime = function (
|
|
146
|
-
// This is fired when the timepicker has updated the time portion of the
|
|
147
|
-
// Update the
|
|
148
|
-
$scope.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
second: 0,
|
|
152
|
-
millisecond: 0,
|
|
153
|
-
});
|
|
154
|
-
updateAPIFromLuxon();
|
|
103
|
+
$scope.updateTime = function () {
|
|
104
|
+
// This is fired when the timepicker has updated the time portion of the moment
|
|
105
|
+
// Update the parentMoment with only the time change
|
|
106
|
+
$scope.parentMoment.hour($scope.timeMoment.hour());
|
|
107
|
+
$scope.parentMoment.minute($scope.timeMoment.minute());
|
|
108
|
+
updateAPIFromMoment();
|
|
155
109
|
};
|
|
156
110
|
$scope.updateTimeZone = function (zoneOffset) {
|
|
157
|
-
if ($scope.
|
|
158
|
-
// The zone
|
|
111
|
+
if ($scope.parentMoment !== '') {
|
|
112
|
+
// The zone offest displays with a dst offset (see date-time-zone-factory for details)
|
|
159
113
|
// When we save back to the API we need to re-account for that offset
|
|
160
|
-
// Create a
|
|
161
|
-
const isDST =
|
|
114
|
+
// Create a moment to determine if we are dst
|
|
115
|
+
const isDST = moment_1.default($scope.parentMoment.format()).isDST();
|
|
162
116
|
// adjust the zoneOffset passed from the UI if the date is dst
|
|
163
117
|
zoneOffset = (isDST) ? zoneOffset + 1 : zoneOffset;
|
|
164
|
-
//
|
|
165
|
-
|
|
166
|
-
const sign = zoneOffset >= 0 ? '+' : '-';
|
|
167
|
-
const absOffset = Math.abs(zoneOffset);
|
|
168
|
-
const hours = Math.floor(absOffset);
|
|
169
|
-
const minutes = Math.round((absOffset - hours) * 60);
|
|
170
|
-
let zoneString;
|
|
171
|
-
if (minutes === 0) {
|
|
172
|
-
// For whole hours, we can use the simple format like "UTC+3" or "UTC-5"
|
|
173
|
-
zoneString = `UTC${sign}${hours}`;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
// For fractional hours, we need the HH:MM format like "UTC+03:30" or "UTC-03:30"
|
|
177
|
-
zoneString = `UTC${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
|
|
178
|
-
}
|
|
179
|
-
$scope.parentLuxon = $scope.parentLuxon.setZone(zoneString, { keepLocalTime: true });
|
|
118
|
+
// update the zone/offset change
|
|
119
|
+
$scope.parentMoment.utcOffset(zoneOffset, true);
|
|
180
120
|
}
|
|
181
|
-
|
|
121
|
+
updateAPIFromMoment();
|
|
182
122
|
};
|
|
183
123
|
$scope.pickerOpened = function () {
|
|
184
124
|
$scope.onOpen();
|