Skip to content
This repository was archived by the owner on May 30, 2019. It is now read-only.

Commit 667ddcb

Browse files
committed
browser: catch up java-spring with src
1 parent baee1ed commit 667ddcb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

appserver/java-spring/static/app/directives/ssFacetDateRange.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ define(['app/module'], function (module) {
4141
* | `dateEndPlaceholder` | {@type string} | Formatted representation of the late date found (shadowed) search results to use as placeholder in the dateEnd picker. |
4242
* | `pickerDateStart` | {@type Date? } | If a Date object, the value of the dateStart search constraint represented as a day for the dateStart picker. |
4343
* | `pickerDateEnd` | {@type Date? } | If a Date object, the value of the dateEnd search constraint represented as a day for the dateEnd picker. |
44+
* | `lastValid` | {@type object } | Stores the last valid Date values for pickerDateStart and pickerDateEnd to be used in the case of an invalid date through manual entry. |
4445
*/
4546

4647
/* jshint ignore:end */
@@ -182,6 +183,8 @@ define(['app/module'], function (module) {
182183
return false; // no more jquery event handling
183184
};
184185

186+
// simple utility function thtat checks to see if the date passed
187+
// has a value that is different from the value of the constraint
185188
var assignIfDifferent = function (newDate, constraint) {
186189
var newValidDate = isNaN(newDate) ? null : newDate;
187190
if (newValidDate === null) {
@@ -237,6 +240,8 @@ define(['app/module'], function (module) {
237240
return false;
238241
};
239242

243+
// clears the range selection on the chart,
244+
// as well as the constraint values
240245
var clearSelectedRange = function (event) {
241246
scope.$apply(function () {
242247
var noop = !scope.constraints.dateStart.value &&
@@ -251,6 +256,7 @@ define(['app/module'], function (module) {
251256

252257
};
253258

259+
// HighCharts configuration object with event callbacks
254260
scope.highchartsConfig = {
255261
options: {
256262
chart: {
@@ -319,14 +325,21 @@ define(['app/module'], function (module) {
319325

320326
};
321327

328+
// angulas-ui datepicker directive options
322329
scope.dateStartOptions = scope.dateEndOptions = {
323330
formatYear: 'yy',
324331
startingDay: 1,
325332
showWeeks: false,
326333
showButtonBar: false
327334
};
335+
336+
// angulas-ui datepicker extended option for ensuring that the
337+
// datepicker only ever parses manually entered dates strictly
338+
// and does not attempt to set the picker value unless the
339+
// input matches the required format
328340
scope.parseStrict = true;
329341

342+
// clears the constraint associated with a datepicker input
330343
scope.clearSingleDate = function (inputModel) {
331344
if (inputModel === 'pickerDateStart') {
332345
scope.constraints.dateStart.value = null;
@@ -336,6 +349,7 @@ define(['app/module'], function (module) {
336349
}
337350
};
338351

352+
// closes the datepicker popup UI for both datepickers
339353
scope.closePickers = function () {
340354
scope['dateStartOpened'] = false;
341355
scope['dateEndOpened'] = false;
@@ -385,6 +399,10 @@ define(['app/module'], function (module) {
385399
event.stopPropagation();
386400
};
387401

402+
// applyPickerDates triggered on ng-change, which occurs on
403+
// selection of a date by the picker pop-up, or during manual
404+
// entry of a date on keydown 'enter' or blur events
405+
// (see ngModelOnblurOnenter directive below for more details)
388406
scope.applyPickerDates = function () {
389407
var foundChange = false;
390408
var el = scope.selectedInput;
@@ -449,6 +467,10 @@ define(['app/module'], function (module) {
449467
},
450468

451469
post: function (scope) {
470+
// watches for pickerDateStart & pickerDateEnd, storing the last
471+
// valid date (scope.lastValid) that was entered into the field.
472+
// These scope values are used to restore the value of the input
473+
// in the cause of an invalid date through manual entry.
452474
scope.lastValid = [];
453475
scope.$watch('pickerDateStart', function (newValue, oldValue) {
454476
if (newValue) {
@@ -550,6 +572,10 @@ define(['app/module'], function (module) {
550572
}
551573
]); // end directive
552574

575+
// directive for triggering the ng-change event ONLY when the
576+
// keydown 'enter' or blur event occur. The directive was created to support
577+
// UX requirements to only validate a date that has been manually entered
578+
// during those two events.
553579
module.directive('ngModelOnblurOnenter', function () {
554580
return {
555581
restrict: 'A',

0 commit comments

Comments
 (0)