-
Notifications
You must be signed in to change notification settings - Fork 31
Create widget type to accommodate time-sensitive content #524
Create widget type to accommodate time-sensitive content #524
Conversation
/** | ||
* | ||
*/ | ||
var configureAnnualBenefitsEnrollmentContent = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To generalize this so it doesn't need annual-benefits-enrollment-specific stuff: have it compute the days until the next template switch and expose that integer to the template.
As in, it's currently showing the before-benefit-enrollment-starts content. And it knows the date on which it'll switch to the next template. So it computes the quantity days until that happens, and exposes it to the current template as daysRemainingShowingThisTemplate
or daysUntilNextTemplate
or whatever. And then in the actual ABE content, the before-enrollment template uses, references this variable to get at the count.
So then the ABE start date arrives. Boing, onto next template. And that template gets the count of days until the template after it. So the during-ABE content could include the countdown until the end of ABE.
Turtles all the way down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that doesn't account for is the warning that the active period is going to begin. ABE widget has the countdown during the active period, but also has a "Begins [given date]" case leading up to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good 👍
I'd highly recommend importing Moment for any and all date processing.
I've left some notes on what Moment functions could help. 📓 🕐
$scope.enrollmentPeriodStatus = 'ongoing'; | ||
} | ||
// Determine whether enrollment period is upcoming or already over | ||
} else if ($filter('filterDifferenceFromDate')( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (value.isAnnual) { | ||
startDate = (new Date).getFullYear() + '-' + startDate; | ||
endDate = (new Date).getFullYear() + '-' + endDate; | ||
if ($filter('filterDateRange')(startDate, endDate)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*/ | ||
var configureAnnualBenefitsEnrollmentContent = function() { | ||
// Set enrollment period dates for current year | ||
$scope.enrollStartDate = (new Date).getFullYear() + '-' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would LOVE to use moment. Hopefully this gets the conversation started again :)
if ($filter('filterDateRange')( | ||
$scope.enrollStartDate, $scope.enrollEndDate)) { | ||
// Calculate countdown | ||
$scope.daysLeft = $filter('filterDifferenceFromDate')( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
define(['angular'], function(angular) { | ||
return angular.module('portal.widgets.filters', []) | ||
.filter('filterDateRange', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return today >= rangeStart && today < rangeEnd; | ||
}; | ||
}) | ||
.filter('filterDifferenceFromDate', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else if ($filter('filterDifferenceFromDate')( | ||
$scope.enrollStartDate) > 0) { | ||
$scope.enrollmentPeriodStatus = 'upcoming'; | ||
} else if ($filter('filterDifferenceFromDate')( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// If date range is annual, not for a specific year, | ||
// use current year in range | ||
if (value.isAnnual) { | ||
startDate = (new Date).getFullYear() + '-' + startDate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// use current year in range | ||
if (value.isAnnual) { | ||
startDate = (new Date).getFullYear() + '-' + startDate; | ||
endDate = (new Date).getFullYear() + '-' + endDate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📓 👷♂️ 🏁 AppVeyor CI error appears to be the same one from #523
https://travis-ci.org/UW-Madison-DoIT/uw-frame/jobs/275607992#L725-L731 |
docs(license): adds license header to files
…frame into benefits-type
}) | ||
.filter('filterForDateWithYear', function() { | ||
return function(date) { | ||
var validWithYear = /([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐎 to limit performance implications consider anchoring the start and the end
/^([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))$/
📓 https://momentjs.com/docs/#/parsing/is-valid/ is a wonderful thing
.filter('filterForDateWithYear', function() { | ||
return function(date) { | ||
var validWithYear = /([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/; | ||
var validDayAndMonth = /(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐎 to limit performance implications consider anchoring the start and the end
/^(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/
📓 https://momentjs.com/docs/#/parsing/is-valid/ is a wonderful thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👷♂️ ⛔
docs\make-a-widget.md
390:5 warning Incorrect indentation before bullet: remove 2 spaces list-item-bullet-indent remark-lint
391:5 warning Incorrect indentation before bullet: remove 2 spaces list-item-bullet-indent remark-lint
392:5 warning Incorrect indentation before bullet: remove 2 spaces list-item-bullet-indent remark-lint
393:5 warning Incorrect indentation before bullet: remove 2 spaces list-item-bullet-indent remark-lint
395:133-395:136 warning Found reference to undefined definition no-undefined-references remark-lint
395:133-395:136 warning Use the trailing [] on reference links no-shortcut-reference-link remark-lint
395:304-395:307 warning Found reference to undefined definition no-undefined-references remark-lint
395:304-395:307 warning Use the trailing [] on reference links no-shortcut-reference-link remark-lint
398:5 warning Incorrect indentation before bullet: remove 2 spaces list-item-bullet-indent remark-lint
399:5 warning Incorrect indentation before bullet: remove 2 spaces list-item-bullet-indent remark-lint
414:419-414:440 warning Use the trailing [] on reference links no-shortcut-reference-link remark-lint
414:419-414:440 warning Found reference to undefined definition no-undefined-references remark-lint
415:412-415:431 warning Use the trailing [] on reference links no-shortcut-reference-link remark-lint
415:412-415:431 warning Found reference to undefined definition no-undefined-references remark-lint
https://ci.appveyor.com/project/vertein/uw-frame/build/1.0.388#L1111
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the lint issues have been resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MUMUP-2780: "Apply lessons learned to refactor Annual Benefits Enrollment widget."
In this PR
Screenshots
Contributor License Agreement adherence: